From 244569686f786b12cdb0b842a8b7594f8f78c585 Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 5 Dec 2024 09:07:20 +0000 Subject: [PATCH] Upload lcov report for dlt-daemon --- .gitmodules | 3 - dlt_lcov_report/amber.png | Bin 0 -> 141 bytes .../dlt-control-common.c.func-sort-c.html | 148 + .../console/dlt-control-common.c.func.html | 148 + .../console/dlt-control-common.c.gcov.html | 1050 ++ .../console/dlt-convert.c.func-sort-c.html | 84 + .../console/dlt-convert.c.func.html | 84 + .../console/dlt-convert.c.gcov.html | 610 + .../console/dlt-receive.c.func-sort-c.html | 100 + .../console/dlt-receive.c.func.html | 100 + .../console/dlt-receive.c.gcov.html | 819 + dlt_lcov_report/console/index-sort-f.html | 113 + dlt_lcov_report/console/index-sort-l.html | 113 + dlt_lcov_report/console/index.html | 113 + .../dlt-logstorage-common.c.func-sort-c.html | 132 + .../dlt-logstorage-common.c.func.html | 132 + .../dlt-logstorage-common.c.gcov.html | 399 + .../dlt-logstorage-ctrl.c.func-sort-c.html | 124 + .../dlt-logstorage-ctrl.c.func.html | 124 + .../dlt-logstorage-ctrl.c.gcov.html | 678 + .../dlt-logstorage-list.c.func-sort-c.html | 88 + .../dlt-logstorage-list.c.func.html | 88 + .../dlt-logstorage-list.c.gcov.html | 308 + .../console/logstorage/index-sort-f.html | 113 + .../console/logstorage/index-sort-l.html | 113 + dlt_lcov_report/console/logstorage/index.html | 113 + .../daemon/dlt-daemon.c.func-sort-c.html | 240 + dlt_lcov_report/daemon/dlt-daemon.c.func.html | 240 + dlt_lcov_report/daemon/dlt-daemon.c.gcov.html | 4460 ++++++ .../dlt_daemon_client.c.func-sort-c.html | 204 + .../daemon/dlt_daemon_client.c.func.html | 204 + .../daemon/dlt_daemon_client.c.gcov.html | 2875 ++++ .../dlt_daemon_common.c.func-sort-c.html | 200 + .../daemon/dlt_daemon_common.c.func.html | 200 + .../daemon/dlt_daemon_common.c.gcov.html | 2159 +++ .../dlt_daemon_connection.c.func-sort-c.html | 104 + .../daemon/dlt_daemon_connection.c.func.html | 104 + .../daemon/dlt_daemon_connection.c.gcov.html | 517 + ...lt_daemon_event_handler.c.func-sort-c.html | 116 + .../dlt_daemon_event_handler.c.func.html | 116 + .../dlt_daemon_event_handler.c.gcov.html | 614 + ...emon_offline_logstorage.c.func-sort-c.html | 164 + .../dlt_daemon_offline_logstorage.c.func.html | 164 + .../dlt_daemon_offline_logstorage.c.gcov.html | 1342 ++ .../dlt_daemon_serial.c.func-sort-c.html | 76 + .../daemon/dlt_daemon_serial.c.func.html | 76 + .../daemon/dlt_daemon_serial.c.gcov.html | 174 + .../dlt_daemon_socket.c.func-sort-c.html | 92 + .../daemon/dlt_daemon_socket.c.func.html | 92 + .../daemon/dlt_daemon_socket.c.gcov.html | 323 + .../dlt_daemon_unix_socket.c.func-sort-c.html | 80 + .../daemon/dlt_daemon_unix_socket.c.func.html | 80 + .../daemon/dlt_daemon_unix_socket.c.gcov.html | 264 + dlt_lcov_report/daemon/index-sort-f.html | 173 + dlt_lcov_report/daemon/index-sort-l.html | 173 + dlt_lcov_report/daemon/index.html | 173 + dlt_lcov_report/dlt_final_coverage.info | 12708 ++++++++++++++++ dlt_lcov_report/emerald.png | Bin 0 -> 141 bytes .../gateway/dlt_gateway.c.func-sort-c.html | 184 + .../gateway/dlt_gateway.c.func.html | 184 + .../gateway/dlt_gateway.c.gcov.html | 1858 +++ dlt_lcov_report/gateway/index-sort-f.html | 93 + dlt_lcov_report/gateway/index-sort-l.html | 93 + dlt_lcov_report/gateway/index.html | 93 + dlt_lcov_report/gcov.css | 519 + dlt_lcov_report/glass.png | Bin 0 -> 167 bytes dlt_lcov_report/index-sort-f.html | 153 + dlt_lcov_report/index-sort-l.html | 153 + dlt_lcov_report/index.html | 153 + .../lib/dlt_client.c.func-sort-c.html | 196 + dlt_lcov_report/lib/dlt_client.c.func.html | 196 + dlt_lcov_report/lib/dlt_client.c.gcov.html | 1480 ++ .../lib/dlt_env_ll.c.func-sort-c.html | 120 + dlt_lcov_report/lib/dlt_env_ll.c.func.html | 120 + dlt_lcov_report/lib/dlt_env_ll.c.gcov.html | 576 + .../lib/dlt_filetransfer.c.func-sort-c.html | 144 + .../lib/dlt_filetransfer.c.func.html | 144 + .../lib/dlt_filetransfer.c.gcov.html | 856 ++ .../lib/dlt_user.c.func-sort-c.html | 624 + dlt_lcov_report/lib/dlt_user.c.func.html | 624 + dlt_lcov_report/lib/dlt_user.c.gcov.html | 5556 +++++++ dlt_lcov_report/lib/index-sort-f.html | 123 + dlt_lcov_report/lib/index-sort-l.html | 123 + dlt_lcov_report/lib/index.html | 123 + .../dlt_offline_logstorage.c.func-sort-c.html | 288 + .../dlt_offline_logstorage.c.func.html | 288 + .../dlt_offline_logstorage.c.gcov.html | 2883 ++++ ...ine_logstorage_behavior.c.func-sort-c.html | 152 + ...lt_offline_logstorage_behavior.c.func.html | 152 + ...lt_offline_logstorage_behavior.c.gcov.html | 1674 ++ .../offlinelogstorage/index-sort-f.html | 103 + .../offlinelogstorage/index-sort-l.html | 103 + dlt_lcov_report/offlinelogstorage/index.html | 103 + dlt_lcov_report/ruby.png | Bin 0 -> 141 bytes .../shared/dlt_common.c.func-sort-c.html | 452 + dlt_lcov_report/shared/dlt_common.c.func.html | 452 + dlt_lcov_report/shared/dlt_common.c.gcov.html | 4595 ++++++ .../dlt_config_file_parser.c.func-sort-c.html | 132 + .../shared/dlt_config_file_parser.c.func.html | 132 + .../shared/dlt_config_file_parser.c.gcov.html | 645 + .../shared/dlt_log.c.func-sort-c.html | 132 + dlt_lcov_report/shared/dlt_log.c.func.html | 132 + dlt_lcov_report/shared/dlt_log.c.gcov.html | 430 + .../dlt_multiple_files.c.func-sort-c.html | 124 + .../shared/dlt_multiple_files.c.func.html | 124 + .../shared/dlt_multiple_files.c.gcov.html | 575 + .../dlt_offline_trace.c.func-sort-c.html | 76 + .../shared/dlt_offline_trace.c.func.html | 76 + .../shared/dlt_offline_trace.c.gcov.html | 164 + .../shared/dlt_protocol.c.func-sort-c.html | 76 + .../shared/dlt_protocol.c.func.html | 76 + .../shared/dlt_protocol.c.gcov.html | 158 + .../shared/dlt_user_shared.c.func-sort-c.html | 96 + .../shared/dlt_user_shared.c.func.html | 96 + .../shared/dlt_user_shared.c.gcov.html | 299 + dlt_lcov_report/shared/index-sort-f.html | 153 + dlt_lcov_report/shared/index-sort-l.html | 153 + dlt_lcov_report/shared/index.html | 153 + dlt_lcov_report/snow.png | Bin 0 -> 141 bytes dlt_lcov_report/updown.png | Bin 0 -> 117 bytes googletest | 1 - 121 files changed, 64136 insertions(+), 4 deletions(-) create mode 100644 dlt_lcov_report/amber.png create mode 100644 dlt_lcov_report/console/dlt-control-common.c.func-sort-c.html create mode 100644 dlt_lcov_report/console/dlt-control-common.c.func.html create mode 100644 dlt_lcov_report/console/dlt-control-common.c.gcov.html create mode 100644 dlt_lcov_report/console/dlt-convert.c.func-sort-c.html create mode 100644 dlt_lcov_report/console/dlt-convert.c.func.html create mode 100644 dlt_lcov_report/console/dlt-convert.c.gcov.html create mode 100644 dlt_lcov_report/console/dlt-receive.c.func-sort-c.html create mode 100644 dlt_lcov_report/console/dlt-receive.c.func.html create mode 100644 dlt_lcov_report/console/dlt-receive.c.gcov.html create mode 100644 dlt_lcov_report/console/index-sort-f.html create mode 100644 dlt_lcov_report/console/index-sort-l.html create mode 100644 dlt_lcov_report/console/index.html create mode 100644 dlt_lcov_report/console/logstorage/dlt-logstorage-common.c.func-sort-c.html create mode 100644 dlt_lcov_report/console/logstorage/dlt-logstorage-common.c.func.html create mode 100644 dlt_lcov_report/console/logstorage/dlt-logstorage-common.c.gcov.html create mode 100644 dlt_lcov_report/console/logstorage/dlt-logstorage-ctrl.c.func-sort-c.html create mode 100644 dlt_lcov_report/console/logstorage/dlt-logstorage-ctrl.c.func.html create mode 100644 dlt_lcov_report/console/logstorage/dlt-logstorage-ctrl.c.gcov.html create mode 100644 dlt_lcov_report/console/logstorage/dlt-logstorage-list.c.func-sort-c.html create mode 100644 dlt_lcov_report/console/logstorage/dlt-logstorage-list.c.func.html create mode 100644 dlt_lcov_report/console/logstorage/dlt-logstorage-list.c.gcov.html create mode 100644 dlt_lcov_report/console/logstorage/index-sort-f.html create mode 100644 dlt_lcov_report/console/logstorage/index-sort-l.html create mode 100644 dlt_lcov_report/console/logstorage/index.html create mode 100644 dlt_lcov_report/daemon/dlt-daemon.c.func-sort-c.html create mode 100644 dlt_lcov_report/daemon/dlt-daemon.c.func.html create mode 100644 dlt_lcov_report/daemon/dlt-daemon.c.gcov.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_client.c.func-sort-c.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_client.c.func.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_client.c.gcov.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_common.c.func-sort-c.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_common.c.func.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_common.c.gcov.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_connection.c.func-sort-c.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_connection.c.func.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_connection.c.gcov.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_event_handler.c.func-sort-c.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_event_handler.c.func.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_event_handler.c.gcov.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_offline_logstorage.c.func-sort-c.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_offline_logstorage.c.func.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_offline_logstorage.c.gcov.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_serial.c.func-sort-c.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_serial.c.func.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_serial.c.gcov.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_socket.c.func-sort-c.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_socket.c.func.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_socket.c.gcov.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_unix_socket.c.func-sort-c.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_unix_socket.c.func.html create mode 100644 dlt_lcov_report/daemon/dlt_daemon_unix_socket.c.gcov.html create mode 100644 dlt_lcov_report/daemon/index-sort-f.html create mode 100644 dlt_lcov_report/daemon/index-sort-l.html create mode 100644 dlt_lcov_report/daemon/index.html create mode 100644 dlt_lcov_report/dlt_final_coverage.info create mode 100644 dlt_lcov_report/emerald.png create mode 100644 dlt_lcov_report/gateway/dlt_gateway.c.func-sort-c.html create mode 100644 dlt_lcov_report/gateway/dlt_gateway.c.func.html create mode 100644 dlt_lcov_report/gateway/dlt_gateway.c.gcov.html create mode 100644 dlt_lcov_report/gateway/index-sort-f.html create mode 100644 dlt_lcov_report/gateway/index-sort-l.html create mode 100644 dlt_lcov_report/gateway/index.html create mode 100644 dlt_lcov_report/gcov.css create mode 100644 dlt_lcov_report/glass.png create mode 100644 dlt_lcov_report/index-sort-f.html create mode 100644 dlt_lcov_report/index-sort-l.html create mode 100644 dlt_lcov_report/index.html create mode 100644 dlt_lcov_report/lib/dlt_client.c.func-sort-c.html create mode 100644 dlt_lcov_report/lib/dlt_client.c.func.html create mode 100644 dlt_lcov_report/lib/dlt_client.c.gcov.html create mode 100644 dlt_lcov_report/lib/dlt_env_ll.c.func-sort-c.html create mode 100644 dlt_lcov_report/lib/dlt_env_ll.c.func.html create mode 100644 dlt_lcov_report/lib/dlt_env_ll.c.gcov.html create mode 100644 dlt_lcov_report/lib/dlt_filetransfer.c.func-sort-c.html create mode 100644 dlt_lcov_report/lib/dlt_filetransfer.c.func.html create mode 100644 dlt_lcov_report/lib/dlt_filetransfer.c.gcov.html create mode 100644 dlt_lcov_report/lib/dlt_user.c.func-sort-c.html create mode 100644 dlt_lcov_report/lib/dlt_user.c.func.html create mode 100644 dlt_lcov_report/lib/dlt_user.c.gcov.html create mode 100644 dlt_lcov_report/lib/index-sort-f.html create mode 100644 dlt_lcov_report/lib/index-sort-l.html create mode 100644 dlt_lcov_report/lib/index.html create mode 100644 dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage.c.func-sort-c.html create mode 100644 dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage.c.func.html create mode 100644 dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage.c.gcov.html create mode 100644 dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage_behavior.c.func-sort-c.html create mode 100644 dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage_behavior.c.func.html create mode 100644 dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage_behavior.c.gcov.html create mode 100644 dlt_lcov_report/offlinelogstorage/index-sort-f.html create mode 100644 dlt_lcov_report/offlinelogstorage/index-sort-l.html create mode 100644 dlt_lcov_report/offlinelogstorage/index.html create mode 100644 dlt_lcov_report/ruby.png create mode 100644 dlt_lcov_report/shared/dlt_common.c.func-sort-c.html create mode 100644 dlt_lcov_report/shared/dlt_common.c.func.html create mode 100644 dlt_lcov_report/shared/dlt_common.c.gcov.html create mode 100644 dlt_lcov_report/shared/dlt_config_file_parser.c.func-sort-c.html create mode 100644 dlt_lcov_report/shared/dlt_config_file_parser.c.func.html create mode 100644 dlt_lcov_report/shared/dlt_config_file_parser.c.gcov.html create mode 100644 dlt_lcov_report/shared/dlt_log.c.func-sort-c.html create mode 100644 dlt_lcov_report/shared/dlt_log.c.func.html create mode 100644 dlt_lcov_report/shared/dlt_log.c.gcov.html create mode 100644 dlt_lcov_report/shared/dlt_multiple_files.c.func-sort-c.html create mode 100644 dlt_lcov_report/shared/dlt_multiple_files.c.func.html create mode 100644 dlt_lcov_report/shared/dlt_multiple_files.c.gcov.html create mode 100644 dlt_lcov_report/shared/dlt_offline_trace.c.func-sort-c.html create mode 100644 dlt_lcov_report/shared/dlt_offline_trace.c.func.html create mode 100644 dlt_lcov_report/shared/dlt_offline_trace.c.gcov.html create mode 100644 dlt_lcov_report/shared/dlt_protocol.c.func-sort-c.html create mode 100644 dlt_lcov_report/shared/dlt_protocol.c.func.html create mode 100644 dlt_lcov_report/shared/dlt_protocol.c.gcov.html create mode 100644 dlt_lcov_report/shared/dlt_user_shared.c.func-sort-c.html create mode 100644 dlt_lcov_report/shared/dlt_user_shared.c.func.html create mode 100644 dlt_lcov_report/shared/dlt_user_shared.c.gcov.html create mode 100644 dlt_lcov_report/shared/index-sort-f.html create mode 100644 dlt_lcov_report/shared/index-sort-l.html create mode 100644 dlt_lcov_report/shared/index.html create mode 100644 dlt_lcov_report/snow.png create mode 100644 dlt_lcov_report/updown.png delete mode 160000 googletest diff --git a/.gitmodules b/.gitmodules index 8cf8b5e33..e69de29bb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "googletest"] - path = googletest - url = https://github.com/google/googletest.git diff --git a/dlt_lcov_report/amber.png b/dlt_lcov_report/amber.png new file mode 100644 index 0000000000000000000000000000000000000000..2cab170d8359081983a4e343848dfe06bc490f12 GIT binary patch literal 141 zcmeAS@N?(olHy`uVBq!ia0vp^j3CU&3?x-=hn)ga>?NMQuI!iC1^G2tW}LqE04T&+ z;1OBOz`!j8!i<;h*8KqrvZOouIx;Y9?C1WI$O`1M1^9%x{(levWG + + + + + + LCOV - dlt_final_coverage.info - console/dlt-control-common.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console - dlt-control-common.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:14721369.0 %
Date:2024-12-05 09:07:13Functions:181994.7 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
set_verbosity0
dlt_control_callback2
dlt_control_deinit2
dlt_control_init2
dlt_control_init_connection2
dlt_control_listen_to_daemon2
dlt_control_prepare_message2
dlt_control_send_message2
dlt_parse_config_param2
get_timeout2
prepare_extra_headers2
prepare_headers2
set_conf2
set_ecuid2
set_resync_serial_header2
set_send_serial_header2
set_timeout2
get_ecuid4
get_verbosity18
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/dlt-control-common.c.func.html b/dlt_lcov_report/console/dlt-control-common.c.func.html new file mode 100644 index 000000000..52398c74d --- /dev/null +++ b/dlt_lcov_report/console/dlt-control-common.c.func.html @@ -0,0 +1,148 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/dlt-control-common.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console - dlt-control-common.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:14721369.0 %
Date:2024-12-05 09:07:13Functions:181994.7 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_control_callback2
dlt_control_deinit2
dlt_control_init2
dlt_control_init_connection2
dlt_control_listen_to_daemon2
dlt_control_prepare_message2
dlt_control_send_message2
dlt_parse_config_param2
get_ecuid4
get_timeout2
get_verbosity18
prepare_extra_headers2
prepare_headers2
set_conf2
set_ecuid2
set_resync_serial_header2
set_send_serial_header2
set_timeout2
set_verbosity0
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/dlt-control-common.c.gcov.html b/dlt_lcov_report/console/dlt-control-common.c.gcov.html new file mode 100644 index 000000000..76972b985 --- /dev/null +++ b/dlt_lcov_report/console/dlt-control-common.c.gcov.html @@ -0,0 +1,1050 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/dlt-control-common.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console - dlt-control-common.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:14721369.0 %
Date:2024-12-05 09:07:13Functions:181994.7 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /**
+       2             :  * Copyright (C) 2015  Advanced Driver Information Technology.
+       3             :  * This code is developed by Advanced Driver Information Technology.
+       4             :  * Copyright of Advanced Driver Information Technology, Bosch and DENSO.
+       5             :  *
+       6             :  * This file is part of COVESA Project Dlt - Diagnostic Log and Trace console apps.
+       7             :  *
+       8             :  *
+       9             :  * \copyright
+      10             :  * This Source Code Form is subject to the terms of the
+      11             :  * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
+      12             :  * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+      13             :  *
+      14             :  *
+      15             :  * \author Christoph Lipka <clipka@jp.adit-jv.com> ADIT 2015
+      16             :  * \author Frederic Berat <fberat@de.adit-jv.com> ADIT 2015
+      17             :  *
+      18             :  * \file dlt-control-common.c
+      19             :  * For further information see http://www.covesa.org/.
+      20             :  */
+      21             : 
+      22             : /*******************************************************************************
+      23             : **                                                                            **
+      24             : **  SRC-MODULE: dlt-control-common.c                                          **
+      25             : **                                                                            **
+      26             : **  TARGET    : linux                                                         **
+      27             : **                                                                            **
+      28             : **  PROJECT   : DLT                                                           **
+      29             : **                                                                            **
+      30             : **  AUTHOR    : Christoph Lipka clipka@jp.adit-jv.com                         **
+      31             : **  PURPOSE   :                                                               **
+      32             : **                                                                            **
+      33             : **  REMARKS   :                                                               **
+      34             : **                                                                            **
+      35             : **  PLATFORM DEPENDANT [yes/no]: yes                                          **
+      36             : **                                                                            **
+      37             : **  TO BE CHANGED BY USER [yes/no]: no                                        **
+      38             : **                                                                            **
+      39             : *******************************************************************************/
+      40             : 
+      41             : /*******************************************************************************
+      42             : **                      Author Identity                                       **
+      43             : ********************************************************************************
+      44             : **                                                                            **
+      45             : ** Initials     Name                       Company                            **
+      46             : ** --------     -------------------------  ---------------------------------- **
+      47             : **  cl          Christoph Lipka            ADIT                               **
+      48             : **  fb          Frederic Berat             ADIT                               **
+      49             : *******************************************************************************/
+      50             : #define pr_fmt(fmt) "Common control: "fmt
+      51             : 
+      52             : #include <errno.h>
+      53             : #include <dirent.h>
+      54             : #include <stdio.h>
+      55             : #include <stdlib.h>
+      56             : #include <string.h>
+      57             : #include <pthread.h>
+      58             : #include <sys/types.h>
+      59             : #include <sys/socket.h>
+      60             : 
+      61             : #include "dlt_common.h"
+      62             : #include "dlt_protocol.h"
+      63             : #include "dlt_client.h"
+      64             : 
+      65             : #include "dlt-control-common.h"
+      66             : 
+      67             : #ifdef EXTENDED_FILTERING
+      68             :     #   if defined(__linux__) || defined(__ANDROID_API__)
+      69             :     #      include <json-c/json.h> /* for json filter parsing on Linux and Android */
+      70             :     #   endif
+      71             :     #   ifdef __QNX__
+      72             :     #      include <sys/json.h> /* for json filter parsing on QNX */
+      73             :     #   endif
+      74             : #endif
+      75             : 
+      76             : #define DLT_CTRL_APID    "DLTC"
+      77             : #define DLT_CTRL_CTID    "DLTC"
+      78             : 
+      79             : /** @brief Analyze the daemon answer
+      80             :  *
+      81             :  * This function as to be provided by the user of the connection.
+      82             :  *
+      83             :  * @param answer  The textual answer of the daemon
+      84             :  * @param payload The daemons answer payload
+      85             :  * @param length  The daemons answer payload length
+      86             :  *
+      87             :  * @return User defined.
+      88             :  */
+      89             : static int (*response_analyzer_cb)(char *, void *, int);
+      90             : 
+      91             : static pthread_t daemon_connect_thread;
+      92             : static DltClient g_client;
+      93             : static int callback_return = -1;
+      94             : static pthread_mutex_t answer_lock = PTHREAD_MUTEX_INITIALIZER;
+      95             : static pthread_cond_t answer_cond = PTHREAD_COND_INITIALIZER;
+      96             : 
+      97             : static int local_verbose;
+      98             : static char local_ecuid[DLT_CTRL_ECUID_LEN]; /* Name of ECU */
+      99             : static int local_timeout;
+     100             : static char local_filename[DLT_MOUNT_PATH_MAX]= {0}; /* Path to dlt.conf */
+     101             : 
+     102          18 : int get_verbosity(void)
+     103             : {
+     104          46 :     return local_verbose;
+     105             : }
+     106             : 
+     107           0 : void set_verbosity(int v)
+     108             : {
+     109           2 :     local_verbose = !!v;
+     110           0 : }
+     111             : 
+     112           4 : char *get_ecuid(void)
+     113             : {
+     114           4 :     return local_ecuid;
+     115             : }
+     116             : 
+     117           2 : void set_ecuid(char *ecuid)
+     118             : {
+     119           2 :     char *ecuid_conf = NULL;
+     120             : 
+     121           2 :     if (local_ecuid != ecuid) {
+     122             :         /* If user pass NULL, read ECUId from dlt.conf */
+     123           0 :         if (ecuid == NULL) {
+     124           0 :             if (dlt_parse_config_param("ECUId", &ecuid_conf) == 0) {
+     125             :                 memset(local_ecuid, 0, DLT_CTRL_ECUID_LEN);
+     126           0 :                 strncpy(local_ecuid, ecuid_conf, DLT_CTRL_ECUID_LEN);
+     127           0 :                 local_ecuid[DLT_CTRL_ECUID_LEN -1] = '\0';
+     128             :                 if (ecuid_conf !=NULL)
+     129           0 :                     free(ecuid_conf);
+     130             :             }
+     131             :             else {
+     132           0 :                 pr_error("Cannot read ECUid from dlt.conf\n");
+     133             :             }
+     134             :         }
+     135             :         else {
+     136             :             /* Set user passed ECUID */
+     137             :             memset(local_ecuid, 0, DLT_CTRL_ECUID_LEN);
+     138             :             strncpy(local_ecuid, ecuid, DLT_CTRL_ECUID_LEN);
+     139           0 :             local_ecuid[DLT_CTRL_ECUID_LEN - 1] = '\0';
+     140             :         }
+     141             :     }
+     142           2 : }
+     143             : 
+     144           2 : void set_conf(char *file_path)
+     145             : {
+     146           2 :     if (file_path != NULL) {
+     147             :         memset(local_filename, 0, DLT_MOUNT_PATH_MAX);
+     148             :         strncpy(local_filename, file_path, DLT_MOUNT_PATH_MAX);
+     149           2 :         local_filename[DLT_MOUNT_PATH_MAX - 1] = '\0';
+     150             :     }
+     151             :     else {
+     152           0 :         pr_error("Argument is NULL\n");
+     153             :     }
+     154           2 : }
+     155             : 
+     156           2 : int get_timeout(void)
+     157             : {
+     158           2 :     return local_timeout;
+     159             : }
+     160             : 
+     161           2 : void set_timeout(int t)
+     162             : {
+     163           2 :     local_timeout = DLT_CTRL_TIMEOUT;
+     164             : 
+     165           2 :     if (t > 1)
+     166           2 :         local_timeout = t;
+     167             :     else
+     168           0 :         pr_error("Timeout to small. Set to default: %d",
+     169             :                  DLT_CTRL_TIMEOUT);
+     170           2 : }
+     171             : 
+     172           2 : void set_send_serial_header(const int value)
+     173             : {
+     174           2 :     g_client.send_serial_header = value;
+     175           2 : }
+     176             : 
+     177           2 : void set_resync_serial_header(const int value)
+     178             : {
+     179           2 :     g_client.resync_serial_header = value;
+     180           2 : }
+     181             : 
+     182           2 : int dlt_parse_config_param(char *config_id, char **config_data)
+     183             : {
+     184             :     FILE *pFile = NULL;
+     185             :     int value_length = DLT_LINE_LEN;
+     186           2 :     char line[DLT_LINE_LEN - 1] = { 0 };
+     187           2 :     char token[DLT_LINE_LEN] = { 0 };
+     188           2 :     char value[DLT_LINE_LEN] = { 0 };
+     189             :     char *pch = NULL;
+     190             :     const char *filename = NULL;
+     191             : 
+     192           2 :     if (*config_data != NULL)
+     193           0 :         *config_data = NULL;
+     194             : 
+     195             :     /* open configuration file */
+     196           2 :     if (local_filename[0] != 0) {
+     197             :         filename = local_filename;
+     198             :     } else {
+     199             :         filename = CONFIGURATION_FILES_DIR "/dlt.conf";
+     200             :     }
+     201           2 :     pFile = fopen(filename, "r");
+     202             : 
+     203           2 :     if (pFile != NULL) {
+     204             :         while (1) {
+     205             :             /* fetch line from configuration file */
+     206          14 :             if (fgets(line, value_length - 1, pFile) != NULL) {
+     207          12 :                 if (strncmp(line, config_id, strlen(config_id)) == 0) {
+     208           2 :                     pch = strtok(line, " =\r\n");
+     209           2 :                     token[0] = 0;
+     210           2 :                     value[0] = 0;
+     211             : 
+     212           4 :                     while (pch != NULL) {
+     213           4 :                         if (token[0] == 0) {
+     214             :                             strncpy(token, pch, sizeof(token) - 1);
+     215           2 :                             token[sizeof(token) - 1] = 0;
+     216             :                         }
+     217             :                         else {
+     218             :                             strncpy(value, pch, sizeof(value) - 1);
+     219           2 :                             value[sizeof(value) - 1] = 0;
+     220           2 :                             break;
+     221             :                         }
+     222             : 
+     223           2 :                         pch = strtok(NULL, " =\r\n");
+     224             :                     }
+     225             : 
+     226           2 :                     if (token[0] && value[0]) {
+     227           2 :                         if (strcmp(token, config_id) == 0) {
+     228           2 :                             *(config_data) = (char *)
+     229           2 :                                 calloc(DLT_DAEMON_FLAG_MAX, sizeof(char));
+     230             :                             memcpy(*config_data,
+     231             :                                    value,
+     232             :                                    DLT_DAEMON_FLAG_MAX - 1);
+     233             :                         }
+     234             :                     }
+     235             :                 }
+     236             :             }
+     237             :             else {
+     238             :                 break;
+     239             :             }
+     240             :         }
+     241             : 
+     242           2 :         fclose (pFile);
+     243             :     }
+     244             :     else {
+     245           0 :         fprintf(stderr, "Cannot open configuration file: %s\n", filename);
+     246             :     }
+     247             : 
+     248           2 :     if (*config_data == NULL)
+     249           0 :         return -1;
+     250             : 
+     251             :     return 0;
+     252             : }
+     253             : 
+     254             : /** @brief Prepare the extra headers of a DLT message
+     255             :  *
+     256             :  * Modifies the extra headers of the message so that it can be sent.
+     257             :  *
+     258             :  * @param msg The message to be prepared
+     259             :  * @param header The base header to be used.
+     260             :  *
+     261             :  * @return 0 on success, -1 otherwise.
+     262             :  */
+     263           2 : static int prepare_extra_headers(DltMessage *msg, uint8_t *header)
+     264             : {
+     265             :     uint32_t shift = 0;
+     266             : 
+     267           2 :     pr_verbose("Preparing extra headers.\n");
+     268             : 
+     269           2 :     if (!msg || !header)
+     270             :         return -1;
+     271             : 
+     272           2 :     shift = (uint32_t) (sizeof(DltStorageHeader) +
+     273             :         sizeof(DltStandardHeader) +
+     274           2 :         DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp));
+     275             : 
+     276             :     /* Set header extra parameters */
+     277           2 :     dlt_set_id(msg->headerextra.ecu, get_ecuid());
+     278             : 
+     279           2 :     msg->headerextra.tmsp = dlt_uptime();
+     280             : 
+     281             :     /* Copy header extra parameters to header buffer */
+     282           2 :     if (dlt_message_set_extraparameters(msg, get_verbosity()) == -1) {
+     283           0 :         pr_error("Cannot copy header extra parameter\n");
+     284           0 :         return -1;
+     285             :     }
+     286             : 
+     287             :     /* prepare extended header */
+     288           2 :     msg->extendedheader = (DltExtendedHeader *)(header + shift);
+     289             : 
+     290           2 :     msg->extendedheader->msin = DLT_MSIN_CONTROL_REQUEST;
+     291             : 
+     292           2 :     msg->extendedheader->noar = 1; /* one payload packet */
+     293             : 
+     294             :     /* Dummy values have to be set */
+     295           2 :     dlt_set_id(msg->extendedheader->apid, DLT_CTRL_APID);
+     296           2 :     dlt_set_id(msg->extendedheader->ctid, DLT_CTRL_CTID);
+     297             : 
+     298           2 :     return 0;
+     299             : }
+     300             : 
+     301             : /** @brief Prepare the headers of a DLT message
+     302             :  *
+     303             :  * Modifies the headers of the message so that it can be sent.
+     304             :  *
+     305             :  * @param msg The message to be prepared
+     306             :  * @param header The base header to be used.
+     307             :  *
+     308             :  * @return 0 on success, -1 otherwise.
+     309             :  */
+     310           2 : static int prepare_headers(DltMessage *msg, uint8_t *header)
+     311             : {
+     312             :     uint32_t len = 0;
+     313             : 
+     314           2 :     pr_verbose("Preparing headers.\n");
+     315             : 
+     316           2 :     if (!msg || !header)
+     317             :         return -1;
+     318             : 
+     319           2 :     msg->storageheader = (DltStorageHeader *)header;
+     320             : 
+     321           2 :     if (dlt_set_storageheader(msg->storageheader, "") == -1) {
+     322           0 :         pr_error("Storage header initialization failed.\n");
+     323           0 :         return -1;
+     324             :     }
+     325             : 
+     326             :     /* prepare standard header */
+     327           2 :     msg->standardheader =
+     328           2 :         (DltStandardHeader *)(header + sizeof(DltStorageHeader));
+     329             : 
+     330           2 :     msg->standardheader->htyp = DLT_HTYP_WEID |
+     331             :         DLT_HTYP_WTMS | DLT_HTYP_UEH | DLT_HTYP_PROTOCOL_VERSION1;
+     332             : 
+     333             : #if (BYTE_ORDER == BIG_ENDIAN)
+     334             :     msg->standardheader->htyp = (msg->standardheader->htyp | DLT_HTYP_MSBF);
+     335             : #endif
+     336             : 
+     337           2 :     msg->standardheader->mcnt = 0;
+     338             : 
+     339             :     /* prepare length information */
+     340           2 :     msg->headersize = (uint32_t) (sizeof(DltStorageHeader) +
+     341             :         sizeof(DltStandardHeader) +
+     342             :         sizeof(DltExtendedHeader) +
+     343             :         DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp));
+     344             : 
+     345           2 :     len = (uint32_t) (msg->headersize - sizeof(DltStorageHeader) + msg->datasize);
+     346             : 
+     347           2 :     if (len > UINT16_MAX) {
+     348           0 :         pr_error("Message header is too long.\n");
+     349           0 :         return -1;
+     350             :     }
+     351             : 
+     352           2 :     msg->standardheader->len = DLT_HTOBE_16(len);
+     353             : 
+     354           2 :     return 0;
+     355             : }
+     356             : 
+     357             : /** @brief Prepare a DLT message.
+     358             :  *
+     359             :  * The DLT message is built using the data given by the user.
+     360             :  * The data is basically composed of a buffer and a size.
+     361             :  *
+     362             :  * @param data The message body to be used to build the DLT message.
+     363             :  *
+     364             :  * @return 0 on success, -1 otherwise.
+     365             :  */
+     366           2 : static DltMessage *dlt_control_prepare_message(DltControlMsgBody *data)
+     367             : {
+     368             :     DltMessage *msg = NULL;
+     369             : 
+     370           2 :     pr_verbose("Preparing message.\n");
+     371             : 
+     372           2 :     if (data == NULL) {
+     373           0 :         pr_error("Data for message body is NULL\n");
+     374           0 :         return NULL;
+     375             :     }
+     376             : 
+     377           2 :     msg = calloc(1, sizeof(DltMessage));
+     378             : 
+     379           2 :     if (msg == NULL) {
+     380           0 :         pr_error("Cannot allocate memory for Dlt Message\n");
+     381           0 :         return NULL;
+     382             :     }
+     383             : 
+     384           2 :     if (dlt_message_init(msg, get_verbosity()) == -1) {
+     385           0 :         pr_error("Cannot initialize Dlt Message\n");
+     386           0 :         free(msg);
+     387           0 :         return NULL;
+     388             :     }
+     389             : 
+     390             :     /* prepare payload of data */
+     391           2 :     msg->databuffersize = msg->datasize = (uint32_t) data->size;
+     392             : 
+     393             :     /* Allocate memory for Dlt Message's buffer */
+     394           2 :     msg->databuffer = (uint8_t *)calloc(1, data->size);
+     395             : 
+     396           2 :     if (msg->databuffer == NULL) {
+     397           0 :         pr_error("Cannot allocate memory for data buffer\n");
+     398           0 :         free(msg);
+     399           0 :         return NULL;
+     400             :     }
+     401             : 
+     402             :     /* copy data into message */
+     403           2 :     memcpy(msg->databuffer, data->data, data->size);
+     404             : 
+     405             :     /* prepare storage header */
+     406           2 :     if (prepare_headers(msg, msg->headerbuffer)) {
+     407           0 :         dlt_message_free(msg, get_verbosity());
+     408           0 :         free(msg);
+     409           0 :         return NULL;
+     410             :     }
+     411             : 
+     412             :     /* prepare extra headers */
+     413           2 :     if (prepare_extra_headers(msg, msg->headerbuffer)) {
+     414           0 :         dlt_message_free(msg, get_verbosity());
+     415           0 :         free(msg);
+     416           0 :         return NULL;
+     417             :     }
+     418             : 
+     419             :     return msg;
+     420             : }
+     421             : 
+     422             : /** @brief Initialize the connection with the daemon
+     423             :  *
+     424             :  * The connection is initialized using an internal callback. The user's
+     425             :  * response analyzer will be finally executed by this callback.
+     426             :  * The client pointer is used to established the connection.
+     427             :  *
+     428             :  * @param client A pointer to a valid client structure
+     429             :  * @param cb The internal callback to be executed while receiving a new message
+     430             :  *
+     431             :  * @return 0 on success, -1 otherwise.
+     432             :  */
+     433           2 : static int dlt_control_init_connection(DltClient *client, void *cb)
+     434             : {
+     435           2 :     int (*callback)(DltMessage *message, void *data) = cb;
+     436             : 
+     437           2 :     if (!cb || !client) {
+     438           0 :         pr_error("%s: Invalid parameters\n", __func__);
+     439           0 :         return -1;
+     440             :     }
+     441             : 
+     442           2 :     pr_verbose("Initializing the connection.\n");
+     443             : 
+     444           2 :     if (dlt_client_init(client, get_verbosity()) != 0) {
+     445           0 :         pr_error("Failed to register callback (NULL)\n");
+     446           0 :         return -1;
+     447             :     }
+     448             : 
+     449           2 :     dlt_client_register_message_callback(callback);
+     450             : 
+     451           2 :     client->socketPath = NULL;
+     452             : 
+     453           2 :     if (dlt_parse_config_param("ControlSocketPath", &client->socketPath) != 0) {
+     454             :         /* Failed to read from conf, copy default */
+     455           0 :         if (dlt_client_set_socket_path(client, DLT_DAEMON_DEFAULT_CTRL_SOCK_PATH) == -1) {
+     456           0 :             pr_error("set socket path didn't succeed\n");
+     457           0 :             return -1;
+     458             :         }
+     459             :     }
+     460             : 
+     461           2 :     client->mode = DLT_CLIENT_MODE_UNIX;
+     462             : 
+     463           2 :     return dlt_client_connect(client, get_verbosity());
+     464             : }
+     465             : 
+     466             : /** @brief Daemon listener function
+     467             :  *
+     468             :  * This function will continuously read on the DLT socket, until an error occurs
+     469             :  * or the thread executing this function is canceled.
+     470             :  *
+     471             :  * @param data Thread parameter
+     472             :  *
+     473             :  * @return The thread parameter given as argument.
+     474             :  */
+     475           2 : static void *dlt_control_listen_to_daemon(void *data)
+     476             : {
+     477           2 :     pr_verbose("Ready to receive DLT answers.\n");
+     478           2 :     dlt_client_main_loop(&g_client, NULL, get_verbosity());
+     479           2 :     return data;
+     480             : }
+     481             : 
+     482             : /** @brief Internal callback for DLT response
+     483             :  *
+     484             :  * This function is called by the dlt_client_main_loop once a response is read
+     485             :  * from the DLT socket.
+     486             :  * After some basic checks, the user's response analyzer is called. The return
+     487             :  * value of the analyzer is then provided back to the dlt_control_send_message
+     488             :  * function to be given back as a return value.
+     489             :  * As this function is called in a dedicated thread, the return value is
+     490             :  * provided using a global variable.
+     491             :  * Access to this variable is controlled through a dedicated mutex.
+     492             :  * New values are signaled using a dedicated condition variable.
+     493             :  *
+     494             :  * @param message The DLT answer
+     495             :  * @param data Unused
+     496             :  *
+     497             :  * @return The analyzer return value or -1 on early errors.
+     498             :  */
+     499           2 : static int dlt_control_callback(DltMessage *message, void *data)
+     500             : {
+     501           2 :     char text[DLT_RECEIVE_BUFSIZE] = { 0 };
+     502             :     (void)data;
+     503             : 
+     504           2 :     if (message == NULL) {
+     505           0 :         pr_error("Received message is null\n");
+     506           0 :         return -1;
+     507             :     }
+     508             : 
+     509             :     /* prepare storage header */
+     510           2 :     if (DLT_IS_HTYP_WEID(message->standardheader->htyp))
+     511           2 :         dlt_set_storageheader(message->storageheader, message->headerextra.ecu);
+     512             :     else
+     513           0 :         dlt_set_storageheader(message->storageheader, "LCTL");
+     514             : 
+     515           2 :     dlt_message_header(message, text, DLT_RECEIVE_BUFSIZE, get_verbosity());
+     516             : 
+     517             :     /* Extracting payload */
+     518           2 :     dlt_message_payload(message, text,
+     519             :                         DLT_RECEIVE_BUFSIZE,
+     520             :                         DLT_OUTPUT_ASCII,
+     521             :                         get_verbosity());
+     522             : 
+     523             :     /*
+     524             :      * Checking payload with the provided callback and return the result
+     525             :      */
+     526           2 :     pthread_mutex_lock(&answer_lock);
+     527           4 :     callback_return = response_analyzer_cb(text,
+     528           2 :                                            message->databuffer,
+     529           2 :                                            (int) message->datasize);
+     530           2 :     pthread_cond_signal(&answer_cond);
+     531           2 :     pthread_mutex_unlock(&answer_lock);
+     532             : 
+     533           2 :     return callback_return;
+     534             : }
+     535             : 
+     536             : /** @brief Send a message to the daemon and wait for the asynchronous answer.
+     537             :  *
+     538             :  * The answer is received and analyzed by a dedicated thread. Thus we need
+     539             :  * to wait for the signal from this thread and then read the return value
+     540             :  * to be provided to the user.
+     541             :  * In case of timeout, this function fails.
+     542             :  * The message provided by the user is formated in DLT format before sending.
+     543             :  *
+     544             :  * @param body The message provided by the user
+     545             :  * @param timeout The time to wait before considering that no answer will come
+     546             :  *
+     547             :  * @return The user response analyzer return value, -1 in case of early error.
+     548             :  */
+     549           2 : int dlt_control_send_message(DltControlMsgBody *body, int timeout)
+     550             : {
+     551             :     struct timespec t;
+     552             :     DltMessage *msg = NULL;
+     553             : 
+     554           2 :     if (!body) {
+     555           0 :         pr_error("%s: Invalid input.\n", __func__);
+     556           0 :         return -1;
+     557             :     }
+     558             : 
+     559           2 :     if (clock_gettime(CLOCK_REALTIME, &t) == -1) {
+     560           0 :         pr_error("Cannot read system time.\n");
+     561           0 :         return -1;
+     562             :     }
+     563             : 
+     564           2 :     t.tv_sec += timeout;
+     565             : 
+     566             :     /* send command to daemon here */
+     567           2 :     msg = dlt_control_prepare_message(body);
+     568             : 
+     569           2 :     if (msg == NULL) {
+     570           0 :         pr_error("Control message preparation failed\n");
+     571           0 :         return -1;
+     572             :     }
+     573             : 
+     574           2 :     pthread_mutex_lock(&answer_lock);
+     575             : 
+     576             :     /* Re-init the return value */
+     577           2 :     callback_return = -1;
+     578             : 
+     579           2 :     if (dlt_client_send_message_to_socket(&g_client, msg) != DLT_RETURN_OK)
+     580             :     {
+     581           0 :         pr_error("Sending message to daemon failed\n");
+     582           0 :         dlt_message_free(msg, get_verbosity());
+     583           0 :         free(msg);
+     584             : 
+     585             :         /* make sure the mutex is unlocked to prevent deadlocks */
+     586           0 :         pthread_mutex_unlock(&answer_lock);
+     587           0 :         return -1;
+     588             :     }
+     589             : 
+     590             :     /*
+     591             :     * When a timeouts occurs, pthread_cond_timedwait()
+     592             :     * shall nonetheless release and re-acquire the mutex referenced by mutex
+     593             :     */
+     594           2 :     pthread_cond_timedwait(&answer_cond, &answer_lock, &t);
+     595           2 :     pthread_mutex_unlock(&answer_lock);
+     596             : 
+     597             :     /* Destroying the message */
+     598           2 :     dlt_message_free(msg, get_verbosity());
+     599           2 :     free(msg);
+     600             : 
+     601             :     /* At this point either the value is already correct, either it's still -1.
+     602             :      * Then, we don't care to lock the access.
+     603             :      */
+     604           2 :     return callback_return;
+     605             : }
+     606             : 
+     607             : /** @brief Control communication initialization
+     608             :  *
+     609             :  * This will prepare the DLT connection and the thread dedicated to the
+     610             :  * response listening.
+     611             :  *
+     612             :  * @param response_analyzer User defined function used to analyze the response
+     613             :  * @param ecuid The ECUID to provide to the daemon
+     614             :  * @param verbosity The verbosity level
+     615             :  *
+     616             :  * @return 0 on success, -1 otherwise.
+     617             :  */
+     618           2 : int dlt_control_init(int (*response_analyzer)(char *, void *, int),
+     619             :                      char *ecuid,
+     620             :                      int verbosity)
+     621             : {
+     622           2 :     if (!response_analyzer || !ecuid) {
+     623           0 :         pr_error("%s: Invalid input.\n", __func__);
+     624           0 :         return -1;
+     625             :     }
+     626             : 
+     627           2 :     response_analyzer_cb = response_analyzer;
+     628           2 :     set_ecuid(ecuid);
+     629             :     set_verbosity(verbosity);
+     630             : 
+     631           2 :     if (dlt_control_init_connection(&g_client, dlt_control_callback) != 0) {
+     632           0 :         pr_error("Connection initialization failed\n");
+     633           0 :         dlt_client_cleanup(&g_client, get_verbosity());
+     634           0 :         return -1;
+     635             :     }
+     636             : 
+     637             :     /* Contact DLT daemon */
+     638           2 :     if (pthread_create(&daemon_connect_thread,
+     639             :                        NULL,
+     640             :                        dlt_control_listen_to_daemon,
+     641             :                        NULL) != 0) {
+     642           0 :         pr_error("Cannot create thread to communicate with DLT daemon.\n");
+     643           0 :         return -1;
+     644             :     }
+     645             : 
+     646             :     return 0;
+     647             : }
+     648             : 
+     649             : /** @brief Control communication clean-up
+     650             :  *
+     651             :  * Cancels the listener thread and clean=up the dlt client structure.
+     652             :  *
+     653             :  * @return 0 on success, -1 otherwise.
+     654             :  */
+     655           2 : int dlt_control_deinit(void)
+     656             : {
+     657             :     /* At this stage, we want to stop sending/receiving
+     658             :      * from dlt-daemon. So in order to avoid cancellation
+     659             :      * at recv(), shutdown and close the socket
+     660             :      */
+     661           2 :     if (g_client.receiver.fd) {
+     662           2 :         shutdown(g_client.receiver.fd, SHUT_RDWR);
+     663           2 :         close(g_client.receiver.fd);
+     664           2 :         g_client.receiver.fd = -1;
+     665             :     }
+     666             : 
+     667             :         /* Stopping the listener thread */
+     668           2 :     if (pthread_cancel(daemon_connect_thread)) {
+     669           0 :         pr_error("Unable to cancel the thread with ERRNO=%s\n", strerror(errno));
+     670             :     }
+     671             :     else {
+     672           2 :         if (pthread_join(daemon_connect_thread, NULL)) {
+     673           0 :             pr_error("Unable to join the thread with ERRNO=%s\n", strerror(errno));
+     674             :         }
+     675             :     }
+     676             : 
+     677             :     /* Closing the socket */
+     678           2 :     return dlt_client_cleanup(&g_client, get_verbosity());
+     679             : }
+     680             : 
+     681             : 
+     682             : #ifdef EXTENDED_FILTERING /* EXTENDED_FILTERING */
+     683             : #   if defined(__linux__) || defined(__ANDROID_API__)
+     684             : DltReturnValue dlt_json_filter_load(DltFilter *filter, const char *filename, int verbose)
+     685             : {
+     686             :     if ((filter == NULL) || (filename == NULL))
+     687             :         return DLT_RETURN_WRONG_PARAMETER;
+     688             : 
+     689             :     if(verbose)
+     690             :         pr_verbose("dlt_json_filter_load()\n");
+     691             : 
+     692             :     FILE *handle;
+     693             :     char buffer[JSON_FILTER_SIZE*DLT_FILTER_MAX];
+     694             :     struct json_object *j_parsed_json;
+     695             :     struct json_object *j_app_id;
+     696             :     struct json_object *j_context_id;
+     697             :     struct json_object *j_log_level;
+     698             :     struct json_object *j_payload_min;
+     699             :     struct json_object *j_payload_max;
+     700             :     enum json_tokener_error jerr;
+     701             : 
+     702             :     char app_id[DLT_ID_SIZE + 1] = "";
+     703             :     char context_id[DLT_ID_SIZE + 1] = "";
+     704             :     int32_t log_level = 0;
+     705             :     int32_t payload_max = INT32_MAX;
+     706             :     int32_t payload_min = 0;
+     707             : 
+     708             :     handle = fopen(filename, "r");
+     709             : 
+     710             :     if (handle == NULL) {
+     711             :         pr_error("Filter file %s cannot be opened!\n", filename);
+     712             :         return DLT_RETURN_ERROR;
+     713             :     }
+     714             : 
+     715             :     if (fread(buffer, sizeof(buffer), 1, handle) != 0) {
+     716             :         if (!feof(handle)) {
+     717             :             pr_error("Filter file %s is to big for reading it with current buffer!\n", filename);
+     718             :             return DLT_RETURN_ERROR;
+     719             :         }
+     720             :     }
+     721             : 
+     722             :     j_parsed_json = json_tokener_parse_verbose(buffer, &jerr);
+     723             : 
+     724             :     if (jerr != json_tokener_success) {
+     725             :         pr_error("Faild to parse given filter %s: %s\n", filename, json_tokener_error_desc(jerr));
+     726             :         return DLT_RETURN_ERROR;
+     727             :     }
+     728             : 
+     729             :     printf("The following filter(s) are applied: \n");
+     730             :     pr_verbose("The following filter(s) are applied: \n");
+     731             :     int iterator = 0;
+     732             :     json_object_object_foreach(j_parsed_json, key, val)
+     733             :     {
+     734             :         if (iterator >= DLT_FILTER_MAX) {
+     735             :             pr_error("Maximum number (%d) of allowed filters reached, ignoring rest of filters!\n",
+     736             :                      DLT_FILTER_MAX);
+     737             :             break;
+     738             :         }
+     739             : 
+     740             :         printf("%s:\n", key);
+     741             :         pr_verbose("%s:\n", key);
+     742             : 
+     743             :         if (json_object_object_get_ex(val, "AppId", &j_app_id))
+     744             :             strncpy(app_id, json_object_get_string(j_app_id), DLT_ID_SIZE);
+     745             :         else
+     746             :             dlt_set_id(app_id, "");
+     747             : 
+     748             :         if (json_object_object_get_ex(val, "ContextId", &j_context_id))
+     749             :             strncpy(context_id, json_object_get_string(j_context_id), DLT_ID_SIZE);
+     750             :         else
+     751             :             dlt_set_id(context_id, "");
+     752             : 
+     753             :         if (json_object_object_get_ex(val, "LogLevel", &j_log_level))
+     754             :             log_level = json_object_get_int(j_log_level);
+     755             :         else
+     756             :             log_level = 0;
+     757             : 
+     758             :         if (json_object_object_get_ex(val, "PayloadMin", &j_payload_min))
+     759             :             payload_min = json_object_get_int(j_payload_min);
+     760             :         else
+     761             :             payload_min = 0;
+     762             : 
+     763             :         if (json_object_object_get_ex(val, "PayloadMax", &j_payload_max))
+     764             :             payload_max = json_object_get_int(j_payload_max);
+     765             :         else
+     766             :             payload_max = INT32_MAX;
+     767             : 
+     768             :         dlt_filter_add(filter, app_id, context_id, log_level, payload_min, payload_max, verbose);
+     769             : 
+     770             :         printf("\tAppId: %.*s\n", DLT_ID_SIZE, app_id);
+     771             :         pr_verbose("\tAppId: %.*s\n", DLT_ID_SIZE, app_id);
+     772             :         printf("\tConextId: %.*s\n", DLT_ID_SIZE, context_id);
+     773             :         pr_verbose("\tConextId: %.*s\n", DLT_ID_SIZE, context_id);
+     774             :         printf("\tLogLevel: %i\n", log_level);
+     775             :         pr_verbose("\tLogLevel: %i\n", log_level);
+     776             :         printf("\tPayloadMin: %i\n", payload_min);
+     777             :         pr_verbose("\tPayloadMin: %i\n", payload_min);
+     778             :         printf("\tPayloadMax: %i\n", payload_max);
+     779             :         pr_verbose("\tPayloadMax: %i\n", payload_max);
+     780             : 
+     781             :         iterator++;
+     782             :     }
+     783             : 
+     784             :     fclose(handle);
+     785             : 
+     786             :     return DLT_RETURN_OK;
+     787             : }
+     788             : #   endif /* __Linux__ */
+     789             : 
+     790             : #   ifdef __QNX__
+     791             : DltReturnValue dlt_json_filter_load(DltFilter *filter, const char *filename, int verbose)
+     792             : {
+     793             :     if ((filter == NULL) || (filename == NULL))
+     794             :         return DLT_RETURN_WRONG_PARAMETER;
+     795             : 
+     796             :     if(verbose)
+     797             :         pr_verbose("dlt_json_filter_load()\n");
+     798             : 
+     799             :     json_decoder_t *j_decoder = json_decoder_create();
+     800             : 
+     801             :     const char *s_app_id;
+     802             :     const char *s_context_id;
+     803             :     int32_t log_level = 0;
+     804             :     int32_t payload_max = INT32_MAX;
+     805             :     int32_t payload_min = 0;
+     806             : 
+     807             :     json_decoder_error_t ret = json_decoder_parse_file(j_decoder, filename);
+     808             : 
+     809             :     if (ret != JSON_DECODER_OK) {
+     810             :         pr_error("Faild to parse given filter %s: json_decoder_error_t is %i\n", filename, ret);
+     811             :         return DLT_RETURN_ERROR;
+     812             :     }
+     813             : 
+     814             :     json_decoder_push_object(j_decoder, NULL, true);
+     815             : 
+     816             :     int iterator = 0;
+     817             :     bool end_of_json = false;
+     818             : 
+     819             :     while (!end_of_json) {
+     820             :         if (iterator >= DLT_FILTER_MAX) {
+     821             :             pr_error("Maximum number (%d) of allowed filters reached, ignoring rest of filters!\n",
+     822             :                      DLT_FILTER_MAX);
+     823             :             break;
+     824             :         }
+     825             : 
+     826             :         if (json_decoder_next(j_decoder) == JSON_DECODER_NOT_FOUND)
+     827             :             end_of_json = true;
+     828             : 
+     829             :         json_decoder_previous(j_decoder);
+     830             : 
+     831             :         printf("%s:\n", json_decoder_name(j_decoder));
+     832             :         json_decoder_push_object(j_decoder, NULL, true);
+     833             : 
+     834             :         if (json_decoder_get_string(j_decoder, "AppId", &s_app_id, true) != JSON_DECODER_OK)
+     835             :             s_app_id = "";
+     836             : 
+     837             :         if (json_decoder_get_string(j_decoder, "ContextId", &s_context_id, true) != JSON_DECODER_OK)
+     838             :             s_context_id = "";
+     839             : 
+     840             :         if (json_decoder_get_int(j_decoder, "LogLevel", &log_level, true) != JSON_DECODER_OK)
+     841             :             log_level = 0;
+     842             : 
+     843             :         if (json_decoder_get_int(j_decoder, "PayloadMin", &payload_min, true) != JSON_DECODER_OK)
+     844             :             payload_min = 0;
+     845             : 
+     846             :         if (json_decoder_get_int(j_decoder, "PayloadMax", &payload_max, true) != JSON_DECODER_OK)
+     847             :             payload_max = INT32_MAX;
+     848             : 
+     849             :         char app_id[DLT_ID_SIZE];
+     850             :         char context_id[DLT_ID_SIZE];
+     851             : 
+     852             :         #pragma GCC diagnostic push
+     853             :         #pragma GCC diagnostic ignored "-Wstringop-truncation"
+     854             :         strncpy(app_id, s_app_id, DLT_ID_SIZE);
+     855             :         strncpy(context_id, s_context_id, DLT_ID_SIZE);
+     856             :         #pragma GCC diagnostic pop
+     857             : 
+     858             :         dlt_filter_add(filter, app_id, context_id, log_level, payload_min, payload_max, verbose);
+     859             : 
+     860             :         printf("\tAppId: %.*s\n", DLT_ID_SIZE, app_id);
+     861             :         printf("\tConextId: %.*s\n", DLT_ID_SIZE, context_id);
+     862             :         printf("\tLogLevel: %i\n", log_level);
+     863             :         printf("\tPayloadMin: %i\n", payload_min);
+     864             :         printf("\tPayloadMax: %i\n", payload_max);
+     865             : 
+     866             :         json_decoder_pop(j_decoder);
+     867             : 
+     868             :         iterator++;
+     869             :     }
+     870             : 
+     871             :     json_decoder_destroy(j_decoder);
+     872             : 
+     873             :     return DLT_RETURN_OK;
+     874             : }
+     875             : #   endif /* __QNX__ */
+     876             : #endif /* EXTENDED_FILTERING */
+     877             : 
+     878             : #ifdef EXTENDED_FILTERING /* EXTENDED_FILTERING */
+     879             : #   if defined(__linux__) || defined(__ANDROID_API__)
+     880             : DltReturnValue dlt_json_filter_save(DltFilter *filter, const char *filename, int verbose)
+     881             : {
+     882             :     if ((filter == NULL) || (filename == NULL))
+     883             :         return DLT_RETURN_WRONG_PARAMETER;
+     884             : 
+     885             :     if(verbose)
+     886             :         pr_verbose("dlt_json_filter_save()\n");
+     887             : 
+     888             :     struct json_object *json_filter_obj = json_object_new_object();
+     889             : 
+     890             :     for (int num = 0; num < filter->counter; num++) {
+     891             :         struct json_object *tmp_json_obj = json_object_new_object();
+     892             :         char filter_name[JSON_FILTER_NAME_SIZE];
+     893             :         sprintf(filter_name, "filter%i", num);
+     894             : 
+     895             :         if (filter->apid[num][DLT_ID_SIZE - 1] != 0)
+     896             :             json_object_object_add(tmp_json_obj, "AppId", json_object_new_string_len(filter->apid[num], DLT_ID_SIZE));
+     897             :         else
+     898             :             json_object_object_add(tmp_json_obj, "AppId", json_object_new_string(filter->apid[num]));
+     899             : 
+     900             :         if (filter->ctid[num][DLT_ID_SIZE - 1] != 0)
+     901             :             json_object_object_add(tmp_json_obj, "ContextId",
+     902             :                                    json_object_new_string_len(filter->ctid[num], DLT_ID_SIZE));
+     903             :         else
+     904             :             json_object_object_add(tmp_json_obj, "ContextId", json_object_new_string(filter->ctid[num]));
+     905             : 
+     906             :         json_object_object_add(tmp_json_obj, "LogLevel", json_object_new_int(filter->log_level[num]));
+     907             :         json_object_object_add(tmp_json_obj, "PayloadMin", json_object_new_int(filter->payload_min[num]));
+     908             :         json_object_object_add(tmp_json_obj, "PayloadMax", json_object_new_int(filter->payload_max[num]));
+     909             : 
+     910             :         json_object_object_add(json_filter_obj, filter_name, tmp_json_obj);
+     911             :     }
+     912             : 
+     913             :     printf("Saving current filter into '%s'\n", filename);
+     914             :     json_object_to_file((char*)filename, json_filter_obj);
+     915             : 
+     916             :     return DLT_RETURN_OK;
+     917             : }
+     918             : #   endif /* __Linux__ */
+     919             : 
+     920             : #   ifdef __QNX__
+     921             : DltReturnValue dlt_json_filter_save(DltFilter *filter, const char *filename, int verbose)
+     922             : {
+     923             :     if ((filter == NULL) || (filename == NULL))
+     924             :         return DLT_RETURN_WRONG_PARAMETER;
+     925             : 
+     926             :     if(verbose)
+     927             :         pr_verbose("dlt_json_filter_save()\n");
+     928             : 
+     929             :     char s_app_id[DLT_ID_SIZE + 1];
+     930             :     char s_context_id[DLT_ID_SIZE + 1];
+     931             : 
+     932             :     json_encoder_t *j_encoder = json_encoder_create();
+     933             :     json_encoder_start_object(j_encoder, NULL);
+     934             : 
+     935             :     for (int num = 0; num < filter->counter; num++) {
+     936             :         char filter_name[JSON_FILTER_NAME_SIZE];
+     937             :         sprintf(filter_name, "filter%i", num);
+     938             :         json_encoder_start_object(j_encoder, filter_name);
+     939             : 
+     940             :         strncpy(s_app_id, filter->apid[num], DLT_ID_SIZE);
+     941             : 
+     942             :         if (filter->apid[num][DLT_ID_SIZE - 1] != 0)
+     943             :             s_app_id[DLT_ID_SIZE] = '\0';
+     944             : 
+     945             :         strncpy(s_context_id, filter->ctid[num], DLT_ID_SIZE);
+     946             : 
+     947             :         if (filter->ctid[num][DLT_ID_SIZE - 1] != 0)
+     948             :             s_context_id[DLT_ID_SIZE] = '\0';
+     949             : 
+     950             :         json_encoder_add_string(j_encoder, "AppId", s_app_id);
+     951             :         json_encoder_add_string(j_encoder, "ContextId", s_context_id);
+     952             :         json_encoder_add_int(j_encoder, "LogLevel", filter->log_level[num]);
+     953             :         json_encoder_add_int(j_encoder, "PayloadMin", filter->payload_min[num]);
+     954             :         json_encoder_add_int(j_encoder, "PayloadMax", filter->payload_max[num]);
+     955             : 
+     956             :         json_encoder_end_object(j_encoder);
+     957             :     }
+     958             : 
+     959             :     json_encoder_end_object(j_encoder);
+     960             : 
+     961             :     printf("Saving current filter into '%s'\n", filename);
+     962             :     FILE *handle = fopen(filename, "w");
+     963             :     int filter_buffer_size = 100 * (filter->counter);
+     964             :     char filter_buffer[filter_buffer_size];
+     965             :     snprintf(filter_buffer, filter_buffer_size, json_encoder_buffer(j_encoder));
+     966             :     fprintf(handle, filter_buffer);
+     967             : 
+     968             :     fclose(handle);
+     969             :     json_encoder_destroy(j_encoder);
+     970             : 
+     971             :     return DLT_RETURN_OK;
+     972             : }
+     973             : #   endif /* __QNX__ */
+     974             : #endif /* EXTENDED_FILTERING */
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/dlt-convert.c.func-sort-c.html b/dlt_lcov_report/console/dlt-convert.c.func-sort-c.html new file mode 100644 index 000000000..96b582997 --- /dev/null +++ b/dlt_lcov_report/console/dlt-convert.c.func-sort-c.html @@ -0,0 +1,84 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/dlt-convert.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console - dlt-convert.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:4018421.7 %
Date:2024-12-05 09:07:13Functions:1333.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
empty_dir0
usage0
main18
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/dlt-convert.c.func.html b/dlt_lcov_report/console/dlt-convert.c.func.html new file mode 100644 index 000000000..c2c95a696 --- /dev/null +++ b/dlt_lcov_report/console/dlt-convert.c.func.html @@ -0,0 +1,84 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/dlt-convert.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console - dlt-convert.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:4018421.7 %
Date:2024-12-05 09:07:13Functions:1333.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
empty_dir0
main18
usage0
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/dlt-convert.c.gcov.html b/dlt_lcov_report/console/dlt-convert.c.gcov.html new file mode 100644 index 000000000..56b13f9e0 --- /dev/null +++ b/dlt_lcov_report/console/dlt-convert.c.gcov.html @@ -0,0 +1,610 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/dlt-convert.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console - dlt-convert.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:4018421.7 %
Date:2024-12-05 09:07:13Functions:1333.3 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2011-2015, BMW AG
+       5             :  *
+       6             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       7             :  *
+       8             :  * This Source Code Form is subject to the terms of the
+       9             :  * Mozilla Public License (MPL), v. 2.0.
+      10             :  * If a copy of the MPL was not distributed with this file,
+      11             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      12             :  *
+      13             :  * For further information see http://www.covesa.org/.
+      14             :  */
+      15             : 
+      16             : /*!
+      17             :  * \author Alexander Wenzel <alexander.aw.wenzel@bmw.de>
+      18             :  *
+      19             :  * \copyright Copyright © 2011-2015 BMW AG. \n
+      20             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      21             :  *
+      22             :  * \file dlt-convert.c
+      23             :  */
+      24             : 
+      25             : /*******************************************************************************
+      26             : **                                                                            **
+      27             : **  SRC-MODULE: dlt-convert.c                                                 **
+      28             : **                                                                            **
+      29             : **  TARGET    : linux                                                         **
+      30             : **                                                                            **
+      31             : **  PROJECT   : DLT                                                           **
+      32             : **                                                                            **
+      33             : **  AUTHOR    : Alexander Wenzel Alexander.AW.Wenzel@bmw.de                   **
+      34             : **              Markus Klein                                                  **
+      35             : **                                                                            **
+      36             : **  PURPOSE   :                                                               **
+      37             : **                                                                            **
+      38             : **  REMARKS   :                                                               **
+      39             : **                                                                            **
+      40             : **  PLATFORM DEPENDANT [yes/no]: yes                                          **
+      41             : **                                                                            **
+      42             : **  TO BE CHANGED BY USER [yes/no]: no                                        **
+      43             : **                                                                            **
+      44             : *******************************************************************************/
+      45             : 
+      46             : /*******************************************************************************
+      47             : **                      Author Identity                                       **
+      48             : ********************************************************************************
+      49             : **                                                                            **
+      50             : ** Initials     Name                       Company                            **
+      51             : ** --------     -------------------------  ---------------------------------- **
+      52             : **  aw          Alexander Wenzel           BMW                                **
+      53             : **  mk          Markus Klein               Fraunhofer ESK                     **
+      54             : *******************************************************************************/
+      55             : 
+      56             : /*******************************************************************************
+      57             : **                      Author Identity                                       **
+      58             : ********************************************************************************
+      59             : **                                                                            **
+      60             : ** Initials     Name                       Company                            **
+      61             : ** --------     -------------------------  ---------------------------------- **
+      62             : **  aw          Alexander Wenzel           BMW                                **
+      63             : *******************************************************************************/
+      64             : 
+      65             : /*******************************************************************************
+      66             : **                      Revision Control History                              **
+      67             : *******************************************************************************/
+      68             : 
+      69             : /*
+      70             :  * $LastChangedRevision: 1670 $
+      71             :  * $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
+      72             :  * $LastChangedBy$
+      73             :  * Initials    Date         Comment
+      74             :  * aw          13.01.2010   initial
+      75             :  */
+      76             : 
+      77             : #include <dirent.h>
+      78             : #include <stdio.h>
+      79             : #include <stdlib.h>
+      80             : #include <unistd.h>
+      81             : #include <string.h>
+      82             : #include <ctype.h>
+      83             : #include <errno.h>
+      84             : 
+      85             : #include <sys/stat.h>
+      86             : #include <fcntl.h>
+      87             : 
+      88             : #include <sys/uio.h> /* writev() */
+      89             : 
+      90             : #include "dlt_common.h"
+      91             : 
+      92             : #define COMMAND_SIZE        1024    /* Size of command */
+      93             : #define FILENAME_SIZE       1024    /* Size of filename */
+      94             : #define DLT_EXTENSION       "dlt"
+      95             : #define DLT_CONVERT_WS      "/tmp/dlt_convert_workspace/"
+      96             : 
+      97             : /**
+      98             :  * Print usage information of tool.
+      99             :  */
+     100           0 : void usage()
+     101             : {
+     102             :     char version[DLT_CONVERT_TEXTBUFSIZE];
+     103             : 
+     104           0 :     dlt_get_version(version, 255);
+     105             : 
+     106             :     printf("Usage: dlt-convert [options] [commands] file1 [file2]\n");
+     107             :     printf("Read DLT files, print DLT messages as ASCII and store the messages again.\n");
+     108             :     printf("Use filters to filter DLT messages.\n");
+     109             :     printf("Use Ranges and Output file to cut DLT files.\n");
+     110             :     printf("Use two files and Output file to join DLT files.\n");
+     111             :     printf("%s \n", version);
+     112             :     printf("Commands:\n");
+     113             :     printf("  -h            Usage\n");
+     114             :     printf("  -a            Print DLT file; payload as ASCII\n");
+     115             :     printf("  -x            Print DLT file; payload as hex\n");
+     116             :     printf("  -m            Print DLT file; payload as hex and ASCII\n");
+     117             :     printf("  -s            Print DLT file; only headers\n");
+     118             :     printf("  -o filename   Output messages in new DLT file\n");
+     119             :     printf("Options:\n");
+     120             :     printf("  -v            Verbose mode\n");
+     121             :     printf("  -c            Count number of messages\n");
+     122             :     printf("  -f filename   Enable filtering of messages\n");
+     123             :     printf("  -b number     First <number> messages to be handled\n");
+     124             :     printf("  -e number     Last <number> messages to be handled\n");
+     125             :     printf("  -w            Follow dlt file while file is increasing\n");
+     126             :     printf("  -t            Handling input compressed files (tar.gz)\n");
+     127           0 : }
+     128             : 
+     129           0 : void empty_dir(const char *dir)
+     130             : {
+     131           0 :     struct dirent **files = { 0 };
+     132             :     struct stat st;
+     133             :     uint32_t n = 0;
+     134           0 :     char tmp_filename[FILENAME_SIZE] = { 0 };
+     135             :     uint32_t i;
+     136             : 
+     137           0 :     if (dir == NULL) {
+     138           0 :         fprintf(stderr, "ERROR: %s: invalid arguments\n", __FUNCTION__);
+     139           0 :         return;
+     140             :     }
+     141             : 
+     142           0 :     if (stat(dir, &st) == 0) {
+     143           0 :         if (S_ISDIR(st.st_mode)) {
+     144           0 :             n = (uint32_t) scandir(dir, &files, NULL, alphasort);
+     145             : 
+     146             :             /* Do not include /. and /.. */
+     147           0 :             if (n < 2)
+     148           0 :                 fprintf(stderr, "ERROR: Failed to scan %s with error %s\n",
+     149           0 :                         dir, strerror(errno));
+     150           0 :             else if (n == 2)
+     151             :                 printf("%s is already empty\n", dir);
+     152             :             else {
+     153           0 :                 for (i = 2; i < n; i++) {
+     154             :                     memset(tmp_filename, 0, FILENAME_SIZE);
+     155           0 :                     snprintf(tmp_filename, FILENAME_SIZE, "%s%s", dir, files[i]->d_name);
+     156             : 
+     157           0 :                     if (remove(tmp_filename) != 0)
+     158           0 :                         fprintf(stderr, "ERROR: Failed to delete %s with error %s\n",
+     159           0 :                                 tmp_filename, strerror(errno));
+     160             :                 }
+     161           0 :                 if (files) {
+     162           0 :                     for (i = 0; i < n ; i++)
+     163           0 :                         if (files[i]) {
+     164           0 :                             free(files[i]);
+     165           0 :                             files[i] = NULL;
+     166             :                         }
+     167           0 :                     free(files);
+     168             :                     files = NULL;
+     169             :                 }
+     170             :             }
+     171             :         }
+     172             :         else
+     173           0 :             fprintf(stderr, "ERROR: %s is not a directory\n", dir);
+     174             :     }
+     175             :     else
+     176           0 :         fprintf(stderr, "ERROR: Failed to stat %s with error %s\n", dir, strerror(errno));
+     177             : }
+     178             : 
+     179             : /**
+     180             :  * Main function of tool.
+     181             :  */
+     182          18 : int main(int argc, char *argv[])
+     183             : {
+     184             :     int vflag = 0;
+     185             :     int cflag = 0;
+     186             :     int aflag = 0;
+     187             :     int sflag = 0;
+     188             :     int xflag = 0;
+     189             :     int mflag = 0;
+     190             :     int wflag = 0;
+     191             :     int tflag = 0;
+     192             :     char *fvalue = 0;
+     193             :     char *bvalue = 0;
+     194             :     char *evalue = 0;
+     195             :     char *ovalue = 0;
+     196             : 
+     197             :     int index;
+     198             :     int c;
+     199             : 
+     200             :     DltFile file;
+     201             :     DltFilter filter;
+     202             : 
+     203             :     int ohandle = -1;
+     204             : 
+     205             :     int num, begin, end;
+     206             : 
+     207          18 :     char text[DLT_CONVERT_TEXTBUFSIZE] = { 0 };
+     208             : 
+     209             :     /* For handling compressed files */
+     210          18 :     char tmp_filename[FILENAME_SIZE] = { 0 };
+     211             :     struct stat st;
+     212             :     memset(&st, 0, sizeof(struct stat));
+     213          18 :     struct dirent **files = { 0 };
+     214             :     int n = 0;
+     215             :     int i = 0;
+     216             : 
+     217             :     struct iovec iov[2];
+     218             :     int bytes_written = 0;
+     219             :     int syserr = 0;
+     220             : 
+     221          18 :     opterr = 0;
+     222             : 
+     223          36 :     while ((c = getopt (argc, argv, "vcashxmwtf:b:e:o:")) != -1) {
+     224          18 :         switch (c)
+     225             :         {
+     226             :         case 'v':
+     227             :         {
+     228             :             vflag = 1;
+     229             :             break;
+     230             :         }
+     231           0 :         case 'c':
+     232             :         {
+     233             :             cflag = 1;
+     234           0 :             break;
+     235             :         }
+     236          18 :         case 'a':
+     237             :         {
+     238             :             aflag = 1;
+     239          18 :             break;
+     240             :         }
+     241           0 :         case 's':
+     242             :         {
+     243             :             sflag = 1;
+     244           0 :             break;
+     245             :         }
+     246           0 :         case 'x':
+     247             :         {
+     248             :             xflag = 1;
+     249           0 :             break;
+     250             :         }
+     251           0 :         case 'm':
+     252             :         {
+     253             :             mflag = 1;
+     254           0 :             break;
+     255             :         }
+     256           0 :         case 'w':
+     257             :         {
+     258             :             wflag = 1;
+     259           0 :             break;
+     260             :         }
+     261           0 :         case 't':
+     262             :         {
+     263             :             tflag = 1;
+     264           0 :             break;
+     265             :         }
+     266           0 :         case 'h':
+     267             :         {
+     268           0 :             usage();
+     269           0 :             return -1;
+     270             :         }
+     271           0 :         case 'f':
+     272             :         {
+     273           0 :             fvalue = optarg;
+     274           0 :             break;
+     275             :         }
+     276           0 :         case 'b':
+     277             :         {
+     278           0 :             bvalue = optarg;
+     279           0 :             break;
+     280             :         }
+     281           0 :         case 'e':
+     282             :         {
+     283           0 :             evalue = optarg;
+     284           0 :             break;
+     285             :         }
+     286           0 :         case 'o':
+     287             :         {
+     288           0 :             ovalue = optarg;
+     289           0 :             break;
+     290             :         }
+     291           0 :         case '?':
+     292             :         {
+     293           0 :             if ((optopt == 'f') || (optopt == 'b') || (optopt == 'e') || (optopt == 'o'))
+     294           0 :                 fprintf (stderr, "Option -%c requires an argument.\n", optopt);
+     295           0 :             else if (isprint (optopt))
+     296           0 :                 fprintf (stderr, "Unknown option `-%c'.\n", optopt);
+     297             :             else
+     298           0 :                 fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
+     299             : 
+     300             :             /* unknown or wrong option used, show usage information and terminate */
+     301           0 :             usage();
+     302           0 :             return -1;
+     303             :         }
+     304             :         default:
+     305             :         {
+     306             :             return -1;    /*for parasoft */
+     307             :         }
+     308             :         }
+     309             :     }
+     310             : 
+     311             :     /* Initialize structure to use DLT file */
+     312          18 :     dlt_file_init(&file, vflag);
+     313             : 
+     314             :     /* first parse filter file if filter parameter is used */
+     315          18 :     if (fvalue) {
+     316           0 :         if (dlt_filter_load(&filter, fvalue, vflag) < DLT_RETURN_OK) {
+     317           0 :             dlt_file_free(&file, vflag);
+     318           0 :             return -1;
+     319             :         }
+     320             : 
+     321           0 :         dlt_file_set_filter(&file, &filter, vflag);
+     322             :     }
+     323             : 
+     324          18 :     if (ovalue) {
+     325             :         ohandle = open(ovalue, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* mode: wb */
+     326             : 
+     327           0 :         if (ohandle == -1) {
+     328           0 :             dlt_file_free(&file, vflag);
+     329           0 :             fprintf(stderr, "ERROR: Output file %s cannot be opened!\n", ovalue);
+     330           0 :             return -1;
+     331             :         }
+     332             :     }
+     333             : 
+     334          18 :     if (tflag) {
+     335             :         /* Prepare the temp dir to untar compressed files */
+     336           0 :         if (stat(DLT_CONVERT_WS, &st) == -1) {
+     337           0 :             if (mkdir(DLT_CONVERT_WS, 0700) != 0) {
+     338           0 :                 fprintf(stderr,"ERROR: Cannot create temp dir %s!\n", DLT_CONVERT_WS);
+     339           0 :                 if (ovalue)
+     340           0 :                     close(ohandle);
+     341             : 
+     342           0 :                 return -1;
+     343             :             }
+     344             :         }
+     345             :         else {
+     346           0 :             if (S_ISDIR(st.st_mode))
+     347           0 :                 empty_dir(DLT_CONVERT_WS);
+     348             :             else
+     349           0 :                 fprintf(stderr, "ERROR: %s is not a directory", DLT_CONVERT_WS);
+     350             :         }
+     351             : 
+     352           0 :         for (index = optind; index < argc; index++) {
+     353             :             /* Check extension of input file
+     354             :              * If it is a compressed file, uncompress it
+     355             :              */
+     356           0 :             if (strcmp(get_filename_ext(argv[index]), DLT_EXTENSION) != 0) {
+     357           0 :                 syserr = dlt_execute_command(NULL, "tar", "xf", argv[index], "-C", DLT_CONVERT_WS, NULL);
+     358           0 :                 if (syserr != 0)
+     359           0 :                     fprintf(stderr, "ERROR: Failed to uncompress %s to %s with error [%d]\n",
+     360           0 :                             argv[index], DLT_CONVERT_WS, WIFEXITED(syserr));
+     361             :             }
+     362             :             else {
+     363           0 :                 syserr = dlt_execute_command(NULL, "cp", argv[index], DLT_CONVERT_WS, NULL);
+     364           0 :                 if (syserr != 0)
+     365           0 :                     fprintf(stderr, "ERROR: Failed to copy %s to %s with error [%d]\n",
+     366           0 :                             argv[index], DLT_CONVERT_WS, WIFEXITED(syserr));
+     367             :             }
+     368             : 
+     369             :         }
+     370             : 
+     371           0 :         n = scandir(DLT_CONVERT_WS, &files, NULL, alphasort);
+     372           0 :         if (n == -1) {
+     373           0 :             fprintf(stderr,"ERROR: Cannot scan temp dir %s!\n", DLT_CONVERT_WS);
+     374           0 :             if (ovalue)
+     375           0 :                 close(ohandle);
+     376             : 
+     377           0 :             return -1;
+     378             :         }
+     379             : 
+     380             :         /* do not include ./ and ../ in the files */
+     381           0 :         argc = optind + (n - 2);
+     382             :     }
+     383             : 
+     384          35 :     for (index = optind; index < argc; index++) {
+     385          18 :         if (tflag) {
+     386             :             memset(tmp_filename, 0, FILENAME_SIZE);
+     387             :             snprintf(tmp_filename, FILENAME_SIZE, "%s%s",
+     388           0 :                     DLT_CONVERT_WS, files[index - optind + 2]->d_name);
+     389             : 
+     390           0 :             argv[index] = tmp_filename;
+     391             :         }
+     392             : 
+     393             :         /* load, analyze data file and create index list */
+     394          18 :         if (dlt_file_open(&file, argv[index], vflag) >= DLT_RETURN_OK) {
+     395         526 :             while (dlt_file_read(&file, vflag) >= DLT_RETURN_OK) {
+     396             :             }
+     397             :         }
+     398             : 
+     399          18 :         if (aflag || sflag || xflag || mflag || ovalue) {
+     400          18 :             if (bvalue)
+     401             :                 begin = atoi(bvalue);
+     402             :             else
+     403             :                 begin = 0;
+     404             : 
+     405          18 :             if (evalue && (wflag == 0))
+     406             :                 end = atoi(evalue);
+     407             :             else
+     408          18 :                 end = file.counter - 1;
+     409             : 
+     410          18 :             if ((begin < 0) || (begin >= file.counter)) {
+     411           1 :                 fprintf(stderr, "ERROR: Selected first message %d is out of range!\n", begin);
+     412           1 :                 if (ovalue)
+     413           0 :                     close(ohandle);
+     414             : 
+     415           1 :                 return -1;
+     416             :             }
+     417             : 
+     418          17 :             if ((end < 0) || (end >= file.counter) || (end < begin)) {
+     419           0 :                 fprintf(stderr, "ERROR: Selected end message %d is out of range!\n", end);
+     420           0 :                 if (ovalue)
+     421           0 :                     close(ohandle);
+     422             : 
+     423           0 :                 return -1;
+     424             :             }
+     425             : 
+     426         526 :             for (num = begin; num <= end; num++) {
+     427         509 :                 if (dlt_file_message(&file, num, vflag) < DLT_RETURN_OK)
+     428           0 :                     continue;
+     429             : 
+     430         509 :                 if (xflag) {
+     431             :                     printf("%d ", num);
+     432           0 :                     if (dlt_message_print_hex(&(file.msg), text, DLT_CONVERT_TEXTBUFSIZE, vflag) < DLT_RETURN_OK)
+     433           0 :                         continue;
+     434             :                 }
+     435         509 :                 else if (aflag) {
+     436             :                     printf("%d ", num);
+     437             : 
+     438         509 :                     if (dlt_message_header(&(file.msg), text, DLT_CONVERT_TEXTBUFSIZE, vflag) < DLT_RETURN_OK)
+     439           0 :                         continue;
+     440             : 
+     441             :                     printf("%s ", text);
+     442             : 
+     443         509 :                     if (dlt_message_payload(&file.msg, text, DLT_CONVERT_TEXTBUFSIZE, DLT_OUTPUT_ASCII, vflag) < DLT_RETURN_OK)
+     444           0 :                         continue;
+     445             : 
+     446             :                     printf("[%s]\n", text);
+     447             :                 }
+     448           0 :                 else if (mflag) {
+     449             :                     printf("%d ", num);
+     450           0 :                     if (dlt_message_print_mixed_plain(&(file.msg), text, DLT_CONVERT_TEXTBUFSIZE, vflag) < DLT_RETURN_OK)
+     451           0 :                         continue;
+     452             :                 }
+     453           0 :                 else if (sflag) {
+     454             :                     printf("%d ", num);
+     455             : 
+     456           0 :                     if (dlt_message_header(&(file.msg), text, DLT_CONVERT_TEXTBUFSIZE, vflag) < DLT_RETURN_OK)
+     457           0 :                         continue;
+     458             : 
+     459             :                     printf("%s \n", text);
+     460             :                 }
+     461             : 
+     462             :                 /* if file output enabled write message */
+     463         509 :                 if (ovalue) {
+     464           0 :                     iov[0].iov_base = file.msg.headerbuffer;
+     465           0 :                     iov[0].iov_len = (uint32_t) file.msg.headersize;
+     466           0 :                     iov[1].iov_base = file.msg.databuffer;
+     467           0 :                     iov[1].iov_len = (uint32_t) file.msg.datasize;
+     468             : 
+     469           0 :                     bytes_written =(int) writev(ohandle, iov, 2);
+     470             : 
+     471           0 :                     if (0 > bytes_written) {
+     472             :                         printf("in main: writev(ohandle, iov, 2); returned an error!");
+     473           0 :                         close(ohandle);
+     474           0 :                         dlt_file_free(&file, vflag);
+     475           0 :                         return -1;
+     476             :                     }
+     477             :                 }
+     478             : 
+     479             :                 /* check for new messages if follow flag set */
+     480         509 :                 if (wflag && (num == end)) {
+     481             :                     while (1) {
+     482           0 :                         while (dlt_file_read(&file, 0) >= 0){
+     483             :                         }
+     484             : 
+     485           0 :                         if (end == (file.counter - 1)) {
+     486             :                             /* Sleep if no new message was received */
+     487             :                             struct timespec req;
+     488           0 :                             req.tv_sec = 0;
+     489           0 :                             req.tv_nsec = 100000000;
+     490           0 :                             nanosleep(&req, NULL);
+     491             :                         }
+     492             :                         else {
+     493             :                             /* set new end of log file and continue reading */
+     494             :                             end = file.counter - 1;
+     495             :                             break;
+     496             :                         }
+     497             :                     }
+     498             :                 }
+     499             :             }
+     500             :         }
+     501             : 
+     502          17 :         if (cflag) {
+     503           0 :             printf("Total number of messages: %d\n", file.counter_total);
+     504             : 
+     505           0 :             if (file.filter)
+     506           0 :                 printf("Filtered number of messages: %d\n", file.counter);
+     507             :         }
+     508             :     }
+     509             : 
+     510          17 :     if (ovalue)
+     511           0 :         close(ohandle);
+     512             : 
+     513          17 :     if (tflag) {
+     514           0 :         empty_dir(DLT_CONVERT_WS);
+     515           0 :         if (files) {
+     516           0 :             for (i = 0; i < n ; i++)
+     517           0 :                 if (files[i])
+     518           0 :                     free(files[i]);
+     519             : 
+     520           0 :             free(files);
+     521             :         }
+     522           0 :         rmdir(DLT_CONVERT_WS);
+     523             :     }
+     524          17 :     if (index == optind) {
+     525             :         /* no file selected, show usage and terminate */
+     526           0 :         fprintf(stderr, "ERROR: No file selected\n");
+     527           0 :         usage();
+     528           0 :         return -1;
+     529             :     }
+     530             : 
+     531          17 :     dlt_file_free(&file, vflag);
+     532             : 
+     533          17 :     return 0;
+     534             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/dlt-receive.c.func-sort-c.html b/dlt_lcov_report/console/dlt-receive.c.func-sort-c.html new file mode 100644 index 000000000..ed1dc32cb --- /dev/null +++ b/dlt_lcov_report/console/dlt-receive.c.func-sort-c.html @@ -0,0 +1,100 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/dlt-receive.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console - dlt-receive.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:8724535.5 %
Date:2024-12-05 09:07:13Functions:3742.9 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
convert_arg_to_byte_size0
dlt_receive_close_output_file0
dlt_receive_open_output_file0
usage0
main1
signal_handler1
dlt_receive_message_callback206
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/dlt-receive.c.func.html b/dlt_lcov_report/console/dlt-receive.c.func.html new file mode 100644 index 000000000..f406131e6 --- /dev/null +++ b/dlt_lcov_report/console/dlt-receive.c.func.html @@ -0,0 +1,100 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/dlt-receive.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console - dlt-receive.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:8724535.5 %
Date:2024-12-05 09:07:13Functions:3742.9 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
convert_arg_to_byte_size0
dlt_receive_close_output_file0
dlt_receive_message_callback206
dlt_receive_open_output_file0
main1
signal_handler1
usage0
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/dlt-receive.c.gcov.html b/dlt_lcov_report/console/dlt-receive.c.gcov.html new file mode 100644 index 000000000..114823e1f --- /dev/null +++ b/dlt_lcov_report/console/dlt-receive.c.gcov.html @@ -0,0 +1,819 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/dlt-receive.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console - dlt-receive.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:8724535.5 %
Date:2024-12-05 09:07:13Functions:3742.9 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2011-2015, BMW AG
+       5             :  *
+       6             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       7             :  *
+       8             :  * This Source Code Form is subject to the terms of the
+       9             :  * Mozilla Public License (MPL), v. 2.0.
+      10             :  * If a copy of the MPL was not distributed with this file,
+      11             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      12             :  *
+      13             :  * For further information see http://www.covesa.org/.
+      14             :  */
+      15             : 
+      16             : /*!
+      17             :  * \author Alexander Wenzel <alexander.aw.wenzel@bmw.de>
+      18             :  *
+      19             :  * \copyright Copyright © 2011-2015 BMW AG. \n
+      20             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      21             :  *
+      22             :  * \file dlt-receive.c
+      23             :  */
+      24             : 
+      25             : 
+      26             : /*******************************************************************************
+      27             : **                                                                            **
+      28             : **  SRC-MODULE: dlt-receive.c                                                 **
+      29             : **                                                                            **
+      30             : **  TARGET    : linux                                                         **
+      31             : **                                                                            **
+      32             : **  PROJECT   : DLT                                                           **
+      33             : **                                                                            **
+      34             : **  AUTHOR    : Alexander Wenzel Alexander.AW.Wenzel@bmw.de                   **
+      35             : **              Markus Klein                                                  **
+      36             : **                                                                            **
+      37             : **  PURPOSE   :                                                               **
+      38             : **                                                                            **
+      39             : **  REMARKS   :                                                               **
+      40             : **                                                                            **
+      41             : **  PLATFORM DEPENDANT [yes/no]: yes                                          **
+      42             : **                                                                            **
+      43             : **  TO BE CHANGED BY USER [yes/no]: no                                        **
+      44             : **                                                                            **
+      45             : *******************************************************************************/
+      46             : 
+      47             : /*******************************************************************************
+      48             : **                      Author Identity                                       **
+      49             : ********************************************************************************
+      50             : **                                                                            **
+      51             : ** Initials     Name                       Company                            **
+      52             : ** --------     -------------------------  ---------------------------------- **
+      53             : **  aw          Alexander Wenzel           BMW                                **
+      54             : **  mk          Markus Klein               Fraunhofer ESK                     **
+      55             : *******************************************************************************/
+      56             : 
+      57             : /*******************************************************************************
+      58             : **                      Revision Control History                              **
+      59             : *******************************************************************************/
+      60             : 
+      61             : /*
+      62             :  * $LastChangedRevision: 1670 $
+      63             :  * $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
+      64             :  * $LastChangedBy$
+      65             :  * Initials    Date         Comment
+      66             :  * aw          13.01.2010   initial
+      67             :  */
+      68             : 
+      69             : #include <ctype.h>      /* for isprint() */
+      70             : #include <stdlib.h>     /* for atoi() */
+      71             : #include <sys/stat.h>   /* for S_IRUSR, S_IWUSR, S_IRGRP, S_IROTH */
+      72             : #include <fcntl.h>      /* for open() */
+      73             : #include <sys/uio.h>    /* for writev() */
+      74             : #include <errno.h>
+      75             : #include <string.h>
+      76             : #include <glob.h>
+      77             : #include <syslog.h>
+      78             : #include <signal.h>
+      79             : #include <sys/socket.h>
+      80             : #ifdef __linux__
+      81             : #   include <linux/limits.h>
+      82             : #else
+      83             : #   include <limits.h>
+      84             : #endif
+      85             : #include <inttypes.h>
+      86             : #include "dlt_log.h"
+      87             : #include "dlt_client.h"
+      88             : #include "dlt-control-common.h"
+      89             : 
+      90             : #define DLT_RECEIVE_ECU_ID "RECV"
+      91             : 
+      92             : DltClient dltclient;
+      93             : static bool sig_close_recv = false;
+      94             : 
+      95           1 : void signal_handler(int signal)
+      96             : {
+      97           1 :     switch (signal) {
+      98           1 :     case SIGHUP:
+      99             :     case SIGTERM:
+     100             :     case SIGINT:
+     101             :     case SIGQUIT:
+     102             :         /* stop main loop */
+     103           1 :         sig_close_recv = true;
+     104           1 :         shutdown(dltclient.receiver.fd, SHUT_RD);
+     105           1 :         break;
+     106             :     default:
+     107             :         /* This case should never happen! */
+     108             :         break;
+     109             :     } /* switch */
+     110             : 
+     111           1 : }
+     112             : 
+     113             : /* Function prototypes */
+     114             : int dlt_receive_message_callback(DltMessage *message, void *data);
+     115             : 
+     116             : typedef struct {
+     117             :     int aflag;
+     118             :     int sflag;
+     119             :     int xflag;
+     120             :     int mflag;
+     121             :     int vflag;
+     122             :     int yflag;
+     123             :     int uflag;
+     124             :     int rflag;
+     125             :     char *ovalue;
+     126             :     char *ovaluebase; /* ovalue without ".dlt" */
+     127             :     char *fvalue;       /* filename for space separated filter file (<AppID> <ContextID>) */
+     128             :     char *jvalue;       /* filename for json filter file */
+     129             :     char *evalue;
+     130             :     int bvalue;
+     131             :     int rvalue;
+     132             :     int sendSerialHeaderFlag;
+     133             :     int resyncSerialHeaderFlag;
+     134             :     int64_t climit;
+     135             :     char ecuid[4];
+     136             :     int ohandle;
+     137             :     int64_t totalbytes; /* bytes written so far into the output file, used to check the file size limit */
+     138             :     int part_num;    /* number of current output file if limit was exceeded */
+     139             :     DltFile file;
+     140             :     DltFilter filter;
+     141             :     int port;
+     142             :     char *ifaddr;
+     143             : } DltReceiveData;
+     144             : 
+     145             : /**
+     146             :  * Print usage information of tool.
+     147             :  */
+     148           0 : void usage()
+     149             : {
+     150             :     char version[255];
+     151             : 
+     152           0 :     dlt_get_version(version, 255);
+     153             : 
+     154             :     printf("Usage: dlt-receive [options] hostname/serial_device_name\n");
+     155             :     printf("Receive DLT messages from DLT daemon and print or store the messages.\n");
+     156             :     printf("Use filters to filter received messages.\n");
+     157             :     printf("%s \n", version);
+     158             :     printf("Options:\n");
+     159             :     printf("  -a            Print DLT messages; payload as ASCII\n");
+     160             :     printf("  -x            Print DLT messages; payload as hex\n");
+     161             :     printf("  -m            Print DLT messages; payload as hex and ASCII\n");
+     162             :     printf("  -s            Print DLT messages; only headers\n");
+     163             :     printf("  -v            Verbose mode\n");
+     164             :     printf("  -h            Usage\n");
+     165             :     printf("  -S            Send message with serial header (Default: Without serial header)\n");
+     166             :     printf("  -R            Enable resync serial header\n");
+     167             :     printf("  -y            Serial device mode\n");
+     168             :     printf("  -u            UDP multicast mode\n");
+     169             :     printf("  -r msecs      Reconnect to server with milli seconds specified\n");
+     170             :     printf("  -i addr       Host interface address\n");
+     171             :     printf("  -b baudrate   Serial device baudrate (Default: 115200)\n");
+     172             :     printf("  -e ecuid      Set ECU ID (Default: RECV)\n");
+     173             :     printf("  -o filename   Output messages in new DLT file\n");
+     174             :     printf("  -c limit      Restrict file size to <limit> bytes when output to file\n");
+     175             :     printf("                When limit is reached, a new file is opened. Use K,M,G as\n");
+     176             :     printf("                suffix to specify kilo-, mega-, giga-bytes respectively\n");
+     177             :     printf("  -f filename   Enable filtering of messages with space separated list (<AppID> <ContextID>)\n");
+     178             :     printf("  -j filename   Enable filtering of messages with filter defined in json file\n");
+     179             :     printf("  -p port       Use the given port instead the default port\n");
+     180             :     printf("                Cannot be used with serial devices\n");
+     181           0 : }
+     182             : 
+     183             : 
+     184           0 : int64_t convert_arg_to_byte_size(char *arg)
+     185             : {
+     186             :     size_t i;
+     187             :     int64_t factor;
+     188             :     int64_t result;
+     189             : 
+     190             :     /* check if valid input */
+     191           0 :     for (i = 0; i < strlen(arg) - 1; ++i)
+     192           0 :         if (!isdigit(arg[i]))
+     193             :             return -2;
+     194             : 
+     195             :     /* last character */
+     196             :     factor = 1;
+     197             : 
+     198           0 :     if ((arg[strlen(arg) - 1] == 'K') || (arg[strlen(arg) - 1] == 'k'))
+     199             :         factor = 1024;
+     200             :     else if ((arg[strlen(arg) - 1] == 'M') || (arg[strlen(arg) - 1] == 'm'))
+     201             :         factor = 1024 * 1024;
+     202             :     else if ((arg[strlen(arg) - 1] == 'G') || (arg[strlen(arg) - 1] == 'g'))
+     203             :         factor = 1024 * 1024 * 1024;
+     204           0 :     else if (!isdigit(arg[strlen(arg) - 1]))
+     205             :         return -2;
+     206             : 
+     207             :     /* range checking */
+     208             :     int64_t const mult = atoll(arg);
+     209             : 
+     210           0 :     if (((INT64_MAX) / factor) < mult)
+     211             :         /* Would overflow! */
+     212             :         return -2;
+     213             : 
+     214           0 :     result = factor * mult;
+     215             : 
+     216             :     /* The result be at least the size of one message
+     217             :      * One message consists of its header + user data:
+     218             :      */
+     219             :     DltMessage msg;
+     220             :     int64_t min_size = sizeof(msg.headerbuffer);
+     221             :     min_size += 2048 /* DLT_USER_BUF_MAX_SIZE */;
+     222             : 
+     223           0 :     if (min_size > result) {
+     224           0 :         dlt_vlog(LOG_ERR,
+     225             :                  "ERROR: Specified limit: %" PRId64 "is smaller than a the size of a single message: %" PRId64 "!\n",
+     226             :                  result,
+     227             :                  min_size);
+     228             :         result = -2;
+     229             :     }
+     230             : 
+     231             :     return result;
+     232             : }
+     233             : 
+     234             : 
+     235             : /*
+     236             :  * open output file
+     237             :  */
+     238           0 : int dlt_receive_open_output_file(DltReceiveData *dltdata)
+     239             : {
+     240             :     /* if (file_already_exists) */
+     241             :     glob_t outer;
+     242             : 
+     243           0 :     if (glob(dltdata->ovalue,
+     244             : #ifndef __ANDROID_API__
+     245             :              GLOB_TILDE |
+     246             : #endif
+     247             :              GLOB_NOSORT, NULL, &outer) == 0) {
+     248           0 :         if (dltdata->vflag)
+     249           0 :             dlt_vlog(LOG_INFO, "File %s already exists, need to rename first\n", dltdata->ovalue);
+     250             : 
+     251           0 :         if (dltdata->part_num < 0) {
+     252             :             char pattern[PATH_MAX + 1];
+     253           0 :             pattern[PATH_MAX] = 0;
+     254           0 :             snprintf(pattern, PATH_MAX, "%s.*.dlt", dltdata->ovaluebase);
+     255             :             glob_t inner;
+     256             : 
+     257             :             /* sort does not help here because we have to traverse the
+     258             :              * full result in any case. Remember, a sorted list would look like:
+     259             :              * foo.1.dlt
+     260             :              * foo.10.dlt
+     261             :              * foo.1000.dlt
+     262             :              * foo.11.dlt
+     263             :              */
+     264           0 :             if (glob(pattern,
+     265             : #ifndef __ANDROID_API__
+     266             :                      GLOB_TILDE |
+     267             : #endif
+     268             :                      GLOB_NOSORT, NULL, &inner) == 0) {
+     269             :                 /* search for the highest number used */
+     270             :                 size_t i;
+     271             : 
+     272           0 :                 for (i = 0; i < inner.gl_pathc; ++i) {
+     273             :                     /* convert string that follows the period after the initial portion,
+     274             :                      * e.g. gt.gl_pathv[i] = foo.1.dlt -> atoi("1.dlt");
+     275             :                      */
+     276           0 :                     int cur = atoi(&inner.gl_pathv[i][strlen(dltdata->ovaluebase) + 1]);
+     277             : 
+     278           0 :                     if (cur > dltdata->part_num)
+     279           0 :                         dltdata->part_num = cur;
+     280             :                 }
+     281             :             }
+     282             : 
+     283           0 :             globfree(&inner);
+     284             : 
+     285           0 :             ++dltdata->part_num;
+     286             : 
+     287             :         }
+     288             : 
+     289             :         char filename[PATH_MAX + 1];
+     290           0 :         filename[PATH_MAX] = 0;
+     291             : 
+     292           0 :         snprintf(filename, PATH_MAX, "%s.%i.dlt", dltdata->ovaluebase,
+     293             :                  dltdata->part_num);
+     294             : 
+     295           0 :         if (rename(dltdata->ovalue, filename) != 0)
+     296           0 :             dlt_vlog(LOG_ERR, "ERROR: rename %s to %s failed with error %s\n",
+     297           0 :                      dltdata->ovalue, filename, strerror(errno));
+     298           0 :         else if (dltdata->vflag) {
+     299           0 :             dlt_vlog(LOG_INFO, "Renaming existing file from %s to %s\n",
+     300             :                      dltdata->ovalue, filename);
+     301           0 :             ++dltdata->part_num;
+     302             :         }
+     303             :     } /* if (file_already_exists) */
+     304             : 
+     305           0 :     globfree(&outer);
+     306             : 
+     307           0 :     dltdata->ohandle = open(dltdata->ovalue, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+     308           0 :     return dltdata->ohandle;
+     309             : }
+     310             : 
+     311             : 
+     312           0 : void dlt_receive_close_output_file(DltReceiveData *dltdata)
+     313             : {
+     314           0 :     if (dltdata->ohandle) {
+     315           0 :         close(dltdata->ohandle);
+     316           0 :         dltdata->ohandle = -1;
+     317             :     }
+     318           0 : }
+     319             : 
+     320             : 
+     321             : /**
+     322             :  * Main function of tool.
+     323             :  */
+     324           1 : int main(int argc, char *argv[])
+     325             : {
+     326             :     DltReceiveData dltdata;
+     327             :     memset(&dltdata, 0, sizeof(dltdata));
+     328             :     int c;
+     329             :     int index;
+     330             : 
+     331             :     /* Initialize dltdata */
+     332           1 :     dltdata.climit = -1; /* default: -1 = unlimited */
+     333           1 :     dltdata.ohandle = -1;
+     334           1 :     dltdata.part_num = -1;
+     335           1 :     dltdata.port = 3490;
+     336             : 
+     337             :     /* Config signal handler */
+     338             :     struct sigaction act;
+     339             : 
+     340             :     /* Initialize signal handler struct */
+     341             :     memset(&act, 0, sizeof(act));
+     342           1 :     act.sa_handler = signal_handler;
+     343           1 :     sigemptyset(&act.sa_mask);
+     344           1 :     sigaction(SIGHUP, &act, 0);
+     345           1 :     sigaction(SIGTERM, &act, 0);
+     346           1 :     sigaction(SIGINT, &act, 0);
+     347           1 :     sigaction(SIGQUIT, &act, 0);
+     348             : 
+     349             :     /* Fetch command line arguments */
+     350           1 :     opterr = 0;
+     351             : 
+     352           2 :     while ((c = getopt(argc, argv, "vashSRyuxmf:j:o:e:b:c:p:i:r:")) != -1)
+     353           1 :         switch (c) {
+     354           0 :         case 'v':
+     355             :         {
+     356           0 :             dltdata.vflag = 1;
+     357           0 :             break;
+     358             :         }
+     359           0 :         case 'a':
+     360             :         {
+     361           0 :             dltdata.aflag = 1;
+     362           0 :             break;
+     363             :         }
+     364           0 :         case 's':
+     365             :         {
+     366           0 :             dltdata.sflag = 1;
+     367           0 :             break;
+     368             :         }
+     369           0 :         case 'x':
+     370             :         {
+     371           0 :             dltdata.xflag = 1;
+     372           0 :             break;
+     373             :         }
+     374           0 :         case 'm':
+     375             :         {
+     376           0 :             dltdata.mflag = 1;
+     377           0 :             break;
+     378             :         }
+     379           0 :         case 'h':
+     380             :         {
+     381           0 :             usage();
+     382           0 :             return -1;
+     383             :         }
+     384           0 :         case 'S':
+     385             :         {
+     386           0 :             dltdata.sendSerialHeaderFlag = 1;
+     387           0 :             break;
+     388             :         }
+     389           0 :         case 'R':
+     390             :         {
+     391           0 :             dltdata.resyncSerialHeaderFlag = 1;
+     392           0 :             break;
+     393             :         }
+     394           0 :         case 'y':
+     395             :         {
+     396           0 :             dltdata.yflag = 1;
+     397           0 :             break;
+     398             :         }
+     399           0 :         case 'u':
+     400             :         {
+     401           0 :             dltdata.uflag = 1;
+     402           0 :             break;
+     403             :         }
+     404           0 :         case 'i':
+     405             :         {
+     406           0 :             dltdata.ifaddr = optarg;
+     407           0 :             break;
+     408             :         }
+     409           0 :         case 'f':
+     410             :         {
+     411           0 :             dltdata.fvalue = optarg;
+     412           0 :             break;
+     413             :         }
+     414           0 :         case 'j':
+     415             :         {
+     416             :             #ifdef EXTENDED_FILTERING
+     417             :             dltdata.jvalue = optarg;
+     418             :             break;
+     419             :             #else
+     420           0 :             fprintf (stderr,
+     421             :                      "Extended filtering is not supported. Please build with the corresponding cmake option to use it.\n");
+     422           0 :             return -1;
+     423             :             #endif
+     424             :         }
+     425           0 :         case 'r': {
+     426           0 :             dltdata.rflag = 1;
+     427           0 :             dltdata.rvalue = atoi(optarg);
+     428           0 :             break;
+     429             :         }
+     430           1 :         case 'o':
+     431             :         {
+     432           1 :             dltdata.ovalue = optarg;
+     433           1 :             size_t to_copy = strlen(dltdata.ovalue);
+     434             : 
+     435           1 :             if (strcmp(&dltdata.ovalue[to_copy - 4], ".dlt") == 0)
+     436             :                 to_copy = to_copy - 4;
+     437             : 
+     438           1 :             dltdata.ovaluebase = (char *)calloc(1, to_copy + 1);
+     439             : 
+     440           1 :             if (dltdata.ovaluebase == NULL) {
+     441           0 :                 fprintf (stderr, "Memory allocation failed.\n");
+     442           0 :                 return -1;
+     443             :             }
+     444             : 
+     445           1 :             dltdata.ovaluebase[to_copy] = '\0';
+     446           1 :             memcpy(dltdata.ovaluebase, dltdata.ovalue, to_copy);
+     447             :             break;
+     448             :         }
+     449           0 :         case 'e':
+     450             :         {
+     451           0 :             dltdata.evalue = optarg;
+     452           0 :             break;
+     453             :         }
+     454           0 :         case 'b':
+     455             :         {
+     456           0 :             dltdata.bvalue = atoi(optarg);
+     457           0 :             break;
+     458             :         }
+     459           0 :         case 'p':
+     460             :         {
+     461           0 :             dltdata.port = atoi(optarg);
+     462           0 :             break;
+     463             :         }
+     464             : 
+     465           0 :         case 'c':
+     466             :         {
+     467           0 :             dltdata.climit = convert_arg_to_byte_size(optarg);
+     468             : 
+     469           0 :             if (dltdata.climit < -1) {
+     470           0 :                 fprintf (stderr, "Invalid argument for option -c.\n");
+     471             :                 /* unknown or wrong option used, show usage information and terminate */
+     472           0 :                 usage();
+     473           0 :                 return -1;
+     474             :             }
+     475             : 
+     476             :             break;
+     477             :         }
+     478           0 :         case '?':
+     479             :         {
+     480           0 :             if ((optopt == 'o') || (optopt == 'f') || (optopt == 'c'))
+     481           0 :                 fprintf (stderr, "Option -%c requires an argument.\n", optopt);
+     482           0 :             else if (isprint (optopt))
+     483           0 :                 fprintf (stderr, "Unknown option `-%c'.\n", optopt);
+     484             :             else
+     485           0 :                 fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
+     486             : 
+     487             :             /* unknown or wrong option used, show usage information and terminate */
+     488           0 :             usage();
+     489           0 :             return -1;
+     490             :         }
+     491           0 :         default:
+     492             :         {
+     493           0 :             abort ();
+     494             :             return -1;    /*for parasoft */
+     495             :         }
+     496             :         }
+     497             : 
+     498             :     /* Initialize DLT Client */
+     499           1 :     dlt_client_init(&dltclient, dltdata.vflag);
+     500             : 
+     501             :     /* Register callback to be called when message was received */
+     502           1 :     dlt_client_register_message_callback(dlt_receive_message_callback);
+     503             : 
+     504             :     /* Setup DLT Client structure */
+     505           1 :     if(dltdata.uflag) {
+     506           0 :         dltclient.mode = DLT_CLIENT_MODE_UDP_MULTICAST;
+     507             :     }
+     508             :     else {
+     509           1 :         dltclient.mode = dltdata.yflag;
+     510             :     }
+     511             : 
+     512           1 :     if (dltclient.mode == DLT_CLIENT_MODE_TCP || dltclient.mode == DLT_CLIENT_MODE_UDP_MULTICAST) {
+     513           1 :         dltclient.port = dltdata.port;
+     514             : 
+     515             :         unsigned int servIPLength = 1; // Counting the terminating 0 byte
+     516           2 :         for (index = optind; index < argc; index++) {
+     517           1 :             servIPLength += strlen(argv[index]);
+     518           1 :             if (index > optind) {
+     519           0 :                 servIPLength++; // For the comma delimiter
+     520             :             }
+     521             :         }
+     522           1 :         if (servIPLength > 1) {
+     523           1 :             char* servIPString = malloc(servIPLength);
+     524           1 :             strcpy(servIPString, argv[optind]);
+     525             : 
+     526           1 :             for (index = optind + 1; index < argc; index++) {
+     527             :                 strcat(servIPString, ",");
+     528           0 :                 strcat(servIPString, argv[index]);
+     529             :             }
+     530             : 
+     531           1 :             int retval = dlt_client_set_server_ip(&dltclient, servIPString);
+     532           1 :             free(servIPString);
+     533             : 
+     534           1 :             if (retval == -1) {
+     535           0 :                 fprintf(stderr, "set server ip didn't succeed\n");
+     536           0 :                 return -1;
+     537             :             }
+     538             :         }
+     539             : 
+     540           1 :         if (dltclient.servIP == 0) {
+     541             :             /* no hostname selected, show usage and terminate */
+     542           0 :             fprintf(stderr, "ERROR: No hostname selected\n");
+     543           0 :             usage();
+     544           0 :             dlt_client_cleanup(&dltclient, dltdata.vflag);
+     545           0 :             return -1;
+     546             :         }
+     547             : 
+     548           1 :         if (dltdata.ifaddr != 0) {
+     549           0 :             if (dlt_client_set_host_if_address(&dltclient, dltdata.ifaddr) != DLT_RETURN_OK) {
+     550           0 :                 fprintf(stderr, "set host interface address didn't succeed\n");
+     551           0 :                 return -1;
+     552             :             }
+     553             :         }
+     554             :     }
+     555             :     else {
+     556           0 :         for (index = optind; index < argc; index++)
+     557           0 :             if (dlt_client_set_serial_device(&dltclient, argv[index]) == -1) {
+     558           0 :                 fprintf(stderr, "set serial device didn't succeed\n");
+     559           0 :                 return -1;
+     560             :             }
+     561             : 
+     562           0 :         if (dltclient.serialDevice == 0) {
+     563             :             /* no serial device name selected, show usage and terminate */
+     564           0 :             fprintf(stderr, "ERROR: No serial device name specified\n");
+     565           0 :             usage();
+     566           0 :             return -1;
+     567             :         }
+     568             : 
+     569           0 :         dlt_client_setbaudrate(&dltclient, dltdata.bvalue);
+     570             :     }
+     571             : 
+     572             :     /* Update the send and resync serial header flags based on command line option */
+     573           1 :     dltclient.send_serial_header = dltdata.sendSerialHeaderFlag;
+     574           1 :     dltclient.resync_serial_header = dltdata.resyncSerialHeaderFlag;
+     575             : 
+     576             :     /* initialise structure to use DLT file */
+     577           1 :     dlt_file_init(&(dltdata.file), dltdata.vflag);
+     578             : 
+     579             :     /* first parse filter file if filter parameter is used */
+     580           1 :     dlt_filter_init(&(dltdata.filter), dltdata.vflag);
+     581             : 
+     582           1 :     if (dltdata.fvalue) {
+     583           0 :         if (dlt_filter_load(&(dltdata.filter), dltdata.fvalue, dltdata.vflag) < DLT_RETURN_OK) {
+     584           0 :             dlt_file_free(&(dltdata.file), dltdata.vflag);
+     585           0 :             return -1;
+     586             :         }
+     587             : 
+     588           0 :         dlt_file_set_filter(&(dltdata.file), &(dltdata.filter), dltdata.vflag);
+     589             :     }
+     590             : 
+     591             :     #ifdef EXTENDED_FILTERING
+     592             : 
+     593             :     if (dltdata.jvalue) {
+     594             :         if (dlt_json_filter_load(&(dltdata.filter), dltdata.jvalue, dltdata.vflag) < DLT_RETURN_OK) {
+     595             :             dlt_file_free(&(dltdata.file), dltdata.vflag);
+     596             :             return -1;
+     597             :         }
+     598             : 
+     599             :         dlt_file_set_filter(&(dltdata.file), &(dltdata.filter), dltdata.vflag);
+     600             :     }
+     601             : 
+     602             :     #endif
+     603             : 
+     604             :     /* open DLT output file */
+     605           1 :     if (dltdata.ovalue) {
+     606           1 :         if (dltdata.climit > -1) {
+     607           0 :             dlt_vlog(LOG_INFO, "Using file size limit of %" PRId64 "bytes\n",
+     608             :                      dltdata.climit);
+     609           0 :             dltdata.ohandle = dlt_receive_open_output_file(&dltdata);
+     610             :         }
+     611             :         else { /* in case no limit for the output file is given, we simply overwrite any existing file */
+     612           1 :             dltdata.ohandle = open(dltdata.ovalue, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+     613             :         }
+     614             : 
+     615           1 :         if (dltdata.ohandle == -1) {
+     616           0 :             dlt_file_free(&(dltdata.file), dltdata.vflag);
+     617           0 :             fprintf(stderr, "ERROR: Output file %s cannot be opened!\n", dltdata.ovalue);
+     618           0 :             return -1;
+     619             :         }
+     620             :     }
+     621             : 
+     622           1 :     if (dltdata.evalue)
+     623           0 :         dlt_set_id(dltdata.ecuid, dltdata.evalue);
+     624             :     else{
+     625           1 :         dlt_set_id(dltdata.ecuid, DLT_RECEIVE_ECU_ID);}
+     626             : 
+     627             :     while (true) {
+     628             :         /* Attempt to connect to TCP socket or open serial device */
+     629           1 :         if (dlt_client_connect(&dltclient, dltdata.vflag) != DLT_RETURN_ERROR) {
+     630             : 
+     631             :             /* Dlt Client Main Loop */
+     632           1 :             dlt_client_main_loop(&dltclient, &dltdata, dltdata.vflag);
+     633             : 
+     634           1 :             if (dltdata.rflag == 1 && sig_close_recv == false) {
+     635           0 :                 dlt_vlog(LOG_INFO, "Reconnect to server with %d milli seconds specified\n", dltdata.rvalue);
+     636           0 :                 sleep(dltdata.rvalue / 1000);
+     637             :             } else {
+     638             :                 /* Dlt Client Cleanup */
+     639           1 :                 dlt_client_cleanup(&dltclient, dltdata.vflag);
+     640           1 :                 break;
+     641             :             }
+     642             :         } else {
+     643             :             break;
+     644             :         }
+     645             :     }
+     646             : 
+     647             :     /* dlt-receive cleanup */
+     648           1 :     if (dltdata.ovalue)
+     649           1 :         close(dltdata.ohandle);
+     650             : 
+     651           1 :     free(dltdata.ovaluebase);
+     652             : 
+     653           1 :     dlt_file_free(&(dltdata.file), dltdata.vflag);
+     654             : 
+     655           1 :     dlt_filter_free(&(dltdata.filter), dltdata.vflag);
+     656             : 
+     657           1 :     return 0;
+     658             : }
+     659             : 
+     660         206 : int dlt_receive_message_callback(DltMessage *message, void *data)
+     661             : {
+     662             :     DltReceiveData *dltdata;
+     663             :     static char text[DLT_RECEIVE_BUFSIZE];
+     664             : 
+     665             :     struct iovec iov[2];
+     666             :     int bytes_written;
+     667             : 
+     668         206 :     if ((message == 0) || (data == 0))
+     669             :         return -1;
+     670             : 
+     671             :     dltdata = (DltReceiveData *)data;
+     672             : 
+     673             :     /* prepare storage header */
+     674         206 :     if (DLT_IS_HTYP_WEID(message->standardheader->htyp))
+     675         206 :         dlt_set_storageheader(message->storageheader, message->headerextra.ecu);
+     676             :     else
+     677           0 :         dlt_set_storageheader(message->storageheader, dltdata->ecuid);
+     678             : 
+     679         206 :     if (((dltdata->fvalue || dltdata->jvalue) == 0) ||
+     680           0 :         (dlt_message_filter_check(message, &(dltdata->filter), dltdata->vflag) == DLT_RETURN_TRUE)) {
+     681             :         /* if no filter set or filter is matching display message */
+     682         206 :         if (dltdata->xflag) {
+     683           0 :             dlt_message_print_hex(message, text, DLT_RECEIVE_BUFSIZE, dltdata->vflag);
+     684             :         }
+     685         206 :         else if (dltdata->aflag)
+     686             :         {
+     687             : 
+     688           0 :             dlt_message_header(message, text, DLT_RECEIVE_BUFSIZE, dltdata->vflag);
+     689             : 
+     690             :             printf("%s ", text);
+     691             : 
+     692           0 :             dlt_message_payload(message, text, DLT_RECEIVE_BUFSIZE, DLT_OUTPUT_ASCII, dltdata->vflag);
+     693             : 
+     694             :             printf("[%s]\n", text);
+     695             :         }
+     696         206 :         else if (dltdata->mflag)
+     697             :         {
+     698           0 :             dlt_message_print_mixed_plain(message, text, DLT_RECEIVE_BUFSIZE, dltdata->vflag);
+     699             :         }
+     700         206 :         else if (dltdata->sflag)
+     701             :         {
+     702             : 
+     703           0 :             dlt_message_header(message, text, DLT_RECEIVE_BUFSIZE, dltdata->vflag);
+     704             : 
+     705             :             printf("%s \n", text);
+     706             :         }
+     707             : 
+     708             :         /* if file output enabled write message */
+     709         206 :         if (dltdata->ovalue) {
+     710         206 :             iov[0].iov_base = message->headerbuffer;
+     711         206 :             iov[0].iov_len = (uint32_t)message->headersize;
+     712         206 :             iov[1].iov_base = message->databuffer;
+     713         206 :             iov[1].iov_len = (uint32_t)message->datasize;
+     714             : 
+     715         206 :             if (dltdata->climit > -1) {
+     716           0 :                 uint32_t bytes_to_write = message->headersize + message->datasize;
+     717             : 
+     718           0 :                 if ((bytes_to_write + dltdata->totalbytes > dltdata->climit)) {
+     719             :                     dlt_receive_close_output_file(dltdata);
+     720             : 
+     721           0 :                     if (dlt_receive_open_output_file(dltdata) < 0) {
+     722             :                         printf(
+     723             :                             "ERROR: dlt_receive_message_callback: Unable to open log when maximum filesize was reached!\n");
+     724           0 :                         return -1;
+     725             :                     }
+     726             : 
+     727           0 :                     dltdata->totalbytes = 0;
+     728             :                 }
+     729             :             }
+     730             : 
+     731         206 :             bytes_written = (int)writev(dltdata->ohandle, iov, 2);
+     732             : 
+     733         206 :             dltdata->totalbytes += bytes_written;
+     734             : 
+     735         206 :             if (0 > bytes_written) {
+     736             :                 printf("dlt_receive_message_callback: writev(dltdata->ohandle, iov, 2); returned an error!");
+     737           0 :                 return -1;
+     738             :             }
+     739             :         }
+     740             :     }
+     741             : 
+     742             :     return 0;
+     743             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/index-sort-f.html b/dlt_lcov_report/console/index-sort-f.html new file mode 100644 index 000000000..f3cec9373 --- /dev/null +++ b/dlt_lcov_report/console/index-sort-f.html @@ -0,0 +1,113 @@ + + + + + + + LCOV - dlt_final_coverage.info - console + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - consoleHitTotalCoverage
Test:dlt_final_coverage.infoLines:27464242.7 %
Date:2024-12-05 09:07:13Functions:222975.9 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt-convert.c +
21.7%21.7%
+
21.7 %40 / 18433.3 %1 / 3
dlt-receive.c +
35.5%35.5%
+
35.5 %87 / 24542.9 %3 / 7
dlt-control-common.c +
69.0%69.0%
+
69.0 %147 / 21394.7 %18 / 19
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/index-sort-l.html b/dlt_lcov_report/console/index-sort-l.html new file mode 100644 index 000000000..1570ca9ee --- /dev/null +++ b/dlt_lcov_report/console/index-sort-l.html @@ -0,0 +1,113 @@ + + + + + + + LCOV - dlt_final_coverage.info - console + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - consoleHitTotalCoverage
Test:dlt_final_coverage.infoLines:27464242.7 %
Date:2024-12-05 09:07:13Functions:222975.9 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt-convert.c +
21.7%21.7%
+
21.7 %40 / 18433.3 %1 / 3
dlt-receive.c +
35.5%35.5%
+
35.5 %87 / 24542.9 %3 / 7
dlt-control-common.c +
69.0%69.0%
+
69.0 %147 / 21394.7 %18 / 19
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/index.html b/dlt_lcov_report/console/index.html new file mode 100644 index 000000000..cd7d1c85e --- /dev/null +++ b/dlt_lcov_report/console/index.html @@ -0,0 +1,113 @@ + + + + + + + LCOV - dlt_final_coverage.info - console + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - consoleHitTotalCoverage
Test:dlt_final_coverage.infoLines:27464242.7 %
Date:2024-12-05 09:07:13Functions:222975.9 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt-control-common.c +
69.0%69.0%
+
69.0 %147 / 21394.7 %18 / 19
dlt-convert.c +
21.7%21.7%
+
21.7 %40 / 18433.3 %1 / 3
dlt-receive.c +
35.5%35.5%
+
35.5 %87 / 24542.9 %3 / 7
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/logstorage/dlt-logstorage-common.c.func-sort-c.html b/dlt_lcov_report/console/logstorage/dlt-logstorage-common.c.func-sort-c.html new file mode 100644 index 000000000..6bcbbe73e --- /dev/null +++ b/dlt_lcov_report/console/logstorage/dlt-logstorage-common.c.func-sort-c.html @@ -0,0 +1,132 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/logstorage/dlt-logstorage-common.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console/logstorage - dlt-logstorage-common.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:328239.0 %
Date:2024-12-05 09:07:13Functions:71546.7 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_logstorage_check_config_file0
dlt_logstorage_check_directory_permission0
dlt_logstorage_deinit_handler0
dlt_logstorage_get_handler_cb0
dlt_logstorage_get_handler_fd0
dlt_logstorage_init_handler0
get_logstorage_control0
set_handler_type0
dlt_logstorage_send_event2
get_default_path2
prepare_message_body2
set_default_event_type2
set_default_path2
get_handler_type4
get_default_event_type6
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/logstorage/dlt-logstorage-common.c.func.html b/dlt_lcov_report/console/logstorage/dlt-logstorage-common.c.func.html new file mode 100644 index 000000000..26c38c96a --- /dev/null +++ b/dlt_lcov_report/console/logstorage/dlt-logstorage-common.c.func.html @@ -0,0 +1,132 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/logstorage/dlt-logstorage-common.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console/logstorage - dlt-logstorage-common.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:328239.0 %
Date:2024-12-05 09:07:13Functions:71546.7 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_logstorage_check_config_file0
dlt_logstorage_check_directory_permission0
dlt_logstorage_deinit_handler0
dlt_logstorage_get_handler_cb0
dlt_logstorage_get_handler_fd0
dlt_logstorage_init_handler0
dlt_logstorage_send_event2
get_default_event_type6
get_default_path2
get_handler_type4
get_logstorage_control0
prepare_message_body2
set_default_event_type2
set_default_path2
set_handler_type0
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/logstorage/dlt-logstorage-common.c.gcov.html b/dlt_lcov_report/console/logstorage/dlt-logstorage-common.c.gcov.html new file mode 100644 index 000000000..e964df013 --- /dev/null +++ b/dlt_lcov_report/console/logstorage/dlt-logstorage-common.c.gcov.html @@ -0,0 +1,399 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/logstorage/dlt-logstorage-common.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console/logstorage - dlt-logstorage-common.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:328239.0 %
Date:2024-12-05 09:07:13Functions:71546.7 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /**
+       2             :  * Copyright (C) 2013 - 2015  Advanced Driver Information Technology.
+       3             :  * This code is developed by Advanced Driver Information Technology.
+       4             :  * Copyright of Advanced Driver Information Technology, Bosch and DENSO.
+       5             :  *
+       6             :  * This file is part of COVESA Project Dlt - Diagnostic Log and Trace console apps.
+       7             :  *
+       8             :  *
+       9             :  * \copyright
+      10             :  * This Source Code Form is subject to the terms of the
+      11             :  * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
+      12             :  * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+      13             :  *
+      14             :  *
+      15             :  * \author Syed Hameed <shameed@jp.adit-jv.com> ADIT 2013 - 2015
+      16             :  * \author Christoph Lipka <clipka@jp.adit-jv.com> ADIT 2015
+      17             :  * \author Frederic Berat <fberat@de.adit-jv.com> ADIT 2015
+      18             :  *
+      19             :  * \file dlt-logstorage-common.c
+      20             :  * For further information see http://www.covesa.org/.
+      21             :  */
+      22             : 
+      23             : /*******************************************************************************
+      24             : **                                                                            **
+      25             : **  SRC-MODULE: dlt-logstorage-common.c                                       **
+      26             : **                                                                            **
+      27             : **  TARGET    : linux                                                         **
+      28             : **                                                                            **
+      29             : **  PROJECT   : DLT                                                           **
+      30             : **                                                                            **
+      31             : **  AUTHOR    : Christoph Lipka clipka@jp.adit-jv.com                         **
+      32             : **              Frederic Berat fberat@de.adit-jv.com                          **
+      33             : **  PURPOSE   :                                                               **
+      34             : **                                                                            **
+      35             : **  REMARKS   : Code extracted from dlt-control-common.c and reworked.        **
+      36             : **                                                                            **
+      37             : **  PLATFORM DEPENDANT [yes/no]: yes                                          **
+      38             : **                                                                            **
+      39             : **  TO BE CHANGED BY USER [yes/no]: no                                        **
+      40             : **                                                                            **
+      41             : *******************************************************************************/
+      42             : 
+      43             : /*******************************************************************************
+      44             : **                      Author Identity                                       **
+      45             : ********************************************************************************
+      46             : **                                                                            **
+      47             : ** Initials     Name                       Company                            **
+      48             : ** --------     -------------------------  ---------------------------------- **
+      49             : **  cl          Christoph Lipka            ADIT                               **
+      50             : **  fb          Frederic Berat             ADIT                               **
+      51             : *******************************************************************************/
+      52             : #define pr_fmt(fmt) "Logstorage common: "fmt
+      53             : 
+      54             : #include <errno.h>
+      55             : #include <dirent.h>
+      56             : #include <stdio.h>
+      57             : #include <stdlib.h>
+      58             : #include <string.h>
+      59             : #include <unistd.h>
+      60             : #include <pthread.h>
+      61             : #include <sys/types.h>
+      62             : #include <sys/socket.h>
+      63             : 
+      64             : #include "dlt_common.h"
+      65             : #include "dlt_protocol.h"
+      66             : #include "dlt_client.h"
+      67             : 
+      68             : #include "dlt-control-common.h"
+      69             : #include "dlt-logstorage-common.h"
+      70             : 
+      71             : #ifdef DLT_LOGSTORAGE_CTRL_UDEV_ENABLE
+      72             : #   include "dlt-logstorage-udev.h"
+      73             : #endif
+      74             : 
+      75             : #include "dlt-logstorage-prop.h"
+      76             : 
+      77             : static struct LogstorageOptions {
+      78             :     int event_type; /**< EVENT_UNMOUNTING/EVENT_MOUNTED */
+      79             :     char device_path[DLT_MOUNT_PATH_MAX]; /**< Default Mount path */
+      80             :     DltLogstorageHandler handler_type; /**< be controlled by udev or prop */
+      81             :     long timeout; /**< Default timeout */
+      82             : } g_options = {
+      83             :     .event_type = EVENT_MOUNTED,
+      84             :     .handler_type = CTRL_NOHANDLER,
+      85             : };
+      86             : 
+      87           4 : DltLogstorageHandler get_handler_type(void)
+      88             : {
+      89           4 :     return g_options.handler_type;
+      90             : }
+      91             : 
+      92           0 : void set_handler_type(char *type)
+      93             : {
+      94           0 :     g_options.handler_type = CTRL_UDEV;
+      95             : 
+      96             :     if (type && check_proprietary_handling(type))
+      97             :         g_options.handler_type = CTRL_PROPRIETARY;
+      98           0 : }
+      99             : 
+     100           6 : int get_default_event_type(void)
+     101             : {
+     102           6 :     return g_options.event_type;
+     103             : }
+     104             : 
+     105           2 : void set_default_event_type(long type)
+     106             : {
+     107           2 :     g_options.event_type = (int) type;
+     108           2 : }
+     109             : 
+     110           2 : char *get_default_path(void)
+     111             : {
+     112           2 :     return g_options.device_path;
+     113             : }
+     114             : 
+     115           2 : void set_default_path(char *path)
+     116             : {
+     117             :     memset(g_options.device_path, 0, DLT_MOUNT_PATH_MAX);
+     118             : 
+     119           2 :     if (path != NULL)
+     120             :         strncpy(g_options.device_path, path, DLT_MOUNT_PATH_MAX - 1);
+     121           2 : }
+     122             : 
+     123             : /* Used by the handlers */
+     124             : static DltLogstorageCtrl lctrl;
+     125             : 
+     126           0 : DltLogstorageCtrl *get_logstorage_control(void)
+     127             : {
+     128           0 :     return &lctrl;
+     129             : }
+     130             : 
+     131           0 : void *dlt_logstorage_get_handler_cb(void)
+     132             : {
+     133           0 :     return lctrl.callback;
+     134             : }
+     135             : 
+     136           0 : int dlt_logstorage_get_handler_fd(void)
+     137             : {
+     138           0 :     return lctrl.fd;
+     139             : }
+     140             : 
+     141             : /** @brief Initialized the handler based on configuration
+     142             :  *
+     143             :  * @return 0 on success, -1 otherwise.
+     144             :  */
+     145           0 : int dlt_logstorage_init_handler(void)
+     146             : {
+     147           0 :     switch (get_handler_type()) {
+     148             :     case CTRL_PROPRIETARY:
+     149             :         return dlt_logstorage_prop_init();
+     150           0 :     case CTRL_UDEV:
+     151             :     default:
+     152             : #ifdef DLT_LOGSTORAGE_CTRL_UDEV_ENABLE
+     153             :         return dlt_logstorage_udev_init();
+     154             : #else
+     155           0 :         return -1;
+     156             : #endif
+     157             :     }
+     158             : }
+     159             : 
+     160             : /** @brief Clean-up the handler based on configuration
+     161             :  *
+     162             :  * @return 0 on success, -1 otherwise.
+     163             :  */
+     164           0 : int dlt_logstorage_deinit_handler(void)
+     165             : {
+     166           0 :     switch (get_handler_type()) {
+     167             :     case CTRL_PROPRIETARY:
+     168             :         return dlt_logstorage_prop_deinit();
+     169           0 :     case CTRL_UDEV:
+     170             :     default:
+     171             : #ifdef DLT_LOGSTORAGE_CTRL_UDEV_ENABLE
+     172             :         return dlt_logstorage_udev_deinit();
+     173             : #else
+     174           0 :         return -1;
+     175             : #endif
+     176             :     }
+     177             : }
+     178             : 
+     179             : /** @brief Search for config file in given mount point
+     180             :  *
+     181             :  * The file is searched at the top directory. The function exits once it
+     182             :  * founds it.
+     183             :  *
+     184             :  * @param mnt_point The mount point to check
+     185             :  *
+     186             :  * @return 1 if the file is found, 0 otherwise.
+     187             :  */
+     188           0 : int dlt_logstorage_check_config_file(char *mnt_point)
+     189             : {
+     190             :     struct dirent **files;
+     191             :     int n;
+     192             :     int i = 0;
+     193             :     int ret = 0;
+     194             : 
+     195           0 :     if ((mnt_point == NULL) || (mnt_point[0] == '\0')) {
+     196           0 :         pr_error("Mount point missing.\n");
+     197           0 :         return ret;
+     198             :     }
+     199             : 
+     200           0 :     pr_verbose("Now scanning %s\n", mnt_point);
+     201             : 
+     202           0 :     n = scandir(mnt_point, &files, NULL, alphasort);
+     203             : 
+     204           0 :     if (n <= 0) {
+     205           0 :         pr_error("Cannot read mounted directory\n");
+     206           0 :         return ret;
+     207             :     }
+     208             : 
+     209             :     do {
+     210           0 :         pr_verbose("Checking %s.\n", files[i]->d_name);
+     211             : 
+     212           0 :         if (strncmp(files[i]->d_name, CONF_NAME, strlen(CONF_NAME)) == 0) {
+     213             :             /* We found it ! */
+     214           0 :             pr_verbose("File found.\n");
+     215             :             ret = 1;
+     216             :             break;
+     217             :         }
+     218           0 :     } while (++i < n);
+     219             : 
+     220           0 :     for (i = 0; i < n; i++)
+     221           0 :         free(files[i]);
+     222             : 
+     223           0 :     free(files);
+     224           0 :     return ret;
+     225             : }
+     226             : 
+     227             : /** @brief Check if given mount point is writable
+     228             :  *
+     229             :  * @param mnt_point The mount point to check
+     230             :  *
+     231             :  * @return 1 if the file is writable, 0 otherwise.
+     232             :  */
+     233           0 : int dlt_logstorage_check_directory_permission(char *mnt_point)
+     234             : {
+     235           0 :     if (mnt_point == NULL) {
+     236           0 :         pr_error("Given mount point is NULL\n");
+     237           0 :         return 0;
+     238             :     }
+     239             : 
+     240           0 :     if (access(mnt_point, W_OK) == 0)
+     241           0 :         return 1;
+     242             : 
+     243             :     return 0;
+     244             : }
+     245             : 
+     246             : /** @brief Prepares the body of the message to be send to DLT
+     247             :  *
+     248             :  * @param body A pointer to the MsgBody structure pointer
+     249             :  * @param conn_type The type of the event (Mounted/Unmounting)
+     250             :  * @param path The mount point path.
+     251             :  *
+     252             :  * @return The body once built or NULL.
+     253             :  */
+     254           2 : static DltControlMsgBody *prepare_message_body(DltControlMsgBody **body,
+     255             :                                                int conn_type,
+     256             :                                                char *path)
+     257             : {
+     258             :     DltServiceOfflineLogstorage *serv = NULL;
+     259             : 
+     260           2 :     if (path == NULL) {
+     261           0 :         pr_error("Mount path is uninitialized.\n");
+     262           0 :         return NULL;
+     263             :     }
+     264             : 
+     265           2 :     pr_verbose("Sending event %d for %s.\n", conn_type, path);
+     266             : 
+     267           2 :     *body = calloc(1, sizeof(DltControlMsgBody));
+     268             : 
+     269           2 :     if (!*body) {
+     270           0 :         pr_error("Not able to allocate memory for body.\n");
+     271           0 :         return *body;
+     272             :     }
+     273             : 
+     274           2 :     (*body)->data = calloc(1, sizeof(DltServiceOfflineLogstorage));
+     275             : 
+     276           2 :     if (!(*body)->data) {
+     277           0 :         free(*body);
+     278           0 :         *body = NULL;
+     279           0 :         pr_error("Not able to allocate memory for body data.\n");
+     280           0 :         return NULL;
+     281             :     }
+     282             : 
+     283           2 :     (*body)->size = sizeof(DltServiceOfflineLogstorage);
+     284             : 
+     285             :     serv = (DltServiceOfflineLogstorage *)(*body)->data;
+     286             : 
+     287           2 :     serv->service_id = DLT_SERVICE_ID_OFFLINE_LOGSTORAGE;
+     288           2 :     serv->connection_type = (uint8_t) conn_type;
+     289             :     /* mount_point is DLT_MOUNT_PATH_MAX + 1 long,
+     290             :      * and the memory is already zeroed.
+     291             :      */
+     292           2 :     strncpy(serv->mount_point, path, DLT_MOUNT_PATH_MAX - 1);
+     293             : 
+     294           2 :     pr_verbose("Body is now ready.\n");
+     295             : 
+     296           2 :     return *body;
+     297             : }
+     298             : 
+     299             : /** @brief Send a logstorage event to DLT
+     300             :  *
+     301             :  * @param type The type of the event (Mounted/Unmounting)
+     302             :  * @param mount_point The mount point for this event
+     303             :  *
+     304             :  * @return 0 On success, -1 otherwise.
+     305             :  */
+     306           2 : int dlt_logstorage_send_event(int type, char *mount_point)
+     307             : {
+     308             :     int ret = 0;
+     309           2 :     DltControlMsgBody *msg_body = NULL;
+     310             : 
+     311             :     /* mount_point is checked against NULL in the preparation */
+     312           2 :     if (!prepare_message_body(&msg_body, type, mount_point)) {
+     313           0 :         pr_error("Data for Dlt Message body is NULL\n");
+     314           0 :         return -1;
+     315             :     }
+     316             : 
+     317           2 :     ret = dlt_control_send_message(msg_body, get_timeout());
+     318             : 
+     319           2 :     free(msg_body->data);
+     320           2 :     free(msg_body);
+     321             : 
+     322           2 :     return ret;
+     323             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/logstorage/dlt-logstorage-ctrl.c.func-sort-c.html b/dlt_lcov_report/console/logstorage/dlt-logstorage-ctrl.c.func-sort-c.html new file mode 100644 index 000000000..23778f1ee --- /dev/null +++ b/dlt_lcov_report/console/logstorage/dlt-logstorage-ctrl.c.func-sort-c.html @@ -0,0 +1,124 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/logstorage/dlt-logstorage-ctrl.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console/logstorage - dlt-logstorage-ctrl.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:4318623.1 %
Date:2024-12-05 09:07:13Functions:41330.8 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
catch_signal0
dlt_logstorage_ctrl_add_event0
dlt_logstorage_ctrl_execute_event_loop0
dlt_logstorage_ctrl_setup_event_loop0
dlt_logstorage_exit0
dlt_logstorage_must_exit0
install_signal_handler0
sd_notify0
usage0
analyze_response2
dlt_logstorage_ctrl_single_request2
main2
parse_args2
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/logstorage/dlt-logstorage-ctrl.c.func.html b/dlt_lcov_report/console/logstorage/dlt-logstorage-ctrl.c.func.html new file mode 100644 index 000000000..90240fc90 --- /dev/null +++ b/dlt_lcov_report/console/logstorage/dlt-logstorage-ctrl.c.func.html @@ -0,0 +1,124 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/logstorage/dlt-logstorage-ctrl.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console/logstorage - dlt-logstorage-ctrl.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:4318623.1 %
Date:2024-12-05 09:07:13Functions:41330.8 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
analyze_response2
catch_signal0
dlt_logstorage_ctrl_add_event0
dlt_logstorage_ctrl_execute_event_loop0
dlt_logstorage_ctrl_setup_event_loop0
dlt_logstorage_ctrl_single_request2
dlt_logstorage_exit0
dlt_logstorage_must_exit0
install_signal_handler0
main2
parse_args2
sd_notify0
usage0
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/logstorage/dlt-logstorage-ctrl.c.gcov.html b/dlt_lcov_report/console/logstorage/dlt-logstorage-ctrl.c.gcov.html new file mode 100644 index 000000000..776d7f8ac --- /dev/null +++ b/dlt_lcov_report/console/logstorage/dlt-logstorage-ctrl.c.gcov.html @@ -0,0 +1,678 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/logstorage/dlt-logstorage-ctrl.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console/logstorage - dlt-logstorage-ctrl.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:4318623.1 %
Date:2024-12-05 09:07:13Functions:41330.8 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /**
+       2             :  * Copyright (C) 2013 - 2015  Advanced Driver Information Technology.
+       3             :  * This code is developed by Advanced Driver Information Technology.
+       4             :  * Copyright of Advanced Driver Information Technology, Bosch and DENSO. *
+       5             :  * This file is part of COVESA Project Dlt - Diagnostic Log and Trace console apps.
+       6             :  *
+       7             :  *
+       8             :  * \copyright
+       9             :  * This Source Code Form is subject to the terms of the
+      10             :  * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
+      11             :  * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+      12             :  *
+      13             :  *
+      14             :  * \author Syed Hameed <shameed@jp.adit-jv.com> ADIT 2013 - 2015
+      15             :  * \author Christoph Lipka <clipka@jp.adit-jv.com> ADIT 2015
+      16             :  * \author Frederic Berat <fberat@de.adit-jv.com> ADIT 2015
+      17             :  *
+      18             :  * \file dlt-logstorage-ctrl.c
+      19             :  * For further information see http://www.covesa.org/.
+      20             :  */
+      21             : /*******************************************************************************
+      22             : **                                                                            **
+      23             : **  SRC-MODULE: dlt-logstorage-ctrl.c                                         **
+      24             : **                                                                            **
+      25             : **  TARGET    : linux                                                         **
+      26             : **                                                                            **
+      27             : **  PROJECT   : DLT                                                           **
+      28             : **                                                                            **
+      29             : **  AUTHOR    : Syed Hameed shameed@jp.adit-jv.com                            **
+      30             : **              Christoph Lipka clipka@jp.adit-jv.com                         **
+      31             : **              AnithaAmmaji.baggam@in.bosch.com                              **
+      32             : **              Frederic Berat fberat@de.adit-jv.com                          **
+      33             : **  PURPOSE   :                                                               **
+      34             : **                                                                            **
+      35             : **  REMARKS   :                                                               **
+      36             : **                                                                            **
+      37             : **  PLATFORM DEPENDANT [yes/no]: yes                                          **
+      38             : **                                                                            **
+      39             : **  TO BE CHANGED BY USER [yes/no]: no                                        **
+      40             : **                                                                            **
+      41             : *******************************************************************************/
+      42             : 
+      43             : /*******************************************************************************
+      44             : **                      Author Identity                                       **
+      45             : ********************************************************************************
+      46             : ** Initials     Name                       Company                            **
+      47             : ** --------     -------------------------  ---------------------------------- **
+      48             : **  sh          Syed Hameed                ADIT                               **
+      49             : **  cl          Christoph Lipka            ADIT                               **
+      50             : **  BA          Anitha BA                  ADIT                               **
+      51             : **  fb          Frederic Berat             ADIT                               **
+      52             : *******************************************************************************/
+      53             : 
+      54             : #define pr_fmt(fmt) "Logstorage control: "fmt
+      55             : 
+      56             : #include <ctype.h>
+      57             : #include <errno.h>
+      58             : #include <stdio.h>
+      59             : #include <stdlib.h>
+      60             : #include <signal.h>
+      61             : #include <string.h>
+      62             : #include <getopt.h>
+      63             : 
+      64             : #include <poll.h>
+      65             : 
+      66             : #if defined(__linux__)
+      67             : #   include "sd-daemon.h"
+      68             : #endif
+      69             : 
+      70             : #include "dlt_protocol.h"
+      71             : #include "dlt_client.h"
+      72             : #include "dlt-control-common.h"
+      73             : #include "dlt-logstorage-common.h"
+      74             : #include "dlt-logstorage-ctrl.h"
+      75             : 
+      76             : #define POLL_TIME_OUT   500
+      77             : #define EV_MASK_REJECTED (POLLERR | POLLHUP | POLLNVAL)
+      78             : 
+      79             : #define DLT_LOGSTORAGE_CTRL_EXIT 1
+      80             : static int must_exit;
+      81             : struct dlt_event {
+      82             :     struct pollfd pfd;
+      83             :     void *func;
+      84             : };
+      85             : 
+      86             : /** @brief Triggers the application exit
+      87             :  *
+      88             :  * The application will exit on next poll timeout.
+      89             :  */
+      90           0 : void dlt_logstorage_exit(void)
+      91             : {
+      92           0 :     must_exit = DLT_LOGSTORAGE_CTRL_EXIT;
+      93           0 : }
+      94             : 
+      95             : /** @brief Check if the application must exit
+      96             :  *
+      97             :  * The application will exit on next poll timeout.
+      98             :  */
+      99           0 : int dlt_logstorage_must_exit(void)
+     100             : {
+     101           0 :     return must_exit;
+     102             : }
+     103             : 
+     104             : /** @brief Signal handler.
+     105             :  *
+     106             :  * Triggers the exit of the application in case of specific signals
+     107             :  *
+     108             :  * @param signo The value of the signal received.
+     109             :  */
+     110           0 : static void catch_signal(int signo)
+     111             : {
+     112           0 :     if (signo) {
+     113           0 :         pr_error("Signal %d received, exiting.", signo);
+     114             :         dlt_logstorage_exit();
+     115             :     }
+     116           0 : }
+     117             : 
+     118             : /** @brief Install a handler for some signals
+     119             :  *
+     120             :  * Handler are installed on exit related signals. That allows to exit from
+     121             :  * the main loop gracefully.
+     122             :  */
+     123           0 : static void install_signal_handler(void)
+     124             : {
+     125           0 :     int signals[] = { SIGINT, SIGQUIT, SIGTERM, 0 };
+     126             :     unsigned int i;
+     127             :     struct sigaction sa;
+     128             : 
+     129           0 :     pr_verbose("Installing signal handler.\n");
+     130             : 
+     131             :     /* install a signal handler for the above listed signals */
+     132           0 :     for (i = 0; signals[i]; i++) {
+     133             :         memset(&sa, 0, sizeof(sa));
+     134           0 :         sa.sa_handler = catch_signal;
+     135             : 
+     136           0 :         if (sigaction(signals[i], &sa, NULL) < 0)
+     137           0 :             pr_error("Failed to install signal %u handler. Error: %s\n",
+     138             :                      signals[i], strerror(errno));
+     139             :     }
+     140           0 : }
+     141             : 
+     142             : #define MAX_RESPONSE_LENGTH 32
+     143             : /** @brief Analyze the daemon answer to a request
+     144             :  *
+     145             :  * This function checks whether if the daemon answered positively to
+     146             :  * the request or not.
+     147             :  *
+     148             :  * @param data    The textual answer
+     149             :  * @param payload The answer payload
+     150             :  * @param len     The answer payload length
+     151             :  * @return 0 on success, -1 otherwise.
+     152             :  */
+     153           2 : static int analyze_response(char *data, void *payload, int len)
+     154             : {
+     155             :     int ret = -1;
+     156           2 :     char resp_ok[MAX_RESPONSE_LENGTH] = { 0 };
+     157           2 :     char resp_warning[MAX_RESPONSE_LENGTH] = { 0 };
+     158           2 :     char resp_perm_denied[MAX_RESPONSE_LENGTH] = { 0 };
+     159             : 
+     160           2 :     if ((data == NULL) || (payload == NULL))
+     161             :         return -1;
+     162             : 
+     163             :     /* satisfy compiler */
+     164             :     (void)payload;
+     165             :     (void)len;
+     166             : 
+     167             :     snprintf(resp_ok,
+     168             :              MAX_RESPONSE_LENGTH,
+     169             :              "service(%d), ok",
+     170             :              DLT_SERVICE_ID_OFFLINE_LOGSTORAGE);
+     171             : 
+     172             :     snprintf(resp_warning,
+     173             :              MAX_RESPONSE_LENGTH,
+     174             :              "service(%d), warning",
+     175             :              DLT_SERVICE_ID_OFFLINE_LOGSTORAGE);
+     176             : 
+     177             :     snprintf(resp_perm_denied,
+     178             :              MAX_RESPONSE_LENGTH,
+     179             :              "service(%d), perm_denied",
+     180             :              DLT_SERVICE_ID_OFFLINE_LOGSTORAGE);
+     181             : 
+     182           2 :     if (strncmp(data, resp_ok, strlen(resp_ok)) == 0)
+     183             :         ret = 0;
+     184             : 
+     185           2 :     if (strncmp(data, resp_warning, strlen(resp_warning)) == 0) {
+     186           0 :         pr_error("Warning:Some filter configurations are ignored due to configuration issues \n");
+     187             :         ret = 0;
+     188             :     }
+     189             : 
+     190           2 :     if (strncmp(data, resp_perm_denied, strlen(resp_perm_denied)) == 0) {
+     191           0 :         pr_error("Warning: Permission denied.\n");
+     192             :         ret = 0;
+     193             :     }
+     194             : 
+     195           2 :     pr_verbose("Response received: '%s'\n", data);
+     196           2 :     pr_verbose("Response expected: '%s'\n", resp_ok);
+     197             : 
+     198             :     return ret;
+     199             : }
+     200             : 
+     201             : /** @brief Add a new event to watch
+     202             :  *
+     203             :  * This function could be exported to be used by udev/prop so that they can
+     204             :  * register several events.
+     205             :  *
+     206             :  * @param ev_hdl The structure containing the file descriptors
+     207             :  * @param fd The file descriptor to watch
+     208             :  * @param cb The callback to be called on event.
+     209             :  *
+     210             :  * @return 0 on success, -1 if the parameters are invalid.
+     211             :  */
+     212           0 : static int dlt_logstorage_ctrl_add_event(struct dlt_event *ev_hdl,
+     213             :                                          int fd,
+     214             :                                          void *cb)
+     215             : {
+     216           0 :     if ((fd < 0) || !cb || !ev_hdl) {
+     217           0 :         pr_error("Wrong parameter to add event (%d %p)\n", fd, cb);
+     218           0 :         return -1;
+     219             :     }
+     220             : 
+     221           0 :     pr_verbose("Setting up the event handler with (%d, %p).\n", fd, cb);
+     222             : 
+     223           0 :     ev_hdl->func = cb;
+     224           0 :     ev_hdl->pfd.fd = fd;
+     225             : 
+     226           0 :     return 0;
+     227             : }
+     228             : 
+     229             : /** @brief Main execution loop
+     230             :  *
+     231             :  * Waits on events, and executes the callbacks retrieved
+     232             :  * back from the event structure.
+     233             :  *
+     234             :  * @return 0 on success, -1 otherwise.
+     235             :  */
+     236           0 : static int dlt_logstorage_ctrl_execute_event_loop(struct dlt_event *ev)
+     237             : {
+     238             :     int ret = 0;
+     239           0 :     int (*callback)() = ev->func;
+     240             : 
+     241           0 :     ret = poll(&ev->pfd, 1, POLL_TIME_OUT);
+     242             : 
+     243           0 :     if (ret <= 0) {
+     244           0 :         if (errno == EINTR)
+     245             :             ret = 0;
+     246             : 
+     247           0 :         if (ret < 0)
+     248           0 :             pr_error("poll error: %s\n", strerror(errno));
+     249             : 
+     250           0 :         return ret;
+     251             :     }
+     252             : 
+     253           0 :     if (ev->pfd.revents == 0)
+     254             :         return 0;
+     255             : 
+     256           0 :     if (ev->pfd.events & EV_MASK_REJECTED) {
+     257           0 :         pr_error("Error while polling. Event received: 0x%x\n", ev->pfd.events);
+     258             :         /* We only support one event producer.
+     259             :          * Error means that this producer died.
+     260             :          */
+     261           0 :         pr_error("Now closing fd and exiting.\n");
+     262           0 :         close(ev->pfd.fd);
+     263           0 :         ev->pfd.fd = -1;
+     264             :         dlt_logstorage_exit();
+     265           0 :         return -1;
+     266             :     }
+     267             : 
+     268           0 :     if (!callback) {
+     269           0 :         pr_error("Callback not found, exiting.\n");
+     270             :         dlt_logstorage_exit();
+     271           0 :         return -1;
+     272             :     }
+     273             : 
+     274           0 :     pr_verbose("Got new event, calling %p.\n", callback);
+     275             : 
+     276           0 :     if (callback() < 0) {
+     277           0 :         pr_error("Error while calling the callback, exiting.\n");
+     278             :         dlt_logstorage_exit();
+     279           0 :         return -1;
+     280             :     }
+     281             : 
+     282             :     return 0;
+     283             : }
+     284             : 
+     285             : /** @brief Start event loop and receive messages from DLT.
+     286             :  *
+     287             :  * The function will first install the signal handler,
+     288             :  * then create the poll instance, initialize the communication controller,
+     289             :  * initialize the event handler and finally start the polling.
+     290             :  *
+     291             :  * @return 0 on success, -1 on error
+     292             :  */
+     293           0 : static int dlt_logstorage_ctrl_setup_event_loop(void)
+     294             : {
+     295             :     int ret = 0;
+     296           0 :     struct dlt_event ev_hdl = {
+     297             :         .pfd = {
+     298             :             .fd = -1,
+     299             :             .events = POLLIN
+     300             :         }
+     301             :     };
+     302             : 
+     303           0 :     install_signal_handler();
+     304             : 
+     305           0 :     pr_verbose("Creating poll instance.\n");
+     306             : 
+     307             :     /* Initializing the communication with the daemon */
+     308           0 :     while (dlt_control_init(analyze_response, get_ecuid(), get_verbosity()) &&
+     309             :            !dlt_logstorage_must_exit()) {
+     310           0 :         pr_error("Failed to initialize connection with the daemon.\n");
+     311           0 :         pr_error("Retrying to connect in %ds.\n", get_timeout());
+     312           0 :         sleep((unsigned int) get_timeout());
+     313             :     }
+     314             : 
+     315           0 :     if (dlt_logstorage_must_exit()) {
+     316           0 :         pr_verbose("Exiting.\n");
+     317           0 :         return 0;
+     318             :     }
+     319             : 
+     320           0 :     pr_verbose("Initializing event generator.\n");
+     321             : 
+     322           0 :     if (dlt_logstorage_init_handler() < 0) {
+     323           0 :         pr_error("Failed to initialize handler.\n");
+     324           0 :         dlt_control_deinit();
+     325           0 :         return -1;
+     326             :     }
+     327             : 
+     328           0 :     if (dlt_logstorage_ctrl_add_event(&ev_hdl,
+     329             :                                       dlt_logstorage_get_handler_fd(),
+     330             :                                       dlt_logstorage_get_handler_cb()) < 0) {
+     331           0 :         pr_error("add_event error: %s\n", strerror(errno));
+     332             :         dlt_logstorage_exit();
+     333             :     }
+     334             : 
+     335           0 :     while (!dlt_logstorage_must_exit() && (ret == 0))
+     336           0 :         ret = dlt_logstorage_ctrl_execute_event_loop(&ev_hdl);
+     337             : 
+     338             :     /* Clean up */
+     339           0 :     dlt_logstorage_deinit_handler();
+     340           0 :     dlt_control_deinit();
+     341             : 
+     342           0 :     return ret;
+     343             : }
+     344             : 
+     345             : /** @brief Send a single command to DLT daemon and wait for response
+     346             :  *
+     347             :  * @return 0 on success, -1 otherwise.
+     348             :  */
+     349           2 : static int dlt_logstorage_ctrl_single_request()
+     350             : {
+     351             :     int ret = 0;
+     352             : 
+     353             :     /* in case sync all caches, an empty path is given */
+     354           2 :     if (get_default_event_type() != EVENT_SYNC_CACHE) {
+     355             :         /* Check if a 'CONF_NAME' file is present at the given path */
+     356           0 :         if (!dlt_logstorage_check_config_file(get_default_path())) {
+     357           0 :             pr_error("No '%s' file available at: %s\n",
+     358             :                      CONF_NAME,
+     359             :                      get_default_path());
+     360           0 :             return -1;
+     361             :         }
+     362             : 
+     363           0 :         if (!dlt_logstorage_check_directory_permission(get_default_path())) {
+     364           0 :             pr_error("'%s' is not writable\n", get_default_path());
+     365           0 :             return -1;
+     366             :         }
+     367             :     }
+     368             : 
+     369             :     /* Initializing the communication with the daemon */
+     370           2 :     while (dlt_control_init(analyze_response, get_ecuid(), get_verbosity()) &&
+     371             :            !dlt_logstorage_must_exit()) {
+     372           0 :         pr_error("Failed to initialize connection with the daemon.\n");
+     373           0 :         pr_error("Retrying to connect in %ds.\n", get_timeout());
+     374           0 :         sleep( (unsigned int) get_timeout());
+     375             :     }
+     376             : 
+     377           2 :     pr_verbose("event type is [%d]\t device path is [%s]\n",
+     378             :                get_default_event_type(),
+     379             :                get_default_path());
+     380             : 
+     381           2 :     ret = dlt_logstorage_send_event(get_default_event_type(),
+     382             :                                     get_default_path());
+     383             : 
+     384           2 :     dlt_control_deinit();
+     385             : 
+     386           2 :     return ret;
+     387             : }
+     388             : 
+     389             : /** @brief Print out the application help
+     390             :  */
+     391           0 : static void usage(void)
+     392             : {
+     393             :     printf("Usage: dlt-logstorage-ctrl [options]\n");
+     394             :     printf("Send a trigger to DLT daemon to connect/disconnect"
+     395             :            "a certain logstorage device\n");
+     396             :     printf("\n");
+     397             :     printf("Options:\n");
+     398             :     printf("  -c --command               Connection type: connect = 1, disconnect = 0\n");
+     399             :     printf("  -d[prop] --daemonize=prop  Run as daemon: prop = use proprietary handler\n");
+     400             :     printf("                             'prop' may be replaced by any meaningful word\n");
+     401             :     printf("                             If prop is not specified, udev will be used\n");
+     402             :     printf("  -e --ecuid                 Set ECU ID (Default: %s)\n", DLT_CTRL_DEFAULT_ECUID);
+     403             :     printf("  -h --help                  Usage\n");
+     404             :     printf("  -p --path                  Mount point path\n");
+     405             :     printf("  -s[path] --snapshot=path   Sync Logstorage cache\n");
+     406             :     printf("                             Don't use -s together with -d and -c\n");
+     407             :     printf("  -t                         Specify connection timeout (Default: %ds)\n",
+     408             :            DLT_CTRL_TIMEOUT);
+     409             :     printf("  -S --send-header           Send message with serial header (Default: Without serial header)\n");
+     410             :     printf("  -R --resync-header         Enable resync serial header\n");
+     411           0 :     printf("  -v --verbose               Set verbose flag (Default:%d)\n", get_verbosity());
+     412             :     printf("  -C filename                DLT daemon configuration file (Default: " CONFIGURATION_FILES_DIR
+     413             :            "/dlt.conf)\n");
+     414           0 : }
+     415             : 
+     416             : static struct option long_options[] = {
+     417             :     {"command",       required_argument,  0,  'c'},
+     418             :     {"daemonize",     optional_argument,  0,  'd'},
+     419             :     {"ecuid",         required_argument,  0,  'e'},
+     420             :     {"help",          no_argument,        0,  'h'},
+     421             :     {"path",          required_argument,  0,  'p'},
+     422             :     {"snapshot",      optional_argument,  0,  's'},
+     423             :     {"timeout",       required_argument,  0,  't'},
+     424             :     {"send-header",   no_argument,        0,  'S'},
+     425             :     {"resync-header", no_argument,        0,  'R'},
+     426             :     {"verbose",       no_argument,        0,  'v'},
+     427             :     {0,               0,                  0,  0}
+     428             : };
+     429             : 
+     430             : /** @brief Parses the application arguments
+     431             :  *
+     432             :  * The arguments are parsed and saved in static structure for future use.
+     433             :  *
+     434             :  * @param argc The amount of arguments
+     435             :  * @param argv The table of arguments
+     436             :  *
+     437             :  * @return 0 on success, -1 otherwise
+     438             :  */
+     439           2 : static int parse_args(int argc, char *argv[])
+     440             : {
+     441             :     int c = -1;
+     442           2 :     int long_index = 0;
+     443             : 
+     444           6 :     while ((c = getopt_long(argc,
+     445             :                             argv,
+     446             :                             ":s::t:hSRe:p:d::c:vC:",
+     447             :                             long_options,
+     448           6 :                             &long_index)) != -1)
+     449           4 :         switch (c) {
+     450           2 :         case 's':
+     451           2 :             set_default_event_type(EVENT_SYNC_CACHE);
+     452             : 
+     453           2 :             if ((optarg != NULL) && (strlen(optarg) >= DLT_MOUNT_PATH_MAX)) {
+     454           0 :                 pr_error("Mount path '%s' too long\n", optarg);
+     455           0 :                 return -1;
+     456             :             }
+     457             : 
+     458           2 :             set_default_path(optarg);
+     459           2 :             break;
+     460           0 :         case 't':
+     461           0 :             if (optarg != NULL)
+     462           0 :                 set_timeout((int) strtol(optarg, NULL, 10));
+     463             :             break;
+     464           0 :         case 'S':
+     465             :         {
+     466           0 :             set_send_serial_header(1);
+     467           0 :             break;
+     468             :         }
+     469           0 :         case 'R':
+     470             :         {
+     471           0 :             set_resync_serial_header(1);
+     472           0 :             break;
+     473             :         }
+     474           0 :         case 'h':
+     475           0 :             usage();
+     476           0 :             return -1;
+     477           0 :         case 'e':
+     478           0 :             set_ecuid(optarg);
+     479           0 :             break;
+     480           0 :         case 'd':
+     481           0 :             pr_verbose("Choosing handler.\n");
+     482           0 :             set_handler_type(optarg);
+     483           0 :             pr_verbose("Handler chosen: %d.\n", get_handler_type());
+     484             :             break;
+     485           0 :         case 'p':
+     486             : 
+     487           0 :             if ((optarg != NULL) && (strlen(optarg) >= DLT_MOUNT_PATH_MAX)) {
+     488           0 :                 pr_error("Mount path '%s' too long\n", optarg);
+     489           0 :                 return -1;
+     490             :             }
+     491             : 
+     492           0 :             set_default_path(optarg);
+     493           0 :             break;
+     494           0 :         case 'c':
+     495           0 :             if (optarg != NULL)
+     496           0 :                 set_default_event_type(strtol(optarg, NULL, 10));
+     497             :             break;
+     498           0 :         case 'v':
+     499           0 :             set_verbosity(1);
+     500           0 :             pr_verbose("Now in verbose mode.\n");
+     501             :             break;
+     502           2 :         case 'C':
+     503           2 :             set_conf(optarg);
+     504           2 :             pr_verbose("Set %s to read options\n", optarg);
+     505             :             break;
+     506           0 :         case ':':
+     507           0 :             pr_error("Option -%c requires an argument.\n", optopt);
+     508           0 :             usage();
+     509           0 :             return -1;
+     510           0 :         case '?':
+     511             : 
+     512           0 :             if (isprint(optopt))
+     513           0 :                 pr_error("Unknown option -%c.\n", optopt);
+     514             :             else
+     515           0 :                 pr_error("Unknown option character \\x%x.\n", optopt);
+     516             : 
+     517           0 :             usage();
+     518           0 :             return -1;
+     519           0 :         default:
+     520           0 :             pr_error("Try %s -h for more information.\n", argv[0]);
+     521           0 :             return -1;
+     522             :         }
+     523             : 
+     524             : 
+     525             : 
+     526           4 :     if ((get_default_event_type() == EVENT_SYNC_CACHE) &&
+     527           2 :         (get_handler_type() != CTRL_NOHANDLER)) {
+     528           0 :         pr_error("Sync caches not available in daemon mode\n");
+     529           0 :         return -1;
+     530             :     }
+     531             : 
+     532             :     /* Retrieve ECUID from dlt.conf */
+     533           2 :     if (get_ecuid() == NULL)
+     534           0 :         set_ecuid(NULL);
+     535             : 
+     536             :     return 0;
+     537             : }
+     538             : 
+     539             : #if !defined(DLT_SYSTEMD_ENABLE)
+     540           0 : int sd_notify(int unset_environment, const char *state)
+     541             : {
+     542             :     /* Satisfy Compiler for warnings */
+     543             :     (void)unset_environment;
+     544             :     (void)state;
+     545           0 :     return 0;
+     546             : }
+     547             : #endif
+     548             : 
+     549             : /** @brief Entry point
+     550             :  *
+     551             :  * Execute the argument parser and call the main feature accordingly.
+     552             :  *
+     553             :  * @param argc The amount of arguments
+     554             :  * @param argv The table of arguments
+     555             :  *
+     556             :  * @return 0 on success, -1 otherwise
+     557             :  */
+     558           2 : int main(int argc, char *argv[])
+     559             : {
+     560             :     int ret = 0;
+     561             : 
+     562           2 :     set_timeout(DLT_CTRL_TIMEOUT);
+     563           2 :     set_send_serial_header(0);
+     564           2 :     set_resync_serial_header(0);
+     565             : 
+     566             :     /* Get command line arguments */
+     567           2 :     if (parse_args(argc, argv) != 0)
+     568             :         return -1;
+     569             : 
+     570             :     /* all parameter valid, start communication with daemon or setup
+     571             :      * communication with control daemon */
+     572           2 :     if (get_handler_type() == CTRL_NOHANDLER) {
+     573           2 :         pr_verbose("One shot.\n");
+     574             : 
+     575           2 :         ret = dlt_logstorage_ctrl_single_request();
+     576             : 
+     577           2 :         if (ret < 0)
+     578           0 :             pr_error("Message failed to be send. Please check DLT config.\n");
+     579             :     }
+     580             :     else {
+     581           0 :         pr_verbose("Entering in daemon mode.\n");
+     582             : 
+     583             :         /* Let's daemonize */
+     584             :         if (sd_notify(0, "READY=1") <= 0) {
+     585           0 :             pr_verbose("SD notify failed, manually daemonizing.\n");
+     586             : 
+     587             :             /* No message can be sent or Systemd is not available.
+     588             :              * Daemonizing manually.
+     589             :              */
+     590           0 :             if (daemon(1, 1)) {
+     591           0 :                 pr_error("Failed to daemonize: %s\n", strerror(errno));
+     592           0 :                 return EXIT_FAILURE;
+     593             :             }
+     594             :         }
+     595             : 
+     596           0 :         pr_verbose("Executing the event loop\n");
+     597           0 :         ret = dlt_logstorage_ctrl_setup_event_loop();
+     598             :     }
+     599             : 
+     600           2 :     pr_verbose("Exiting.\n");
+     601             :     return ret;
+     602             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/logstorage/dlt-logstorage-list.c.func-sort-c.html b/dlt_lcov_report/console/logstorage/dlt-logstorage-list.c.func-sort-c.html new file mode 100644 index 000000000..68e0288f4 --- /dev/null +++ b/dlt_lcov_report/console/logstorage/dlt-logstorage-list.c.func-sort-c.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/logstorage/dlt-logstorage-list.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console/logstorage - dlt-logstorage-list.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:0620.0 %
Date:2024-12-05 09:07:13Functions:040.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
logstorage_delete_dev_info0
logstorage_find_dev_info0
logstorage_store_dev_info0
print_list0
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/logstorage/dlt-logstorage-list.c.func.html b/dlt_lcov_report/console/logstorage/dlt-logstorage-list.c.func.html new file mode 100644 index 000000000..8ca026ea4 --- /dev/null +++ b/dlt_lcov_report/console/logstorage/dlt-logstorage-list.c.func.html @@ -0,0 +1,88 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/logstorage/dlt-logstorage-list.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console/logstorage - dlt-logstorage-list.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:0620.0 %
Date:2024-12-05 09:07:13Functions:040.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
logstorage_delete_dev_info0
logstorage_find_dev_info0
logstorage_store_dev_info0
print_list0
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/logstorage/dlt-logstorage-list.c.gcov.html b/dlt_lcov_report/console/logstorage/dlt-logstorage-list.c.gcov.html new file mode 100644 index 000000000..0a4ce2f54 --- /dev/null +++ b/dlt_lcov_report/console/logstorage/dlt-logstorage-list.c.gcov.html @@ -0,0 +1,308 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/logstorage/dlt-logstorage-list.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console/logstorage - dlt-logstorage-list.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:0620.0 %
Date:2024-12-05 09:07:13Functions:040.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /**
+       2             :  * Copyright (C) 2013 - 2015  Advanced Driver Information Technology.
+       3             :  * This code is developed by Advanced Driver Information Technology.
+       4             :  * Copyright of Advanced Driver Information Technology, Bosch and DENSO.
+       5             :  *
+       6             :  * This file is part of COVESA Project Dlt - Diagnostic Log and Trace console apps.
+       7             :  *
+       8             :  *
+       9             :  * \copyright
+      10             :  * This Source Code Form is subject to the terms of the
+      11             :  * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
+      12             :  * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+      13             :  *
+      14             :  *
+      15             :  * \author Anitha.BA <anithaammaji.baggam@in.bosch.com> ADIT 2015
+      16             :  * \author Christoph Lipka <clipka@jp.adit-jv.com> ADIT 2015
+      17             :  * \author Frederic Berat <fberat@de.adit-jv.com> ADIT 2015
+      18             :  *
+      19             :  * \file dlt-logstorage-list.c
+      20             :  * For further information see http://www.covesa.org/.
+      21             :  */
+      22             : 
+      23             : /*******************************************************************************
+      24             : **                                                                            **
+      25             : **  SRC-MODULE: dlt-logstorage-list.c                                         **
+      26             : **                                                                            **
+      27             : **  TARGET    : linux                                                         **
+      28             : **                                                                            **
+      29             : **  PROJECT   : DLT                                                           **
+      30             : **                                                                            **
+      31             : **  AUTHOR    : Christoph Lipka clipka@jp.adit-jv.com                         **
+      32             : **              Anitha.B.A  anithaammaji.baggam@in.bosch.com                  **
+      33             : **              Frederic Berat fberat@de.adit-jv.com                          **
+      34             : **                                                                            **
+      35             : **  PURPOSE   :  linked list implementation for storing the device info       **
+      36             : **                                                                            **
+      37             : **  REMARKS   :                                                               **
+      38             : **                                                                            **
+      39             : **  PLATFORM DEPENDANT [yes/no]: yes                                          **
+      40             : **                                                                            **
+      41             : **  TO BE CHANGED BY USER [yes/no]: no                                        **
+      42             : **                                                                            **
+      43             : *******************************************************************************/
+      44             : 
+      45             : /*******************************************************************************
+      46             : **                      Author Identity                                       **
+      47             : ********************************************************************************
+      48             : **                                                                            **
+      49             : ** Initials     Name                       Company                            **
+      50             : ** --------     -------------------------  ---------------------------------- **
+      51             : **  BA          Anitha                     ADIT                               **
+      52             : **  cl          Christoph Lipka            ADIT                               **
+      53             : **  fb          Frederic Berat             ADIT                               **
+      54             : *******************************************************************************/
+      55             : #define pr_fmt(fmt) "Log storage list: "fmt
+      56             : 
+      57             : #include <stdio.h>
+      58             : #include <stdlib.h>
+      59             : #include <string.h>
+      60             : #include <unistd.h>
+      61             : 
+      62             : #include "dlt_common.h"
+      63             : #include "dlt-control-common.h"
+      64             : #include "dlt-logstorage-common.h"
+      65             : 
+      66             : static struct LogstorageDeviceInfo
+      67             : {
+      68             :     char *dev_node; /**< The device node */
+      69             :     char *mnt_point; /**< Mount point for this device */
+      70             :     struct LogstorageDeviceInfo *prev; /**< Previous element of the list */
+      71             :     struct LogstorageDeviceInfo *next; /**< Next element of the list */
+      72             : } *g_info;
+      73             : 
+      74             : /** @brief Prints the device list in verbose mode
+      75             :  *
+      76             :  * This can be used to debug the behavior.
+      77             :  * Therefore, it's only available in verbose mode.
+      78             :  */
+      79           0 : void print_list()
+      80             : {
+      81           0 :     struct LogstorageDeviceInfo *ptr = g_info;
+      82           0 :     pr_verbose(" -------Device list-------\n");
+      83             : 
+      84           0 :     while (ptr != NULL) {
+      85           0 :         pr_verbose("%p:\t[%s][%s] \n", ptr, ptr->dev_node, ptr->mnt_point);
+      86           0 :         ptr = ptr->next;
+      87             :     }
+      88             : 
+      89           0 :     pr_verbose(" -------Device list end-------\n\n");
+      90             : 
+      91           0 :     return;
+      92             : }
+      93             : 
+      94             : /** @brief Find element in the list based on device node
+      95             :  *
+      96             :  * Allows to check whether a device is already in the list or
+      97             :  * to find out the one to be removed.
+      98             :  *
+      99             :  * @param node The device node to look for
+     100             :  *
+     101             :  * @return The element of the list found, NULL either.
+     102             :  */
+     103           0 : static struct LogstorageDeviceInfo *logstorage_find_dev_info(const char *node)
+     104             : {
+     105           0 :     struct LogstorageDeviceInfo *ptr = g_info;
+     106             : 
+     107           0 :     if (!node)
+     108             :         return NULL;
+     109             : 
+     110           0 :     pr_verbose("Looking for %s.\n", node);
+     111             : 
+     112           0 :     while (ptr != NULL) {
+     113           0 :         if (strncmp(ptr->dev_node, node, DLT_MOUNT_PATH_MAX) == 0) {
+     114           0 :             pr_verbose("%s found in %p.\n", node, ptr);
+     115             :             break;
+     116             :         }
+     117             :         else {
+     118           0 :             ptr = ptr->next;
+     119             :         }
+     120             :     }
+     121             : 
+     122             :     return ptr;
+     123             : }
+     124             : 
+     125             : /** @brief Add new device in the list
+     126             :  *
+     127             :  * The device is only added if a configuration file has been found and
+     128             :  * if it's not already in the list.
+     129             :  *
+     130             :  * @param node The device node to add
+     131             :  * @param path The corresponding mount point path
+     132             :  *
+     133             :  * @return 0 on success, -1 in case of error.
+     134             :  */
+     135           0 : int logstorage_store_dev_info(const char *node, const char *path)
+     136             : {
+     137             :     struct LogstorageDeviceInfo *ptr = NULL;
+     138             :     size_t path_len = 0;
+     139             : 
+     140           0 :     if ((node == NULL) || (path == NULL)) {
+     141           0 :         pr_error("Invalid input\n");
+     142           0 :         return -1;
+     143             :     }
+     144             : 
+     145           0 :     if (logstorage_find_dev_info(node)) {
+     146           0 :         pr_verbose("%s already in list.\n", node);
+     147           0 :         print_list();
+     148           0 :         return 0;
+     149             :     }
+     150             : 
+     151           0 :     ptr = calloc(1, sizeof(struct LogstorageDeviceInfo));
+     152             : 
+     153           0 :     if (ptr == NULL) {
+     154           0 :         pr_error("Node creation failed\n");
+     155           0 :         return -1;
+     156             :     }
+     157             : 
+     158           0 :     ptr->dev_node = strdup(node);
+     159           0 :     path_len = strlen(path);
+     160             : 
+     161             :     if (path_len > DLT_MOUNT_PATH_MAX)
+     162             :         path_len = (size_t)DLT_MOUNT_PATH_MAX;
+     163             : 
+     164           0 :     ptr->mnt_point = (char *)calloc(1, path_len + 1);
+     165             : 
+     166           0 :     if (ptr->mnt_point == NULL) {
+     167           0 :         pr_error("memory allocation failed for mnt_point\n");
+     168           0 :         free(ptr);
+     169             :         ptr = NULL;
+     170           0 :         return -1;
+     171             :     }
+     172             : 
+     173           0 :     ptr->mnt_point[path_len] = '\0';
+     174           0 :     memcpy(ptr->mnt_point, path, path_len);
+     175             : 
+     176             :     /* Put it on head */
+     177           0 :     ptr->next = g_info;
+     178             : 
+     179           0 :     if (g_info)
+     180           0 :         g_info->prev = ptr;
+     181             : 
+     182           0 :     g_info = ptr;
+     183             : 
+     184           0 :     pr_verbose("%s added to list.\n", node);
+     185           0 :     print_list();
+     186             : 
+     187           0 :     return 0;
+     188             : }
+     189             : 
+     190             : /** @brief Remove a device from the list
+     191             :  *
+     192             :  * If the device is removed from the list, the mount point
+     193             :  * pointer is given back to the caller. That means that
+     194             :  * he has to free it.
+     195             :  *
+     196             :  * @param node The device node to be removed
+     197             :  *
+     198             :  * @return the mount point if the node is found, NULL either.
+     199             :  */
+     200           0 : char *logstorage_delete_dev_info(const char *node)
+     201             : {
+     202             :     struct LogstorageDeviceInfo *del = NULL;
+     203             :     char *ret = NULL;
+     204             : 
+     205           0 :     del = logstorage_find_dev_info(node);
+     206             : 
+     207           0 :     if (del == NULL) {
+     208           0 :         pr_verbose("%s not found in list.\n", node);
+     209           0 :         print_list();
+     210           0 :         return ret;
+     211             :     }
+     212             : 
+     213             :     /* Has to be freed by the caller */
+     214           0 :     ret = del->mnt_point;
+     215             : 
+     216           0 :     if (del->prev)
+     217           0 :         del->prev->next = del->next;
+     218             : 
+     219           0 :     if (del->next)
+     220           0 :         del->next->prev = del->prev;
+     221             : 
+     222           0 :     if (del == g_info)
+     223           0 :         g_info = g_info->next;
+     224             : 
+     225           0 :     free(del->dev_node);
+     226           0 :     free(del);
+     227             : 
+     228           0 :     pr_verbose("%s removed from list.\n", node);
+     229           0 :     print_list();
+     230             : 
+     231           0 :     return ret;
+     232             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/logstorage/index-sort-f.html b/dlt_lcov_report/console/logstorage/index-sort-f.html new file mode 100644 index 000000000..d7a54c982 --- /dev/null +++ b/dlt_lcov_report/console/logstorage/index-sort-f.html @@ -0,0 +1,113 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/logstorage + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console/logstorageHitTotalCoverage
Test:dlt_final_coverage.infoLines:7533022.7 %
Date:2024-12-05 09:07:13Functions:113234.4 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt-logstorage-list.c +
0.0%
+
0.0 %0 / 620.0 %0 / 4
dlt-logstorage-ctrl.c +
23.1%23.1%
+
23.1 %43 / 18630.8 %4 / 13
dlt-logstorage-common.c +
39.0%39.0%
+
39.0 %32 / 8246.7 %7 / 15
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/logstorage/index-sort-l.html b/dlt_lcov_report/console/logstorage/index-sort-l.html new file mode 100644 index 000000000..b8359dafc --- /dev/null +++ b/dlt_lcov_report/console/logstorage/index-sort-l.html @@ -0,0 +1,113 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/logstorage + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console/logstorageHitTotalCoverage
Test:dlt_final_coverage.infoLines:7533022.7 %
Date:2024-12-05 09:07:13Functions:113234.4 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt-logstorage-list.c +
0.0%
+
0.0 %0 / 620.0 %0 / 4
dlt-logstorage-ctrl.c +
23.1%23.1%
+
23.1 %43 / 18630.8 %4 / 13
dlt-logstorage-common.c +
39.0%39.0%
+
39.0 %32 / 8246.7 %7 / 15
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/logstorage/index.html b/dlt_lcov_report/console/logstorage/index.html new file mode 100644 index 000000000..a07668072 --- /dev/null +++ b/dlt_lcov_report/console/logstorage/index.html @@ -0,0 +1,113 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/logstorage + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console/logstorageHitTotalCoverage
Test:dlt_final_coverage.infoLines:7533022.7 %
Date:2024-12-05 09:07:13Functions:113234.4 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt-logstorage-common.c +
39.0%39.0%
+
39.0 %32 / 8246.7 %7 / 15
dlt-logstorage-ctrl.c +
23.1%23.1%
+
23.1 %43 / 18630.8 %4 / 13
dlt-logstorage-list.c +
0.0%
+
0.0 %0 / 620.0 %0 / 4
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt-daemon.c.func-sort-c.html b/dlt_lcov_report/daemon/dlt-daemon.c.func-sort-c.html new file mode 100644 index 000000000..f2aa67432 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt-daemon.c.func-sort-c.html @@ -0,0 +1,240 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt-daemon.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt-daemon.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:606115252.6 %
Date:2024-12-05 09:07:13Functions:314273.8 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_process_client_messages_serial0
dlt_daemon_process_user_message_log_mode0
dlt_daemon_process_user_message_marker0
dlt_daemon_process_user_message_not_sup0
dlt_daemon_process_user_message_overflow0
dlt_daemon_process_user_message_set_app_ll_ts0
dlt_daemon_send_message_overflow0
enforce_context_ll_and_ts_keep_message0
file_read_everything0
file_read_field0
usage0
dlt_daemon_daemonize2
dlt_daemon_process_control_connect2
dlt_daemon_send_ringbuffer_to_client2
dlt_daemon_check_numeric_setting3
dlt_daemon_process_client_connect4
dlt_daemon_process_control_messages4
dlt_daemon_close_socket5
dlt_daemon_process_user_message_unregister_application6
dlt_daemon_process_user_message_register_application7
dlt_daemon_create_pipes_dir9
dlt_daemon_exit_trigger9
dlt_daemon_init_fifo9
dlt_daemon_init_serial9
dlt_daemon_initialize_control_socket9
dlt_daemon_local_cleanup9
dlt_daemon_local_connection_init9
dlt_daemon_local_ecu_version_init9
dlt_daemon_local_init_p19
dlt_daemon_local_init_p29
dlt_daemon_signal_handler9
dlt_mkdir_recursive9
main9
option_file_parser9
option_handling9
create_timer_fd10
dlt_daemon_process_client_messages11
dlt_daemon_process_user_message_unregister_context37
dlt_daemon_process_user_message_register_context38
dlt_daemon_log_internal40
dlt_daemon_process_user_messages1523
dlt_daemon_process_user_message_log5809
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt-daemon.c.func.html b/dlt_lcov_report/daemon/dlt-daemon.c.func.html new file mode 100644 index 000000000..550d20c0e --- /dev/null +++ b/dlt_lcov_report/daemon/dlt-daemon.c.func.html @@ -0,0 +1,240 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt-daemon.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt-daemon.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:606115252.6 %
Date:2024-12-05 09:07:13Functions:314273.8 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
create_timer_fd10
dlt_daemon_check_numeric_setting3
dlt_daemon_close_socket5
dlt_daemon_create_pipes_dir9
dlt_daemon_daemonize2
dlt_daemon_exit_trigger9
dlt_daemon_init_fifo9
dlt_daemon_init_serial9
dlt_daemon_initialize_control_socket9
dlt_daemon_local_cleanup9
dlt_daemon_local_connection_init9
dlt_daemon_local_ecu_version_init9
dlt_daemon_local_init_p19
dlt_daemon_local_init_p29
dlt_daemon_log_internal40
dlt_daemon_process_client_connect4
dlt_daemon_process_client_messages11
dlt_daemon_process_client_messages_serial0
dlt_daemon_process_control_connect2
dlt_daemon_process_control_messages4
dlt_daemon_process_user_message_log5809
dlt_daemon_process_user_message_log_mode0
dlt_daemon_process_user_message_marker0
dlt_daemon_process_user_message_not_sup0
dlt_daemon_process_user_message_overflow0
dlt_daemon_process_user_message_register_application7
dlt_daemon_process_user_message_register_context38
dlt_daemon_process_user_message_set_app_ll_ts0
dlt_daemon_process_user_message_unregister_application6
dlt_daemon_process_user_message_unregister_context37
dlt_daemon_process_user_messages1523
dlt_daemon_send_message_overflow0
dlt_daemon_send_ringbuffer_to_client2
dlt_daemon_signal_handler9
dlt_mkdir_recursive9
enforce_context_ll_and_ts_keep_message0
file_read_everything0
file_read_field0
main9
option_file_parser9
option_handling9
usage0
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt-daemon.c.gcov.html b/dlt_lcov_report/daemon/dlt-daemon.c.gcov.html new file mode 100644 index 000000000..d7bb22fc7 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt-daemon.c.gcov.html @@ -0,0 +1,4460 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt-daemon.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt-daemon.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:606115252.6 %
Date:2024-12-05 09:07:13Functions:314273.8 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2011-2015, BMW AG
+       5             :  *
+       6             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       7             :  *
+       8             :  * This Source Code Form is subject to the terms of the
+       9             :  * Mozilla Public License (MPL), v. 2.0.
+      10             :  * If a copy of the MPL was not distributed with this file,
+      11             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      12             :  *
+      13             :  * For further information see http://www.covesa.org/.
+      14             :  */
+      15             : 
+      16             : /*!
+      17             :  * \author
+      18             :  * Alexander Wenzel <alexander.aw.wenzel@bmw.de>
+      19             :  * Markus Klein <Markus.Klein@esk.fraunhofer.de>
+      20             :  * Mikko Rapeli <mikko.rapeli@bmw.de>
+      21             :  *
+      22             :  * \copyright Copyright © 2011-2015 BMW AG. \n
+      23             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      24             :  *
+      25             :  * \file dlt-daemon.c
+      26             :  */
+      27             : 
+      28             : #include <netdb.h>
+      29             : #include <ctype.h>
+      30             : #include <stdio.h>      /* for printf() and fprintf() */
+      31             : #include <sys/socket.h> /* for socket(), connect(), (), and recv() */
+      32             : #include <sys/un.h>
+      33             : #include <arpa/inet.h>  /* for sockaddr_in and inet_addr() */
+      34             : #include <stdlib.h>     /* for atoi() and exit() */
+      35             : #include <string.h>     /* for memset() */
+      36             : #include <unistd.h>     /* for close() and access */
+      37             : #include <fcntl.h>
+      38             : #include <signal.h>
+      39             : #include <syslog.h>
+      40             : #include <errno.h>
+      41             : #include <pthread.h>
+      42             : #include <grp.h>
+      43             : 
+      44             : #ifdef linux
+      45             : #   include <sys/timerfd.h>
+      46             : #endif
+      47             : #include <sys/stat.h>
+      48             : #include <sys/time.h>
+      49             : #include <libgen.h>
+      50             : 
+      51             : #if defined(linux) && defined(__NR_statx)
+      52             : #   include <linux/stat.h>
+      53             : #endif
+      54             : 
+      55             : #ifdef DLT_DAEMON_VSOCK_IPC_ENABLE
+      56             : #   ifdef linux
+      57             : #       include <linux/vm_sockets.h>
+      58             : #   endif
+      59             : #   ifdef __QNX__
+      60             : #       include <vm_sockets.h>
+      61             : #   endif
+      62             : #endif
+      63             : 
+      64             : #include "dlt_types.h"
+      65             : #include "dlt-daemon.h"
+      66             : #include "dlt-daemon_cfg.h"
+      67             : #include "dlt_daemon_common_cfg.h"
+      68             : 
+      69             : #include "dlt_daemon_socket.h"
+      70             : #include "dlt_daemon_unix_socket.h"
+      71             : #include "dlt_daemon_serial.h"
+      72             : 
+      73             : #include "dlt_daemon_client.h"
+      74             : #include "dlt_daemon_connection.h"
+      75             : #include "dlt_daemon_event_handler.h"
+      76             : #include "dlt_daemon_offline_logstorage.h"
+      77             : #include "dlt_gateway.h"
+      78             : 
+      79             : #ifdef UDP_CONNECTION_SUPPORT
+      80             : #   include "dlt_daemon_udp_socket.h"
+      81             : #endif
+      82             : #if defined(DLT_SYSTEMD_WATCHDOG_ENABLE) || defined(DLT_SYSTEMD_ENABLE)
+      83             : #   include "sd-daemon.h"
+      84             : #endif
+      85             : 
+      86             : /**
+      87             :  * \defgroup daemon DLT Daemon
+      88             :  * \addtogroup daemon
+      89             :  \{
+      90             :  */
+      91             : 
+      92             : #define DLT_DAEMON_APP_ID "DLTD"
+      93             : #define DLT_DAEMON_CTX_ID "INTM"
+      94             : 
+      95             : 
+      96             : static int dlt_daemon_log_internal(DltDaemon *daemon,
+      97             :                                    DltDaemonLocal *daemon_local, char *str,
+      98             :                                    DltLogLevelType level, const char *app_id,
+      99             :                                    const char *ctx_id, int verbose);
+     100             : 
+     101             : static int dlt_daemon_check_numeric_setting(char *token,
+     102             :                                             char *value,
+     103             :                                             unsigned long *data);
+     104             : 
+     105             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+     106             : 
+     107             : struct DltTraceLoadLogParams {
+     108             :     DltDaemon *daemon;
+     109             :     DltDaemonLocal *daemon_local;
+     110             :     int verbose;
+     111             :     char *app_id;
+     112             : };
+     113             : 
+     114             : static DltReturnValue dlt_daemon_output_internal_msg(DltLogLevelType loglevel, const char *text, void *params);
+     115             : 
+     116             : pthread_rwlock_t trace_load_rw_lock;
+     117             : #endif
+     118             : 
+     119             : /* used in main event loop and signal handler */
+     120             : int g_exit = 0;
+     121             : 
+     122             : int g_signo = 0;
+     123             : 
+     124             : /* used for value from conf file */
+     125             : static int value_length = 1024;
+     126             : 
+     127             : static char dlt_timer_conn_types[DLT_TIMER_UNKNOWN + 1] = {
+     128             :     [DLT_TIMER_PACKET] = DLT_CONNECTION_ONE_S_TIMER,
+     129             :     [DLT_TIMER_ECU] = DLT_CONNECTION_SIXTY_S_TIMER,
+     130             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+     131             :     [DLT_TIMER_SYSTEMD] = DLT_CONNECTION_SYSTEMD_TIMER,
+     132             : #endif
+     133             :     [DLT_TIMER_GATEWAY] = DLT_CONNECTION_GATEWAY_TIMER,
+     134             :     [DLT_TIMER_UNKNOWN] = DLT_CONNECTION_TYPE_MAX
+     135             : };
+     136             : 
+     137             : static char dlt_timer_names[DLT_TIMER_UNKNOWN + 1][32] = {
+     138             :     [DLT_TIMER_PACKET] = "Timing packet",
+     139             :     [DLT_TIMER_ECU] = "ECU version",
+     140             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+     141             :     [DLT_TIMER_SYSTEMD] = "Systemd watchdog",
+     142             : #endif
+     143             :     [DLT_TIMER_GATEWAY] = "Gateway",
+     144             :     [DLT_TIMER_UNKNOWN] = "Unknown timer"
+     145             : };
+     146             : 
+     147             : #ifdef __QNX__
+     148             : static int dlt_timer_pipes[DLT_TIMER_UNKNOWN][2] = {
+     149             :     /* [timer_id] = {read_pipe, write_pipe} */
+     150             :     [DLT_TIMER_PACKET] = {DLT_FD_INIT, DLT_FD_INIT},
+     151             :     [DLT_TIMER_ECU] = {DLT_FD_INIT, DLT_FD_INIT},
+     152             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+     153             :     [DLT_TIMER_SYSTEMD] = {DLT_FD_INIT, DLT_FD_INIT},
+     154             : #endif
+     155             :     [DLT_TIMER_GATEWAY] = {DLT_FD_INIT, DLT_FD_INIT}
+     156             : };
+     157             : 
+     158             : static pthread_t timer_threads[DLT_TIMER_UNKNOWN] = {
+     159             :     [DLT_TIMER_PACKET] = 0,
+     160             :     [DLT_TIMER_ECU] = 0,
+     161             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+     162             :     [DLT_TIMER_SYSTEMD] = 0,
+     163             : #endif
+     164             :     [DLT_TIMER_GATEWAY] = 0
+     165             : };
+     166             : 
+     167             : static DltDaemonPeriodicData *timer_data[DLT_TIMER_UNKNOWN] = {
+     168             :     [DLT_TIMER_PACKET] = NULL,
+     169             :     [DLT_TIMER_ECU] = NULL,
+     170             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+     171             :     [DLT_TIMER_SYSTEMD] = NULL,
+     172             : #endif
+     173             :     [DLT_TIMER_GATEWAY] = NULL
+     174             : };
+     175             : 
+     176             : void close_pipes(int fds[2])
+     177             : {
+     178             :     if (fds[0] > 0) {
+     179             :         close(fds[0]);
+     180             :         fds[0] = DLT_FD_INIT;
+     181             :     }
+     182             : 
+     183             :     if (fds[1] > 0) {
+     184             :         close(fds[1]);
+     185             :         fds[1] = DLT_FD_INIT;
+     186             :     }
+     187             : }
+     188             : 
+     189             : #endif // __QNX__
+     190             : 
+     191             : /**
+     192             :  * Print usage information of tool.
+     193             :  */
+     194           0 : void usage()
+     195             : {
+     196             :     char version[DLT_DAEMON_TEXTBUFSIZE];
+     197           0 :     dlt_get_version(version, DLT_DAEMON_TEXTBUFSIZE);
+     198             : 
+     199             :     /*printf("DLT logging daemon %s %s\n", _DLT_PACKAGE_VERSION, _DLT_PACKAGE_VERSION_STATE); */
+     200             :     /*printf("Compile options: %s %s %s %s",_DLT_SYSTEMD_ENABLE, _DLT_SYSTEMD_WATCHDOG_ENABLE, _DLT_TEST_ENABLE, _DLT_SHM_ENABLE); */
+     201             :     printf("%s", version);
+     202             :     printf("Usage: dlt-daemon [options]\n");
+     203             :     printf("Options:\n");
+     204             :     printf("  -d            Daemonize\n");
+     205             :     printf("  -h            Usage\n");
+     206             :     printf("  -c filename   DLT daemon configuration file (Default: " CONFIGURATION_FILES_DIR "/dlt.conf)\n");
+     207             : 
+     208             : #ifdef DLT_DAEMON_USE_FIFO_IPC
+     209             :     printf("  -t directory  Directory for local fifo and user-pipes (Default: /tmp)\n");
+     210             :     printf("                (Applications wanting to connect to a daemon using a\n");
+     211             :     printf("                custom directory need to be started with the environment \n");
+     212             :     printf("                variable DLT_PIPE_DIR set appropriately)\n");
+     213             : #endif
+     214             : 
+     215             : #ifdef DLT_SHM_ENABLE
+     216             :     printf("  -s filename   The file name to create the share memory (Default: /dlt-shm)\n");
+     217             :     printf("                (Applications wanting to connect to a daemon using a\n");
+     218             :     printf("                custom shm name need to be started with the environment \n");
+     219             :     printf("                variable DLT_SHM_NAME set appropriately)\n");
+     220             : #endif
+     221             :     printf("  -p port       port to monitor for incoming requests (Default: 3490)\n");
+     222             :     printf("                (Applications wanting to connect to a daemon using a custom\n");
+     223             :     printf("                port need to be started with the environment variable\n");
+     224             :     printf("                DLT_DAEMON_TCP_PORT set appropriately)\n");
+     225             : #ifdef DLT_LOG_LEVEL_APP_CONFIG
+     226             :     printf("  -a filename   The filename for load default app id log levels (Default: " CONFIGURATION_FILES_DIR "/dlt-log-levels.conf)\n");
+     227             : #endif
+     228             : 
+     229             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+     230             :     printf("  -l filename   The filename for load limits (Default: " CONFIGURATION_FILES_DIR "/dlt-trace-load.conf)\n");
+     231             : #endif
+     232             : 
+     233             : #
+     234           0 : } /* usage() */
+     235             : 
+     236             : /**
+     237             :  * Option handling
+     238             :  */
+     239           9 : int option_handling(DltDaemonLocal *daemon_local, int argc, char *argv[])
+     240             : {
+     241             :     int c;
+     242             :     char options[255];
+     243             :     memset(options, 0, sizeof options);
+     244             :     const char *const default_options = "hdc:t:p:";
+     245             :     strcpy(options, default_options);
+     246             : 
+     247           9 :     if (daemon_local == 0) {
+     248           0 :         fprintf (stderr, "Invalid parameter passed to option_handling()\n");
+     249           0 :         return -1;
+     250             :     }
+     251             : 
+     252             :     /* Initialize flags */
+     253             :     memset(daemon_local, 0, sizeof(DltDaemonLocal));
+     254             : 
+     255             :     /* default values */
+     256           9 :     daemon_local->flags.port = DLT_DAEMON_TCP_PORT;
+     257             : 
+     258             : #ifdef DLT_DAEMON_USE_FIFO_IPC
+     259           9 :     dlt_log_set_fifo_basedir(DLT_USER_IPC_PATH);
+     260             : #endif
+     261             : 
+     262             : #ifdef DLT_SHM_ENABLE
+     263             :     strncpy(dltShmName, "/dlt-shm", NAME_MAX);
+     264             : #endif
+     265             : 
+     266           9 :     opterr = 0;
+     267             : 
+     268             : #ifdef DLT_SHM_ENABLE
+     269             :     strcpy(options + strlen(options), "s:");
+     270             : #endif
+     271             : #ifdef DLT_LOG_LEVEL_APP_CONFIG
+     272             :     strcpy(options + strlen(options), "a:");
+     273             : #endif
+     274             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+     275             :     strcpy(options + strlen(options), "l:");
+     276             : #endif
+     277          20 :     while ((c = getopt(argc, argv, options)) != -1)
+     278          11 :         switch (c) {
+     279           2 :         case 'd':
+     280             :         {
+     281           2 :             daemon_local->flags.dflag = 1;
+     282           2 :             break;
+     283             :         }
+     284           8 :         case 'c':
+     285             :         {
+     286           8 :             strncpy(daemon_local->flags.cvalue, optarg, NAME_MAX);
+     287             :             break;
+     288             :         }
+     289             : #ifdef DLT_LOG_LEVEL_APP_CONFIG
+     290             :         case 'a':
+     291             :         {
+     292             :             strncpy(daemon_local->flags.avalue, optarg, NAME_MAX);
+     293             :             break;
+     294             :         }
+     295             : #endif
+     296             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+     297             :         case 'l':
+     298             :         {
+     299             :             strncpy(daemon_local->flags.lvalue, optarg, NAME_MAX);
+     300             :             break;
+     301             :         }
+     302             : #endif
+     303             : #ifdef DLT_DAEMON_USE_FIFO_IPC
+     304           0 :         case 't':
+     305             :         {
+     306           0 :             dlt_log_set_fifo_basedir(optarg);
+     307           0 :             break;
+     308             :         }
+     309             : #endif
+     310             : 
+     311             : #ifdef DLT_SHM_ENABLE
+     312             :         case 's':
+     313             :         {
+     314             :             strncpy(dltShmName, optarg, NAME_MAX);
+     315             :             break;
+     316             :         }
+     317             : #endif
+     318           1 :         case 'p':
+     319             :         {
+     320           1 :             daemon_local->flags.port = (unsigned int) atoi(optarg);
+     321             : 
+     322           1 :             if (daemon_local->flags.port == 0) {
+     323           0 :                 fprintf (stderr, "Invalid port `%s' specified.\n", optarg);
+     324           0 :                 return -1;
+     325             :             }
+     326             : 
+     327             :             break;
+     328             :         }
+     329           0 :         case 'h':
+     330             :         {
+     331           0 :             usage();
+     332           0 :             return -2; /* return no error */
+     333             :         }
+     334             : 
+     335           0 :         case '?':
+     336             :         {
+     337           0 :             if ((optopt == 'c') || (optopt == 't') || (optopt == 'p')
+     338             :     #ifdef DLT_LOG_LEVEL_APP_CONFIG
+     339             :                   || (optopt == 'a')
+     340             :     #endif
+     341             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+     342             :                 || (optopt == 'l')
+     343             : #endif
+     344             :           )
+     345           0 :                 fprintf (stderr, "Option -%c requires an argument.\n", optopt);
+     346           0 :             else if (isprint (optopt))
+     347           0 :                 fprintf (stderr, "Unknown option `-%c'.\n", optopt);
+     348             :             else
+     349           0 :                 fprintf (stderr, "Unknown option character `\\x%x'.\n", (uint32_t)optopt);
+     350             : 
+     351             :             /* unknown or wrong option used, show usage information and terminate */
+     352           0 :             usage();
+     353           0 :             return -1;
+     354             :         }
+     355           0 :         default:
+     356             :         {
+     357           0 :             fprintf (stderr, "Invalid option, this should never occur!\n");
+     358           0 :             return -1;
+     359             :         }
+     360             :         }
+     361             : 
+     362             :     /* switch() */
+     363             : 
+     364             : #ifdef DLT_DAEMON_USE_FIFO_IPC
+     365           9 :     snprintf(daemon_local->flags.userPipesDir, DLT_PATH_MAX,
+     366             :              "%s/dltpipes", dltFifoBaseDir);
+     367           9 :     snprintf(daemon_local->flags.daemonFifoName, DLT_PATH_MAX,
+     368             :              "%s/dlt", dltFifoBaseDir);
+     369             : #endif
+     370             : 
+     371             : #ifdef DLT_SHM_ENABLE
+     372             :     strncpy(daemon_local->flags.dltShmName, dltShmName, NAME_MAX);
+     373             : #endif
+     374             : 
+     375           9 :     return 0;
+     376             : 
+     377             : }  /* option_handling() */
+     378             : 
+     379             : /**
+     380             :  * Option file parser
+     381             :  */
+     382           9 : int option_file_parser(DltDaemonLocal *daemon_local)
+     383           9 : {
+     384             :     FILE *pFile;
+     385           9 :     char line[value_length - 1];
+     386           9 :     char token[value_length];
+     387           9 :     char value[value_length];
+     388             :     char *pch;
+     389             :     const char *filename;
+     390             :     ssize_t n;
+     391             : 
+     392             :     /* set default values for configuration */
+     393           9 :     daemon_local->flags.sharedMemorySize = DLT_SHM_SIZE;
+     394           9 :     daemon_local->flags.sendMessageTime = 0;
+     395           9 :     daemon_local->flags.offlineTraceDirectory[0] = 0;
+     396           9 :     daemon_local->flags.offlineTraceFileSize = 1000000;
+     397           9 :     daemon_local->flags.offlineTraceMaxSize = 4000000;
+     398           9 :     daemon_local->flags.offlineTraceFilenameTimestampBased = true;
+     399           9 :     daemon_local->flags.loggingMode = DLT_LOG_TO_CONSOLE;
+     400           9 :     daemon_local->flags.loggingLevel = LOG_INFO;
+     401             : 
+     402             : #ifdef DLT_DAEMON_USE_UNIX_SOCKET_IPC
+     403             :     n = snprintf(daemon_local->flags.loggingFilename,
+     404             :                  sizeof(daemon_local->flags.loggingFilename),
+     405             :                  "%s/dlt.log", DLT_USER_IPC_PATH);
+     406             : #else /* DLT_DAEMON_USE_FIFO_IPC */
+     407           9 :     n = snprintf(daemon_local->flags.loggingFilename,
+     408             :                  sizeof(daemon_local->flags.loggingFilename),
+     409             :                  "%s/dlt.log", dltFifoBaseDir);
+     410             : #endif
+     411             : 
+     412           9 :     if (n < 0 || (size_t)n > sizeof(daemon_local->flags.loggingFilename)) {
+     413           0 :         dlt_vlog(LOG_WARNING, "%s: snprintf truncation/error(%ld) %s\n",
+     414             :                 __func__, n, daemon_local->flags.loggingFilename);
+     415             :     }
+     416           9 :     daemon_local->flags.enableLoggingFileLimit = false;
+     417           9 :     daemon_local->flags.loggingFileSize = 250000;
+     418           9 :     daemon_local->flags.loggingFileMaxSize = 1000000;
+     419             : 
+     420           9 :     daemon_local->timeoutOnSend = 4;
+     421           9 :     daemon_local->RingbufferMinSize = DLT_DAEMON_RINGBUFFER_MIN_SIZE;
+     422           9 :     daemon_local->RingbufferMaxSize = DLT_DAEMON_RINGBUFFER_MAX_SIZE;
+     423           9 :     daemon_local->RingbufferStepSize = DLT_DAEMON_RINGBUFFER_STEP_SIZE;
+     424           9 :     daemon_local->daemonFifoSize = 0;
+     425           9 :     daemon_local->flags.sendECUSoftwareVersion = 0;
+     426           9 :     memset(daemon_local->flags.pathToECUSoftwareVersion, 0, sizeof(daemon_local->flags.pathToECUSoftwareVersion));
+     427           9 :     memset(daemon_local->flags.ecuSoftwareVersionFileField, 0, sizeof(daemon_local->flags.ecuSoftwareVersionFileField));
+     428           9 :     daemon_local->flags.sendTimezone = 0;
+     429           9 :     daemon_local->flags.offlineLogstorageMaxDevices = 0;
+     430           9 :     daemon_local->flags.offlineLogstorageDirPath[0] = 0;
+     431           9 :     daemon_local->flags.offlineLogstorageTimestamp = 1;
+     432           9 :     daemon_local->flags.offlineLogstorageDelimiter = '_';
+     433           9 :     daemon_local->flags.offlineLogstorageMaxCounter = UINT_MAX;
+     434           9 :     daemon_local->flags.offlineLogstorageMaxCounterIdx = 0;
+     435           9 :     daemon_local->flags.offlineLogstorageOptionalCounter = false;
+     436           9 :     daemon_local->flags.offlineLogstorageCacheSize = 30000; /* 30MB */
+     437           9 :     dlt_daemon_logstorage_set_logstorage_cache_size(
+     438             :         daemon_local->flags.offlineLogstorageCacheSize);
+     439           9 :     strncpy(daemon_local->flags.ctrlSockPath,
+     440             :             DLT_DAEMON_DEFAULT_CTRL_SOCK_PATH,
+     441             :             sizeof(daemon_local->flags.ctrlSockPath));
+     442             : #ifdef DLT_DAEMON_USE_UNIX_SOCKET_IPC
+     443             :     snprintf(daemon_local->flags.appSockPath, DLT_IPC_PATH_MAX, "%s/dlt", DLT_USER_IPC_PATH);
+     444             : 
+     445             :     if (strlen(DLT_USER_IPC_PATH) > DLT_IPC_PATH_MAX)
+     446             :         fprintf(stderr, "Provided path too long...trimming it to path[%s]\n",
+     447             :                 daemon_local->flags.appSockPath);
+     448             : 
+     449             : #else /* DLT_DAEMON_USE_FIFO_IPC */
+     450           9 :     memset(daemon_local->flags.daemonFifoGroup, 0, sizeof(daemon_local->flags.daemonFifoGroup));
+     451             : #endif
+     452           9 :     daemon_local->flags.gatewayMode = 0;
+     453           9 :     strncpy(daemon_local->flags.gatewayConfigFile,
+     454             :             DLT_GATEWAY_CONFIG_PATH,
+     455             :             DLT_DAEMON_FLAG_MAX);
+     456           9 :     daemon_local->flags.autoResponseGetLogInfoOption = 7;
+     457           9 :     daemon_local->flags.contextLogLevel = DLT_LOG_INFO;
+     458           9 :     daemon_local->flags.contextTraceStatus = DLT_TRACE_STATUS_OFF;
+     459           9 :     daemon_local->flags.enforceContextLLAndTS = 0; /* default is off */
+     460             : #ifdef UDP_CONNECTION_SUPPORT
+     461             :     daemon_local->UDPConnectionSetup = MULTICAST_CONNECTION_ENABLED;
+     462             :     strncpy(daemon_local->UDPMulticastIPAddress, MULTICASTIPADDRESS, MULTICASTIP_MAX_SIZE - 1);
+     463             :     daemon_local->UDPMulticastIPPort = MULTICASTIPPORT;
+     464             : #endif
+     465           9 :     daemon_local->flags.ipNodes = NULL;
+     466           9 :     daemon_local->flags.injectionMode = 1;
+     467             : 
+     468             :     /* open configuration file */
+     469           9 :     if (daemon_local->flags.cvalue[0])
+     470           8 :         filename = daemon_local->flags.cvalue;
+     471             :     else
+     472             :         filename = CONFIGURATION_FILES_DIR "/dlt.conf";
+     473             : 
+     474             :     /*printf("Load configuration from file: %s\n",filename); */
+     475           9 :     pFile = fopen (filename, "r");
+     476             : 
+     477           9 :     if (pFile != NULL) {
+     478             :         while (1) {
+     479             :             /* fetch line from configuration file */
+     480         112 :             if (fgets (line, value_length - 1, pFile) != NULL) {
+     481          49 :                 pch = strtok (line, " =\r\n");
+     482          49 :                 token[0] = 0;
+     483          49 :                 value[0] = 0;
+     484             : 
+     485          92 :                 while (pch != NULL) {
+     486          86 :                     if (strcmp(pch, "#") == 0)
+     487             :                         break;
+     488             : 
+     489          86 :                     if (token[0] == 0) {
+     490          43 :                         strncpy(token, pch, sizeof(token) - 1);
+     491          43 :                         token[sizeof(token) - 1] = 0;
+     492             :                     }
+     493             :                     else {
+     494          43 :                         strncpy(value, pch, sizeof(value) - 1);
+     495          43 :                         value[sizeof(value) - 1] = 0;
+     496          43 :                         break;
+     497             :                     }
+     498             : 
+     499          43 :                     pch = strtok (NULL, " =\r\n");
+     500             :                 }
+     501             : 
+     502          49 :                 if (token[0] && value[0]) {
+     503             :                     /* parse arguments here */
+     504          43 :                     if (strcmp(token, "Verbose") == 0) {
+     505           0 :                         daemon_local->flags.vflag = atoi(value);
+     506             :                         /*printf("Option: %s=%s\n",token,value); */
+     507             :                     }
+     508          43 :                     else if (strcmp(token, "PrintASCII") == 0)
+     509             :                     {
+     510           0 :                         daemon_local->flags.aflag = atoi(value);
+     511             :                         /*printf("Option: %s=%s\n",token,value); */
+     512             :                     }
+     513          43 :                     else if (strcmp(token, "PrintHex") == 0)
+     514             :                     {
+     515           0 :                         daemon_local->flags.xflag = atoi(value);
+     516             :                         /*printf("Option: %s=%s\n",token,value); */
+     517             :                     }
+     518          43 :                     else if (strcmp(token, "PrintHeadersOnly") == 0)
+     519             :                     {
+     520           0 :                         daemon_local->flags.sflag = atoi(value);
+     521             :                         /*printf("Option: %s=%s\n",token,value); */
+     522             :                     }
+     523          43 :                     else if (strcmp(token, "SendSerialHeader") == 0)
+     524             :                     {
+     525           0 :                         daemon_local->flags.lflag = atoi(value);
+     526             :                         /*printf("Option: %s=%s\n",token,value); */
+     527             :                     }
+     528          43 :                     else if (strcmp(token, "SendContextRegistration") == 0)
+     529             :                     {
+     530           1 :                         daemon_local->flags.rflag = atoi(value);
+     531             :                         /*printf("Option: %s=%s\n",token,value); */
+     532             :                     }
+     533          42 :                     else if (strcmp(token, "SendContextRegistrationOption") == 0)
+     534             :                     {
+     535           0 :                         daemon_local->flags.autoResponseGetLogInfoOption = atoi(value);
+     536             :                         /*printf("Option: %s=%s\n",token,value); */
+     537             :                     }
+     538          42 :                     else if (strcmp(token, "SendMessageTime") == 0)
+     539             :                     {
+     540           0 :                         daemon_local->flags.sendMessageTime = atoi(value);
+     541             :                         /*printf("Option: %s=%s\n",token,value); */
+     542             :                     }
+     543          42 :                     else if (strcmp(token, "RS232SyncSerialHeader") == 0)
+     544             :                     {
+     545           0 :                         daemon_local->flags.mflag = atoi(value);
+     546             :                         /*printf("Option: %s=%s\n",token,value); */
+     547             :                     }
+     548          42 :                     else if (strcmp(token, "TCPSyncSerialHeader") == 0)
+     549             :                     {
+     550           0 :                         daemon_local->flags.nflag = atoi(value);
+     551             :                         /*printf("Option: %s=%s\n",token,value); */
+     552             :                     }
+     553          42 :                     else if (strcmp(token, "RS232DeviceName") == 0)
+     554             :                     {
+     555           0 :                         strncpy(daemon_local->flags.yvalue, value, NAME_MAX);
+     556           0 :                         daemon_local->flags.yvalue[NAME_MAX] = 0;
+     557             :                         /*printf("Option: %s=%s\n",token,value); */
+     558             :                     }
+     559          42 :                     else if (strcmp(token, "RS232Baudrate") == 0)
+     560             :                     {
+     561           0 :                         strncpy(daemon_local->flags.bvalue, value, NAME_MAX);
+     562           0 :                         daemon_local->flags.bvalue[NAME_MAX] = 0;
+     563             :                         /*printf("Option: %s=%s\n",token,value); */
+     564             :                     }
+     565          42 :                     else if (strcmp(token, "ECUId") == 0)
+     566             :                     {
+     567           1 :                         strncpy(daemon_local->flags.evalue, value, NAME_MAX);
+     568           1 :                         daemon_local->flags.evalue[NAME_MAX] = 0;
+     569             :                         /*printf("Option: %s=%s\n",token,value); */
+     570             :                     }
+     571          41 :                     else if (strcmp(token, "PersistanceStoragePath") == 0)
+     572             :                     {
+     573           0 :                         strncpy(daemon_local->flags.ivalue, value, NAME_MAX);
+     574           0 :                         daemon_local->flags.ivalue[NAME_MAX] = 0;
+     575             :                         /*printf("Option: %s=%s\n",token,value); */
+     576             :                     }
+     577          41 :                     else if (strcmp(token, "LoggingMode") == 0)
+     578             :                     {
+     579           1 :                         daemon_local->flags.loggingMode = (DltLoggingMode)atoi(value);
+     580             :                         /*printf("Option: %s=%s\n",token,value); */
+     581             :                     }
+     582          40 :                     else if (strcmp(token, "LoggingLevel") == 0)
+     583             :                     {
+     584           1 :                         daemon_local->flags.loggingLevel = atoi(value);
+     585             :                         /*printf("Option: %s=%s\n",token,value); */
+     586             :                     }
+     587          39 :                     else if (strcmp(token, "LoggingFilename") == 0)
+     588             :                     {
+     589             :                         strncpy(daemon_local->flags.loggingFilename,
+     590             :                                 value,
+     591             :                                 sizeof(daemon_local->flags.loggingFilename) - 1);
+     592           1 :                         daemon_local->flags.loggingFilename[sizeof(daemon_local->flags.loggingFilename) - 1] = 0;
+     593             :                         /*printf("Option: %s=%s\n",token,value); */
+     594             :                     }
+     595          38 :                     else if (strcmp(token, "EnableLoggingFileLimit") == 0)
+     596             :                     {
+     597           0 :                         daemon_local->flags.enableLoggingFileLimit = (bool)atoi(value);
+     598             :                     }
+     599          38 :                     else if (strcmp(token, "LoggingFileSize") == 0)
+     600             :                     {
+     601           0 :                         daemon_local->flags.loggingFileSize = atoi(value);
+     602             :                     }
+     603          38 :                     else if (strcmp(token, "LoggingFileMaxSize") == 0)
+     604             :                     {
+     605           0 :                         daemon_local->flags.loggingFileMaxSize = atoi(value);
+     606             :                     }
+     607          38 :                     else if (strcmp(token, "TimeOutOnSend") == 0)
+     608             :                     {
+     609           1 :                         daemon_local->timeoutOnSend = atoi(value);
+     610             :                         /*printf("Option: %s=%s\n",token,value); */
+     611             :                     }
+     612          37 :                     else if (strcmp(token, "RingbufferMinSize") == 0)
+     613             :                     {
+     614           1 :                         if (dlt_daemon_check_numeric_setting(token,
+     615             :                                 value, &(daemon_local->RingbufferMinSize)) < 0) {
+     616           0 :                             fclose (pFile);
+     617           0 :                             return -1;
+     618             :                         }
+     619             :                     }
+     620          36 :                     else if (strcmp(token, "RingbufferMaxSize") == 0)
+     621             :                     {
+     622           1 :                         if (dlt_daemon_check_numeric_setting(token,
+     623             :                                 value, &(daemon_local->RingbufferMaxSize)) < 0) {
+     624           0 :                             fclose (pFile);
+     625           0 :                             return -1;
+     626             :                         }
+     627             :                     }
+     628          35 :                     else if (strcmp(token, "RingbufferStepSize") == 0)
+     629             :                     {
+     630           1 :                         if (dlt_daemon_check_numeric_setting(token,
+     631             :                                 value, &(daemon_local->RingbufferStepSize)) < 0) {
+     632           0 :                             fclose (pFile);
+     633           0 :                             return -1;
+     634             :                         }
+     635             :                     }
+     636          34 :                     else if (strcmp(token, "SharedMemorySize") == 0)
+     637             :                     {
+     638           1 :                         daemon_local->flags.sharedMemorySize = atoi(value);
+     639             :                         /*printf("Option: %s=%s\n",token,value); */
+     640             :                     }
+     641          33 :                     else if (strcmp(token, "OfflineTraceDirectory") == 0)
+     642             :                     {
+     643           0 :                         strncpy(daemon_local->flags.offlineTraceDirectory, value,
+     644             :                                 sizeof(daemon_local->flags.offlineTraceDirectory) - 1);
+     645             :                         daemon_local->flags.offlineTraceDirectory[sizeof(daemon_local->flags.offlineTraceDirectory) -
+     646           0 :                                                                   1] = 0;
+     647             :                         /*printf("Option: %s=%s\n",token,value); */
+     648             :                     }
+     649          33 :                     else if (strcmp(token, "OfflineTraceFileSize") == 0)
+     650             :                     {
+     651           0 :                         daemon_local->flags.offlineTraceFileSize = atoi(value);
+     652             :                         /*printf("Option: %s=%s\n",token,value); */
+     653             :                     }
+     654          33 :                     else if (strcmp(token, "OfflineTraceMaxSize") == 0)
+     655             :                     {
+     656           0 :                         daemon_local->flags.offlineTraceMaxSize = atoi(value);
+     657             :                         /*printf("Option: %s=%s\n",token,value); */
+     658             :                     }
+     659          33 :                     else if (strcmp(token, "OfflineTraceFileNameTimestampBased") == 0)
+     660             :                     {
+     661           0 :                         daemon_local->flags.offlineTraceFilenameTimestampBased = (bool)atoi(value);
+     662             :                         /*printf("Option: %s=%s\n",token,value); */
+     663             :                     }
+     664          33 :                     else if (strcmp(token, "SendECUSoftwareVersion") == 0)
+     665             :                     {
+     666           0 :                         daemon_local->flags.sendECUSoftwareVersion = atoi(value);
+     667             :                         /*printf("Option: %s=%s\n",token,value); */
+     668             :                     }
+     669          33 :                     else if (strcmp(token, "PathToECUSoftwareVersion") == 0)
+     670             :                     {
+     671             :                         strncpy(daemon_local->flags.pathToECUSoftwareVersion, value,
+     672             :                                 sizeof(daemon_local->flags.pathToECUSoftwareVersion) - 1);
+     673             :                         daemon_local->flags.pathToECUSoftwareVersion[sizeof(daemon_local->flags.pathToECUSoftwareVersion)
+     674           0 :                                                                      - 1] = 0;
+     675             :                         /*printf("Option: %s=%s\n",token,value); */
+     676             :                     }
+     677          33 :                     else if (strcmp(token, "ECUSoftwareVersionFileField") == 0) {
+     678             :                         strncpy(daemon_local->flags.ecuSoftwareVersionFileField, value,
+     679             :                                 sizeof(daemon_local->flags.ecuSoftwareVersionFileField) - 1);
+     680             :                         daemon_local->flags.ecuSoftwareVersionFileField[sizeof(daemon_local->flags.ecuSoftwareVersionFileField)
+     681           0 :                                                                      - 1] = 0;
+     682             :                         /*printf("Option: %s=%s\n",token,value); */
+     683             :                     }
+     684          33 :                     else if (strcmp(token, "SendTimezone") == 0)
+     685             :                     {
+     686           0 :                         daemon_local->flags.sendTimezone = atoi(value);
+     687             :                         /*printf("Option: %s=%s\n",token,value); */
+     688             :                     }
+     689          33 :                     else if (strcmp(token, "OfflineLogstorageMaxDevices") == 0)
+     690             :                     {
+     691           6 :                         daemon_local->flags.offlineLogstorageMaxDevices = (uint32_t) atoi(value);
+     692             :                     }
+     693          27 :                     else if (strcmp(token, "OfflineLogstorageDirPath") == 0)
+     694             :                     {
+     695           6 :                         strncpy(daemon_local->flags.offlineLogstorageDirPath,
+     696             :                                 value,
+     697             :                                 sizeof(daemon_local->flags.offlineLogstorageDirPath) - 1);
+     698             :                     }
+     699          21 :                     else if (strcmp(token, "OfflineLogstorageTimestamp") == 0)
+     700             :                     {
+     701             :                         /* Check if set to 0, default otherwise */
+     702           6 :                         if (atoi(value) == 0)
+     703           6 :                             daemon_local->flags.offlineLogstorageTimestamp = 0;
+     704             :                     }
+     705          15 :                     else if (strcmp(token, "OfflineLogstorageDelimiter") == 0)
+     706             :                     {
+     707             :                         /* Check if valid punctuation, default otherwise*/
+     708           0 :                         if (ispunct((char)value[0]))
+     709           0 :                             daemon_local->flags.offlineLogstorageDelimiter = (char)value[0];
+     710             :                     }
+     711          15 :                     else if (strcmp(token, "OfflineLogstorageMaxCounter") == 0)
+     712             :                     {
+     713           0 :                         daemon_local->flags.offlineLogstorageMaxCounter = (unsigned int) atoi(value);
+     714           0 :                         daemon_local->flags.offlineLogstorageMaxCounterIdx = (unsigned int) strlen(value);
+     715          15 :                     } else if (strcmp(token, "OfflineLogstorageOptionalIndex") == 0) {
+     716           6 :                         daemon_local->flags.offlineLogstorageOptionalCounter = atoi(value);
+     717             :                     }
+     718           9 :                     else if (strcmp(token, "OfflineLogstorageCacheSize") == 0)
+     719             :                     {
+     720           0 :                         daemon_local->flags.offlineLogstorageCacheSize =
+     721           0 :                             (unsigned int)atoi(value);
+     722           0 :                         dlt_daemon_logstorage_set_logstorage_cache_size(
+     723             :                             daemon_local->flags.offlineLogstorageCacheSize);
+     724             :                     }
+     725           9 :                     else if (strcmp(token, "ControlSocketPath") == 0)
+     726             :                     {
+     727             :                         memset(
+     728             :                             daemon_local->flags.ctrlSockPath,
+     729             :                             0,
+     730             :                             DLT_DAEMON_FLAG_MAX);
+     731             :                         strncpy(
+     732             :                             daemon_local->flags.ctrlSockPath,
+     733             :                             value,
+     734             :                             DLT_DAEMON_FLAG_MAX - 1);
+     735             :                     }
+     736           2 :                     else if (strcmp(token, "GatewayMode") == 0)
+     737             :                     {
+     738           1 :                         daemon_local->flags.gatewayMode = atoi(value);
+     739             :                         /*printf("Option: %s=%s\n",token,value); */
+     740             :                     }
+     741           1 :                     else if (strcmp(token, "GatewayConfigFile") == 0)
+     742             :                     {
+     743             :                         memset(
+     744             :                             daemon_local->flags.gatewayConfigFile,
+     745             :                             0,
+     746             :                             DLT_DAEMON_FLAG_MAX);
+     747             :                         strncpy(
+     748             :                             daemon_local->flags.gatewayConfigFile,
+     749             :                             value,
+     750             :                             DLT_DAEMON_FLAG_MAX - 1);
+     751             :                     }
+     752           0 :                     else if (strcmp(token, "ContextLogLevel") == 0)
+     753             :                     {
+     754             :                         int const intval = atoi(value);
+     755             : 
+     756           0 :                         if ((intval >= DLT_LOG_OFF) && (intval <= DLT_LOG_VERBOSE)) {
+     757           0 :                             daemon_local->flags.contextLogLevel = intval;
+     758             :                             printf("Option: %s=%s\n", token, value);
+     759             :                         }
+     760             :                         else {
+     761           0 :                             fprintf(stderr,
+     762             :                                     "Invalid value for ContextLogLevel: %i. Must be in range [%i..%i]\n",
+     763             :                                     intval,
+     764             :                                     DLT_LOG_OFF,
+     765             :                                     DLT_LOG_VERBOSE);
+     766             :                         }
+     767             :                     }
+     768           0 :                     else if (strcmp(token, "ContextTraceStatus") == 0)
+     769             :                     {
+     770             :                         int const intval = atoi(value);
+     771             : 
+     772           0 :                         if ((intval >= DLT_TRACE_STATUS_OFF) && (intval <= DLT_TRACE_STATUS_ON)) {
+     773           0 :                             daemon_local->flags.contextTraceStatus = intval;
+     774             :                             printf("Option: %s=%s\n", token, value);
+     775             :                         }
+     776             :                         else {
+     777           0 :                             fprintf(stderr,
+     778             :                                     "Invalid value for ContextTraceStatus: %i. Must be in range [%i..%i]\n",
+     779             :                                     intval,
+     780             :                                     DLT_TRACE_STATUS_OFF,
+     781             :                                     DLT_TRACE_STATUS_ON);
+     782             :                         }
+     783             :                     }
+     784           0 :                     else if (strcmp(token, "ForceContextLogLevelAndTraceStatus") == 0)
+     785             :                     {
+     786             :                         int const intval = atoi(value);
+     787             : 
+     788           0 :                         if ((intval >= 0) && (intval <= 1)) {
+     789           0 :                             daemon_local->flags.enforceContextLLAndTS = intval;
+     790             :                             printf("Option: %s=%s\n", token, value);
+     791             :                         }
+     792             :                         else {
+     793           0 :                             fprintf(stderr,
+     794             :                                     "Invalid value for ForceContextLogLevelAndTraceStatus: %i. Must be 0, 1\n",
+     795             :                                     intval);
+     796             :                         }
+     797             :                     }
+     798             : 
+     799             : #ifdef DLT_DAEMON_USE_FIFO_IPC
+     800           0 :                     else if (strcmp(token, "DaemonFIFOSize") == 0)
+     801             :                     {
+     802           0 :                         if (dlt_daemon_check_numeric_setting(token,
+     803             :                                 value, &(daemon_local->daemonFifoSize)) < 0) {
+     804           0 :                             fclose (pFile);
+     805           0 :                             return -1;
+     806             :                         }
+     807             : #ifndef __linux__
+     808             :                             printf("Option DaemonFIFOSize is set but only supported on Linux. Ignored.\n");
+     809             : #endif
+     810             :                     }
+     811           0 :                     else if (strcmp(token, "DaemonFifoGroup") == 0)
+     812             :                     {
+     813             :                         strncpy(daemon_local->flags.daemonFifoGroup, value, NAME_MAX);
+     814           0 :                         daemon_local->flags.daemonFifoGroup[NAME_MAX] = 0;
+     815             :                     }
+     816             : #endif
+     817             : #ifdef UDP_CONNECTION_SUPPORT
+     818             :                     else if (strcmp(token, "UDPConnectionSetup") == 0)
+     819             :                     {
+     820             :                         const long longval = strtol(value, NULL, 10);
+     821             : 
+     822             :                         if ((longval == MULTICAST_CONNECTION_DISABLED)
+     823             :                             || (longval == MULTICAST_CONNECTION_ENABLED)) {
+     824             :                             daemon_local->UDPConnectionSetup = longval;
+     825             :                             printf("Option: %s=%s\n", token, value);
+     826             :                         }
+     827             :                         else {
+     828             :                             daemon_local->UDPConnectionSetup = MULTICAST_CONNECTION_DISABLED;
+     829             :                             fprintf(stderr,
+     830             :                                     "Invalid value for UDPConnectionSetup set to default %ld\n",
+     831             :                                     longval);
+     832             :                         }
+     833             :                     }
+     834             :                     else if (strcmp(token, "UDPMulticastIPAddress") == 0)
+     835             :                     {
+     836             :                         strncpy(daemon_local->UDPMulticastIPAddress, value,
+     837             :                                 MULTICASTIP_MAX_SIZE - 1);
+     838             :                     }
+     839             :                     else if (strcmp(token, "UDPMulticastIPPort") == 0)
+     840             :                     {
+     841             :                         daemon_local->UDPMulticastIPPort = strtol(value, NULL, 10);
+     842             :                     }
+     843             : #endif
+     844           0 :                     else if (strcmp(token, "BindAddress") == 0)
+     845             :                     {
+     846             :                         DltBindAddress_t *newNode = NULL;
+     847             :                         DltBindAddress_t *temp = NULL;
+     848             : 
+     849           0 :                         char *tok = strtok(value, ",;");
+     850             : 
+     851           0 :                         if (tok != NULL) {
+     852           0 :                             daemon_local->flags.ipNodes = calloc(1, sizeof(DltBindAddress_t));
+     853             : 
+     854           0 :                             if (daemon_local->flags.ipNodes == NULL) {
+     855           0 :                                 dlt_vlog(LOG_ERR, "Could not allocate for IP list\n");
+     856           0 :                                 fclose(pFile);
+     857           0 :                                 return -1;
+     858             :                             }
+     859             :                             else {
+     860           0 :                                 strncpy(daemon_local->flags.ipNodes->ip,
+     861             :                                         tok,
+     862             :                                         sizeof(daemon_local->flags.ipNodes->ip) - 1);
+     863           0 :                                 daemon_local->flags.ipNodes->next = NULL;
+     864             :                                 temp = daemon_local->flags.ipNodes;
+     865             : 
+     866           0 :                                 tok = strtok(NULL, ",;");
+     867             : 
+     868           0 :                                 while (tok != NULL) {
+     869           0 :                                     newNode = calloc(1, sizeof(DltBindAddress_t));
+     870             : 
+     871           0 :                                     if (newNode == NULL) {
+     872           0 :                                         dlt_vlog(LOG_ERR, "Could not allocate for IP list\n");
+     873           0 :                                         fclose(pFile);
+     874           0 :                                         return -1;
+     875             :                                     }
+     876             :                                     else {
+     877           0 :                                         strncpy(newNode->ip, tok, sizeof(newNode->ip) - 1);
+     878             :                                     }
+     879             : 
+     880           0 :                                     temp->next = newNode;
+     881             :                                     temp = temp->next;
+     882           0 :                                     tok = strtok(NULL, ",;");
+     883             :                                 }
+     884             :                             }
+     885             :                         }
+     886             :                         else {
+     887           0 :                             dlt_vlog(LOG_WARNING, "BindAddress option is empty\n");
+     888             :                         }
+     889             :                     }
+     890           0 :                     else if (strcmp(token, "InjectionMode") == 0) {
+     891           0 :                         daemon_local->flags.injectionMode = atoi(value);
+     892             :                     }
+     893             :                     else {
+     894           0 :                         fprintf(stderr, "Unknown option: %s=%s\n", token, value);
+     895             :                     }
+     896             :                 }
+     897             :             }
+     898             :             else {
+     899             :                 break;
+     900             :             }
+     901             :         }
+     902             : 
+     903           7 :         fclose (pFile);
+     904             :     }
+     905             :     else {
+     906           2 :         fprintf(stderr, "Cannot open configuration file: %s\n", filename);
+     907             :     }
+     908             : 
+     909             :     return 0;
+     910             : }
+     911             : 
+     912             : #ifdef DLT_LOG_LEVEL_APP_CONFIG
+     913             : /**
+     914             :  * Load configuration file parser
+     915             :  */
+     916             : 
+     917             : static int compare_app_id_conf(const void *lhs, const void *rhs)
+     918             : {
+     919             :     return strncmp(((DltDaemonContextLogSettings *)lhs)->apid,
+     920             :                    ((DltDaemonContextLogSettings *)rhs)->apid, DLT_ID_SIZE);
+     921             : }
+     922             : 
+     923             : int app_id_default_log_level_config_parser(DltDaemon *daemon,
+     924             :                                            DltDaemonLocal *daemon_local) {
+     925             :     FILE *pFile;
+     926             :     char line[value_length - 1];
+     927             :     char app_id_value[value_length];
+     928             :     char ctx_id_value[value_length];
+     929             :     DltLogLevelType log_level_value;
+     930             : 
+     931             :     char *pch;
+     932             :     const char *filename;
+     933             : 
+     934             :     /* open configuration file */
+     935             :     filename = daemon_local->flags.avalue[0]
+     936             :                    ? daemon_local->flags.avalue
+     937             :                    : CONFIGURATION_FILES_DIR "/dlt-log-levels.conf";
+     938             : 
+     939             :     pFile = fopen(filename, "r");
+     940             :     if (pFile == NULL) {
+     941             :         dlt_vlog(LOG_WARNING, "Cannot open app log level configuration%s\n", filename);
+     942             :         return -errno;
+     943             :     }
+     944             : 
+     945             :     /* fetch lines from configuration file */
+     946             :     while (fgets(line, value_length - 1, pFile) != NULL) {
+     947             :         pch = strtok(line, " \t");
+     948             :         memset(app_id_value, 0, value_length);
+     949             :         memset(ctx_id_value, 0, value_length);
+     950             :         log_level_value = DLT_LOG_MAX;
+     951             : 
+     952             :         /* ignore comments and new lines*/
+     953             :         if (strncmp(pch, "#", 1) == 0 || strncmp(pch, "\n", 1) == 0
+     954             :             || strlen(pch) < 1)
+     955             :             continue;
+     956             : 
+     957             :         strncpy(app_id_value, pch, sizeof(app_id_value) - 1);
+     958             :         app_id_value[sizeof(app_id_value) - 1] = 0;
+     959             :         if (strlen(app_id_value) == 0 || strlen(app_id_value) > DLT_ID_SIZE) {
+     960             :             if (app_id_value[strlen(app_id_value) - 1] == '\n') {
+     961             :                 dlt_vlog(LOG_WARNING, "Missing log level for apid %s in log settings\n",
+     962             :                          app_id_value);
+     963             :             } else {
+     964             :                 dlt_vlog(LOG_WARNING,
+     965             :                          "Invalid apid for log settings settings: app id: %s\n",
+     966             :                          app_id_value);
+     967             :             }
+     968             : 
+     969             :             continue;
+     970             :         }
+     971             : 
+     972             :         char *pch_next1 = strtok(NULL, " \t");
+     973             :         char *pch_next2 = strtok(NULL, " \t");
+     974             :         char *log_level;
+     975             :         /* no context id given, log level is next token */
+     976             :         if (pch_next2 == NULL || pch_next2[0] == '#') {
+     977             :             log_level = pch_next1;
+     978             :         } else {
+     979             :             /* context id is given, log level is second to next token */
+     980             :             log_level = pch_next2;
+     981             : 
+     982             :             /* next token is token id */
+     983             :             strncpy(ctx_id_value, pch_next1, sizeof(ctx_id_value) - 1);
+     984             :             if (strlen(ctx_id_value) == 0 || strlen(app_id_value) > DLT_ID_SIZE) {
+     985             :                 dlt_vlog(LOG_WARNING,
+     986             :                          "Invalid ctxid for log settings: app id: %s "
+     987             :                          "(skipping line)\n",
+     988             :                          app_id_value);
+     989             :                 continue;
+     990             :             }
+     991             : 
+     992             :             ctx_id_value[sizeof(ctx_id_value) - 1] = 0;
+     993             :         }
+     994             : 
+     995             :         errno = 0;
+     996             :         log_level_value = strtol(log_level, NULL, 10);
+     997             :         if (errno != 0 || log_level_value >= DLT_LOG_MAX ||
+     998             :             log_level_value <= DLT_LOG_DEFAULT) {
+     999             :             dlt_vlog(LOG_WARNING,
+    1000             :                      "Invalid log level (%i), app id %s, conversion error: %s\n",
+    1001             :                      log_level_value, app_id_value, strerror(errno));
+    1002             :             continue;
+    1003             :         }
+    1004             : 
+    1005             :         DltDaemonContextLogSettings *settings =
+    1006             :             dlt_daemon_find_configured_app_id_ctx_id_settings(
+    1007             :                 daemon, app_id_value, NULL);
+    1008             : 
+    1009             :         if (settings != NULL &&
+    1010             :             strncmp(settings->ctid, ctx_id_value, DLT_ID_SIZE) == 0) {
+    1011             :             if (strlen(ctx_id_value) > 0) {
+    1012             :                 dlt_vlog(LOG_WARNING,
+    1013             :                          "Appid %s with ctxid %s is already configured, skipping "
+    1014             :                          "duplicated entry\n",
+    1015             :                          app_id_value, ctx_id_value);
+    1016             :             } else {
+    1017             :                 dlt_vlog(LOG_WARNING,
+    1018             :                          "Appid %s is already configured, skipping duplicated entry\n",
+    1019             :                          app_id_value);
+    1020             :             }
+    1021             : 
+    1022             :             continue;
+    1023             :         }
+    1024             : 
+    1025             :         /* allocate one more element in the trace load settings */
+    1026             :         DltDaemonContextLogSettings *tmp =
+    1027             :             realloc(daemon->app_id_log_level_settings,
+    1028             :                     (++daemon->num_app_id_log_level_settings) *
+    1029             :                         sizeof(DltDaemonContextLogSettings));
+    1030             : 
+    1031             :         if (tmp == NULL) {
+    1032             :             dlt_log(LOG_CRIT, "Failed to allocate memory for app load settings\n");
+    1033             :             continue;
+    1034             :         }
+    1035             : 
+    1036             :         daemon->app_id_log_level_settings = tmp;
+    1037             : 
+    1038             :         /* update newly created entry */
+    1039             :         settings = &daemon->app_id_log_level_settings
+    1040             :                         [daemon->num_app_id_log_level_settings -1];
+    1041             : 
+    1042             :         memset(settings, 0, sizeof(DltDaemonContextLogSettings));
+    1043             :         memcpy(settings->apid, app_id_value, DLT_ID_SIZE);
+    1044             :         memcpy(settings->ctid, ctx_id_value, DLT_ID_SIZE);
+    1045             :         settings->log_level = log_level_value;
+    1046             : 
+    1047             :         /* make sure ids are 0 terminated for printing */
+    1048             :         char apid_buf[DLT_ID_SIZE + 1] = {0};
+    1049             :         char ctid_buf[DLT_ID_SIZE + 1] = {0};
+    1050             :         memcpy(apid_buf, app_id_value, DLT_ID_SIZE);
+    1051             :         memcpy(ctid_buf, ctx_id_value, DLT_ID_SIZE);
+    1052             : 
+    1053             :         /* log with or without context id */
+    1054             :         if (strlen(ctid_buf) > 0) {
+    1055             :             dlt_vlog(
+    1056             :                 LOG_INFO,
+    1057             :                 "Configured trace limits for app id %s, context id %s, level %u\n",
+    1058             :                 apid_buf, ctid_buf, log_level_value);
+    1059             :         } else {
+    1060             :             dlt_vlog(LOG_INFO, "Configured trace limits for app id %s, level %u\n",
+    1061             :                      apid_buf, log_level_value);
+    1062             :         }
+    1063             : 
+    1064             :     } /* while */
+    1065             :     fclose(pFile);
+    1066             : 
+    1067             :     /* list must be sorted to speed up dlt_daemon_find_configured_app_id_ctx_id_settings */
+    1068             :     qsort(daemon->app_id_log_level_settings,
+    1069             :             daemon->num_app_id_log_level_settings,
+    1070             :             sizeof(DltDaemonContextLogSettings), compare_app_id_conf);
+    1071             : 
+    1072             :     return 0;
+    1073             : }
+    1074             : #endif
+    1075             : 
+    1076             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+    1077             : static bool is_ascii_only(const char *str) {
+    1078             :     while (*str) {
+    1079             :         if ((unsigned char)*str > 127) {
+    1080             :             return false;
+    1081             :         }
+    1082             :         str++;
+    1083             :     }
+    1084             :     return true;
+    1085             : }
+    1086             : 
+    1087             : /**
+    1088             :  * Load configuration file parser
+    1089             :  */
+    1090             : int trace_load_config_file_parser(DltDaemon *daemon, DltDaemonLocal *daemon_local)
+    1091             : {
+    1092             :     FILE *pFile;
+    1093             :     const int max_tokens = 4;
+    1094             :     const int min_tokens = 3;
+    1095             :     char tokens[max_tokens][value_length];
+    1096             :     char line[value_length - 1];
+    1097             :     char app_id_value[value_length];
+    1098             :     char ctx_id_value[value_length];
+    1099             :     char soft_limit_value[value_length];
+    1100             :     char hard_limit_value[value_length];
+    1101             :     int i;
+    1102             :     uint32_t soft_limit;
+    1103             :     uint32_t hard_limit;
+    1104             : 
+    1105             :     char *pch;
+    1106             :     const char *filename;
+    1107             : 
+    1108             :     bool skipped;
+    1109             : 
+    1110             :     if (daemon->preconfigured_trace_load_settings != NULL) {
+    1111             :         free(daemon->preconfigured_trace_load_settings);
+    1112             :         daemon->preconfigured_trace_load_settings = NULL;
+    1113             :         daemon->preconfigured_trace_load_settings_count = 0;
+    1114             :     }
+    1115             :     daemon->preconfigured_trace_load_settings = malloc(sizeof(DltTraceLoadSettings));
+    1116             :     if (daemon->preconfigured_trace_load_settings == NULL) {
+    1117             :         dlt_log(LOG_CRIT, "Failed to allocate memory for trace load settings\n");
+    1118             :         return DLT_RETURN_ERROR;
+    1119             :     }
+    1120             : 
+    1121             :     /* open configuration file */
+    1122             :     filename = daemon_local->flags.lvalue[0]
+    1123             :                    ? daemon_local->flags.lvalue
+    1124             :                    : CONFIGURATION_FILES_DIR "/dlt-trace-load.conf";
+    1125             : 
+    1126             :     pFile = fopen (filename, "r");
+    1127             :     if (pFile == NULL) {
+    1128             :         dlt_vlog(LOG_WARNING, "Cannot open trace load configuration file: %s\n",
+    1129             :                  filename);
+    1130             :         return -errno;
+    1131             :     }
+    1132             : 
+    1133             :     while (1) {
+    1134             :         /* fetch line from configuration file */
+    1135             :         if (fgets(line, value_length - 1, pFile) == NULL) {
+    1136             :             break;
+    1137             :         }
+    1138             : 
+    1139             :         pch = strtok(line, " ");
+    1140             :         app_id_value[0] = 0;
+    1141             :         ctx_id_value[0] = 0;
+    1142             :         soft_limit_value[0] = 0;
+    1143             :         hard_limit_value[0] = 0;
+    1144             :         soft_limit = 0U;
+    1145             :         hard_limit = 0U;
+    1146             :         memset(tokens, 0, sizeof(tokens));
+    1147             :         i = 0;
+    1148             : 
+    1149             :         skipped = false;
+    1150             :         while (pch != NULL && i < max_tokens) {
+    1151             :             /* ignore comments, empty lines and new lines */
+    1152             :             if (strncmp(pch, "#", 1) == 0 || strncmp(pch, "\n", 1) == 0 ||
+    1153             :                 strncmp(pch, "\r", 1) == 0 || strncmp(pch, " ", 1) == 0) {
+    1154             :                 skipped = true;
+    1155             :                 break;
+    1156             :             }
+    1157             :             strncpy(tokens[i], pch, sizeof(tokens[i]) - 1);
+    1158             :             pch = strtok(NULL, " ");
+    1159             :             ++i;
+    1160             :         }
+    1161             : 
+    1162             :         if (skipped && i < min_tokens)
+    1163             :             continue;
+    1164             : 
+    1165             :         if (pch != NULL
+    1166             :             && (pch[0] != '\n')
+    1167             :             && (pch[0] != '\t')
+    1168             :             && (pch[0] != ' ')
+    1169             :             && (pch[0] != '#')) {
+    1170             :             dlt_vlog(LOG_WARNING,
+    1171             :                      "Invalid trace load settings: too many tokens in line '%s'\n", line);
+    1172             :             continue;
+    1173             :         }
+    1174             : 
+    1175             :         bool has_ctx_id = i == max_tokens;
+    1176             :         int soft_limit_idx = has_ctx_id ? 2 : 1;
+    1177             :         int hard_limit_idx = has_ctx_id ? 3 : 2;
+    1178             : 
+    1179             :         strncpy(app_id_value, tokens[0], sizeof(app_id_value) - 1);
+    1180             :         if ((strlen(app_id_value) == 0)
+    1181             :             || (strlen(app_id_value) > DLT_ID_SIZE)
+    1182             :             || (!is_ascii_only(app_id_value))) {
+    1183             :             dlt_vlog(LOG_WARNING,
+    1184             :                      "Invalid apid for trace load settings: app id: '%s'\n", app_id_value);
+    1185             :             continue;
+    1186             :         }
+    1187             : 
+    1188             :         if (has_ctx_id) {
+    1189             :             strncpy(ctx_id_value, tokens[1], sizeof(ctx_id_value) - 1);
+    1190             :             if ((strlen(ctx_id_value) == 0)
+    1191             :                 || (strlen(ctx_id_value) > DLT_ID_SIZE)
+    1192             :                 || (!is_ascii_only(ctx_id_value))) {
+    1193             :                 dlt_vlog(LOG_WARNING,
+    1194             :                          "Invalid ctid for trace load settings: context id: '%s'\n", ctx_id_value);
+    1195             :                 continue;
+    1196             :             }
+    1197             :         }
+    1198             : 
+    1199             :         if (strlen(tokens[soft_limit_idx]) == 0) {
+    1200             :             dlt_vlog(LOG_WARNING,
+    1201             :                      "Invalid soft_limit for trace load settings: app id: '%.4s', '%s'\n",
+    1202             :                      app_id_value, tokens[soft_limit_idx]);
+    1203             :             continue;
+    1204             :         }
+    1205             : 
+    1206             :         if (strlen(tokens[hard_limit_idx]) == 0) {
+    1207             :             dlt_vlog(LOG_WARNING,
+    1208             :                      "Invalid hard_limit for trace load settings: app id: '%.4s', '%s'\n",
+    1209             :                      app_id_value, tokens[hard_limit_idx]);
+    1210             :             continue;
+    1211             :         }
+    1212             : 
+    1213             :         strncpy(soft_limit_value, tokens[soft_limit_idx],
+    1214             :                 sizeof(soft_limit_value) - 1);
+    1215             :         strncpy(hard_limit_value, tokens[hard_limit_idx],
+    1216             :                 sizeof(hard_limit_value) - 1);
+    1217             : 
+    1218             :         errno = 0;
+    1219             :         char *endptr;
+    1220             :         endptr = NULL;
+    1221             :         soft_limit = strtoul(soft_limit_value, &endptr, 10);
+    1222             :         if ((errno != 0)
+    1223             :             || ((soft_limit == 0) && (soft_limit_value[0] != '0'))
+    1224             :             || (soft_limit_value[0] == '-')
+    1225             :             || ((*endptr != '\n') && (*endptr != '\0'))) {
+    1226             :             dlt_vlog(LOG_WARNING,
+    1227             :                      "Invalid soft_limit for trace load settings: app id: '%.4s', soft_limit '%s'\n",
+    1228             :                      app_id_value, soft_limit_value);
+    1229             :             continue;
+    1230             :         }
+    1231             : 
+    1232             :         errno = 0;
+    1233             :         endptr = NULL;
+    1234             :         hard_limit = strtoul(hard_limit_value, &endptr, 10);
+    1235             :         if ((errno != 0)
+    1236             :             || ((hard_limit == 0) && (hard_limit_value[0] != '0'))
+    1237             :             || (hard_limit_value[0] == '-')
+    1238             :             || ((*endptr != '\n') && (*endptr != '\0'))) {
+    1239             :             dlt_vlog(LOG_WARNING,
+    1240             :                      "Invalid hard_limit for trace load settings: app id: '%.4s', hard_limit '%s'\n",
+    1241             :                      app_id_value, hard_limit_value);
+    1242             :             continue;
+    1243             :         }
+    1244             : 
+    1245             :         if (soft_limit > hard_limit) {
+    1246             :             dlt_vlog(LOG_WARNING,
+    1247             :                      "Invalid trace load settings: app id: '%.4s', soft limit %u is greater than hard limit %u\n",
+    1248             :                      app_id_value, soft_limit, hard_limit);
+    1249             :             continue;
+    1250             :         }
+    1251             : 
+    1252             :         DltTraceLoadSettings *settings = NULL;
+    1253             :         int num_settings = 0;
+    1254             :         DltReturnValue find_trace_settings_return_value = dlt_daemon_find_preconfigured_trace_load_settings(
+    1255             :             daemon, app_id_value, ctx_id_value, &settings, &num_settings,
+    1256             :             0);
+    1257             :         if (find_trace_settings_return_value != DLT_RETURN_OK || num_settings != 0) {
+    1258             :             dlt_vlog(LOG_WARNING,
+    1259             :                      "App id '%.4s' is already configured, or an error occurred, skipping entry\n",
+    1260             :                      app_id_value);
+    1261             :             if (settings != NULL) {
+    1262             :                 free(settings);
+    1263             :             }
+    1264             :             continue;
+    1265             :         }
+    1266             : 
+    1267             :         /* allocate one more element in the trace load settings */
+    1268             :         DltTraceLoadSettings *tmp =
+    1269             :             realloc(daemon->preconfigured_trace_load_settings,
+    1270             :                     (++daemon->preconfigured_trace_load_settings_count) *
+    1271             :                         sizeof(DltTraceLoadSettings));
+    1272             : 
+    1273             :         if (tmp == NULL) {
+    1274             :             dlt_log(LOG_CRIT,
+    1275             :                     "Failed to allocate memory for trace load settings\n");
+    1276             :             return DLT_RETURN_ERROR;
+    1277             :         }
+    1278             : 
+    1279             :         daemon->preconfigured_trace_load_settings = tmp;
+    1280             :         settings = &daemon->preconfigured_trace_load_settings
+    1281             :                         [daemon->preconfigured_trace_load_settings_count - 1];
+    1282             :         memset(settings, 0, sizeof(DltTraceLoadSettings));
+    1283             :         settings->soft_limit = soft_limit;
+    1284             :         settings->hard_limit = hard_limit;
+    1285             : 
+    1286             :         memcpy(settings->apid, app_id_value, DLT_ID_SIZE);
+    1287             :         if (has_ctx_id) {
+    1288             :             memcpy(settings->ctid, ctx_id_value, DLT_ID_SIZE);
+    1289             :             dlt_vlog(LOG_INFO,
+    1290             :                      "Configured trace limits for app id '%.4s', ctx id '%.4s', soft limit: %u, hard_limit: %u\n",
+    1291             :                      app_id_value, ctx_id_value, soft_limit, hard_limit);
+    1292             :         } else {
+    1293             :             dlt_vlog(LOG_INFO,
+    1294             :                      "Configured trace limits for app id '%.4s', soft limit: %u, hard_limit: %u\n",
+    1295             :                      app_id_value, soft_limit, hard_limit);
+    1296             :         }
+    1297             : 
+    1298             : 
+    1299             : 
+    1300             :     } /* while */
+    1301             :     fclose(pFile);
+    1302             : 
+    1303             :     // sort limits to improve search performance
+    1304             :     qsort(daemon->preconfigured_trace_load_settings, daemon->preconfigured_trace_load_settings_count,
+    1305             :           sizeof(DltTraceLoadSettings),
+    1306             :           dlt_daemon_compare_trace_load_settings);
+    1307             :     return 0;
+    1308             : }
+    1309             : #endif
+    1310             : 
+    1311           9 : static int dlt_mkdir_recursive(const char *dir)
+    1312             : {
+    1313             :     int ret = 0;
+    1314             :     char tmp[PATH_MAX + 1];
+    1315             :     char *p = NULL;
+    1316             :     char *end = NULL;
+    1317             :     size_t len;
+    1318             : 
+    1319             :     strncpy(tmp, dir, PATH_MAX);
+    1320           9 :     len = strlen(tmp);
+    1321             : 
+    1322           9 :     if (tmp[len - 1] == '/')
+    1323           0 :         tmp[len - 1] = 0;
+    1324             : 
+    1325           9 :     end = tmp + len;
+    1326             : 
+    1327          36 :     for (p = tmp + 1; ((*p) && (ret == 0)) || ((ret == -1 && errno == EEXIST) && (p != end)); p++)
+    1328          27 :         if (*p == '/') {
+    1329           0 :             *p = 0;
+    1330             : 
+    1331           0 :             if (access(tmp, F_OK) != 0 && errno == ENOENT) {
+    1332           0 :                 ret = mkdir(tmp,
+    1333             :                 #ifdef DLT_DAEMON_USE_FIFO_IPC
+    1334             :                                 S_IRWXU);
+    1335             :                 #else
+    1336             :                     S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH  | S_IWOTH /*S_IRWXU*/);
+    1337             :                 #endif
+    1338             :             }
+    1339             : 
+    1340           0 :             *p = '/';
+    1341             :         }
+    1342             : 
+    1343             : 
+    1344             : 
+    1345           9 :     if ((ret == 0) || ((ret == -1) && (errno == EEXIST)))
+    1346           9 :         ret = mkdir(tmp,
+    1347             :         #ifdef DLT_DAEMON_USE_FIFO_IPC
+    1348             :                     S_IRWXU);
+    1349             :         #else
+    1350             :                     S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH  | S_IWOTH /*S_IRWXU*/);
+    1351             :         #endif
+    1352             : 
+    1353           9 :     if ((ret == -1) && (errno == EEXIST))
+    1354             :         ret = 0;
+    1355             : 
+    1356           9 :     return ret;
+    1357             : }
+    1358             : 
+    1359             : #ifdef DLT_DAEMON_USE_FIFO_IPC
+    1360           9 : static DltReturnValue dlt_daemon_create_pipes_dir(char *dir)
+    1361             : {
+    1362             :     int ret = DLT_RETURN_OK;
+    1363             : 
+    1364           9 :     if (dir == NULL) {
+    1365           0 :         dlt_vlog(LOG_ERR, "%s: Invalid parameter\n", __func__);
+    1366           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    1367             :     }
+    1368             : 
+    1369             :     /* create dlt pipes directory */
+    1370           9 :     ret = mkdir(dir,
+    1371             :                 S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_ISVTX);
+    1372             : 
+    1373           9 :     if ((ret == -1) && (errno != EEXIST)) {
+    1374           0 :         dlt_vlog(LOG_ERR,
+    1375             :                  "FIFO user dir %s cannot be created (%s)!\n",
+    1376             :                  dir,
+    1377             :                  strerror(errno));
+    1378             : 
+    1379           0 :         return DLT_RETURN_ERROR;
+    1380             :     }
+    1381             : 
+    1382             :     /* S_ISGID cannot be set by mkdir, let's reassign right bits */
+    1383           9 :     ret = chmod(dir,
+    1384             :                 S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH | S_ISGID |
+    1385             :                 S_ISVTX);
+    1386             : 
+    1387           9 :     if (ret == -1) {
+    1388           0 :         dlt_vlog(LOG_ERR,
+    1389             :                  "FIFO user dir %s cannot be chmoded (%s)!\n",
+    1390             :                  dir,
+    1391           0 :                  strerror(errno));
+    1392             : 
+    1393           0 :         return DLT_RETURN_ERROR;
+    1394             :     }
+    1395             : 
+    1396             :     return ret;
+    1397             : }
+    1398             : #endif
+    1399             : // This will be defined when unit testing, so functions
+    1400             : // from this file can be tested without defining main twice
+    1401             : #ifndef DLT_DAEMON_UNIT_TESTS_NO_MAIN
+    1402             : /**
+    1403             :  * Main function of tool.
+    1404             :  */
+    1405           9 : int main(int argc, char *argv[])
+    1406             : {
+    1407             :     char version[DLT_DAEMON_TEXTBUFSIZE];
+    1408             :     char local_str[DLT_DAEMON_TEXTBUFSIZE];
+    1409             :     DltDaemonLocal daemon_local;
+    1410             :     DltDaemon daemon;
+    1411             :     int back = 0;
+    1412             : 
+    1413             :     memset(&daemon_local, 0, sizeof(DltDaemonLocal));
+    1414             :     memset(&daemon, 0, sizeof(DltDaemon));
+    1415             : 
+    1416             :     /* Command line option handling */
+    1417           9 :     if ((back = option_handling(&daemon_local, argc, argv)) < 0) {
+    1418           0 :         if (back != -2)
+    1419           0 :             fprintf (stderr, "option_handling() failed!\n");
+    1420             : 
+    1421           0 :         return -1;
+    1422             :     }
+    1423             : 
+    1424             :     /* Configuration file option handling */
+    1425           9 :     if ((back = option_file_parser(&daemon_local)) < 0) {
+    1426           0 :         if (back != -2)
+    1427           0 :             fprintf (stderr, "option_file_parser() failed!\n");
+    1428             : 
+    1429           0 :         return -1;
+    1430             :     }
+    1431             : 
+    1432             :     /* Initialize internal logging facility */
+    1433           9 :     dlt_log_set_filename(daemon_local.flags.loggingFilename);
+    1434           9 :     dlt_log_set_level(daemon_local.flags.loggingLevel);
+    1435             :     DltReturnValue log_init_result =
+    1436           9 :             dlt_log_init_multiple_logfiles_support(daemon_local.flags.loggingMode,
+    1437           9 :                                                    daemon_local.flags.enableLoggingFileLimit,
+    1438             :                                                    daemon_local.flags.loggingFileSize,
+    1439             :                                                    daemon_local.flags.loggingFileMaxSize);
+    1440             : 
+    1441           9 :     if (log_init_result != DLT_RETURN_OK) {
+    1442           0 :       fprintf(stderr, "Failed to init internal logging\n");
+    1443             : 
+    1444             : #if WITH_DLT_FILE_LOGGING_SYSLOG_FALLBACK
+    1445             :         if (daemon_local.flags.loggingMode == DLT_LOG_TO_FILE) {
+    1446             :           fprintf(stderr, "Falling back to syslog mode\n");
+    1447             : 
+    1448             :           daemon_local.flags.loggingMode = DLT_LOG_TO_SYSLOG;
+    1449             :           log_init_result = dlt_log_init(daemon_local.flags.loggingMode);
+    1450             :           if (log_init_result != DLT_RETURN_OK) {
+    1451             :             fprintf(stderr, "Failed to setup syslog logging, internal logs will "
+    1452             :                             "not be available\n");
+    1453             :           }
+    1454             :       }
+    1455             : #endif
+    1456             :     }
+    1457             : 
+    1458             :     /* Print version information */
+    1459           9 :     dlt_get_version(version, DLT_DAEMON_TEXTBUFSIZE);
+    1460             : 
+    1461           9 :     dlt_vlog(LOG_NOTICE, "Starting DLT Daemon; %s\n", version);
+    1462             : 
+    1463           9 :     PRINT_FUNCTION_VERBOSE(daemon_local.flags.vflag);
+    1464             : 
+    1465             : /* Make sure the parent user directory is created */
+    1466             : #ifdef DLT_DAEMON_USE_FIFO_IPC
+    1467             : 
+    1468           9 :     if (dlt_mkdir_recursive(dltFifoBaseDir) != 0) {
+    1469           0 :         dlt_vlog(LOG_ERR, "Base dir %s cannot be created!\n", dltFifoBaseDir);
+    1470           0 :         return -1;
+    1471             :   }
+    1472             : 
+    1473             : #else
+    1474             :     if (dlt_mkdir_recursive(DLT_USER_IPC_PATH) != 0) {
+    1475             :         dlt_vlog(LOG_ERR, "Base dir %s cannot be created!\n", daemon_local.flags.appSockPath);
+    1476             :         return -1;
+    1477             :     }
+    1478             : 
+    1479             : #endif
+    1480             : 
+    1481             :     /* --- Daemon init phase 1 begin --- */
+    1482           9 :     if (dlt_daemon_local_init_p1(&daemon, &daemon_local, daemon_local.flags.vflag) == -1) {
+    1483           0 :         dlt_log(LOG_CRIT, "Initialization of phase 1 failed!\n");
+    1484           0 :         return -1;
+    1485             :     }
+    1486             : 
+    1487             :     /* --- Daemon init phase 1 end --- */
+    1488             : 
+    1489           9 :     if (dlt_daemon_prepare_event_handling(&daemon_local.pEvent)) {
+    1490             :         /* TODO: Perform clean-up */
+    1491           0 :         dlt_log(LOG_CRIT, "Initialization of event handling failed!\n");
+    1492           0 :         return -1;
+    1493             :     }
+    1494             : 
+    1495             :     /* --- Daemon connection init begin */
+    1496           9 :     if (dlt_daemon_local_connection_init(&daemon, &daemon_local, daemon_local.flags.vflag) == -1) {
+    1497           0 :         dlt_log(LOG_CRIT, "Initialization of local connections failed!\n");
+    1498           0 :         return -1;
+    1499             :     }
+    1500             : 
+    1501             :     /* --- Daemon connection init end */
+    1502             : 
+    1503           9 :     if (dlt_daemon_init_runtime_configuration(&daemon, daemon_local.flags.ivalue, daemon_local.flags.vflag) == -1) {
+    1504           0 :         dlt_log(LOG_ERR, "Could not load runtime config\n");
+    1505           0 :         return -1;
+    1506             :     }
+    1507             : 
+    1508             :     /*
+    1509             :      * Load dlt-runtime.cfg if available.
+    1510             :      * This must be loaded before offline setup
+    1511             :      */
+    1512           9 :     dlt_daemon_configuration_load(&daemon, daemon.runtime_configuration, daemon_local.flags.vflag);
+    1513             : 
+    1514             :     /* --- Daemon init phase 2 begin --- */
+    1515           9 :     if (dlt_daemon_local_init_p2(&daemon, &daemon_local, daemon_local.flags.vflag) == -1) {
+    1516           0 :         dlt_log(LOG_CRIT, "Initialization of phase 2 failed!\n");
+    1517           0 :         return -1;
+    1518             :     }
+    1519             : 
+    1520             : #ifdef DLT_LOG_LEVEL_APP_CONFIG
+    1521             :     /* Load control app id level configuration file without setting `back` to
+    1522             :      * prevent exit if file is missing */
+    1523             :     if (app_id_default_log_level_config_parser(&daemon, &daemon_local) < 0) {
+    1524             :         dlt_vlog(LOG_WARNING, "app_id_default_log_level_config_parser() failed, "
+    1525             :                            "no app specific log levels will be configured\n");
+    1526             :     }
+    1527             : #endif
+    1528             : 
+    1529             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+    1530             :     /* Load control trace load configuration file without setting `back` to prevent exit if file is missing */
+    1531             :     pthread_rwlock_init(&trace_load_rw_lock, NULL);
+    1532             :     if (trace_load_config_file_parser(&daemon, &daemon_local) < 0) {
+    1533             :         dlt_vlog(LOG_WARNING, "trace_load_config_file_parser() failed, using defaults for all app ids!\n");
+    1534             :     }
+    1535             : #endif
+    1536             : 
+    1537             :     /* --- Daemon init phase 2 end --- */
+    1538             : 
+    1539           9 :     if (daemon_local.flags.offlineLogstorageDirPath[0])
+    1540           6 :         if (dlt_daemon_logstorage_setup_internal_storage(
+    1541             :                 &daemon,
+    1542             :                 &daemon_local,
+    1543             :                 daemon_local.flags.offlineLogstorageDirPath,
+    1544             :                 daemon_local.flags.vflag) == -1)
+    1545           0 :             dlt_log(LOG_INFO,
+    1546             :                     "Setting up internal offline log storage failed!\n");
+    1547             : 
+    1548             :     /* create fd for watchdog */
+    1549             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+    1550             :     {
+    1551             :         char *watchdogUSec = getenv("WATCHDOG_USEC");
+    1552             :         int watchdogTimeoutSeconds = 0;
+    1553             : 
+    1554             :         dlt_log(LOG_DEBUG, "Systemd watchdog initialization\n");
+    1555             : 
+    1556             :         if (watchdogUSec)
+    1557             :             watchdogTimeoutSeconds = atoi(watchdogUSec) / 2000000;
+    1558             : 
+    1559             :         daemon.watchdog_trigger_interval = watchdogTimeoutSeconds;
+    1560             :         create_timer_fd(&daemon_local,
+    1561             :                         watchdogTimeoutSeconds,
+    1562             :                         watchdogTimeoutSeconds,
+    1563             :                         DLT_TIMER_SYSTEMD);
+    1564             :     }
+    1565             : #endif
+    1566             : 
+    1567             :     /* create fd for timer timing packets */
+    1568           9 :     create_timer_fd(&daemon_local, 1, 1, DLT_TIMER_PACKET);
+    1569             : 
+    1570             :     /* create fd for timer ecu version */
+    1571           9 :     if ((daemon_local.flags.sendECUSoftwareVersion > 0) ||
+    1572           9 :         (daemon_local.flags.sendTimezone > 0))
+    1573           0 :         create_timer_fd(&daemon_local, 60, 60, DLT_TIMER_ECU);
+    1574             : 
+    1575             :     /* initiate gateway */
+    1576           9 :     if (daemon_local.flags.gatewayMode == 1) {
+    1577           1 :         if (dlt_gateway_init(&daemon_local, daemon_local.flags.vflag) == -1) {
+    1578           0 :             dlt_log(LOG_CRIT, "Failed to create gateway\n");
+    1579           0 :             return -1;
+    1580             :         }
+    1581             : 
+    1582             :         /* create gateway timer */
+    1583           1 :         create_timer_fd(&daemon_local,
+    1584             :                         daemon_local.pGateway.interval,
+    1585             :                         daemon_local.pGateway.interval,
+    1586             :                         DLT_TIMER_GATEWAY);
+    1587             :     }
+    1588             : 
+    1589             :     /* For offline tracing we still can use the same states */
+    1590             :     /* as for socket sending. Using this trick we see the traces */
+    1591             :     /* In the offline trace AND in the socket stream. */
+    1592           9 :     if (daemon_local.flags.yvalue[0])
+    1593           0 :         dlt_daemon_change_state(&daemon, DLT_DAEMON_STATE_SEND_DIRECT);
+    1594             :     else
+    1595           9 :         dlt_daemon_change_state(&daemon, DLT_DAEMON_STATE_BUFFER);
+    1596             : 
+    1597           9 :     dlt_daemon_init_user_information(&daemon,
+    1598             :                                      &daemon_local.pGateway,
+    1599             :                                      daemon_local.flags.gatewayMode,
+    1600             :                                      daemon_local.flags.vflag);
+    1601             : 
+    1602             :     /*
+    1603             :      * Check for app and ctx runtime cfg.
+    1604             :      * These cfg must be loaded after ecuId and num_user_lists are available
+    1605             :      */
+    1606           9 :     if ((dlt_daemon_applications_load(&daemon, daemon.runtime_application_cfg,
+    1607           0 :                                       daemon_local.flags.vflag) == 0) &&
+    1608           0 :         (dlt_daemon_contexts_load(&daemon, daemon.runtime_context_cfg,
+    1609             :                                   daemon_local.flags.vflag) == 0))
+    1610           0 :         daemon.runtime_context_cfg_loaded = 1;
+    1611             : 
+    1612           9 :     dlt_daemon_log_internal(&daemon, &daemon_local,
+    1613             :                             "Daemon launched. Starting to output traces...",
+    1614             :                             DLT_LOG_INFO, DLT_DAEMON_APP_ID, DLT_DAEMON_CTX_ID,
+    1615             :                             daemon_local.flags.vflag);
+    1616             : 
+    1617             :     /* Even handling loop. */
+    1618        1577 :     while ((back >= 0) && (g_exit >= 0))
+    1619        1568 :         back = dlt_daemon_handle_event(&daemon_local.pEvent,
+    1620             :                                        &daemon,
+    1621             :                                        &daemon_local);
+    1622             : 
+    1623           9 :     snprintf(local_str, DLT_DAEMON_TEXTBUFSIZE, "Exiting DLT daemon... [%d]",
+    1624             :              g_signo);
+    1625           9 :     dlt_daemon_log_internal(&daemon, &daemon_local, local_str, DLT_LOG_INFO,
+    1626             :                             DLT_DAEMON_APP_ID, DLT_DAEMON_CTX_ID,
+    1627             :                             daemon_local.flags.vflag);
+    1628           9 :     dlt_vlog(LOG_NOTICE, "%s%s", local_str, "\n");
+    1629             : 
+    1630           9 :     dlt_daemon_local_cleanup(&daemon, &daemon_local, daemon_local.flags.vflag);
+    1631             : 
+    1632             : #ifdef UDP_CONNECTION_SUPPORT
+    1633             :     dlt_daemon_udp_close_connection();
+    1634             : #endif
+    1635             : 
+    1636           9 :     dlt_gateway_deinit(&daemon_local.pGateway, daemon_local.flags.vflag);
+    1637             : 
+    1638           9 :     dlt_daemon_free(&daemon, daemon_local.flags.vflag);
+    1639             : 
+    1640           9 :     dlt_log(LOG_NOTICE, "Leaving DLT daemon\n");
+    1641             : 
+    1642           9 :     dlt_log_free();
+    1643             : 
+    1644           9 :     return 0;
+    1645             : 
+    1646             : } /* main() */
+    1647             : #endif
+    1648             : 
+    1649           9 : int dlt_daemon_local_init_p1(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
+    1650             : {
+    1651           9 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1652             :     int ret = DLT_RETURN_OK;
+    1653             : 
+    1654           9 :     if ((daemon == 0) || (daemon_local == 0)) {
+    1655           0 :         dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_local_init_p1()\n");
+    1656           0 :         return -1;
+    1657             :     }
+    1658             : 
+    1659             : #if defined(DLT_SYSTEMD_WATCHDOG_ENABLE) || defined(DLT_SYSTEMD_ENABLE)
+    1660             :     ret = sd_booted();
+    1661             : 
+    1662             :     if (ret == 0) {
+    1663             :         dlt_log(LOG_CRIT, "System not booted with systemd!\n");
+    1664             :     }
+    1665             :     else if (ret < 0)
+    1666             :     {
+    1667             :         dlt_log(LOG_CRIT, "sd_booted failed!\n");
+    1668             :         return -1;
+    1669             :     }
+    1670             :     else {
+    1671             :         dlt_log(LOG_INFO, "System booted with systemd\n");
+    1672             :     }
+    1673             : 
+    1674             : #endif
+    1675             : 
+    1676             : #ifdef DLT_DAEMON_USE_FIFO_IPC
+    1677             : 
+    1678           9 :     if (dlt_daemon_create_pipes_dir(daemon_local->flags.userPipesDir) == DLT_RETURN_ERROR)
+    1679             :         return DLT_RETURN_ERROR;
+    1680             : 
+    1681             : #endif
+    1682             : 
+    1683             :     /* Check for daemon mode */
+    1684           9 :     if (daemon_local->flags.dflag)
+    1685           2 :         dlt_daemon_daemonize(daemon_local->flags.vflag);
+    1686             : 
+    1687             :     /* initialise structure to use DLT file */
+    1688           9 :     ret = dlt_file_init(&(daemon_local->file), daemon_local->flags.vflag);
+    1689             : 
+    1690           9 :     if (ret == DLT_RETURN_ERROR) {
+    1691           0 :         dlt_log(LOG_ERR, "Could not initialize file structure\n");
+    1692             :         /* Return value ignored, dlt daemon will exit */
+    1693           0 :         dlt_file_free(&(daemon_local->file), daemon_local->flags.vflag);
+    1694           0 :         return ret;
+    1695             :     }
+    1696             : 
+    1697           9 :     signal(SIGPIPE, SIG_IGN);
+    1698             : 
+    1699           9 :     signal(SIGTERM, dlt_daemon_signal_handler); /* software termination signal from kill */
+    1700           9 :     signal(SIGHUP, dlt_daemon_signal_handler);  /* hangup signal */
+    1701           9 :     signal(SIGQUIT, dlt_daemon_signal_handler);
+    1702           9 :     signal(SIGINT, dlt_daemon_signal_handler);
+    1703             : #ifdef __QNX__
+    1704             :     signal(SIGUSR1, dlt_daemon_signal_handler); /* for timer threads */
+    1705             : #endif
+    1706             : 
+    1707           9 :     return DLT_RETURN_OK;
+    1708             : }
+    1709             : 
+    1710           9 : int dlt_daemon_local_init_p2(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
+    1711             : {
+    1712           9 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1713             : 
+    1714           9 :     if ((daemon == 0) || (daemon_local == 0)) {
+    1715           0 :         dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_local_init_p2()\n");
+    1716           0 :         return -1;
+    1717             :     }
+    1718             : 
+    1719             :     /* Daemon data */
+    1720           9 :     if (dlt_daemon_init(daemon, daemon_local->RingbufferMinSize, daemon_local->RingbufferMaxSize,
+    1721           9 :                         daemon_local->RingbufferStepSize, daemon_local->flags.ivalue,
+    1722             :                         daemon_local->flags.contextLogLevel,
+    1723             :                         daemon_local->flags.contextTraceStatus, daemon_local->flags.enforceContextLLAndTS,
+    1724             :                         daemon_local->flags.vflag) == -1) {
+    1725           0 :         dlt_log(LOG_ERR, "Could not initialize daemon data\n");
+    1726           0 :         return -1;
+    1727             :     }
+    1728             : 
+    1729             :     /* init offline trace */
+    1730           9 :     if (((daemon->mode == DLT_USER_MODE_INTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH)) &&
+    1731           0 :         daemon_local->flags.offlineTraceDirectory[0]) {
+    1732           0 :         if (multiple_files_buffer_init(&(daemon_local->offlineTrace),
+    1733           0 :                                        daemon_local->flags.offlineTraceDirectory,
+    1734             :                                        daemon_local->flags.offlineTraceFileSize,
+    1735             :                                        daemon_local->flags.offlineTraceMaxSize,
+    1736           0 :                                        daemon_local->flags.offlineTraceFilenameTimestampBased,
+    1737             :                                        false,
+    1738             :                                        DLT_OFFLINETRACE_FILENAME_BASE,
+    1739             :                                        DLT_OFFLINETRACE_FILENAME_EXT) == -1) {
+    1740           0 :             dlt_log(LOG_ERR, "Could not initialize offline trace\n");
+    1741           0 :             return -1;
+    1742             :         }
+    1743             :     }
+    1744             : 
+    1745             :     /* Init offline logstorage for MAX devices */
+    1746           9 :     if (daemon_local->flags.offlineLogstorageMaxDevices > 0) {
+    1747           6 :         daemon->storage_handle = malloc(sizeof(DltLogStorage) * daemon_local->flags.offlineLogstorageMaxDevices);
+    1748             : 
+    1749           6 :         if (daemon->storage_handle == NULL) {
+    1750           0 :             dlt_log(LOG_ERR, "Could not initialize offline logstorage\n");
+    1751           0 :             return -1;
+    1752             :         }
+    1753             : 
+    1754             :         memset(daemon->storage_handle, 0, (sizeof(DltLogStorage) * daemon_local->flags.offlineLogstorageMaxDevices));
+    1755             :     }
+    1756             : 
+    1757             :     /* Set ECU id of daemon */
+    1758           9 :     if (daemon_local->flags.evalue[0])
+    1759           1 :         dlt_set_id(daemon->ecuid, daemon_local->flags.evalue);
+    1760             :     else
+    1761           8 :         dlt_set_id(daemon->ecuid, DLT_DAEMON_ECU_ID);
+    1762             : 
+    1763             :     /* Set flag for optional sending of serial header */
+    1764           9 :     daemon->sendserialheader = daemon_local->flags.lflag;
+    1765             : 
+    1766             : #ifdef DLT_SHM_ENABLE
+    1767             : 
+    1768             :     /* init shared memory */
+    1769             :     if (dlt_shm_init_server(&(daemon_local->dlt_shm), daemon_local->flags.dltShmName,
+    1770             :                             daemon_local->flags.sharedMemorySize) == DLT_RETURN_ERROR) {
+    1771             :         dlt_log(LOG_ERR, "Could not initialize shared memory\n");
+    1772             :         return -1;
+    1773             :     }
+    1774             : 
+    1775             :     daemon_local->recv_buf_shm = (unsigned char *)calloc(1, DLT_SHM_RCV_BUFFER_SIZE);
+    1776             : 
+    1777             :     if (NULL == daemon_local->recv_buf_shm) {
+    1778             :         dlt_log(LOG_ERR, "failed to allocated the buffer to receive shm data\n");
+    1779             :         return -1;
+    1780             :     }
+    1781             : 
+    1782             : #endif
+    1783             : 
+    1784             :     /* prepare main loop */
+    1785           9 :     if (dlt_message_init(&(daemon_local->msg), daemon_local->flags.vflag) == DLT_RETURN_ERROR) {
+    1786           0 :         dlt_log(LOG_ERR, "Could not initialize message\n");
+    1787           0 :         return -1;
+    1788             :     }
+    1789             : 
+    1790             :     /* configure sending timing packets */
+    1791           9 :     if (daemon_local->flags.sendMessageTime)
+    1792           0 :         daemon->timingpackets = 1;
+    1793             : 
+    1794             :     /* Get ECU version info from a file. If it fails, use dlt_version as fallback. */
+    1795           9 :     if (dlt_daemon_local_ecu_version_init(daemon, daemon_local, daemon_local->flags.vflag) < 0) {
+    1796           9 :         daemon->ECUVersionString = malloc(DLT_DAEMON_TEXTBUFSIZE);
+    1797             : 
+    1798           9 :         if (daemon->ECUVersionString == 0) {
+    1799           0 :             dlt_log(LOG_WARNING, "Could not allocate memory for version string\n");
+    1800           0 :             return -1;
+    1801             :         }
+    1802             : 
+    1803           9 :         dlt_get_version(daemon->ECUVersionString, DLT_DAEMON_TEXTBUFSIZE);
+    1804             :     }
+    1805             : 
+    1806             :     /* Set to allows to maintain logstorage loglevel as default */
+    1807           9 :     daemon->maintain_logstorage_loglevel = DLT_MAINTAIN_LOGSTORAGE_LOGLEVEL_ON;
+    1808             : 
+    1809           9 :     return 0;
+    1810             : }
+    1811             : 
+    1812           9 : static int dlt_daemon_init_serial(DltDaemonLocal *daemon_local)
+    1813             : {
+    1814             :     /* create and open serial connection from/to client */
+    1815             :     /* open serial connection */
+    1816             :     int fd = -1;
+    1817             : 
+    1818           9 :     if (daemon_local->flags.yvalue[0] == '\0')
+    1819             :         return 0;
+    1820             : 
+    1821           0 :     fd = open(daemon_local->flags.yvalue, O_RDWR);
+    1822             : 
+    1823           0 :     if (fd < 0) {
+    1824           0 :         dlt_vlog(LOG_ERR, "Failed to open serial device %s\n",
+    1825             :                  daemon_local->flags.yvalue);
+    1826             : 
+    1827           0 :         daemon_local->flags.yvalue[0] = 0;
+    1828           0 :         return -1;
+    1829             :     }
+    1830             : 
+    1831           0 :     if (isatty(fd)) {
+    1832             :         int speed = DLT_DAEMON_SERIAL_DEFAULT_BAUDRATE;
+    1833             : 
+    1834           0 :         if (daemon_local->flags.bvalue[0])
+    1835           0 :             speed = atoi(daemon_local->flags.bvalue);
+    1836             : 
+    1837           0 :         daemon_local->baudrate = dlt_convert_serial_speed(speed);
+    1838             : 
+    1839           0 :         if (dlt_setup_serial(fd, (speed_t) daemon_local->baudrate) < 0) {
+    1840           0 :             close(fd);
+    1841           0 :             daemon_local->flags.yvalue[0] = 0;
+    1842             : 
+    1843           0 :             dlt_vlog(LOG_ERR, "Failed to configure serial device %s (%s) \n",
+    1844           0 :                      daemon_local->flags.yvalue, strerror(errno));
+    1845             : 
+    1846           0 :             return -1;
+    1847             :         }
+    1848             : 
+    1849           0 :         if (daemon_local->flags.vflag)
+    1850           0 :             dlt_log(LOG_DEBUG, "Serial init done\n");
+    1851             :     }
+    1852             :     else {
+    1853           0 :         close(fd);
+    1854           0 :         fprintf(stderr,
+    1855             :                 "Device is not a serial device, device = %s (%s) \n",
+    1856             :                 daemon_local->flags.yvalue,
+    1857           0 :                 strerror(errno));
+    1858           0 :         daemon_local->flags.yvalue[0] = 0;
+    1859           0 :         return -1;
+    1860             :     }
+    1861             : 
+    1862           0 :     return dlt_connection_create(daemon_local,
+    1863             :                                  &daemon_local->pEvent,
+    1864             :                                  fd,
+    1865             :                                  POLLIN,
+    1866             :                                  DLT_CONNECTION_CLIENT_MSG_SERIAL);
+    1867             : }
+    1868             : 
+    1869             : #ifdef DLT_DAEMON_USE_FIFO_IPC
+    1870           9 : static int dlt_daemon_init_fifo(DltDaemonLocal *daemon_local)
+    1871             : {
+    1872             :     int ret;
+    1873             :     int fd = -1;
+    1874             :     int fifo_size;
+    1875             : 
+    1876             :     /* open named pipe(FIFO) to receive DLT messages from users */
+    1877           9 :     umask(0);
+    1878             : 
+    1879             :     /* Try to delete existing pipe, ignore result of unlink */
+    1880           9 :     const char *tmpFifo = daemon_local->flags.daemonFifoName;
+    1881           9 :     unlink(tmpFifo);
+    1882             : 
+    1883           9 :     ret = mkfifo(tmpFifo, S_IRUSR | S_IWUSR | S_IWGRP);
+    1884             : 
+    1885           9 :     if (ret == -1) {
+    1886           0 :         dlt_vlog(LOG_WARNING, "FIFO user %s cannot be created (%s)!\n",
+    1887           0 :                  tmpFifo, strerror(errno));
+    1888           0 :         return -1;
+    1889             :     } /* if */
+    1890             : 
+    1891             :     /* Set group of daemon FIFO */
+    1892           9 :     if (daemon_local->flags.daemonFifoGroup[0] != 0) {
+    1893           0 :         errno = 0;
+    1894           0 :         struct group *group_dlt = getgrnam(daemon_local->flags.daemonFifoGroup);
+    1895             : 
+    1896           0 :         if (group_dlt) {
+    1897           0 :             ret = chown(tmpFifo, -1, group_dlt->gr_gid);
+    1898             : 
+    1899           0 :             if (ret == -1)
+    1900           0 :                 dlt_vlog(LOG_ERR, "FIFO user %s cannot be chowned to group %s (%s)\n",
+    1901             :                          tmpFifo, daemon_local->flags.daemonFifoGroup,
+    1902             :                          strerror(errno));
+    1903             :         }
+    1904           0 :         else if ((errno == 0) || (errno == ENOENT) || (errno == EBADF) || (errno == EPERM))
+    1905             :         {
+    1906           0 :             dlt_vlog(LOG_ERR, "Group name %s is not found (%s)\n",
+    1907             :                      daemon_local->flags.daemonFifoGroup,
+    1908             :                      strerror(errno));
+    1909             :         }
+    1910             :         else {
+    1911           0 :             dlt_vlog(LOG_ERR, "Failed to get group id of %s (%s)\n",
+    1912             :                      daemon_local->flags.daemonFifoGroup,
+    1913             :                      strerror(errno));
+    1914             :         }
+    1915             :     }
+    1916             : 
+    1917             :     fd = open(tmpFifo, O_RDWR);
+    1918             : 
+    1919           9 :     if (fd == -1) {
+    1920           0 :         dlt_vlog(LOG_WARNING, "FIFO user %s cannot be opened (%s)!\n",
+    1921           0 :                  tmpFifo, strerror(errno));
+    1922           0 :         return -1;
+    1923             :     } /* if */
+    1924             : 
+    1925             : #ifdef __linux__
+    1926             :     /* F_SETPIPE_SZ and F_GETPIPE_SZ are only supported for Linux.
+    1927             :      * For other OSes it depends on its system e.g. pipe manager.
+    1928             :      */
+    1929           9 :     if (daemon_local->daemonFifoSize != 0) {
+    1930             :         /* Set Daemon FIFO size */
+    1931           0 :         if (fcntl(fd, F_SETPIPE_SZ, daemon_local->daemonFifoSize) == -1)
+    1932           0 :             dlt_vlog(LOG_ERR, "set FIFO size error: %s\n", strerror(errno));
+    1933             :     }
+    1934             : 
+    1935             :     /* Get Daemon FIFO size */
+    1936           9 :     if ((fifo_size = fcntl(fd, F_GETPIPE_SZ, 0)) == -1)
+    1937           0 :         dlt_vlog(LOG_ERR, "get FIFO size error: %s\n", strerror(errno));
+    1938             :     else
+    1939           9 :         dlt_vlog(LOG_INFO, "FIFO size: %d\n", fifo_size);
+    1940             : #endif
+    1941             : 
+    1942             :     /* Early init, to be able to catch client (app) connections
+    1943             :      * as soon as possible. This registration is automatically ignored
+    1944             :      * during next execution.
+    1945             :      */
+    1946           9 :     return dlt_connection_create(daemon_local,
+    1947             :                                  &daemon_local->pEvent,
+    1948             :                                  fd,
+    1949             :                                  POLLIN,
+    1950             :                                  DLT_CONNECTION_APP_MSG);
+    1951             : }
+    1952             : #endif
+    1953             : 
+    1954             : #ifdef DLT_DAEMON_VSOCK_IPC_ENABLE
+    1955             : static int dlt_daemon_init_vsock(DltDaemonLocal *daemon_local)
+    1956             : {
+    1957             :     int fd;
+    1958             :     struct sockaddr_vm addr;
+    1959             : 
+    1960             :     fd = socket(AF_VSOCK, SOCK_STREAM, 0);
+    1961             :     if (fd == -1) {
+    1962             :         dlt_vlog(LOG_ERR, "Failed to create VSOCK socket: %s\n", strerror(errno));
+    1963             :         return -1;
+    1964             :     }
+    1965             : 
+    1966             :     memset(&addr, 0, sizeof(addr));
+    1967             :     addr.svm_family = AF_VSOCK;
+    1968             :     addr.svm_port = DLT_VSOCK_PORT;
+    1969             :     addr.svm_cid = VMADDR_CID_ANY;
+    1970             : 
+    1971             :     if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) != 0) {
+    1972             :         dlt_vlog(LOG_ERR, "Failed to bind VSOCK socket: %s\n", strerror(errno));
+    1973             :         close(fd);
+    1974             :         return -1;
+    1975             :     }
+    1976             : 
+    1977             :     if (listen(fd, 1) != 0) {
+    1978             :         dlt_vlog(LOG_ERR, "Failed to listen on VSOCK socket: %s\n", strerror(errno));
+    1979             :         close(fd);
+    1980             :         return -1;
+    1981             :     }
+    1982             : 
+    1983             :     return dlt_connection_create(daemon_local,
+    1984             :                                  &daemon_local->pEvent,
+    1985             :                                  fd,
+    1986             :                                  POLLIN,
+    1987             :                                  DLT_CONNECTION_APP_CONNECT);
+    1988             : }
+    1989             : #endif
+    1990             : 
+    1991             : #ifdef DLT_DAEMON_USE_UNIX_SOCKET_IPC
+    1992             : static DltReturnValue dlt_daemon_init_app_socket(DltDaemonLocal *daemon_local)
+    1993             : {
+    1994             :     /* socket access permission set to srw-rw-rw- (666) */
+    1995             :     int mask = S_IXUSR | S_IXGRP | S_IXOTH;
+    1996             :     DltReturnValue ret = DLT_RETURN_OK;
+    1997             :     int fd = -1;
+    1998             : 
+    1999             :     if (daemon_local == NULL) {
+    2000             :         dlt_vlog(LOG_ERR, "%s: Invalid function parameters\n", __func__);
+    2001             :         return DLT_RETURN_ERROR;
+    2002             :     }
+    2003             : 
+    2004             : #ifdef ANDROID
+    2005             :     /* on android if we want to use security contexts on Unix sockets,
+    2006             :      * they should be created by init (see dlt-daemon.rc in src/daemon)
+    2007             :      * and recovered through the below API */
+    2008             :     ret = dlt_daemon_unix_android_get_socket(&fd, daemon_local->flags.appSockPath);
+    2009             :     if (ret < DLT_RETURN_OK) {
+    2010             :         /* we failed to get app socket created by init.
+    2011             :          * To avoid blocking users to launch dlt-daemon only through
+    2012             :          * init on android (e.g: by hand for debugging purpose), try to
+    2013             :          * create app socket by ourselves */
+    2014             :         ret = dlt_daemon_unix_socket_open(&fd,
+    2015             :                                           daemon_local->flags.appSockPath,
+    2016             :                                           SOCK_STREAM,
+    2017             :                                           mask);
+    2018             :     }
+    2019             : #else
+    2020             :     ret = dlt_daemon_unix_socket_open(&fd,
+    2021             :                                       daemon_local->flags.appSockPath,
+    2022             :                                       SOCK_STREAM,
+    2023             :                                       mask);
+    2024             : #endif
+    2025             :     if (ret == DLT_RETURN_OK) {
+    2026             :         if (dlt_connection_create(daemon_local,
+    2027             :                                   &daemon_local->pEvent,
+    2028             :                                   fd,
+    2029             :                                   POLLIN,
+    2030             :                                   DLT_CONNECTION_APP_CONNECT)) {
+    2031             :             dlt_log(LOG_CRIT, "Could not create connection for app socket.\n");
+    2032             :             return DLT_RETURN_ERROR;
+    2033             :         }
+    2034             :     }
+    2035             :     else {
+    2036             :         dlt_log(LOG_CRIT, "Could not create and open app socket.\n");
+    2037             :         return DLT_RETURN_ERROR;
+    2038             :     }
+    2039             : 
+    2040             :     return ret;
+    2041             : }
+    2042             : #endif
+    2043             : 
+    2044           9 : static DltReturnValue dlt_daemon_initialize_control_socket(DltDaemonLocal *daemon_local)
+    2045             : {
+    2046             :     /* socket access permission set to srw-rw---- (660)  */
+    2047             :     int mask = S_IXUSR | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH;
+    2048             :     DltReturnValue ret = DLT_RETURN_OK;
+    2049           9 :     int fd = -1;
+    2050             : 
+    2051           9 :     if (daemon_local == NULL) {
+    2052           0 :         dlt_vlog(LOG_ERR, "%s: Invalid function parameters\n", __func__);
+    2053           0 :         return -1;
+    2054             :     }
+    2055             : 
+    2056             : #ifdef ANDROID
+    2057             :     /* on android if we want to use security contexts on Unix sockets,
+    2058             :      * they should be created by init (see dlt-daemon.rc in src/daemon)
+    2059             :      * and recovered through the below API */
+    2060             :     ret = dlt_daemon_unix_android_get_socket(&fd, daemon_local->flags.ctrlSockPath);
+    2061             :     if (ret < DLT_RETURN_OK) {
+    2062             :         /* we failed to get app socket created by init.
+    2063             :          * To avoid blocking users to launch dlt-daemon only through
+    2064             :          * init on android (e.g by hand for debugging purpose), try to
+    2065             :          * create app socket by ourselves */
+    2066             :         ret = dlt_daemon_unix_socket_open(&fd,
+    2067             :                                           daemon_local->flags.ctrlSockPath,
+    2068             :                                           SOCK_STREAM,
+    2069             :                                           mask);
+    2070             :     }
+    2071             : #else
+    2072           9 :     ret = dlt_daemon_unix_socket_open(&fd,
+    2073           9 :                                       daemon_local->flags.ctrlSockPath,
+    2074             :                                       SOCK_STREAM,
+    2075             :                                       mask);
+    2076             : #endif
+    2077           9 :     if (ret == DLT_RETURN_OK) {
+    2078           9 :         if (dlt_connection_create(daemon_local,
+    2079             :                                   &daemon_local->pEvent,
+    2080             :                                   fd,
+    2081             :                                   POLLIN,
+    2082             :                                   DLT_CONNECTION_CONTROL_CONNECT) < DLT_RETURN_OK) {
+    2083           0 :             dlt_log(LOG_ERR, "Could not initialize control socket.\n");
+    2084             :             ret = DLT_RETURN_ERROR;
+    2085             :         }
+    2086             :     }
+    2087             : 
+    2088             :     return ret;
+    2089             : }
+    2090             : 
+    2091           9 : int dlt_daemon_local_connection_init(DltDaemon *daemon,
+    2092             :                                      DltDaemonLocal *daemon_local,
+    2093             :                                      int verbose)
+    2094             : {
+    2095           9 :     int fd = -1;
+    2096             : 
+    2097           9 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2098             : 
+    2099           9 :     if ((daemon == NULL) || (daemon_local == NULL)) {
+    2100           0 :         dlt_vlog(LOG_ERR, "%s: Invalid function parameters\n", __func__);
+    2101           0 :         return -1;
+    2102             :     }
+    2103             : 
+    2104           9 :     DltBindAddress_t *head = daemon_local->flags.ipNodes;
+    2105             : 
+    2106             : #ifdef DLT_DAEMON_USE_UNIX_SOCKET_IPC
+    2107             :     /* create and open socket to receive incoming connections from user application */
+    2108             :     if (dlt_daemon_init_app_socket(daemon_local) < DLT_RETURN_OK) {
+    2109             :         dlt_log(LOG_ERR, "Unable to initialize app socket.\n");
+    2110             :         return DLT_RETURN_ERROR;
+    2111             :     }
+    2112             : 
+    2113             : #else /* DLT_DAEMON_USE_FIFO_IPC */
+    2114             : 
+    2115           9 :     if (dlt_daemon_init_fifo(daemon_local)) {
+    2116           0 :         dlt_log(LOG_ERR, "Unable to initialize fifo.\n");
+    2117           0 :         return DLT_RETURN_ERROR;
+    2118             :     }
+    2119             : 
+    2120             : #endif
+    2121             : 
+    2122             : #ifdef DLT_DAEMON_VSOCK_IPC_ENABLE
+    2123             :     if (dlt_daemon_init_vsock(daemon_local) != 0) {
+    2124             :         dlt_log(LOG_ERR, "Unable to initialize app VSOCK socket.\n");
+    2125             :         return DLT_RETURN_ERROR;
+    2126             :     }
+    2127             : #endif
+    2128             : 
+    2129             :     /* create and open socket to receive incoming connections from client */
+    2130           9 :     daemon_local->client_connections = 0;
+    2131             : 
+    2132           9 :     if (head == NULL) { /* no IP set in BindAddress option, will use "0.0.0.0" as default */
+    2133             : 
+    2134           9 :         if (dlt_daemon_socket_open(&fd, daemon_local->flags.port, "0.0.0.0") == DLT_RETURN_OK) {
+    2135           9 :             if (dlt_connection_create(daemon_local,
+    2136             :                                       &daemon_local->pEvent,
+    2137             :                                       fd,
+    2138             :                                       POLLIN,
+    2139             :                                       DLT_CONNECTION_CLIENT_CONNECT)) {
+    2140           0 :                 dlt_log(LOG_ERR, "Could not initialize main socket.\n");
+    2141           0 :                 return DLT_RETURN_ERROR;
+    2142             :             }
+    2143             :         }
+    2144             :         else {
+    2145           0 :             dlt_log(LOG_ERR, "Could not initialize main socket.\n");
+    2146           0 :             return DLT_RETURN_ERROR;
+    2147             :         }
+    2148             :     }
+    2149             :     else {
+    2150             :         bool any_open = false;
+    2151           0 :         while (head != NULL) { /* open socket for each IP in the bindAddress list */
+    2152             : 
+    2153           0 :             if (dlt_daemon_socket_open(&fd, daemon_local->flags.port, head->ip) == DLT_RETURN_OK) {
+    2154           0 :                 if (dlt_connection_create(daemon_local,
+    2155             :                                           &daemon_local->pEvent,
+    2156             :                                           fd,
+    2157             :                                           POLLIN,
+    2158             :                                           DLT_CONNECTION_CLIENT_CONNECT)) {
+    2159           0 :                     dlt_vlog(LOG_ERR, "Could not create connection, for binding %s\n", head->ip);
+    2160             :                 } else {
+    2161             :                     any_open = true;
+    2162             :                 }
+    2163             :             }
+    2164             :             else {
+    2165           0 :                 dlt_vlog(LOG_ERR, "Could not open main socket, for binding %s\n", head->ip);
+    2166             :             }
+    2167             : 
+    2168           0 :             head = head->next;
+    2169             :         }
+    2170             : 
+    2171           0 :         if (!any_open) {
+    2172           0 :             dlt_vlog(LOG_ERR, "Failed create main socket for any configured binding\n");
+    2173           0 :             return DLT_RETURN_ERROR;
+    2174             :         }
+    2175             :     }
+    2176             : 
+    2177             : #ifdef UDP_CONNECTION_SUPPORT
+    2178             : 
+    2179             :     if (daemon_local->UDPConnectionSetup == MULTICAST_CONNECTION_ENABLED) {
+    2180             :         if (dlt_daemon_udp_connection_setup(daemon_local) < 0) {
+    2181             :             dlt_log(LOG_ERR, "UDP fd creation failed\n");
+    2182             :             return DLT_RETURN_ERROR;
+    2183             :         }
+    2184             :         else {
+    2185             :             dlt_log(LOG_INFO, "UDP fd creation success\n");
+    2186             :         }
+    2187             :     }
+    2188             : 
+    2189             : #endif
+    2190             : 
+    2191             :     /* create and open unix socket to receive incoming connections from
+    2192             :      * control application */
+    2193           9 :     if (dlt_daemon_initialize_control_socket(daemon_local) < DLT_RETURN_OK) {
+    2194           0 :         dlt_log(LOG_ERR, "Could not initialize control socket.\n");
+    2195           0 :         return DLT_RETURN_ERROR;
+    2196             :     }
+    2197             : 
+    2198             :     /* Init serial */
+    2199           9 :     if (dlt_daemon_init_serial(daemon_local) < 0) {
+    2200           0 :         dlt_log(LOG_ERR, "Could not initialize daemon data\n");
+    2201           0 :         return DLT_RETURN_ERROR;
+    2202             :     }
+    2203             : 
+    2204             :     return 0;
+    2205             : }
+    2206             : 
+    2207           0 : static char* file_read_everything(FILE* const file, const size_t sizeLimit)
+    2208             : {
+    2209           0 :     if (!file) {
+    2210             :         return NULL;
+    2211             :     }
+    2212             : 
+    2213             :     /* Get the file size. Bail out if stat fails. */
+    2214           0 :     const int fd = fileno(file);
+    2215           0 :     struct stat s_buf = {0};
+    2216           0 :     if (fstat(fd, &s_buf) < 0) {
+    2217           0 :         dlt_log(LOG_WARNING, "failed to stat file size\n");
+    2218           0 :         fclose(file);
+    2219           0 :         return NULL;
+    2220             :     }
+    2221             : 
+    2222             :     /* Size limit includes NULL terminator. */
+    2223           0 :     const off_t size = s_buf.st_size;
+    2224           0 :     if (size < 0 || (size_t)size >= sizeLimit) {
+    2225           0 :         dlt_log(LOG_WARNING, "file size invalid\n");
+    2226           0 :         fclose(file);
+    2227           0 :         return NULL;
+    2228             :     }
+    2229             : 
+    2230           0 :     char* const string = malloc((size_t)size + 1);
+    2231           0 :     if (!string) {
+    2232           0 :         dlt_log(LOG_WARNING, "failed to allocate string for file contents\n");
+    2233           0 :         fclose(file);
+    2234           0 :         return NULL;
+    2235             :     }
+    2236             : 
+    2237             :     off_t offset = 0;
+    2238           0 :     while (!feof(file)) {
+    2239           0 :         offset += (off_t)fread(string + offset, 1, (size_t)size, file);
+    2240             : 
+    2241           0 :         if (ferror(file)) {
+    2242           0 :             dlt_log(LOG_WARNING, "failed to read file\n");
+    2243           0 :             free(string);
+    2244           0 :             fclose(file);
+    2245           0 :             return NULL;
+    2246             :         }
+    2247             : 
+    2248           0 :         if (offset > size) {
+    2249           0 :             dlt_log(LOG_WARNING, "file too long for buffer\n");
+    2250           0 :             free(string);
+    2251           0 :             fclose(file);
+    2252           0 :             return NULL;
+    2253             :         }
+    2254             :     }
+    2255             : 
+    2256           0 :     string[offset] = '\0'; /* append null termination at end of string */
+    2257             : 
+    2258           0 :     return string;
+    2259             : }
+    2260             : 
+    2261           0 : static char* file_read_field(FILE* const file, const char* const fieldName)
+    2262             : {
+    2263           0 :     if (!file) {
+    2264             :         return NULL;
+    2265             :     }
+    2266             : 
+    2267             :     const char* const kDelimiters = "\r\n\"\'=";
+    2268           0 :     const size_t fieldNameLen = strlen(fieldName);
+    2269             : 
+    2270             :     char* result = NULL;
+    2271             : 
+    2272           0 :     char* buffer = NULL;
+    2273           0 :     size_t bufferSize = 0;
+    2274             : 
+    2275             :     while (true) {
+    2276             :         ssize_t lineSize = getline(&buffer, &bufferSize, file);
+    2277           0 :         if (lineSize < 0 || !buffer) {
+    2278             :             /* end of file */
+    2279             :             break;
+    2280             :         }
+    2281             : 
+    2282             :         char* line = buffer;
+    2283             : 
+    2284             :         /* trim trailing delimiters */
+    2285           0 :         while (lineSize >= 1 && strchr(kDelimiters, line[lineSize - 1]) != NULL) {
+    2286           0 :             line[lineSize - 1] = '\0';
+    2287           0 :             --lineSize;
+    2288             :         }
+    2289             : 
+    2290             :         /* check fieldName */
+    2291           0 :         if (strncmp(line, fieldName, fieldNameLen) == 0 &&
+    2292           0 :             (size_t)lineSize >= (fieldNameLen + 1) &&
+    2293           0 :             strchr(kDelimiters, line[fieldNameLen]) != NULL) {
+    2294             :             /* trim fieldName */
+    2295             :             line += fieldNameLen;
+    2296             : 
+    2297             :             /* trim delimiter */
+    2298           0 :             ++line;
+    2299             : 
+    2300             :             /* trim leading delimiters */
+    2301           0 :             while (*line != '\0' && strchr(kDelimiters, *line) != NULL) {
+    2302           0 :                 ++line;
+    2303             :                 --lineSize;
+    2304             :             }
+    2305             : 
+    2306           0 :             result = strdup(line);
+    2307           0 :             break;
+    2308             :         }
+    2309             :     }
+    2310             : 
+    2311           0 :     free(buffer);
+    2312             : 
+    2313           0 :     return result;
+    2314             : }
+    2315             : 
+    2316           9 : int dlt_daemon_local_ecu_version_init(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
+    2317             : {
+    2318             :     FILE *f = NULL;
+    2319             : 
+    2320           9 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2321             : 
+    2322             :     /* By default, version string is null. */
+    2323           9 :     daemon->ECUVersionString = NULL;
+    2324             : 
+    2325             :     /* Open the file. Bail out if error occurs */
+    2326           9 :     f = fopen(daemon_local->flags.pathToECUSoftwareVersion, "r");
+    2327             : 
+    2328           9 :     if (f == NULL) {
+    2329             :         /* Error level notice, because this might be deliberate choice */
+    2330           9 :         dlt_log(LOG_NOTICE, "Failed to open ECU Software version file.\n");
+    2331           9 :         return -1;
+    2332             :     }
+    2333             : 
+    2334           0 :     if (daemon_local->flags.ecuSoftwareVersionFileField[0] != '\0') {
+    2335           0 :         daemon->ECUVersionString = file_read_field(f, daemon_local->flags.ecuSoftwareVersionFileField);
+    2336             :     } else {
+    2337           0 :         daemon->ECUVersionString = file_read_everything(f, DLT_DAEMON_TEXTBUFSIZE);
+    2338             :     }
+    2339             : 
+    2340           0 :     fclose(f);
+    2341             : 
+    2342           0 :     return (daemon->ECUVersionString != NULL) ? 0 : -1;
+    2343             : }
+    2344             : 
+    2345           9 : void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
+    2346             : {
+    2347           9 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2348             : 
+    2349           9 :     if ((daemon == 0) || (daemon_local == 0)) {
+    2350           0 :         dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_local_cleanup()\n");
+    2351           0 :         return;
+    2352             :     }
+    2353             : 
+    2354             :     /* Don't receive event anymore */
+    2355           9 :     dlt_event_handler_cleanup_connections(&daemon_local->pEvent);
+    2356             : 
+    2357           9 :     dlt_message_free(&(daemon_local->msg), daemon_local->flags.vflag);
+    2358             : 
+    2359             :     /* free shared memory */
+    2360           9 :     if (daemon_local->flags.offlineTraceDirectory[0])
+    2361           0 :         multiple_files_buffer_free(&(daemon_local->offlineTrace));
+    2362             : 
+    2363             :     /* Ignore result */
+    2364           9 :     dlt_file_free(&(daemon_local->file), daemon_local->flags.vflag);
+    2365             : 
+    2366             : #ifdef DLT_DAEMON_USE_FIFO_IPC
+    2367             :     /* Try to delete existing pipe, ignore result of unlink() */
+    2368           9 :     unlink(daemon_local->flags.daemonFifoName);
+    2369             : #else /* DLT_DAEMON_USE_UNIX_SOCKET_IPC */
+    2370             :     /* Try to delete existing pipe, ignore result of unlink() */
+    2371             :     if (unlink(daemon_local->flags.appSockPath) != 0) {
+    2372             :         dlt_vlog(LOG_WARNING, "%s: unlink() failed: %s\n",
+    2373             :                 __func__, strerror(errno));
+    2374             :     }
+    2375             : #endif
+    2376             : 
+    2377             : #ifdef DLT_SHM_ENABLE
+    2378             :     /* free shared memory */
+    2379             :     dlt_shm_free_server(&(daemon_local->dlt_shm), daemon_local->flags.dltShmName);
+    2380             :     free(daemon_local->recv_buf_shm);
+    2381             :     daemon_local->recv_buf_shm = NULL;
+    2382             : #endif
+    2383             : 
+    2384           9 :     if (daemon_local->flags.offlineLogstorageMaxDevices > 0) {
+    2385             :         /* disconnect all logstorage devices */
+    2386           6 :         dlt_daemon_logstorage_cleanup(daemon,
+    2387             :                                       daemon_local,
+    2388             :                                       daemon_local->flags.vflag);
+    2389             : 
+    2390           6 :         free(daemon->storage_handle);
+    2391             :     }
+    2392             : 
+    2393           9 :     if (daemon->ECUVersionString != NULL)
+    2394           9 :         free(daemon->ECUVersionString);
+    2395             : 
+    2396           9 :     if (unlink(daemon_local->flags.ctrlSockPath) != 0) {
+    2397           1 :         dlt_vlog(LOG_WARNING, "%s: unlink() failed: %s\n",
+    2398           1 :                 __func__, strerror(errno));
+    2399             :     }
+    2400             : 
+    2401             :     /* free IP list */
+    2402           9 :     free(daemon_local->flags.ipNodes);
+    2403             : }
+    2404             : 
+    2405           9 : void dlt_daemon_exit_trigger()
+    2406             : {
+    2407             :     /* stop event loop */
+    2408           9 :     g_exit = -1;
+    2409             : 
+    2410             : #ifdef DLT_DAEMON_USE_FIFO_IPC
+    2411           9 :     char tmp[DLT_PATH_MAX] = { 0 };
+    2412             : 
+    2413             :     ssize_t n;
+    2414           9 :     n = snprintf(tmp, DLT_PATH_MAX, "%s/dlt", dltFifoBaseDir);
+    2415           9 :     if (n < 0 || (size_t)n > DLT_PATH_MAX) {
+    2416           0 :         dlt_vlog(LOG_WARNING, "%s: snprintf truncation/error(%ld) %s\n",
+    2417             :                 __func__, n, tmp);
+    2418             :     }
+    2419             : 
+    2420           9 :     (void)unlink(tmp);
+    2421             : #endif
+    2422             : 
+    2423             : #ifdef __QNX__
+    2424             :     dlt_daemon_cleanup_timers();
+    2425             : #endif
+    2426             : 
+    2427           9 : }
+    2428             : 
+    2429           9 : void dlt_daemon_signal_handler(int sig)
+    2430             : {
+    2431           9 :     g_signo = sig;
+    2432             : 
+    2433           9 :     switch (sig) {
+    2434           9 :         case SIGHUP:
+    2435             :         case SIGTERM:
+    2436             :         case SIGINT:
+    2437             :         case SIGQUIT:
+    2438             :         {
+    2439             :             /* finalize the server */
+    2440           9 :             dlt_vlog(LOG_NOTICE, "Exiting DLT daemon due to signal: %s\n",
+    2441             :                      strsignal(sig));
+    2442           9 :             dlt_daemon_exit_trigger();
+    2443           9 :             break;
+    2444             :         }
+    2445             :         default:
+    2446             :         {
+    2447             :             /* This case should never happen! */
+    2448             :             break;
+    2449             :         }
+    2450             :     } /* switch */
+    2451             : 
+    2452           9 : } /* dlt_daemon_signal_handler() */
+    2453             : 
+    2454             : #ifdef __QNX__
+    2455             : void dlt_daemon_cleanup_timers()
+    2456             : {
+    2457             :     int i = 0;
+    2458             :     while (i < DLT_TIMER_UNKNOWN) {
+    2459             :         /* Remove FIFO of every timer and kill timer thread */
+    2460             :         if (0 != timer_threads[i]) {
+    2461             :             pthread_kill(timer_threads[i], SIGUSR1);
+    2462             :             pthread_join(timer_threads[i], NULL);
+    2463             :             timer_threads[i] = 0;
+    2464             : 
+    2465             :             close_pipes(dlt_timer_pipes[i]);
+    2466             : 
+    2467             :             /* Free data of every timer */
+    2468             :             if (NULL != timer_data[i]) {
+    2469             :                 free(timer_data[i]);
+    2470             :                 timer_data[i] = NULL;
+    2471             :             }
+    2472             :         }
+    2473             :         i++;
+    2474             :     }
+    2475             : }
+    2476             : #endif
+    2477             : 
+    2478           2 : void dlt_daemon_daemonize(int verbose)
+    2479             : {
+    2480             :     int i;
+    2481             :     int fd;
+    2482             : 
+    2483           2 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2484             : 
+    2485           2 :     dlt_log(LOG_NOTICE, "Daemon mode\n");
+    2486             : 
+    2487             :     /* Daemonize */
+    2488           2 :     i = fork();
+    2489             : 
+    2490           4 :     if (i < 0) {
+    2491           0 :         dlt_log(LOG_CRIT, "Unable to fork(), exiting DLT daemon\n");
+    2492           0 :         exit(-1); /* fork error */
+    2493             :     }
+    2494             : 
+    2495           4 :     if (i > 0)
+    2496           2 :         exit(0); /* parent exits */
+    2497             : 
+    2498             :     /* child (daemon) continues */
+    2499             : 
+    2500             :     /* Process independency */
+    2501             : 
+    2502             :     /* obtain a new process group */
+    2503           2 :     if (setsid() == -1) {
+    2504           0 :         dlt_log(LOG_CRIT, "setsid() failed, exiting DLT daemon\n");
+    2505           0 :         exit(-1); /* fork error */
+    2506             :     }
+    2507             : 
+    2508             :     /* Open standard descriptors stdin, stdout, stderr */
+    2509             :     fd = open("/dev/null", O_RDWR);
+    2510             : 
+    2511           2 :     if (fd != -1) {
+    2512             :         /* Redirect STDOUT to /dev/null */
+    2513           2 :         if (dup2(fd, STDOUT_FILENO) < 0)
+    2514           0 :             dlt_vlog(LOG_WARNING, "Failed to direct stdout to /dev/null. Error: %s\n", strerror(errno));
+    2515             : 
+    2516             :         /* Redirect STDERR to /dev/null */
+    2517           2 :         if (dup2(fd, STDERR_FILENO) < 0)
+    2518           0 :             dlt_vlog(LOG_WARNING, "Failed to direct stderr to /dev/null. Error: %s\n", strerror(errno));
+    2519             : 
+    2520           2 :         close(fd);
+    2521             :     }
+    2522             :     else {
+    2523           0 :         dlt_log(LOG_CRIT, "Error opening /dev/null, exiting DLT daemon\n");
+    2524           0 :         exit(-1); /* fork error */
+    2525             :     }
+    2526             : 
+    2527             :     /* Set umask */
+    2528           2 :     umask(DLT_DAEMON_UMASK);
+    2529             : 
+    2530             :     /* Change to root directory */
+    2531           2 :     if (chdir("/") < 0)
+    2532           0 :         dlt_log(LOG_WARNING, "Failed to chdir to root\n");
+    2533             : 
+    2534             :     /* Catch signals */
+    2535           2 :     signal(SIGCHLD, SIG_IGN); /* ignore child */
+    2536           2 :     signal(SIGTSTP, SIG_IGN); /* ignore tty signals */
+    2537           2 :     signal(SIGTTOU, SIG_IGN);
+    2538           2 :     signal(SIGTTIN, SIG_IGN);
+    2539             : 
+    2540           2 : } /* dlt_daemon_daemonize() */
+    2541             : 
+    2542             : /* This function logs str to the configured output sink (socket, serial, offline trace).
+    2543             :  * To avoid recursion this function must be called only from DLT highlevel functions.
+    2544             :  * E. g. calling it to output a failure when the open of the offline trace file fails
+    2545             :  * would cause an endless loop because dlt_daemon_log_internal() would itself again try
+    2546             :  * to open the offline trace file.
+    2547             :  * This is a dlt-daemon only function. The libdlt has no equivalent function available. */
+    2548          40 : int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local,
+    2549             :                             char *str, DltLogLevelType level,
+    2550             :                             const char *app_id, const char *ctx_id, int verbose)
+    2551             : {
+    2552          40 :     DltMessage msg = { 0 };
+    2553             :     static uint8_t uiMsgCount = 0;
+    2554             :     DltStandardHeaderExtra *pStandardExtra = NULL;
+    2555             :     uint32_t uiType;
+    2556             :     uint16_t uiSize;
+    2557             :     uint32_t uiExtraSize;
+    2558             : 
+    2559          40 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2560             : 
+    2561             :     /* Set storageheader */
+    2562          40 :     msg.storageheader = (DltStorageHeader *)(msg.headerbuffer);
+    2563          40 :     dlt_set_storageheader(msg.storageheader, daemon->ecuid);
+    2564             : 
+    2565             :     /* Set standardheader */
+    2566          40 :     msg.standardheader = (DltStandardHeader *)(msg.headerbuffer + sizeof(DltStorageHeader));
+    2567          40 :     msg.standardheader->htyp = DLT_HTYP_UEH | DLT_HTYP_WEID | DLT_HTYP_WSID | DLT_HTYP_WTMS |
+    2568             :         DLT_HTYP_PROTOCOL_VERSION1;
+    2569          40 :     msg.standardheader->mcnt = uiMsgCount++;
+    2570             : 
+    2571             :     uiExtraSize = (uint32_t) (DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp) +
+    2572             :         (DLT_IS_HTYP_UEH(msg.standardheader->htyp) ? sizeof(DltExtendedHeader) : 0));
+    2573          40 :     msg.headersize = (uint32_t) sizeof(DltStorageHeader) + (uint32_t) sizeof(DltStandardHeader) + uiExtraSize;
+    2574             : 
+    2575             :     /* Set extraheader */
+    2576             :     pStandardExtra =
+    2577             :         (DltStandardHeaderExtra *)(msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader));
+    2578          40 :     dlt_set_id(pStandardExtra->ecu, daemon->ecuid);
+    2579          40 :     pStandardExtra->tmsp = DLT_HTOBE_32(dlt_uptime());
+    2580          40 :     pStandardExtra->seid = (unsigned int) DLT_HTOBE_32(getpid());
+    2581             : 
+    2582             :     /* Set extendedheader */
+    2583          40 :     msg.extendedheader =
+    2584          40 :         (DltExtendedHeader *)(msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+    2585          40 :                               DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp));
+    2586          40 :     msg.extendedheader->msin = DLT_MSIN_VERB | (DLT_TYPE_LOG << DLT_MSIN_MSTP_SHIFT) |
+    2587          40 :         ((level << DLT_MSIN_MTIN_SHIFT) & DLT_MSIN_MTIN);
+    2588          40 :     msg.extendedheader->noar = 1;
+    2589          40 :     dlt_set_id(msg.extendedheader->apid, app_id);
+    2590          40 :     dlt_set_id(msg.extendedheader->ctid, ctx_id);
+    2591             : 
+    2592             :     /* Set payload data... */
+    2593          40 :     uiType = DLT_TYPE_INFO_STRG;
+    2594          40 :     uiSize = (uint16_t) (strlen(str) + 1);
+    2595          40 :     msg.datasize = (uint32_t) (sizeof(uint32_t) + sizeof(uint16_t) + uiSize);
+    2596             : 
+    2597          40 :     msg.databuffer = (uint8_t *)malloc((size_t) msg.datasize);
+    2598          40 :     msg.databuffersize = msg.datasize;
+    2599             : 
+    2600          40 :     if (msg.databuffer == 0) {
+    2601           0 :         dlt_log(LOG_WARNING, "Can't allocate buffer for get log info message\n");
+    2602           0 :         return -1;
+    2603             :     }
+    2604             : 
+    2605             :     msg.datasize = 0;
+    2606             :     memcpy((uint8_t *)(msg.databuffer + msg.datasize), (uint8_t *)(&uiType), sizeof(uint32_t));
+    2607          40 :     msg.datasize += (uint32_t) sizeof(uint32_t);
+    2608          40 :     memcpy((uint8_t *)(msg.databuffer + msg.datasize), (uint8_t *)(&uiSize), sizeof(uint16_t));
+    2609          40 :     msg.datasize += (uint32_t) sizeof(uint16_t);
+    2610          40 :     memcpy((uint8_t *)(msg.databuffer + msg.datasize), str, uiSize);
+    2611          40 :     msg.datasize += uiSize;
+    2612             : 
+    2613             :     /* Calc length */
+    2614          40 :     msg.standardheader->len = DLT_HTOBE_16(msg.headersize - sizeof(DltStorageHeader) + msg.datasize);
+    2615             : 
+    2616          40 :     dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL, daemon,daemon_local,
+    2617             :                            msg.headerbuffer, sizeof(DltStorageHeader),
+    2618             :                            msg.headerbuffer + sizeof(DltStorageHeader),
+    2619          40 :                            (int) (msg.headersize - sizeof(DltStorageHeader)),
+    2620          40 :                            msg.databuffer, (int) msg.datasize, verbose);
+    2621             : 
+    2622          40 :     free(msg.databuffer);
+    2623             : 
+    2624          40 :     return 0;
+    2625             : }
+    2626             : 
+    2627           3 : int dlt_daemon_check_numeric_setting(char *token,
+    2628             :                                     char *value,
+    2629             :                                     unsigned long *data)
+    2630           3 : {
+    2631           3 :     char value_check[value_length];
+    2632           3 :     value_check[0] = 0;
+    2633           3 :     sscanf(value, "%lu%s", data, value_check);
+    2634           3 :     if (value_check[0] || !isdigit(value[0])) {
+    2635           0 :         fprintf(stderr, "Invalid input [%s] detected in option %s\n",
+    2636             :                 value,
+    2637             :                 token);
+    2638           0 :         return -1;
+    2639             :     }
+    2640             :     return 0;
+    2641             : }
+    2642             : 
+    2643           4 : int dlt_daemon_process_client_connect(DltDaemon *daemon,
+    2644             :                                       DltDaemonLocal *daemon_local,
+    2645             :                                       DltReceiver *receiver,
+    2646             :                                       int verbose)
+    2647             : {
+    2648             :     socklen_t cli_size;
+    2649             :     struct sockaddr_un cli;
+    2650             : 
+    2651             :     int in_sock = -1;
+    2652           4 :     char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
+    2653             : 
+    2654           4 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2655             : 
+    2656           4 :     if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
+    2657           0 :         dlt_log(LOG_ERR,
+    2658             :                 "Invalid function parameters used for function "
+    2659             :                 "dlt_daemon_process_client_connect()\n");
+    2660           0 :         return -1;
+    2661             :     }
+    2662             : 
+    2663             :     /* event from TCP server socket, new connection */
+    2664           4 :     cli_size = sizeof(cli);
+    2665             : 
+    2666           4 :     if ((in_sock = accept(receiver->fd, (struct sockaddr *)&cli, &cli_size)) < 0) {
+    2667           0 :         if (errno == ECONNABORTED) // Caused by nmap -v -p 3490 -Pn <IP of dlt-daemon>
+    2668             :             return 0;
+    2669           0 :         dlt_vlog(LOG_ERR, "accept() for socket %d failed: %s\n", receiver->fd, strerror(errno));
+    2670           0 :         return -1;
+    2671             :     }
+    2672             : 
+    2673             :     /* check if file file descriptor was already used, and make it invalid if it
+    2674             :      * is reused. */
+    2675             :     /* This prevents sending messages to wrong file descriptor */
+    2676           4 :     dlt_daemon_applications_invalidate_fd(daemon, daemon->ecuid, in_sock, verbose);
+    2677           4 :     dlt_daemon_contexts_invalidate_fd(daemon, daemon->ecuid, in_sock, verbose);
+    2678             : 
+    2679             :     /* Set socket timeout in reception */
+    2680             :     struct timeval timeout_send;
+    2681           4 :     timeout_send.tv_sec = daemon_local->timeoutOnSend;
+    2682           4 :     timeout_send.tv_usec = 0;
+    2683             : 
+    2684           4 :     if (setsockopt (in_sock,
+    2685             :                     SOL_SOCKET,
+    2686             :                     SO_SNDTIMEO,
+    2687             :                     (char *)&timeout_send,
+    2688             :                     sizeof(timeout_send)) < 0)
+    2689           0 :         dlt_log(LOG_WARNING, "setsockopt failed\n");
+    2690             : 
+    2691           4 :     if (dlt_connection_create(daemon_local,
+    2692             :                               &daemon_local->pEvent,
+    2693             :                               in_sock,
+    2694             :                               POLLIN,
+    2695             :                               DLT_CONNECTION_CLIENT_MSG_TCP)) {
+    2696           0 :         dlt_log(LOG_ERR, "Failed to register new client. \n");
+    2697           0 :         close(in_sock);
+    2698           0 :         return -1;
+    2699             :     }
+    2700             : 
+    2701             :     /* send connection info about connected */
+    2702           4 :     dlt_daemon_control_message_connection_info(in_sock,
+    2703             :                                                daemon,
+    2704             :                                                daemon_local,
+    2705             :                                                DLT_CONNECTION_STATUS_CONNECTED,
+    2706             :                                                "",
+    2707             :                                                verbose);
+    2708             : 
+    2709             :     /* send ecu version string */
+    2710           4 :     if (daemon_local->flags.sendECUSoftwareVersion > 0) {
+    2711             :         if (daemon_local->flags.sendECUSoftwareVersion > 0)
+    2712           0 :             dlt_daemon_control_get_software_version(DLT_DAEMON_SEND_TO_ALL,
+    2713             :                                                     daemon,
+    2714             :                                                     daemon_local,
+    2715             :                                                     daemon_local->flags.vflag);
+    2716             : 
+    2717           0 :         if (daemon_local->flags.sendTimezone > 0)
+    2718           0 :             dlt_daemon_control_message_timezone(DLT_DAEMON_SEND_TO_ALL,
+    2719             :                                                 daemon,
+    2720             :                                                 daemon_local,
+    2721             :                                                 daemon_local->flags.vflag);
+    2722             :     }
+    2723             : 
+    2724           4 :     snprintf(local_str, DLT_DAEMON_TEXTBUFSIZE,
+    2725             :              "New client connection #%d established, Total Clients : %d",
+    2726             :              in_sock, daemon_local->client_connections);
+    2727             : 
+    2728           4 :     dlt_daemon_log_internal(daemon, daemon_local, local_str, DLT_LOG_INFO,
+    2729             :                             DLT_DAEMON_APP_ID, DLT_DAEMON_CTX_ID,
+    2730             :                             daemon_local->flags.vflag);
+    2731           4 :     dlt_vlog(LOG_DEBUG, "%s%s", local_str, "\n");
+    2732             : 
+    2733           4 :     if (daemon_local->client_connections == 1) {
+    2734           2 :         if (daemon_local->flags.vflag)
+    2735           0 :             dlt_log(LOG_DEBUG, "Send ring-buffer to client\n");
+    2736             : 
+    2737           2 :         dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_SEND_BUFFER);
+    2738             : 
+    2739           2 :         if (dlt_daemon_send_ringbuffer_to_client(daemon, daemon_local, verbose) == -1) {
+    2740           0 :             dlt_log(LOG_WARNING, "Can't send contents of ringbuffer to clients\n");
+    2741           0 :             close(in_sock);
+    2742             :             in_sock = -1;
+    2743           0 :             return -1;
+    2744             :         }
+    2745             : 
+    2746             :         /* send new log state to all applications */
+    2747           2 :         daemon->connectionState = 1;
+    2748           2 :         dlt_daemon_user_send_all_log_state(daemon, verbose);
+    2749             : 
+    2750             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+    2751             :         /* Reset number of received bytes from FIFO */
+    2752             :         daemon->bytes_recv = 0;
+    2753             : #endif
+    2754             :     }
+    2755             : 
+    2756             :     return 0;
+    2757             : }
+    2758             : 
+    2759          11 : int dlt_daemon_process_client_messages(DltDaemon *daemon,
+    2760             :                                        DltDaemonLocal *daemon_local,
+    2761             :                                        DltReceiver *receiver,
+    2762             :                                        int verbose)
+    2763             : {
+    2764             :     int bytes_to_be_removed = 0;
+    2765             :     int must_close_socket = -1;
+    2766             : 
+    2767          11 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2768             : 
+    2769          11 :     if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
+    2770           0 :         dlt_log(LOG_ERR,
+    2771             :                 "Invalid function parameters used for function "
+    2772             :                 "dlt_daemon_process_client_messages()\n");
+    2773           0 :         return -1;
+    2774             :     }
+    2775             : 
+    2776          11 :     must_close_socket = dlt_receiver_receive(receiver);
+    2777             : 
+    2778          11 :     if (must_close_socket < 0) {
+    2779           0 :         dlt_daemon_close_socket(receiver->fd,
+    2780             :                                 daemon,
+    2781             :                                 daemon_local,
+    2782             :                                 verbose);
+    2783           0 :         return -1;
+    2784             :     }
+    2785             : 
+    2786             :     /* Process all received messages */
+    2787          21 :     while (dlt_message_read(&(daemon_local->msg),
+    2788          21 :                             (uint8_t *)receiver->buf,
+    2789          21 :                             (unsigned int) receiver->bytesRcvd,
+    2790             :                             daemon_local->flags.nflag,
+    2791          21 :                             daemon_local->flags.vflag) == DLT_MESSAGE_ERROR_OK) {
+    2792             :         /* Check for control message */
+    2793          10 :         if ((0 < receiver->fd) &&
+    2794          10 :             DLT_MSG_IS_CONTROL_REQUEST(&(daemon_local->msg)))
+    2795          10 :             dlt_daemon_client_process_control(receiver->fd,
+    2796             :                                               daemon,
+    2797             :                                               daemon_local,
+    2798             :                                               &(daemon_local->msg),
+    2799             :                                               daemon_local->flags.vflag);
+    2800             : 
+    2801          10 :         bytes_to_be_removed = (int) (daemon_local->msg.headersize +
+    2802          10 :             daemon_local->msg.datasize -
+    2803             :             sizeof(DltStorageHeader));
+    2804             : 
+    2805          10 :         if (daemon_local->msg.found_serialheader)
+    2806             :             bytes_to_be_removed += (int) sizeof(dltSerialHeader);
+    2807             : 
+    2808          10 :         if (daemon_local->msg.resync_offset)
+    2809           0 :             bytes_to_be_removed += daemon_local->msg.resync_offset;
+    2810             : 
+    2811          10 :         if (dlt_receiver_remove(receiver, bytes_to_be_removed) == -1) {
+    2812           0 :             dlt_log(LOG_WARNING,
+    2813             :                     "Can't remove bytes from receiver for sockets\n");
+    2814           0 :             return -1;
+    2815             :         }
+    2816             :     } /* while */
+    2817             : 
+    2818          11 :     if (dlt_receiver_move_to_begin(receiver) == -1) {
+    2819           0 :         dlt_log(LOG_WARNING,
+    2820             :                 "Can't move bytes to beginning of receiver buffer for sockets\n");
+    2821           0 :         return -1;
+    2822             :     }
+    2823             : 
+    2824          11 :     if (must_close_socket == 0)
+    2825             :         /* FIXME: Why the hell do we need to close the socket
+    2826             :          * on control message reception ??
+    2827             :          */
+    2828           1 :         dlt_daemon_close_socket(receiver->fd,
+    2829             :                                 daemon,
+    2830             :                                 daemon_local,
+    2831             :                                 verbose);
+    2832             : 
+    2833             :     return 0;
+    2834             : }
+    2835             : 
+    2836           0 : int dlt_daemon_process_client_messages_serial(DltDaemon *daemon,
+    2837             :                                               DltDaemonLocal *daemon_local,
+    2838             :                                               DltReceiver *receiver,
+    2839             :                                               int verbose)
+    2840             : {
+    2841             :     int bytes_to_be_removed = 0;
+    2842             : 
+    2843           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2844             : 
+    2845           0 :     if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
+    2846           0 :         dlt_log(LOG_ERR,
+    2847             :                 "Invalid function parameters used for function "
+    2848             :                 "dlt_daemon_process_client_messages_serial()\n");
+    2849           0 :         return -1;
+    2850             :     }
+    2851             : 
+    2852           0 :     if (dlt_receiver_receive(receiver) <= 0) {
+    2853           0 :         dlt_log(LOG_WARNING,
+    2854             :                 "dlt_receiver_receive_fd() for messages from serial interface "
+    2855             :                 "failed!\n");
+    2856           0 :         return -1;
+    2857             :     }
+    2858             : 
+    2859             :     /* Process all received messages */
+    2860           0 :     while (dlt_message_read(&(daemon_local->msg),
+    2861           0 :                             (uint8_t *)receiver->buf,
+    2862           0 :                             (unsigned int) receiver->bytesRcvd,
+    2863             :                             daemon_local->flags.mflag,
+    2864           0 :                             daemon_local->flags.vflag) == DLT_MESSAGE_ERROR_OK) {
+    2865             :         /* Check for control message */
+    2866           0 :         if (DLT_MSG_IS_CONTROL_REQUEST(&(daemon_local->msg))) {
+    2867           0 :             if (dlt_daemon_client_process_control(receiver->fd,
+    2868             :                                                   daemon,
+    2869             :                                                   daemon_local,
+    2870             :                                                   &(daemon_local->msg),
+    2871             :                                                   daemon_local->flags.vflag)
+    2872             :                 == -1) {
+    2873           0 :                 dlt_log(LOG_WARNING, "Can't process control messages\n");
+    2874           0 :                 return -1;
+    2875             :             }
+    2876             :         }
+    2877             : 
+    2878           0 :         bytes_to_be_removed = (int) (daemon_local->msg.headersize +
+    2879           0 :             daemon_local->msg.datasize -
+    2880             :             sizeof(DltStorageHeader));
+    2881             : 
+    2882           0 :         if (daemon_local->msg.found_serialheader)
+    2883             :             bytes_to_be_removed += (int) sizeof(dltSerialHeader);
+    2884             : 
+    2885           0 :         if (daemon_local->msg.resync_offset)
+    2886           0 :             bytes_to_be_removed += daemon_local->msg.resync_offset;
+    2887             : 
+    2888           0 :         if (dlt_receiver_remove(receiver, bytes_to_be_removed) == -1) {
+    2889           0 :             dlt_log(LOG_WARNING,
+    2890             :                     "Can't remove bytes from receiver for serial connection\n");
+    2891           0 :             return -1;
+    2892             :         }
+    2893             :     } /* while */
+    2894             : 
+    2895           0 :     if (dlt_receiver_move_to_begin(receiver) == -1) {
+    2896           0 :         dlt_log(LOG_WARNING,
+    2897             :                 "Can't move bytes to beginning of receiver buffer for serial "
+    2898             :                 "connection\n");
+    2899           0 :         return -1;
+    2900             :     }
+    2901             : 
+    2902             :     return 0;
+    2903             : }
+    2904             : 
+    2905           2 : int dlt_daemon_process_control_connect(
+    2906             :     DltDaemon *daemon,
+    2907             :     DltDaemonLocal *daemon_local,
+    2908             :     DltReceiver *receiver,
+    2909             :     int verbose)
+    2910             : {
+    2911             :     socklen_t ctrl_size;
+    2912             :     struct sockaddr_un ctrl;
+    2913             :     int in_sock = -1;
+    2914             : 
+    2915           2 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2916             : 
+    2917           2 :     if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
+    2918           0 :         dlt_log(LOG_ERR,
+    2919             :                 "Invalid function parameters used for function "
+    2920             :                 "dlt_daemon_process_control_connect()\n");
+    2921           0 :         return -1;
+    2922             :     }
+    2923             : 
+    2924             :     /* event from UNIX server socket, new connection */
+    2925           2 :     ctrl_size = sizeof(ctrl);
+    2926             : 
+    2927           2 :     if ((in_sock = accept(receiver->fd, (struct sockaddr *)&ctrl, &ctrl_size)) < 0) {
+    2928           0 :         dlt_vlog(LOG_ERR, "accept() on UNIX control socket %d failed: %s\n", receiver->fd, strerror(errno));
+    2929           0 :         return -1;
+    2930             :     }
+    2931             : 
+    2932             :     /* check if file file descriptor was already used, and make it invalid if it
+    2933             :      *  is reused */
+    2934             :     /* This prevents sending messages to wrong file descriptor */
+    2935           2 :     dlt_daemon_applications_invalidate_fd(daemon, daemon->ecuid, in_sock, verbose);
+    2936           2 :     dlt_daemon_contexts_invalidate_fd(daemon, daemon->ecuid, in_sock, verbose);
+    2937             : 
+    2938           2 :     if (dlt_connection_create(daemon_local,
+    2939             :                               &daemon_local->pEvent,
+    2940             :                               in_sock,
+    2941             :                               POLLIN,
+    2942             :                               DLT_CONNECTION_CONTROL_MSG)) {
+    2943           0 :         dlt_log(LOG_ERR, "Failed to register new client. \n");
+    2944             :         /* TODO: Perform clean-up */
+    2945           0 :         return -1;
+    2946             :     }
+    2947             : 
+    2948           2 :     if (verbose)
+    2949           0 :         dlt_vlog(LOG_INFO, "New connection to control client established\n");
+    2950             : 
+    2951             :     return 0;
+    2952             : }
+    2953             : 
+    2954             : #if defined DLT_DAEMON_USE_UNIX_SOCKET_IPC || defined DLT_DAEMON_VSOCK_IPC_ENABLE
+    2955             : int dlt_daemon_process_app_connect(
+    2956             :     DltDaemon *daemon,
+    2957             :     DltDaemonLocal *daemon_local,
+    2958             :     DltReceiver *receiver,
+    2959             :     int verbose)
+    2960             : {
+    2961             :     int in_sock = -1;
+    2962             : 
+    2963             :     PRINT_FUNCTION_VERBOSE(verbose);
+    2964             : 
+    2965             :     if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
+    2966             :         dlt_vlog(LOG_ERR,
+    2967             :                  "%s: Invalid parameters\n",
+    2968             :                  __func__);
+    2969             :         return DLT_RETURN_WRONG_PARAMETER;
+    2970             :     }
+    2971             : 
+    2972             :     /* event from server socket, new connection */
+    2973             : 
+    2974             :     if ((in_sock = accept(receiver->fd, NULL, NULL)) < 0) {
+    2975             :         dlt_vlog(LOG_ERR, "accept() on UNIX socket %d failed: %s\n", receiver->fd, strerror(errno));
+    2976             :         return -1;
+    2977             :     }
+    2978             : 
+    2979             :     /* check if file file descriptor was already used, and make it invalid if it
+    2980             :      * is reused. This prevents sending messages to wrong file descriptor */
+    2981             :     dlt_daemon_applications_invalidate_fd(daemon, daemon->ecuid, in_sock, verbose);
+    2982             :     dlt_daemon_contexts_invalidate_fd(daemon, daemon->ecuid, in_sock, verbose);
+    2983             : 
+    2984             :     if (dlt_connection_create(daemon_local,
+    2985             :                               &daemon_local->pEvent,
+    2986             :                               in_sock,
+    2987             :                               POLLIN,
+    2988             :                               DLT_CONNECTION_APP_MSG)) {
+    2989             :         dlt_log(LOG_ERR, "Failed to register new application. \n");
+    2990             :         close(in_sock);
+    2991             :         return -1;
+    2992             :     }
+    2993             : 
+    2994             :     if (verbose)
+    2995             :         dlt_vlog(LOG_INFO, "New connection to application established\n");
+    2996             : 
+    2997             :     return 0;
+    2998             : }
+    2999             : #endif
+    3000             : 
+    3001           4 : int dlt_daemon_process_control_messages(
+    3002             :     DltDaemon *daemon,
+    3003             :     DltDaemonLocal *daemon_local,
+    3004             :     DltReceiver *receiver,
+    3005             :     int verbose)
+    3006             : {
+    3007             :     int bytes_to_be_removed = 0;
+    3008             : 
+    3009           4 :     PRINT_FUNCTION_VERBOSE(verbose);
+    3010             : 
+    3011           4 :     if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
+    3012           0 :         dlt_log(LOG_ERR,
+    3013             :                 "Invalid function parameters used for function "
+    3014             :                 "dlt_daemon_process_control_messages()\n");
+    3015           0 :         return -1;
+    3016             :     }
+    3017             : 
+    3018           4 :     if (dlt_receiver_receive(receiver) <= 0) {
+    3019           2 :         dlt_daemon_close_socket(receiver->fd,
+    3020             :                                 daemon,
+    3021             :                                 daemon_local,
+    3022             :                                 verbose);
+    3023             :         /* FIXME: Why the hell do we need to close the socket
+    3024             :          * on control message reception ??
+    3025             :          */
+    3026           2 :         return 0;
+    3027             :     }
+    3028             : 
+    3029             :     /* Process all received messages */
+    3030           4 :     while (dlt_message_read(
+    3031             :                &(daemon_local->msg),
+    3032           4 :                (uint8_t *)receiver->buf,
+    3033           4 :                (unsigned int) receiver->bytesRcvd,
+    3034             :                daemon_local->flags.nflag,
+    3035           4 :                daemon_local->flags.vflag) == DLT_MESSAGE_ERROR_OK) {
+    3036             :         /* Check for control message */
+    3037           2 :         if ((receiver->fd > 0) &&
+    3038           2 :             DLT_MSG_IS_CONTROL_REQUEST(&(daemon_local->msg)))
+    3039           2 :             dlt_daemon_client_process_control(receiver->fd,
+    3040             :                                               daemon, daemon_local,
+    3041             :                                               &(daemon_local->msg),
+    3042             :                                               daemon_local->flags.vflag);
+    3043             : 
+    3044           2 :         bytes_to_be_removed = (int) (daemon_local->msg.headersize +
+    3045           2 :             daemon_local->msg.datasize -
+    3046             :             sizeof(DltStorageHeader));
+    3047             : 
+    3048           2 :         if (daemon_local->msg.found_serialheader)
+    3049             :             bytes_to_be_removed += (int) sizeof(dltSerialHeader);
+    3050             : 
+    3051           2 :         if (daemon_local->msg.resync_offset)
+    3052           0 :             bytes_to_be_removed += daemon_local->msg.resync_offset;
+    3053             : 
+    3054           2 :         if (dlt_receiver_remove(receiver, bytes_to_be_removed) == -1) {
+    3055           0 :             dlt_log(LOG_WARNING,
+    3056             :                     "Can't remove bytes from receiver for sockets\n");
+    3057           0 :             return -1;
+    3058             :         }
+    3059             :     } /* while */
+    3060             : 
+    3061           2 :     if (dlt_receiver_move_to_begin(receiver) == -1) {
+    3062           0 :         dlt_log(LOG_WARNING, "Can't move bytes to beginning of receiver buffer for sockets\n");
+    3063           0 :         return -1;
+    3064             :     }
+    3065             : 
+    3066             :     return 0;
+    3067             : }
+    3068             : 
+    3069           0 : static int dlt_daemon_process_user_message_not_sup(DltDaemon *daemon,
+    3070             :                                                    DltDaemonLocal *daemon_local,
+    3071             :                                                    DltReceiver *receiver,
+    3072             :                                                    int verbose)
+    3073             : {
+    3074           0 :     DltUserHeader *userheader = (DltUserHeader *)(receiver->buf);
+    3075             :     (void)daemon;
+    3076             :     (void)daemon_local;
+    3077             : 
+    3078           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    3079             : 
+    3080           0 :     dlt_vlog(LOG_ERR, "Invalid user message type received: %u!\n",
+    3081             :              userheader->message);
+    3082             : 
+    3083             :     /* remove user header */
+    3084           0 :     if (dlt_receiver_remove(receiver, sizeof(DltUserHeader)) == -1)
+    3085           0 :         dlt_log(LOG_WARNING,
+    3086             :                 "Can't remove bytes from receiver for user messages\n");
+    3087             : 
+    3088           0 :     return -1;
+    3089             : }
+    3090             : 
+    3091             : static dlt_daemon_process_user_message_func process_user_func[DLT_USER_MESSAGE_NOT_SUPPORTED] = {
+    3092             :     dlt_daemon_process_user_message_not_sup,
+    3093             :     dlt_daemon_process_user_message_log,
+    3094             :     dlt_daemon_process_user_message_register_application,
+    3095             :     dlt_daemon_process_user_message_unregister_application,
+    3096             :     dlt_daemon_process_user_message_register_context,
+    3097             :     dlt_daemon_process_user_message_unregister_context,
+    3098             :     dlt_daemon_process_user_message_not_sup,
+    3099             :     dlt_daemon_process_user_message_not_sup,
+    3100             :     dlt_daemon_process_user_message_overflow,
+    3101             :     dlt_daemon_process_user_message_set_app_ll_ts,
+    3102             :     dlt_daemon_process_user_message_not_sup,
+    3103             :     dlt_daemon_process_user_message_not_sup,
+    3104             :     dlt_daemon_process_user_message_not_sup,
+    3105             :     dlt_daemon_process_user_message_marker,
+    3106             :     dlt_daemon_process_user_message_not_sup,
+    3107             :     dlt_daemon_process_user_message_not_sup
+    3108             : };
+    3109             : 
+    3110        1523 : int dlt_daemon_process_user_messages(DltDaemon *daemon,
+    3111             :                                      DltDaemonLocal *daemon_local,
+    3112             :                                      DltReceiver *receiver,
+    3113             :                                      int verbose)
+    3114             : {
+    3115             :     int offset = 0;
+    3116             :     int run_loop = 1;
+    3117             :     int32_t min_size = (int32_t) sizeof(DltUserHeader);
+    3118             :     DltUserHeader *userheader;
+    3119             :     int recv;
+    3120             : 
+    3121        1523 :     PRINT_FUNCTION_VERBOSE(verbose);
+    3122             : 
+    3123        1523 :     if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
+    3124           0 :         dlt_log(LOG_ERR,
+    3125             :                 "Invalid function parameters used for function "
+    3126             :                 "dlt_daemon_process_user_messages()\n");
+    3127           0 :         return -1;
+    3128             :     }
+    3129             : 
+    3130        1523 :     recv = dlt_receiver_receive(receiver);
+    3131             : 
+    3132        1523 :     if (recv <= 0 && receiver->type == DLT_RECEIVE_SOCKET) {
+    3133           0 :         dlt_daemon_close_socket(receiver->fd,
+    3134             :                                 daemon,
+    3135             :                                 daemon_local,
+    3136             :                                 verbose);
+    3137           0 :         return 0;
+    3138             :     }
+    3139        1523 :     else if (recv < 0) {
+    3140           0 :         dlt_log(LOG_WARNING,
+    3141             :                 "dlt_receiver_receive_fd() for user messages failed!\n");
+    3142           0 :         return -1;
+    3143             :     }
+    3144             : 
+    3145             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+    3146             :     /* Count up number of received bytes from FIFO */
+    3147             :     if (receiver->bytesRcvd > receiver->lastBytesRcvd)
+    3148             :     {
+    3149             :         daemon->bytes_recv += receiver->bytesRcvd - receiver->lastBytesRcvd;
+    3150             :     }
+    3151             : #endif
+    3152             : 
+    3153             :     /* look through buffer as long as data is in there */
+    3154        7420 :     while ((receiver->bytesRcvd >= min_size) && run_loop) {
+    3155             :         dlt_daemon_process_user_message_func func = NULL;
+    3156             : 
+    3157             :         offset = 0;
+    3158        5897 :         userheader = (DltUserHeader *)(receiver->buf + offset);
+    3159             : 
+    3160        5897 :         while (!dlt_user_check_userheader(userheader) &&
+    3161           0 :                (offset + min_size <= receiver->bytesRcvd)) {
+    3162             :             /* resync if necessary */
+    3163           0 :             offset++;
+    3164           0 :             userheader = (DltUserHeader *)(receiver->buf + offset);
+    3165             :         }
+    3166             : 
+    3167             :         /* Check for user header pattern */
+    3168        5897 :         if (!dlt_user_check_userheader(userheader))
+    3169             :             break;
+    3170             : 
+    3171             :         /* Set new start offset */
+    3172        5897 :         if (offset > 0) {
+    3173           0 :             if (dlt_receiver_remove(receiver, offset) == -1) {
+    3174           0 :                 dlt_log(LOG_WARNING,
+    3175             :                         "Can't remove offset from receiver\n");
+    3176           0 :                 return -1;
+    3177             :             }
+    3178             :         }
+    3179             : 
+    3180        5897 :         if (userheader->message >= DLT_USER_MESSAGE_NOT_SUPPORTED)
+    3181             :             func = dlt_daemon_process_user_message_not_sup;
+    3182             :         else
+    3183        5897 :             func = process_user_func[userheader->message];
+    3184             : 
+    3185        5897 :         if (func(daemon,
+    3186             :                  daemon_local,
+    3187             :                  receiver,
+    3188             :                  daemon_local->flags.vflag) == -1)
+    3189             :             run_loop = 0;
+    3190             :     }
+    3191             : 
+    3192             :     /* keep not read data in buffer */
+    3193        1523 :     if (dlt_receiver_move_to_begin(receiver) == -1) {
+    3194           0 :         dlt_log(LOG_WARNING,
+    3195             :                 "Can't move bytes to beginning of receiver buffer for user "
+    3196             :                 "messages\n");
+    3197           0 :         return -1;
+    3198             :     }
+    3199             : 
+    3200             :     return 0;
+    3201             : }
+    3202             : 
+    3203           0 : int dlt_daemon_process_user_message_overflow(DltDaemon *daemon,
+    3204             :                                              DltDaemonLocal *daemon_local,
+    3205             :                                              DltReceiver *rec,
+    3206             :                                              int verbose)
+    3207             : {
+    3208             :     uint32_t len = sizeof(DltUserControlMsgBufferOverflow);
+    3209             :     DltUserControlMsgBufferOverflow userpayload;
+    3210             : 
+    3211           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    3212             : 
+    3213           0 :     if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
+    3214           0 :         dlt_vlog(LOG_ERR, "Invalid function parameters used for %s\n",
+    3215             :                  __func__);
+    3216           0 :         return -1;
+    3217             :     }
+    3218             : 
+    3219           0 :     if (dlt_receiver_check_and_get(rec,
+    3220             :                                    &userpayload,
+    3221             :                                    len,
+    3222             :                                    DLT_RCV_SKIP_HEADER | DLT_RCV_REMOVE) < 0)
+    3223             :         /* Not enough bytes received */
+    3224             :         return -1;
+    3225             : 
+    3226             :     /* Store in daemon, that a message buffer overflow has occured */
+    3227             :     /* look if TCP connection to client is available or it least message can be put into buffer */
+    3228           0 :     if (dlt_daemon_control_message_buffer_overflow(DLT_DAEMON_SEND_TO_ALL,
+    3229             :                                                    daemon,
+    3230             :                                                    daemon_local,
+    3231             :                                                    userpayload.overflow_counter,
+    3232             :                                                    userpayload.apid,
+    3233             :                                                    verbose))
+    3234             :         /* there was an error when storing message */
+    3235             :         /* add the counter of lost messages to the daemon counter */
+    3236           0 :         daemon->overflow_counter += userpayload.overflow_counter;
+    3237             : 
+    3238             :     return 0;
+    3239             : }
+    3240             : 
+    3241           0 : int dlt_daemon_send_message_overflow(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
+    3242             : {
+    3243             :     int ret;
+    3244           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    3245             : 
+    3246           0 :     if ((daemon == 0) || (daemon_local == 0)) {
+    3247           0 :         dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_process_user_message_overflow()\n");
+    3248           0 :         return DLT_DAEMON_ERROR_UNKNOWN;
+    3249             :     }
+    3250             : 
+    3251             :     /* Store in daemon, that a message buffer overflow has occured */
+    3252           0 :     if ((ret =
+    3253           0 :              dlt_daemon_control_message_buffer_overflow(DLT_DAEMON_SEND_TO_ALL, daemon, daemon_local,
+    3254             :                                                         daemon->overflow_counter,
+    3255             :                                                         "", verbose)))
+    3256           0 :         return ret;
+    3257             : 
+    3258             :     return DLT_DAEMON_ERROR_OK;
+    3259             : }
+    3260             : 
+    3261           7 : int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
+    3262             :                                                          DltDaemonLocal *daemon_local,
+    3263             :                                                          DltReceiver *rec,
+    3264             :                                                          int verbose)
+    3265             : {
+    3266             :     uint32_t len = sizeof(DltUserControlMsgRegisterApplication);
+    3267             :     uint32_t to_remove = 0;
+    3268             :     DltDaemonApplication *application = NULL;
+    3269             :     DltDaemonApplication *old_application = NULL;
+    3270             :     pid_t old_pid = 0;
+    3271           7 :     char description[DLT_DAEMON_DESCSIZE + 1] = { '\0' };
+    3272             :     DltUserControlMsgRegisterApplication userapp;
+    3273             :     char *origin;
+    3274             :     int fd = -1;
+    3275             : 
+    3276           7 :     PRINT_FUNCTION_VERBOSE(verbose);
+    3277             : 
+    3278           7 :     if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
+    3279           0 :         dlt_vlog(LOG_ERR, "Invalid function parameters used for %s\n",
+    3280             :                  __func__);
+    3281           0 :         return -1;
+    3282             :     }
+    3283             : 
+    3284             :     memset(&userapp, 0, sizeof(DltUserControlMsgRegisterApplication));
+    3285           7 :     origin = rec->buf;
+    3286             : 
+    3287             :     /* Adding temp variable to check the return value */
+    3288             :     int temp = 0;
+    3289             : 
+    3290             :     /* We shall not remove data before checking that everything is there. */
+    3291           7 :     temp = dlt_receiver_check_and_get(rec,
+    3292             :                                            &userapp,
+    3293             :                                            len,
+    3294             :                                            DLT_RCV_SKIP_HEADER);
+    3295             : 
+    3296           7 :     if (temp < 0)
+    3297             :         /* Not enough bytes received */
+    3298             :         return -1;
+    3299             :     else {
+    3300           7 :         to_remove = (uint32_t) temp;
+    3301             :     }
+    3302             : 
+    3303           7 :     len = userapp.description_length;
+    3304             : 
+    3305           7 :     if (len > DLT_DAEMON_DESCSIZE) {
+    3306             :         len = DLT_DAEMON_DESCSIZE;
+    3307           0 :         dlt_log(LOG_WARNING, "Application description exceeds limit\n");
+    3308             :     }
+    3309             : 
+    3310             :     /* adjust buffer pointer */
+    3311           7 :     rec->buf += to_remove + sizeof(DltUserHeader);
+    3312             : 
+    3313           7 :     if (dlt_receiver_check_and_get(rec, description, len, DLT_RCV_NONE) < 0) {
+    3314           0 :         dlt_log(LOG_ERR, "Unable to get application description\n");
+    3315             :         /* in case description was not readable, set dummy description */
+    3316             :         memcpy(description, "Unknown", sizeof("Unknown"));
+    3317             : 
+    3318             :         /* unknown len of original description, set to 0 to not remove in next
+    3319             :          * step. Because message buffer is re-adjusted the corrupted description
+    3320             :          * is ignored. */
+    3321             :         len = 0;
+    3322             :     }
+    3323             : 
+    3324             :     /* adjust to_remove */
+    3325           7 :     to_remove += (uint32_t) sizeof(DltUserHeader) + len;
+    3326             :     /* point to begin of message */
+    3327           7 :     rec->buf = origin;
+    3328             : 
+    3329             :     /* We can now remove data. */
+    3330           7 :     if (dlt_receiver_remove(rec, (int) to_remove) != DLT_RETURN_OK) {
+    3331           0 :         dlt_log(LOG_WARNING, "Can't remove bytes from receiver\n");
+    3332           0 :         return -1;
+    3333             :     }
+    3334             : 
+    3335           7 :     old_application = dlt_daemon_application_find(daemon, userapp.apid, daemon->ecuid, verbose);
+    3336             : 
+    3337           7 :     if (old_application != NULL)
+    3338           0 :         old_pid = old_application->pid;
+    3339             : 
+    3340           7 :     if (rec->type == DLT_RECEIVE_SOCKET)
+    3341           0 :         fd = rec->fd; /* For sockets, an app specific fd has already been created with accept(). */
+    3342             : 
+    3343           7 :     application = dlt_daemon_application_add(daemon,
+    3344             :                                              userapp.apid,
+    3345             :                                              userapp.pid,
+    3346             :                                              description,
+    3347             :                                              fd,
+    3348             :                                              daemon->ecuid,
+    3349             :                                              verbose);
+    3350             : 
+    3351             :     /* send log state to new application */
+    3352           7 :     dlt_daemon_user_send_log_state(daemon, application, verbose);
+    3353             : 
+    3354           7 :     if (application == NULL) {
+    3355           0 :         dlt_vlog(LOG_WARNING, "Can't add ApplicationID '%.4s' for PID %d\n",
+    3356             :                  userapp.apid, userapp.pid);
+    3357           0 :         return -1;
+    3358             :     }
+    3359           7 :     else if (old_pid != application->pid)
+    3360             :     {
+    3361           7 :         char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
+    3362             : 
+    3363           7 :         snprintf(local_str,
+    3364             :                  DLT_DAEMON_TEXTBUFSIZE,
+    3365             :                  "ApplicationID '%.4s' registered for PID %d, Description=%s",
+    3366           7 :                  application->apid,
+    3367             :                  application->pid,
+    3368             :                  application->application_description);
+    3369           7 :         dlt_daemon_log_internal(daemon, daemon_local, local_str, DLT_LOG_INFO,
+    3370             :                                 DLT_DAEMON_APP_ID, DLT_DAEMON_CTX_ID,
+    3371             :                                 daemon_local->flags.vflag);
+    3372           7 :         dlt_vlog(LOG_DEBUG, "%s%s", local_str, "\n");
+    3373             :     }
+    3374             : 
+    3375             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+    3376             :     if (dlt_daemon_user_send_trace_load_config(daemon, application, verbose) != DLT_RETURN_OK)
+    3377             :         dlt_vlog(LOG_WARNING, "Cannot send trace config to Apid: %.4s, PID: %d\n",
+    3378             :                  application->apid, application->pid);
+    3379             : #endif
+    3380             : 
+    3381             :     return 0;
+    3382             : }
+    3383             : 
+    3384          38 : int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
+    3385             :                                                      DltDaemonLocal *daemon_local,
+    3386             :                                                      DltReceiver *rec,
+    3387             :                                                      int verbose)
+    3388             : {
+    3389             :     uint32_t to_remove = 0;
+    3390             :     uint32_t len = sizeof(DltUserControlMsgRegisterContext);
+    3391             :     DltUserControlMsgRegisterContext userctxt;
+    3392          38 :     char description[DLT_DAEMON_DESCSIZE + 1] = { '\0' };
+    3393             :     DltDaemonApplication *application = NULL;
+    3394             :     DltDaemonContext *context = NULL;
+    3395             :     DltServiceGetLogInfoRequest *req = NULL;
+    3396             :     char *origin;
+    3397             : 
+    3398             :     DltMessage msg;
+    3399             : 
+    3400          38 :     PRINT_FUNCTION_VERBOSE(verbose);
+    3401             : 
+    3402          38 :     if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
+    3403           0 :         dlt_vlog(LOG_ERR, "Invalid function parameters used for %s\n",
+    3404             :                  __func__);
+    3405           0 :         return -1;
+    3406             :     }
+    3407             : 
+    3408             :     memset(&userctxt, 0, sizeof(DltUserControlMsgRegisterContext));
+    3409          38 :     origin = rec->buf;
+    3410             : 
+    3411             :     /* Adding temp variable to check the return value */
+    3412             :     int temp = 0;
+    3413             : 
+    3414          38 :     temp = dlt_receiver_check_and_get(rec,
+    3415             :                                            &userctxt,
+    3416             :                                            len,
+    3417             :                                            DLT_RCV_SKIP_HEADER);
+    3418             : 
+    3419          38 :     if (temp < 0)
+    3420             :         /* Not enough bytes received */
+    3421             :         return -1;
+    3422             :     else {
+    3423          38 :         to_remove = (uint32_t) temp;
+    3424             :     }
+    3425             : 
+    3426          38 :     len = userctxt.description_length;
+    3427             : 
+    3428          38 :     if (len > DLT_DAEMON_DESCSIZE) {
+    3429           0 :         dlt_vlog(LOG_WARNING, "Context description exceeds limit: %u\n", len);
+    3430             :         len = DLT_DAEMON_DESCSIZE;
+    3431             :     }
+    3432             : 
+    3433             :     /* adjust buffer pointer */
+    3434          38 :     rec->buf += to_remove + sizeof(DltUserHeader);
+    3435             : 
+    3436          38 :     if (dlt_receiver_check_and_get(rec, description, len, DLT_RCV_NONE) < 0) {
+    3437           0 :         dlt_log(LOG_ERR, "Unable to get context description\n");
+    3438             :         /* in case description was not readable, set dummy description */
+    3439             :         memcpy(description, "Unknown", sizeof("Unknown"));
+    3440             : 
+    3441             :         /* unknown len of original description, set to 0 to not remove in next
+    3442             :          * step. Because message buffer is re-adjusted the corrupted description
+    3443             :          * is ignored. */
+    3444             :         len = 0;
+    3445             :     }
+    3446             : 
+    3447             :     /* adjust to_remove */
+    3448          38 :     to_remove += (uint32_t) sizeof(DltUserHeader) + len;
+    3449             :     /* point to begin of message */
+    3450          38 :     rec->buf = origin;
+    3451             : 
+    3452             :     /* We can now remove data. */
+    3453          38 :     if (dlt_receiver_remove(rec, (int) to_remove) != DLT_RETURN_OK) {
+    3454           0 :         dlt_log(LOG_WARNING, "Can't remove bytes from receiver\n");
+    3455           0 :         return -1;
+    3456             :     }
+    3457             : 
+    3458          38 :     application = dlt_daemon_application_find(daemon,
+    3459             :                                               userctxt.apid,
+    3460          38 :                                               daemon->ecuid,
+    3461             :                                               verbose);
+    3462             : 
+    3463          38 :     if (application == 0) {
+    3464           0 :         dlt_vlog(LOG_WARNING,
+    3465             :                  "ApID '%.4s' not found for new ContextID '%.4s' in %s\n",
+    3466             :                  userctxt.apid,
+    3467             :                  userctxt.ctid,
+    3468             :                  __func__);
+    3469             : 
+    3470           0 :         return 0;
+    3471             :     }
+    3472             : 
+    3473             :     /* Set log level */
+    3474          38 :     if (userctxt.log_level == DLT_USER_LOG_LEVEL_NOT_SET) {
+    3475          38 :         userctxt.log_level = DLT_LOG_DEFAULT;
+    3476             :     } else {
+    3477             :         /* Plausibility check */
+    3478           0 :         if ((userctxt.log_level < DLT_LOG_DEFAULT) ||
+    3479             :                 (userctxt.log_level > DLT_LOG_VERBOSE)) {
+    3480             :             return -1;
+    3481             :         }
+    3482             :     }
+    3483             : 
+    3484             :     /* Set trace status */
+    3485          38 :     if (userctxt.trace_status == DLT_USER_TRACE_STATUS_NOT_SET) {
+    3486          38 :         userctxt.trace_status = DLT_TRACE_STATUS_DEFAULT;
+    3487             :     } else {
+    3488             :         /* Plausibility check */
+    3489           0 :         if ((userctxt.trace_status < DLT_TRACE_STATUS_DEFAULT) ||
+    3490             :                 (userctxt.trace_status > DLT_TRACE_STATUS_ON)) {
+    3491             :             return -1;
+    3492             :         }
+    3493             :     }
+    3494             : 
+    3495          38 :     context = dlt_daemon_context_add(daemon,
+    3496             :                                      userctxt.apid,
+    3497             :                                      userctxt.ctid,
+    3498          38 :                                      userctxt.log_level,
+    3499          38 :                                      userctxt.trace_status,
+    3500             :                                      userctxt.log_level_pos,
+    3501             :                                      application->user_handle,
+    3502             :                                      description,
+    3503             :                                      daemon->ecuid,
+    3504             :                                      verbose);
+    3505             : 
+    3506          38 :     if (context == 0) {
+    3507           0 :         dlt_vlog(LOG_WARNING,
+    3508             :                  "Can't add ContextID '%.4s' for ApID '%.4s'\n in %s",
+    3509             :                  userctxt.ctid, userctxt.apid, __func__);
+    3510           0 :         return -1;
+    3511             :     }
+    3512             :     else {
+    3513          38 :         char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
+    3514             : 
+    3515          38 :         snprintf(local_str,
+    3516             :                  DLT_DAEMON_TEXTBUFSIZE,
+    3517             :                  "ContextID '%.4s' registered for ApID '%.4s', Description=%s",
+    3518          38 :                  context->ctid,
+    3519          38 :                  context->apid,
+    3520             :                  context->context_description);
+    3521             : 
+    3522          38 :         if (verbose)
+    3523           0 :             dlt_daemon_log_internal(daemon, daemon_local, local_str,
+    3524             :                                     DLT_LOG_INFO, DLT_DAEMON_APP_ID,
+    3525             :                                     DLT_DAEMON_CTX_ID, verbose);
+    3526             : 
+    3527          38 :         dlt_vlog(LOG_DEBUG, "%s%s", local_str, "\n");
+    3528             :     }
+    3529             : 
+    3530          38 :     if (daemon_local->flags.offlineLogstorageMaxDevices)
+    3531             :         /* Store log level set for offline logstorage into context structure*/
+    3532          33 :         context->storage_log_level =
+    3533          33 :             (int8_t) dlt_daemon_logstorage_get_loglevel(daemon,
+    3534          33 :                                                (int8_t) daemon_local->flags.offlineLogstorageMaxDevices,
+    3535             :                                                userctxt.apid,
+    3536             :                                                userctxt.ctid);
+    3537             :     else
+    3538           5 :         context->storage_log_level = DLT_LOG_DEFAULT;
+    3539             : 
+    3540             :     /* Create automatic get log info response for registered context */
+    3541          38 :     if (daemon_local->flags.rflag) {
+    3542             :         /* Prepare request for get log info with one application and one context */
+    3543           0 :         if (dlt_message_init(&msg, verbose) == -1) {
+    3544           0 :             dlt_log(LOG_WARNING, "Can't initialize message");
+    3545           0 :             return -1;
+    3546             :         }
+    3547             : 
+    3548           0 :         msg.datasize = sizeof(DltServiceGetLogInfoRequest);
+    3549             : 
+    3550           0 :         if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
+    3551           0 :             free(msg.databuffer);
+    3552           0 :             msg.databuffer = 0;
+    3553             :         }
+    3554             : 
+    3555           0 :         if (msg.databuffer == 0) {
+    3556           0 :             msg.databuffer = (uint8_t *)malloc(msg.datasize);
+    3557           0 :             msg.databuffersize = msg.datasize;
+    3558             :         }
+    3559             : 
+    3560           0 :         if (msg.databuffer == 0) {
+    3561           0 :             dlt_log(LOG_WARNING, "Can't allocate buffer for get log info message\n");
+    3562           0 :             return -1;
+    3563             :         }
+    3564             : 
+    3565             :         req = (DltServiceGetLogInfoRequest *)msg.databuffer;
+    3566             : 
+    3567           0 :         req->service_id = DLT_SERVICE_ID_GET_LOG_INFO;
+    3568           0 :         req->options = (uint8_t) daemon_local->flags.autoResponseGetLogInfoOption;
+    3569           0 :         dlt_set_id(req->apid, userctxt.apid);
+    3570           0 :         dlt_set_id(req->ctid, userctxt.ctid);
+    3571           0 :         dlt_set_id(req->com, "remo");
+    3572             : 
+    3573           0 :         dlt_daemon_control_get_log_info(DLT_DAEMON_SEND_TO_ALL, daemon, daemon_local, &msg, verbose);
+    3574             : 
+    3575           0 :         dlt_message_free(&msg, verbose);
+    3576             :     }
+    3577             : 
+    3578          38 :     if (context->user_handle >= DLT_FD_MINIMUM) {
+    3579          38 :         if ((userctxt.log_level == DLT_LOG_DEFAULT) || (userctxt.trace_status == DLT_TRACE_STATUS_DEFAULT)) {
+    3580             :             /* This call also replaces the default values with the values defined for default */
+    3581          38 :             if (dlt_daemon_user_send_log_level(daemon, context, verbose) == -1) {
+    3582           0 :                 dlt_vlog(LOG_WARNING, "Can't send current log level as response to %s for (%.4s;%.4s)\n",
+    3583             :                          __func__,
+    3584             :                          context->apid,
+    3585             :                          context->ctid);
+    3586           0 :                 return -1;
+    3587             :             }
+    3588             :         }
+    3589             :     }
+    3590             : 
+    3591             :     return 0;
+    3592             : }
+    3593             : 
+    3594           6 : int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon,
+    3595             :                                                            DltDaemonLocal *daemon_local,
+    3596             :                                                            DltReceiver *rec,
+    3597             :                                                            int verbose)
+    3598             : {
+    3599             :     uint32_t len = sizeof(DltUserControlMsgUnregisterApplication);
+    3600             :     DltUserControlMsgUnregisterApplication userapp;
+    3601             :     DltDaemonApplication *application = NULL;
+    3602             :     DltDaemonContext *context;
+    3603             :     int i, offset_base;
+    3604             :     DltDaemonRegisteredUsers *user_list = NULL;
+    3605             : 
+    3606           6 :     PRINT_FUNCTION_VERBOSE(verbose);
+    3607             : 
+    3608           6 :     if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
+    3609           0 :         dlt_vlog(LOG_ERR,
+    3610             :                  "Invalid function parameters used for %s\n",
+    3611             :                  __func__);
+    3612           0 :         return -1;
+    3613             :     }
+    3614             : 
+    3615           6 :     if (dlt_receiver_check_and_get(rec,
+    3616             :                                    &userapp,
+    3617             :                                    len,
+    3618             :                                    DLT_RCV_SKIP_HEADER | DLT_RCV_REMOVE) < 0)
+    3619             :         /* Not enough bytes received */
+    3620             :         return -1;
+    3621             : 
+    3622           6 :     user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+    3623             : 
+    3624           6 :     if (user_list == NULL)
+    3625             :         return -1;
+    3626             : 
+    3627           6 :     if (user_list->num_applications > 0) {
+    3628             :         /* Delete this application and all corresponding contexts
+    3629             :          * for this application from internal table.
+    3630             :          */
+    3631           6 :         application = dlt_daemon_application_find(daemon,
+    3632             :                                                   userapp.apid,
+    3633             :                                                   daemon->ecuid,
+    3634             :                                                   verbose);
+    3635             : 
+    3636           6 :         if (application) {
+    3637             :             /* Calculate start offset within contexts[] */
+    3638             :             offset_base = 0;
+    3639             : 
+    3640           6 :             for (i = 0; i < (application - (user_list->applications)); i++)
+    3641           0 :                 offset_base += user_list->applications[i].num_contexts;
+    3642             : 
+    3643           6 :             for (i = (application->num_contexts) - 1; i >= 0; i--) {
+    3644           0 :                 context = &(user_list->contexts[offset_base + i]);
+    3645             : 
+    3646           0 :                 if (context) {
+    3647             :                     /* Delete context */
+    3648           0 :                     if (dlt_daemon_context_del(daemon,
+    3649             :                                                context,
+    3650             :                                                daemon->ecuid,
+    3651             :                                                verbose) == -1) {
+    3652           0 :                         dlt_vlog(LOG_WARNING,
+    3653             :                                  "Can't delete CtID '%.4s' for ApID '%.4s' in %s\n",
+    3654           0 :                                  context->ctid,
+    3655           0 :                                  context->apid,
+    3656             :                                  __func__);
+    3657           0 :                         return -1;
+    3658             :                     }
+    3659             :                 }
+    3660             :             }
+    3661             : 
+    3662             :             /* Delete this application entry from internal table*/
+    3663           6 :             if (dlt_daemon_application_del(daemon,
+    3664             :                                            application,
+    3665             :                                            daemon->ecuid,
+    3666             :                                            verbose) == -1) {
+    3667           0 :                 dlt_vlog(LOG_WARNING,
+    3668             :                          "Can't delete ApID '%.4s' in %s\n",
+    3669           0 :                          application->apid,
+    3670             :                          __func__);
+    3671           0 :                 return -1;
+    3672             :             }
+    3673             :             else {
+    3674           6 :                 char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
+    3675             : 
+    3676             :                 snprintf(local_str,
+    3677             :                          DLT_DAEMON_TEXTBUFSIZE,
+    3678             :                          "Unregistered ApID '%.4s'",
+    3679             :                          userapp.apid);
+    3680           6 :                 dlt_daemon_log_internal(daemon, daemon_local, local_str,
+    3681             :                                         DLT_LOG_INFO, DLT_DAEMON_APP_ID,
+    3682             :                                         DLT_DAEMON_CTX_ID, verbose);
+    3683           6 :                 dlt_vlog(LOG_DEBUG, "%s%s", local_str, "\n");
+    3684             :             }
+    3685             :         }
+    3686             :     }
+    3687             : 
+    3688             :     return 0;
+    3689             : }
+    3690             : 
+    3691          37 : int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon,
+    3692             :                                                        DltDaemonLocal *daemon_local,
+    3693             :                                                        DltReceiver *rec,
+    3694             :                                                        int verbose)
+    3695             : {
+    3696             :     uint32_t len = sizeof(DltUserControlMsgUnregisterContext);
+    3697             :     DltUserControlMsgUnregisterContext userctxt;
+    3698             :     DltDaemonContext *context;
+    3699             : 
+    3700          37 :     PRINT_FUNCTION_VERBOSE(verbose);
+    3701             : 
+    3702          37 :     if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
+    3703           0 :         dlt_vlog(LOG_ERR,
+    3704             :                  "Invalid function parameters used for %s\n",
+    3705             :                  __func__);
+    3706             : 
+    3707           0 :         return -1;
+    3708             :     }
+    3709             : 
+    3710          37 :     if (dlt_receiver_check_and_get(rec,
+    3711             :                                    &userctxt,
+    3712             :                                    len,
+    3713             :                                    DLT_RCV_SKIP_HEADER | DLT_RCV_REMOVE) < 0)
+    3714             :         /* Not enough bytes received */
+    3715             :         return -1;
+    3716             : 
+    3717          37 :     context = dlt_daemon_context_find(daemon,
+    3718             :                                       userctxt.apid,
+    3719             :                                       userctxt.ctid,
+    3720          37 :                                       daemon->ecuid,
+    3721             :                                       verbose);
+    3722             : 
+    3723             :     /* In case the daemon is loaded with predefined contexts and its context
+    3724             :      * unregisters, the context information will not be deleted from daemon's
+    3725             :      * table until its parent application is unregistered.
+    3726             :      */
+    3727          37 :     if (context && (context->predefined == false)) {
+    3728             :         /* Delete this connection entry from internal table*/
+    3729          37 :         if (dlt_daemon_context_del(daemon, context, daemon->ecuid, verbose) == -1) {
+    3730           0 :             dlt_vlog(LOG_WARNING,
+    3731             :                      "Can't delete CtID '%.4s' for ApID '%.4s' in %s\n",
+    3732             :                      userctxt.ctid,
+    3733             :                      userctxt.apid,
+    3734             :                      __func__);
+    3735           0 :             return -1;
+    3736             :         }
+    3737             :         else {
+    3738          37 :             char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
+    3739             : 
+    3740             :             snprintf(local_str,
+    3741             :                      DLT_DAEMON_TEXTBUFSIZE,
+    3742             :                      "Unregistered CtID '%.4s' for ApID '%.4s'",
+    3743             :                      userctxt.ctid,
+    3744             :                      userctxt.apid);
+    3745             : 
+    3746          37 :             if (verbose)
+    3747           0 :                 dlt_daemon_log_internal(daemon, daemon_local, local_str,
+    3748             :                                         DLT_LOG_INFO, DLT_DAEMON_APP_ID,
+    3749             :                                         DLT_DAEMON_CTX_ID, verbose);
+    3750             : 
+    3751          37 :             dlt_vlog(LOG_DEBUG, "%s%s", local_str, "\n");
+    3752             :         }
+    3753             :     }
+    3754             : 
+    3755             :     /* Create automatic unregister context response for unregistered context */
+    3756          37 :     if (daemon_local->flags.rflag)
+    3757           0 :         dlt_daemon_control_message_unregister_context(DLT_DAEMON_SEND_TO_ALL,
+    3758             :                                                       daemon,
+    3759             :                                                       daemon_local,
+    3760             :                                                       userctxt.apid,
+    3761             :                                                       userctxt.ctid,
+    3762             :                                                       "remo",
+    3763             :                                                       verbose);
+    3764             : 
+    3765             :     return 0;
+    3766             : }
+    3767             : 
+    3768        5809 : int dlt_daemon_process_user_message_log(DltDaemon *daemon,
+    3769             :                                         DltDaemonLocal *daemon_local,
+    3770             :                                         DltReceiver *rec,
+    3771             :                                         int verbose)
+    3772             : {
+    3773             :     int ret = 0;
+    3774             :     int size = 0;
+    3775             : 
+    3776        5809 :     PRINT_FUNCTION_VERBOSE(verbose);
+    3777             : 
+    3778        5809 :     if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
+    3779           0 :         dlt_vlog(LOG_ERR, "%s: invalid function parameters.\n", __func__);
+    3780           0 :         return DLT_DAEMON_ERROR_UNKNOWN;
+    3781             :     }
+    3782             : 
+    3783             : #ifdef DLT_SYSTEMD_WATCHDOG_ENFORCE_MSG_RX_ENABLE
+    3784             :     daemon->received_message_since_last_watchdog_interval = 1;
+    3785             : #endif
+    3786             : #ifdef DLT_SHM_ENABLE
+    3787             : 
+    3788             :     /** In case of SHM, the header still received via fifo/unix_socket receiver,
+    3789             :      * so we need to remove header from the receiver.
+    3790             :      */
+    3791             :     if (dlt_receiver_remove(rec, sizeof(DltUserHeader)) < 0)
+    3792             :         /* Not enough bytes received to remove*/
+    3793             :         return DLT_DAEMON_ERROR_UNKNOWN;
+    3794             : 
+    3795             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+    3796             :     const unsigned int start_time = dlt_uptime();
+    3797             : #endif
+    3798             : 
+    3799             :     while (1) {
+    3800             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+    3801             :         const unsigned int uptime = dlt_uptime();
+    3802             :         if ((uptime - start_time) / 10000 > daemon->watchdog_trigger_interval) {
+    3803             :             dlt_vlog(LOG_WARNING,
+    3804             :                      "spent already 1 watchdog trigger interval in %s, yielding to process other events.\n", __func__);
+    3805             :             if (sd_notify(0, "WATCHDOG=1") < 0)
+    3806             :                 dlt_vlog(LOG_CRIT, "Could not reset systemd watchdog from %s\n", __func__);
+    3807             :             break;
+    3808             :         }
+    3809             : #endif
+    3810             : 
+    3811             :         /* get log message from SHM then store into receiver buffer */
+    3812             :         size = dlt_shm_pull(&(daemon_local->dlt_shm),
+    3813             :                             daemon_local->recv_buf_shm,
+    3814             :                             DLT_SHM_RCV_BUFFER_SIZE);
+    3815             : 
+    3816             :         if (size <= 0)
+    3817             :             break;
+    3818             : 
+    3819             :         ret = dlt_message_read(&(daemon_local->msg),
+    3820             :                                daemon_local->recv_buf_shm, size, 0, verbose);
+    3821             : 
+    3822             :         if (DLT_MESSAGE_ERROR_OK != ret) {
+    3823             :             dlt_shm_remove(&(daemon_local->dlt_shm));
+    3824             :             dlt_log(LOG_WARNING, "failed to read messages from shm.\n");
+    3825             :             return DLT_DAEMON_ERROR_UNKNOWN;
+    3826             :         }
+    3827             : 
+    3828             : #if defined(DLT_LOG_LEVEL_APP_CONFIG) || defined(DLT_TRACE_LOAD_CTRL_ENABLE)
+    3829             :         DltDaemonApplication *app = dlt_daemon_application_find(
+    3830             :             daemon, daemon_local->msg.extendedheader->apid, daemon->ecuid, verbose);
+    3831             : #endif
+    3832             : 
+    3833             :         /* discard non-allowed levels if enforcement is on */
+    3834             :         bool keep_message = enforce_context_ll_and_ts_keep_message(
+    3835             :             daemon_local
+    3836             : #ifdef DLT_LOG_LEVEL_APP_CONFIG
+    3837             :             , app
+    3838             : #endif
+    3839             :         );
+    3840             : 
+    3841             :         // check trace_load
+    3842             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+    3843             :         keep_message &= trace_load_keep_message(app, size, daemon, daemon_local, verbose);
+    3844             : #endif
+    3845             : 
+    3846             :         if (keep_message)
+    3847             :           dlt_daemon_client_send_message_to_all_client(daemon, daemon_local, verbose);
+    3848             : 
+    3849             :         if (DLT_DAEMON_ERROR_OK != ret)
+    3850             :             dlt_log(LOG_ERR, "failed to send message to client.\n");
+    3851             :     }
+    3852             : 
+    3853             : #else
+    3854        5809 :     ret = dlt_message_read(&(daemon_local->msg),
+    3855        5809 :                            (unsigned char *)rec->buf + sizeof(DltUserHeader),
+    3856        5809 :                            (unsigned int) ((unsigned int) rec->bytesRcvd - sizeof(DltUserHeader)),
+    3857             :                            0,
+    3858             :                            verbose);
+    3859             : 
+    3860        5809 :     if (ret != DLT_MESSAGE_ERROR_OK) {
+    3861           0 :         if (ret != DLT_MESSAGE_ERROR_SIZE)
+    3862             :             /* This is a normal usecase: The daemon reads the data in 10kb chunks.
+    3863             :              * Thus the last trace in this chunk is probably not complete and will be completed
+    3864             :              * with the next chunk read. This happens always when the FIFO is filled with more than 10kb before
+    3865             :              * the daemon is able to read from the FIFO.
+    3866             :              * Thus the loglevel of this message is set to DEBUG.
+    3867             :              * A cleaner solution would be to check more in detail whether the message is not complete (normal usecase)
+    3868             :              * or the headers are corrupted (error case). */
+    3869           0 :             dlt_log(LOG_DEBUG, "Can't read messages from receiver\n");
+    3870             : 
+    3871           0 :         if (dlt_receiver_remove(rec, rec->bytesRcvd) != DLT_RETURN_OK) {
+    3872             :             /* In certain rare scenarios where only a partial message has been received
+    3873             :              * (Eg: kernel IPC buffer memory being full), we want to discard the message
+    3874             :              * and not broadcast it forward to connected clients. Since the DLT library
+    3875             :              * checks return value of the writev() call against the sent total message
+    3876             :              * length, the partial message will be buffered and retransmitted again.
+    3877             :              * This implicitly ensures that no message loss occurs.
+    3878             :              */
+    3879           0 :             dlt_log(LOG_WARNING, "failed to remove required bytes from receiver.\n");
+    3880             :         }
+    3881             : 
+    3882           0 :         return DLT_DAEMON_ERROR_UNKNOWN;
+    3883             :     }
+    3884             : 
+    3885             : #if defined(DLT_LOG_LEVEL_APP_CONFIG) || defined(DLT_TRACE_LOAD_CTRL_ENABLE)
+    3886             :     DltDaemonApplication *app = dlt_daemon_application_find(
+    3887             :         daemon, daemon_local->msg.extendedheader->apid, daemon->ecuid, verbose);
+    3888             : #endif
+    3889             : 
+    3890             :     /* discard non-allowed levels if enforcement is on */
+    3891           0 :     bool keep_message = enforce_context_ll_and_ts_keep_message(
+    3892             :         daemon_local
+    3893             : #ifdef DLT_LOG_LEVEL_APP_CONFIG
+    3894             :         , app
+    3895             : #endif
+    3896             :     );
+    3897             : 
+    3898             :     // check trace_load
+    3899             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+    3900             :     keep_message &=
+    3901             :         trace_load_keep_message(app, size, daemon, daemon_local, verbose);
+    3902             : #endif
+    3903             : 
+    3904           0 :     if (keep_message)
+    3905        5809 :       dlt_daemon_client_send_message_to_all_client(daemon, daemon_local, verbose);
+    3906             : 
+    3907             :     /* keep not read data in buffer */
+    3908        5809 :     size = (int) (daemon_local->msg.headersize +
+    3909        5809 :         daemon_local->msg.datasize - sizeof(DltStorageHeader) +
+    3910             :         sizeof(DltUserHeader));
+    3911             : 
+    3912        5809 :     if (daemon_local->msg.found_serialheader)
+    3913             :         size += (int) sizeof(dltSerialHeader);
+    3914             : 
+    3915        5809 :     if (dlt_receiver_remove(rec, size) != DLT_RETURN_OK) {
+    3916           0 :         dlt_log(LOG_WARNING, "failed to remove bytes from receiver.\n");
+    3917           0 :         return DLT_DAEMON_ERROR_UNKNOWN;
+    3918             :     }
+    3919             : 
+    3920             : #endif
+    3921             : 
+    3922             :     return DLT_DAEMON_ERROR_OK;
+    3923             : }
+    3924             : 
+    3925           0 : bool enforce_context_ll_and_ts_keep_message(DltDaemonLocal *daemon_local
+    3926             : #ifdef DLT_LOG_LEVEL_APP_CONFIG
+    3927             :                                             , DltDaemonApplication *app
+    3928             : #endif
+    3929             : )
+    3930             : {
+    3931        5809 :     if (!daemon_local->flags.enforceContextLLAndTS ||
+    3932           0 :         !daemon_local->msg.extendedheader) {
+    3933             :         return true;
+    3934             :     }
+    3935             : 
+    3936             : #ifdef DLT_LOG_LEVEL_APP_CONFIG
+    3937             :     if (app == NULL) {
+    3938             :         return true;
+    3939             :     }
+    3940             : #endif
+    3941             : 
+    3942           0 :     const int mtin = DLT_GET_MSIN_MTIN(daemon_local->msg.extendedheader->msin);
+    3943             : #ifdef DLT_LOG_LEVEL_APP_CONFIG
+    3944             :     if (app->num_context_log_level_settings > 0) {
+    3945             :         DltDaemonContextLogSettings *log_settings =
+    3946             :             dlt_daemon_find_app_log_level_config(app, daemon_local->msg.extendedheader->ctid);
+    3947             : 
+    3948             :         if (log_settings != NULL) {
+    3949             :             return mtin <= log_settings->log_level;
+    3950             :         }
+    3951             :     }
+    3952             : #endif
+    3953           0 :     return mtin <= daemon_local->flags.contextLogLevel;
+    3954             : }
+    3955             : 
+    3956             : 
+    3957             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+    3958             : bool trace_load_keep_message(DltDaemonApplication *app,
+    3959             :                              const int size, DltDaemon *const daemon,
+    3960             :                              DltDaemonLocal *const daemon_local,
+    3961             :                              int verbose)
+    3962             : {
+    3963             :     bool keep_message = true;
+    3964             :     if (app == NULL || !daemon_local->msg.extendedheader) {
+    3965             :         return keep_message;
+    3966             :     }
+    3967             : 
+    3968             :     DltMessage* msg = &daemon_local->msg;
+    3969             :     const int mtin = DLT_GET_MSIN_MTIN(msg->extendedheader->msin);
+    3970             : 
+    3971             :     struct DltTraceLoadLogParams params = {
+    3972             :         daemon,
+    3973             :         daemon_local,
+    3974             :         verbose,
+    3975             :         app->apid,
+    3976             :     };
+    3977             : 
+    3978             :     DltTraceLoadSettings *trace_load_settings =
+    3979             :         dlt_find_runtime_trace_load_settings(
+    3980             :             app->trace_load_settings, app->trace_load_settings_count,
+    3981             :             app->apid, msg->extendedheader->ctid);
+    3982             : 
+    3983             :     if (trace_load_settings != NULL) {
+    3984             :         pthread_rwlock_wrlock(&trace_load_rw_lock);
+    3985             :         keep_message = dlt_check_trace_load(
+    3986             :             trace_load_settings, mtin, msg->headerextra.tmsp, size,
+    3987             :             dlt_daemon_output_internal_msg, (void *)(&params));
+    3988             :         pthread_rwlock_unlock(&trace_load_rw_lock);
+    3989             :     }
+    3990             :     else {
+    3991             :         dlt_vlog(
+    3992             :             LOG_ERR,
+    3993             :             "Failed to lookup trace load limits for %s, "
+    3994             :             "dropping message, likely app was not registered properly\n",
+    3995             :             app->apid);
+    3996             :         keep_message = false;
+    3997             :     }
+    3998             : 
+    3999             :     return keep_message;
+    4000             : }
+    4001             : #endif
+    4002             : 
+    4003           0 : int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon,
+    4004             :                                                   DltDaemonLocal *daemon_local,
+    4005             :                                                   DltReceiver *rec,
+    4006             :                                                   int verbose)
+    4007             : {
+    4008             :     uint32_t len = sizeof(DltUserControlMsgAppLogLevelTraceStatus);
+    4009             :     DltUserControlMsgAppLogLevelTraceStatus userctxt;
+    4010             :     DltDaemonApplication *application;
+    4011             :     DltDaemonContext *context;
+    4012             :     int i, offset_base;
+    4013             :     int8_t old_log_level, old_trace_status;
+    4014             :     DltDaemonRegisteredUsers *user_list = NULL;
+    4015             : 
+    4016           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    4017             : 
+    4018           0 :     if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
+    4019           0 :         dlt_vlog(LOG_ERR,
+    4020             :                  "Invalid function parameters used for %s\n",
+    4021             :                  __func__);
+    4022           0 :         return DLT_RETURN_ERROR;
+    4023             :     }
+    4024             : 
+    4025           0 :     user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+    4026             : 
+    4027           0 :     if (user_list == NULL)
+    4028             :         return DLT_RETURN_ERROR;
+    4029             : 
+    4030             :     memset(&userctxt, 0, len);
+    4031             : 
+    4032           0 :     if (dlt_receiver_check_and_get(rec,
+    4033             :                                    &userctxt,
+    4034             :                                    len,
+    4035             :                                    DLT_RCV_SKIP_HEADER | DLT_RCV_REMOVE) < 0)
+    4036             :         /* Not enough bytes received */
+    4037             :         return DLT_RETURN_ERROR;
+    4038             : 
+    4039           0 :     if (user_list->num_applications > 0) {
+    4040             :         /* Get all contexts with application id matching the received application id */
+    4041           0 :         application = dlt_daemon_application_find(daemon,
+    4042             :                                                   userctxt.apid,
+    4043             :                                                   daemon->ecuid,
+    4044             :                                                   verbose);
+    4045             : 
+    4046           0 :         if (application) {
+    4047             :             /* Calculate start offset within contexts[] */
+    4048             :             offset_base = 0;
+    4049             : 
+    4050           0 :             for (i = 0; i < (application - (user_list->applications)); i++)
+    4051           0 :                 offset_base += user_list->applications[i].num_contexts;
+    4052             : 
+    4053           0 :             for (i = 0; i < application->num_contexts; i++) {
+    4054           0 :                 context = &(user_list->contexts[offset_base + i]);
+    4055             : 
+    4056           0 :                 if (context) {
+    4057           0 :                     old_log_level = context->log_level;
+    4058           0 :                     context->log_level = (int8_t) userctxt.log_level; /* No endianess conversion necessary*/
+    4059             : 
+    4060           0 :                     old_trace_status = context->trace_status;
+    4061           0 :                     context->trace_status = (int8_t) userctxt.trace_status;   /* No endianess conversion necessary */
+    4062             : 
+    4063             :                     /* The following function sends also the trace status */
+    4064           0 :                     if ((context->user_handle >= DLT_FD_MINIMUM) &&
+    4065           0 :                         (dlt_daemon_user_send_log_level(daemon,
+    4066             :                                                         context,
+    4067             :                                                         verbose) != 0)) {
+    4068           0 :                         context->log_level = old_log_level;
+    4069           0 :                         context->trace_status = old_trace_status;
+    4070             :                     }
+    4071             :                 }
+    4072             :             }
+    4073             :         }
+    4074             :     }
+    4075             : 
+    4076             :     return DLT_RETURN_OK;
+    4077             : }
+    4078             : 
+    4079           0 : int dlt_daemon_process_user_message_log_mode(DltDaemon *daemon,
+    4080             :                                              DltDaemonLocal *daemon_local,
+    4081             :                                              DltReceiver *rec,
+    4082             :                                              int verbose)
+    4083             : {
+    4084             :     DltUserControlMsgLogMode userctxt;
+    4085             :     uint32_t len = sizeof(DltUserControlMsgLogMode);
+    4086             : 
+    4087           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    4088             : 
+    4089           0 :     if ((daemon == 0) || (daemon_local == 0)) {
+    4090           0 :         dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_process_log_mode()\n");
+    4091           0 :         return -1;
+    4092             :     }
+    4093             : 
+    4094             :     memset(&userctxt, 0, len);
+    4095             : 
+    4096           0 :     if (dlt_receiver_check_and_get(rec,
+    4097             :                                    &userctxt,
+    4098             :                                    len,
+    4099             :                                    DLT_RCV_SKIP_HEADER | DLT_RCV_REMOVE) < 0)
+    4100             :         /* Not enough bytes received */
+    4101             :         return -1;
+    4102             : 
+    4103             :     /* set the new log mode */
+    4104           0 :     daemon->mode = userctxt.log_mode;
+    4105             : 
+    4106             :     /* write configuration persistantly */
+    4107           0 :     dlt_daemon_configuration_save(daemon, daemon->runtime_configuration, verbose);
+    4108             : 
+    4109           0 :     return 0;
+    4110             : }
+    4111             : 
+    4112           0 : int dlt_daemon_process_user_message_marker(DltDaemon *daemon,
+    4113             :                                            DltDaemonLocal *daemon_local,
+    4114             :                                            DltReceiver *rec,
+    4115             :                                            int verbose)
+    4116             : {
+    4117             :     uint32_t len = sizeof(DltUserControlMsgLogMode);
+    4118             :     DltUserControlMsgLogMode userctxt;
+    4119           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    4120             : 
+    4121           0 :     if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
+    4122           0 :         dlt_vlog(LOG_ERR, "Invalid function parameters used for %s\n",
+    4123             :                  __func__);
+    4124           0 :         return -1;
+    4125             :     }
+    4126             : 
+    4127             :     memset(&userctxt, 0, len);
+    4128             : 
+    4129           0 :     if (dlt_receiver_check_and_get(rec,
+    4130             :                                    &userctxt,
+    4131             :                                    len,
+    4132             :                                    DLT_RCV_SKIP_HEADER | DLT_RCV_REMOVE) < 0)
+    4133             :         /* Not enough bytes received */
+    4134             :         return -1;
+    4135             : 
+    4136             :     /* Create automatic unregister context response for unregistered context */
+    4137           0 :     dlt_daemon_control_message_marker(DLT_DAEMON_SEND_TO_ALL, daemon, daemon_local, verbose);
+    4138             : 
+    4139           0 :     return 0;
+    4140             : }
+    4141             : 
+    4142           2 : int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
+    4143             : {
+    4144             :     int ret;
+    4145             :     static uint8_t data[DLT_DAEMON_RCVBUFSIZE];
+    4146             :     int length;
+    4147             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+    4148             :     uint32_t curr_time = 0U;
+    4149             : #endif
+    4150             : 
+    4151           2 :     PRINT_FUNCTION_VERBOSE(verbose);
+    4152             : 
+    4153           2 :     if ((daemon == 0) || (daemon_local == 0)) {
+    4154           0 :         dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_send_ringbuffer_to_client()\n");
+    4155           0 :         return DLT_DAEMON_ERROR_UNKNOWN;
+    4156             :     }
+    4157             : 
+    4158           2 :     if (dlt_buffer_get_message_count(&(daemon->client_ringbuffer)) <= 0) {
+    4159           0 :         dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_SEND_DIRECT);
+    4160           0 :         return DLT_DAEMON_ERROR_OK;
+    4161             :     }
+    4162             : 
+    4163           4 :     while ((length = dlt_buffer_copy(&(daemon->client_ringbuffer), data, sizeof(data))) > 0) {
+    4164             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+    4165             :         dlt_daemon_trigger_systemd_watchdog_if_necessary(&curr_time, daemon->watchdog_trigger_interval);
+    4166             : #endif
+    4167             : 
+    4168           4 :         if ((ret =
+    4169           4 :                  dlt_daemon_client_send(DLT_DAEMON_SEND_FORCE, daemon, daemon_local, 0, 0, data, length, 0, 0,
+    4170             :                                         verbose)))
+    4171           0 :             return ret;
+    4172             : 
+    4173           4 :         dlt_buffer_remove(&(daemon->client_ringbuffer));
+    4174             : 
+    4175           4 :         if (daemon->state != DLT_DAEMON_STATE_SEND_BUFFER)
+    4176           0 :             dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_SEND_BUFFER);
+    4177             : 
+    4178           4 :         if (dlt_buffer_get_message_count(&(daemon->client_ringbuffer)) <= 0) {
+    4179           2 :             dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_SEND_DIRECT);
+    4180           2 :             return DLT_DAEMON_ERROR_OK;
+    4181             :         }
+    4182             :     }
+    4183             : 
+    4184             :     return DLT_DAEMON_ERROR_OK;
+    4185             : }
+    4186             : 
+    4187             : #ifdef __QNX__
+    4188             : static void *timer_thread(void *data)
+    4189             : {
+    4190             :     int pexit = 0;
+    4191             :     unsigned int sleep_ret = 0;
+    4192             : 
+    4193             :     DltDaemonPeriodicData* timer_thread_data = (DltDaemonPeriodicData*) data;
+    4194             : 
+    4195             :     /* Timer will start in starts_in sec*/
+    4196             :     if ((sleep_ret = sleep(timer_thread_data->starts_in))) {
+    4197             :         dlt_vlog(LOG_NOTICE, "Sleep remains [%u] for starting!"
+    4198             :                 "Stop thread of timer [%d]\n",
+    4199             :                 sleep_ret, timer_thread_data->timer_id);
+    4200             :          close_pipes(dlt_timer_pipes[timer_thread_data->timer_id]);
+    4201             :          return NULL;
+    4202             :     }
+    4203             : 
+    4204             :     while (1) {
+    4205             :         if ((dlt_timer_pipes[timer_thread_data->timer_id][1] > 0) &&
+    4206             :                 (0 > write(dlt_timer_pipes[timer_thread_data->timer_id][1], "1", 1))) {
+    4207             :             dlt_vlog(LOG_ERR, "Failed to send notification for timer [%s]!\n",
+    4208             :                     dlt_timer_names[timer_thread_data->timer_id]);
+    4209             :             pexit = 1;
+    4210             :         }
+    4211             : 
+    4212             :         if (pexit || g_exit) {
+    4213             :             dlt_vlog(LOG_NOTICE, "Received signal!"
+    4214             :                     "Stop thread of timer [%d]\n",
+    4215             :                     timer_thread_data->timer_id);
+    4216             :             close_pipes(dlt_timer_pipes[timer_thread_data->timer_id]);
+    4217             :             return NULL;
+    4218             :         }
+    4219             : 
+    4220             :         if ((sleep_ret = sleep(timer_thread_data->period_sec))) {
+    4221             :             dlt_vlog(LOG_NOTICE, "Sleep remains [%u] for interval!"
+    4222             :                     "Stop thread of timer [%d]\n",
+    4223             :                     sleep_ret, timer_thread_data->timer_id);
+    4224             :              close_pipes(dlt_timer_pipes[timer_thread_data->timer_id]);
+    4225             :              return NULL;
+    4226             :         }
+    4227             :     }
+    4228             : }
+    4229             : #endif
+    4230             : 
+    4231          10 : int create_timer_fd(DltDaemonLocal *daemon_local,
+    4232             :                     int period_sec,
+    4233             :                     int starts_in,
+    4234             :                     DltTimers timer_id)
+    4235             : {
+    4236             :     int local_fd = DLT_FD_INIT;
+    4237             :     char *timer_name = NULL;
+    4238             : 
+    4239          10 :     if (timer_id >= DLT_TIMER_UNKNOWN) {
+    4240           0 :         dlt_log(DLT_LOG_ERROR, "Unknown timer.");
+    4241           0 :         return -1;
+    4242             :     }
+    4243             : 
+    4244          10 :     timer_name = dlt_timer_names[timer_id];
+    4245             : 
+    4246          10 :     if (daemon_local == NULL) {
+    4247           0 :         dlt_log(DLT_LOG_ERROR, "Daemon local structure is NULL");
+    4248           0 :         return -1;
+    4249             :     }
+    4250             : 
+    4251          10 :     if ((period_sec <= 0) || (starts_in <= 0)) {
+    4252             :         /* timer not activated via the service file */
+    4253           0 :         dlt_vlog(LOG_INFO, "<%s> not set: period=0\n", timer_name);
+    4254             :         local_fd = DLT_FD_INIT;
+    4255             :     }
+    4256             :     else {
+    4257             : #ifdef linux
+    4258             :         struct itimerspec l_timer_spec;
+    4259          10 :         local_fd = timerfd_create(CLOCK_MONOTONIC, 0);
+    4260             : 
+    4261          10 :         if (local_fd < 0)
+    4262           0 :             dlt_vlog(LOG_WARNING, "<%s> timerfd_create failed: %s\n",
+    4263           0 :                      timer_name, strerror(errno));
+    4264             : 
+    4265          10 :         l_timer_spec.it_interval.tv_sec = period_sec;
+    4266          10 :         l_timer_spec.it_interval.tv_nsec = 0;
+    4267          10 :         l_timer_spec.it_value.tv_sec = starts_in;
+    4268          10 :         l_timer_spec.it_value.tv_nsec = 0;
+    4269             : 
+    4270          10 :         if (timerfd_settime(local_fd, 0, &l_timer_spec, NULL) < 0) {
+    4271           0 :             dlt_vlog(LOG_WARNING, "<%s> timerfd_settime failed: %s\n",
+    4272           0 :                      timer_name, strerror(errno));
+    4273             :             local_fd = DLT_FD_INIT;
+    4274             :         }
+    4275             : #elif __QNX__
+    4276             :         /*
+    4277             :          * Since timerfd is not valid in QNX, new threads are introduced
+    4278             :          * to manage timers and communicate with main thread when timer expires.
+    4279             :          */
+    4280             :         if(0 != pipe(dlt_timer_pipes[timer_id])) {
+    4281             :             dlt_vlog(LOG_ERR, "Failed to create pipe for timer [%s]",
+    4282             :                     dlt_timer_names[timer_id]);
+    4283             :             return -1;
+    4284             :         }
+    4285             :         if (NULL == timer_data[timer_id]) {
+    4286             :             timer_data[timer_id] = calloc(1, sizeof(DltDaemonPeriodicData));
+    4287             :             if (NULL == timer_data[timer_id]) {
+    4288             :                 dlt_vlog(LOG_ERR, "Failed to allocate memory for timer_data [%s]!\n",
+    4289             :                          dlt_timer_names[timer_id]);
+    4290             :                 close_pipes(dlt_timer_pipes[timer_id]);
+    4291             :                 return -1;
+    4292             :             }
+    4293             :         }
+    4294             : 
+    4295             :         timer_data[timer_id]->timer_id = timer_id;
+    4296             :         timer_data[timer_id]->period_sec = period_sec;
+    4297             :         timer_data[timer_id]->starts_in = starts_in;
+    4298             :         timer_data[timer_id]->wakeups_missed = 0;
+    4299             : 
+    4300             :         if (0 != pthread_create(&timer_threads[timer_id], NULL,
+    4301             :                             &timer_thread, (void*)timer_data[timer_id])) {
+    4302             :             dlt_vlog(LOG_ERR, "Failed to create new thread for timer [%s]!\n",
+    4303             :                                      dlt_timer_names[timer_id]);
+    4304             :             /* Clean up timer before returning */
+    4305             :             close_pipes(dlt_timer_pipes[timer_id]);
+    4306             :             free(timer_data[timer_id]);
+    4307             :             timer_data[timer_id] = NULL;
+    4308             : 
+    4309             :             return -1;
+    4310             :         }
+    4311             :         local_fd = dlt_timer_pipes[timer_id][0];
+    4312             : #endif
+    4313             :     }
+    4314             : 
+    4315          10 :     return dlt_connection_create(daemon_local,
+    4316             :                                  &daemon_local->pEvent,
+    4317             :                                  local_fd,
+    4318             :                                  POLLIN,
+    4319          10 :                                  dlt_timer_conn_types[timer_id]);
+    4320             : }
+    4321             : 
+    4322             : /* Close connection function */
+    4323           5 : int dlt_daemon_close_socket(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
+    4324             : {
+    4325           5 :     char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
+    4326             : 
+    4327           5 :     PRINT_FUNCTION_VERBOSE(verbose);
+    4328             : 
+    4329           5 :     if ((daemon_local == NULL) || (daemon == NULL)) {
+    4330           0 :         dlt_log(LOG_ERR, "dlt_daemon_close_socket: Invalid input parmeters\n");
+    4331           0 :         return -1;
+    4332             :     }
+    4333             : 
+    4334             :     /* Closure is done while unregistering has for any connection */
+    4335           5 :     dlt_event_handler_unregister_connection(&daemon_local->pEvent,
+    4336             :                                             daemon_local,
+    4337             :                                             sock);
+    4338             : 
+    4339           5 :     if (daemon_local->client_connections == 0) {
+    4340             :         /* send new log state to all applications */
+    4341           3 :         daemon->connectionState = 0;
+    4342           3 :         dlt_daemon_user_send_all_log_state(daemon, verbose);
+    4343             : 
+    4344             :         /* For offline tracing we still can use the same states */
+    4345             :         /* as for socket sending. Using this trick we see the traces */
+    4346             :         /* In the offline trace AND in the socket stream. */
+    4347           3 :         if (daemon_local->flags.yvalue[0] == 0)
+    4348           3 :             dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_BUFFER);
+    4349             :     }
+    4350             : 
+    4351           5 :     dlt_daemon_control_message_connection_info(DLT_DAEMON_SEND_TO_ALL,
+    4352             :                                                daemon,
+    4353             :                                                daemon_local,
+    4354             :                                                DLT_CONNECTION_STATUS_DISCONNECTED,
+    4355             :                                                "",
+    4356             :                                                verbose);
+    4357             : 
+    4358           5 :     snprintf(local_str, DLT_DAEMON_TEXTBUFSIZE,
+    4359             :              "Client connection #%d closed. Total Clients : %d",
+    4360             :              sock,
+    4361             :              daemon_local->client_connections);
+    4362           5 :     dlt_daemon_log_internal(daemon, daemon_local, local_str, DLT_LOG_INFO,
+    4363             :                             DLT_DAEMON_APP_ID, DLT_DAEMON_CTX_ID,
+    4364             :                             daemon_local->flags.vflag);
+    4365           5 :     dlt_vlog(LOG_DEBUG, "%s%s", local_str, "\n");
+    4366             : 
+    4367           5 :     return 0;
+    4368             : }
+    4369             : 
+    4370             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+    4371             : 
+    4372             : static DltReturnValue dlt_daemon_output_internal_msg(
+    4373             :     const DltLogLevelType loglevel, const char *const text, void* const params) {
+    4374             :     struct DltTraceLoadLogParams* log_params = (struct DltTraceLoadLogParams*)params;
+    4375             :     return dlt_daemon_log_internal(
+    4376             :         log_params->daemon, log_params->daemon_local, (char *)text, loglevel,
+    4377             :         log_params->app_id, DLT_TRACE_LOAD_CONTEXT_ID, log_params->verbose);
+    4378             : }
+    4379             : #endif
+    4380             : 
+    4381             : 
+    4382             : /**
+    4383             :  \}
+    4384             :  */
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_client.c.func-sort-c.html b/dlt_lcov_report/daemon/dlt_daemon_client.c.func-sort-c.html new file mode 100644 index 000000000..346bc1120 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_client.c.func-sort-c.html @@ -0,0 +1,204 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_client.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_client.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:26196627.0 %
Date:2024-12-05 09:07:13Functions:133339.4 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_control_callsw_cinjection0
dlt_daemon_control_message_buffer_overflow0
dlt_daemon_control_message_marker0
dlt_daemon_control_message_time0
dlt_daemon_control_message_timezone0
dlt_daemon_control_message_unregister_context0
dlt_daemon_control_passive_node_connect0
dlt_daemon_control_passive_node_connect_status0
dlt_daemon_control_set_all_log_level0
dlt_daemon_control_set_all_trace_status0
dlt_daemon_control_set_default_log_level0
dlt_daemon_control_set_default_trace_status0
dlt_daemon_control_set_timing_packets0
dlt_daemon_control_set_trace_status0
dlt_daemon_find_multiple_context_and_send_log_level0
dlt_daemon_find_multiple_context_and_send_trace_status0
dlt_daemon_process_sixty_s_timer0
dlt_daemon_process_systemd_timer0
dlt_daemon_send_log_level0
dlt_daemon_send_trace_status0
dlt_daemon_control_get_default_log_level1
dlt_daemon_control_set_log_level1
dlt_daemon_control_service_logstorage2
dlt_daemon_control_service_response3
dlt_daemon_control_get_log_info4
dlt_daemon_control_get_software_version4
dlt_daemon_control_message_connection_info9
dlt_daemon_process_one_s_timer11
dlt_daemon_client_process_control12
dlt_daemon_client_send_control_message21
dlt_daemon_client_send_all_multiple214
dlt_daemon_client_send_message_to_all_client5809
dlt_daemon_client_send5885
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_client.c.func.html b/dlt_lcov_report/daemon/dlt_daemon_client.c.func.html new file mode 100644 index 000000000..510bf4dec --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_client.c.func.html @@ -0,0 +1,204 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_client.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_client.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:26196627.0 %
Date:2024-12-05 09:07:13Functions:133339.4 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_client_process_control12
dlt_daemon_client_send5885
dlt_daemon_client_send_all_multiple214
dlt_daemon_client_send_control_message21
dlt_daemon_client_send_message_to_all_client5809
dlt_daemon_control_callsw_cinjection0
dlt_daemon_control_get_default_log_level1
dlt_daemon_control_get_log_info4
dlt_daemon_control_get_software_version4
dlt_daemon_control_message_buffer_overflow0
dlt_daemon_control_message_connection_info9
dlt_daemon_control_message_marker0
dlt_daemon_control_message_time0
dlt_daemon_control_message_timezone0
dlt_daemon_control_message_unregister_context0
dlt_daemon_control_passive_node_connect0
dlt_daemon_control_passive_node_connect_status0
dlt_daemon_control_service_logstorage2
dlt_daemon_control_service_response3
dlt_daemon_control_set_all_log_level0
dlt_daemon_control_set_all_trace_status0
dlt_daemon_control_set_default_log_level0
dlt_daemon_control_set_default_trace_status0
dlt_daemon_control_set_log_level1
dlt_daemon_control_set_timing_packets0
dlt_daemon_control_set_trace_status0
dlt_daemon_find_multiple_context_and_send_log_level0
dlt_daemon_find_multiple_context_and_send_trace_status0
dlt_daemon_process_one_s_timer11
dlt_daemon_process_sixty_s_timer0
dlt_daemon_process_systemd_timer0
dlt_daemon_send_log_level0
dlt_daemon_send_trace_status0
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_client.c.gcov.html b/dlt_lcov_report/daemon/dlt_daemon_client.c.gcov.html new file mode 100644 index 000000000..9fcf4417a --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_client.c.gcov.html @@ -0,0 +1,2875 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_client.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_client.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:26196627.0 %
Date:2024-12-05 09:07:13Functions:133339.4 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2011-2015, BMW AG
+       5             :  *
+       6             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       7             :  *
+       8             :  * This Source Code Form is subject to the terms of the
+       9             :  * Mozilla Public License (MPL), v. 2.0.
+      10             :  * If a copy of the MPL was not distributed with this file,
+      11             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      12             :  *
+      13             :  * For further information see http://www.covesa.org/.
+      14             :  */
+      15             : 
+      16             : /*!
+      17             :  * \author
+      18             :  * Alexander Wenzel <alexander.aw.wenzel@bmw.de>
+      19             :  * Markus Klein <Markus.Klein@esk.fraunhofer.de>
+      20             :  * Mikko Rapeli <mikko.rapeli@bmw.de>
+      21             :  *
+      22             :  * \copyright Copyright © 2011-2015 BMW AG. \n
+      23             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      24             :  *
+      25             :  * \file dlt_daemon_client.c
+      26             :  */
+      27             : 
+      28             : #include <netdb.h>
+      29             : #include <ctype.h>
+      30             : #include <stdio.h>      /* for printf() and fprintf() */
+      31             : #include <sys/socket.h> /* for socket(), connect(), (), and recv() */
+      32             : #include <sys/stat.h>   /* for stat() */
+      33             : #include <arpa/inet.h>  /* for sockaddr_in and inet_addr() */
+      34             : #include <stdlib.h>     /* for atoi() and exit() */
+      35             : #include <string.h>     /* for memset() */
+      36             : #include <unistd.h>     /* for close() */
+      37             : #include <signal.h>
+      38             : #include <syslog.h>
+      39             : #include <errno.h>
+      40             : #include <pthread.h>
+      41             : 
+      42             : #ifdef linux
+      43             : #   include <sys/timerfd.h>
+      44             : #endif
+      45             : #include <sys/time.h>
+      46             : #if defined(linux) && defined(__NR_statx)
+      47             : #   include <linux/stat.h>
+      48             : #endif
+      49             : 
+      50             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+      51             : #   include <systemd/sd-daemon.h>
+      52             : #endif
+      53             : 
+      54             : #include "dlt_types.h"
+      55             : #include "dlt_log.h"
+      56             : #include "dlt-daemon.h"
+      57             : #include "dlt-daemon_cfg.h"
+      58             : #include "dlt_daemon_common_cfg.h"
+      59             : 
+      60             : #include "dlt_daemon_socket.h"
+      61             : #include "dlt_daemon_serial.h"
+      62             : 
+      63             : #include "dlt_daemon_client.h"
+      64             : #include "dlt_daemon_connection.h"
+      65             : #include "dlt_daemon_event_handler.h"
+      66             : 
+      67             : #include "dlt_daemon_offline_logstorage.h"
+      68             : #include "dlt_gateway.h"
+      69             : 
+      70             : /** Inline function to calculate/set the requested log level or traces status
+      71             :  *  with default log level or trace status when "ForceContextLogLevelAndTraceStatus"
+      72             :  *  is enabled and set to 1 in dlt.conf file.
+      73             :  *
+      74             :  * @param request_log The requested log level (or) trace status
+      75             :  * @param context_log The default log level (or) trace status
+      76             :  *
+      77             :  * @return The log level if requested log level is lower or equal to ContextLogLevel
+      78             :  */
+      79             : static inline int8_t getStatus(uint8_t request_log, int context_log)
+      80             : {
+      81           0 :     return (request_log <= context_log) ? request_log : context_log;
+      82             : }
+      83             : 
+      84             : #ifdef UDP_CONNECTION_SUPPORT
+      85             : #   include "dlt_daemon_udp_socket.h"
+      86             : #endif
+      87             : 
+      88             : /** @brief Sends up to 2 messages to all the clients.
+      89             :  *
+      90             :  * Runs through the client list and sends the messages to them. If the message
+      91             :  * transfer fails and the connection is a socket connection, the socket is closed.
+      92             :  * Takes and release dlt_daemon_mutex.
+      93             :  *
+      94             :  * @param daemon Daemon structure needed for socket closure.
+      95             :  * @param daemon_local Daemon local structure
+      96             :  * @param data1 The first message to be sent.
+      97             :  * @param size1 The size of the first message.
+      98             :  * @param data2 The second message to be send.
+      99             :  * @param size2 The second message size.
+     100             :  * @param verbose Needed for socket closure.
+     101             :  *
+     102             :  * @return The amount of data transfered.
+     103             :  */
+     104         214 : static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon,
+     105             :                                                DltDaemonLocal *daemon_local,
+     106             :                                                void *data1,
+     107             :                                                int size1,
+     108             :                                                void *data2,
+     109             :                                                int size2,
+     110             :                                                int verbose)
+     111             : {
+     112             :     int sent = 0;
+     113             :     unsigned int i = 0;
+     114             :     int ret = 0;
+     115             :     DltConnection *temp = NULL;
+     116             :     int type_mask =
+     117             :         (DLT_CON_MASK_CLIENT_MSG_TCP | DLT_CON_MASK_CLIENT_MSG_SERIAL);
+     118             : 
+     119         214 :     PRINT_FUNCTION_VERBOSE(verbose);
+     120             : 
+     121         214 :     if ((daemon == NULL) || (daemon_local == NULL)) {
+     122           0 :         dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
+     123           0 :         return 0;
+     124             :     }
+     125             : 
+     126        1286 :     for (i = 0; i < daemon_local->pEvent.nfds; i++)
+     127             :     {
+     128        1072 :         temp = dlt_event_handler_find_connection(&(daemon_local->pEvent),
+     129        1072 :                                         daemon_local->pEvent.pfd[i].fd);
+     130             : 
+     131        1072 :         if ((temp == NULL) || (temp->receiver == NULL) ||
+     132        1072 :             !((1 << temp->type) & type_mask)) {
+     133         856 :             dlt_log(LOG_DEBUG, "The connection not found or the connection type not TCP/Serial.\n");
+     134         856 :             continue;
+     135             :         }
+     136             : 
+     137         216 :         ret = dlt_connection_send_multiple(temp,
+     138             :                                            data1,
+     139             :                                            size1,
+     140             :                                            data2,
+     141             :                                            size2,
+     142             :                                            daemon->sendserialheader);
+     143             : 
+     144         216 :         if ((ret != DLT_DAEMON_ERROR_OK) &&
+     145           0 :             (DLT_CONNECTION_CLIENT_MSG_TCP == temp->type)) {
+     146           0 :             dlt_daemon_close_socket(temp->receiver->fd,
+     147             :                                     daemon,
+     148             :                                     daemon_local,
+     149             :                                     verbose);
+     150             :         }
+     151             : 
+     152         216 :         if (ret != DLT_DAEMON_ERROR_OK)
+     153           0 :             dlt_vlog(LOG_WARNING, "%s: send dlt message failed\n", __func__);
+     154             :         else
+     155             :             /* If sent to at  least one client,
+     156             :              * then do not store in ring buffer
+     157             :              */
+     158             :             sent = 1;
+     159             :     } /* for */
+     160             : 
+     161             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+     162             :     if (sent)
+     163             :     {
+     164             :         const uint32_t serial_header = daemon->sendserialheader ? sizeof(dltSerialHeader) : 0;
+     165             :         daemon->bytes_sent += size1 + size2 + serial_header;
+     166             :     }
+     167             : #endif
+     168             : 
+     169             :     return sent;
+     170             : }
+     171             : 
+     172        5885 : int dlt_daemon_client_send(int sock,
+     173             :                            DltDaemon *daemon,
+     174             :                            DltDaemonLocal *daemon_local,
+     175             :                            void *storage_header,
+     176             :                            int storage_header_size,
+     177             :                            void *data1,
+     178             :                            int size1,
+     179             :                            void *data2,
+     180             :                            int size2,
+     181             :                            int verbose)
+     182             : {
+     183             :     int sent, ret;
+     184             :     int ret_logstorage = 0;
+     185             :     static int sent_message_overflow_cnt = 0;
+     186             : 
+     187        5885 :     if ((daemon == NULL) || (daemon_local == NULL)) {
+     188           0 :         dlt_vlog(LOG_ERR, "%s: Invalid arguments\n", __func__);
+     189           0 :         return DLT_DAEMON_ERROR_UNKNOWN;
+     190             :     }
+     191             : 
+     192        5885 :     if ((sock != DLT_DAEMON_SEND_TO_ALL) && (sock != DLT_DAEMON_SEND_FORCE)) {
+     193             :         /* Send message to specific socket */
+     194          16 :         if (isatty(sock)) {
+     195           0 :             if ((ret =
+     196           0 :                      dlt_daemon_serial_send(sock, data1, size1, data2, size2,
+     197           0 :                                             daemon->sendserialheader))) {
+     198           0 :                 dlt_vlog(LOG_WARNING, "%s: serial send dlt message failed\n", __func__);
+     199           0 :                 return ret;
+     200             :             }
+     201             :         } else {
+     202          16 :             if ((ret =
+     203          16 :                      dlt_daemon_socket_send(sock, data1, size1, data2, size2,
+     204          16 :                                             daemon->sendserialheader))) {
+     205           0 :                 dlt_vlog(LOG_WARNING, "%s: socket send dlt message failed\n", __func__);
+     206           0 :                 return ret;
+     207             :             }
+     208             :         }
+     209             : 
+     210          16 :         return DLT_DAEMON_ERROR_OK;
+     211             :     }
+     212             : 
+     213             :     /* write message to offline trace */
+     214             :     /* In the SEND_BUFFER state we must skip offline tracing because the offline traces */
+     215             :     /* are going without buffering directly to the offline trace. Thus we have to filter out */
+     216             :     /* the traces that are coming from the buffer. */
+     217        5869 :     if ((sock != DLT_DAEMON_SEND_FORCE) && (daemon->state != DLT_DAEMON_STATE_SEND_BUFFER)) {
+     218        5865 :         if (((daemon->mode == DLT_USER_MODE_INTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH))
+     219           0 :             && daemon_local->flags.offlineTraceDirectory[0]) {
+     220           0 :             if (dlt_offline_trace_write(&(daemon_local->offlineTrace), storage_header, storage_header_size, data1,
+     221             :                                         size1, data2, size2)) {
+     222             :                 static int error_dlt_offline_trace_write_failed = 0;
+     223             : 
+     224           0 :                 if (!error_dlt_offline_trace_write_failed) {
+     225           0 :                     dlt_vlog(LOG_ERR, "%s: dlt_offline_trace_write failed!\n", __func__);
+     226           0 :                     error_dlt_offline_trace_write_failed = 1;
+     227             :                 }
+     228             : 
+     229             :                 /*return DLT_DAEMON_ERROR_WRITE_FAILED; */
+     230             :             }
+     231             :         }
+     232             : 
+     233             :         /* write messages to offline logstorage only if there is an extended header set
+     234             :          * this need to be checked because the function is dlt_daemon_client_send is called by
+     235             :          * newly introduced dlt_daemon_log_internal */
+     236        5865 :         if (daemon_local->flags.offlineLogstorageMaxDevices > 0)
+     237        5839 :             ret_logstorage = dlt_daemon_logstorage_write(daemon,
+     238             :                                                          &daemon_local->flags,
+     239             :                                                          storage_header,
+     240             :                                                          storage_header_size,
+     241             :                                                          data1,
+     242             :                                                          size1,
+     243             :                                                          data2,
+     244             :                                                          size2);
+     245             :     }
+     246             : 
+     247             :     /* send messages to daemon socket */
+     248        5869 :     if ((daemon->mode == DLT_USER_MODE_EXTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH)) {
+     249             : #ifdef UDP_CONNECTION_SUPPORT
+     250             :         if (daemon_local->UDPConnectionSetup == MULTICAST_CONNECTION_ENABLED) {
+     251             :             /* Forward message to network client if network routing is not disabled */
+     252             :             if (ret_logstorage != 1) {
+     253             :                 dlt_daemon_udp_dltmsg_multicast(data1,
+     254             :                                                 size1,
+     255             :                                                 data2,
+     256             :                                                 size2,
+     257             :                                                 verbose);
+     258             :             }
+     259             :         }
+     260             : 
+     261             : #endif
+     262             : 
+     263        5869 :         if ((sock == DLT_DAEMON_SEND_FORCE) || (daemon->state == DLT_DAEMON_STATE_SEND_DIRECT)) {
+     264             :             /* Forward message to network client if network routing is not disabled */
+     265         415 :             if (ret_logstorage != 1) {
+     266         214 :                 sent = dlt_daemon_client_send_all_multiple(daemon,
+     267             :                                                            daemon_local,
+     268             :                                                            data1,
+     269             :                                                            size1,
+     270             :                                                            data2,
+     271             :                                                            size2,
+     272             :                                                            verbose);
+     273             : 
+     274         214 :                 if ((sock == DLT_DAEMON_SEND_FORCE) && !sent) {
+     275             :                     return DLT_DAEMON_ERROR_SEND_FAILED;
+     276             :                 }
+     277             :             }
+     278             :         }
+     279             :     }
+     280             : 
+     281             :     /* Message was not sent to client, so store it in client ringbuffer */
+     282        5869 :     if ((sock != DLT_DAEMON_SEND_FORCE) &&
+     283        5865 :         ((daemon->state == DLT_DAEMON_STATE_BUFFER) || (daemon->state == DLT_DAEMON_STATE_SEND_BUFFER) ||
+     284             :          (daemon->state == DLT_DAEMON_STATE_BUFFER_FULL))) {
+     285        5454 :         if (daemon->state != DLT_DAEMON_STATE_BUFFER_FULL) {
+     286             :             /* Store message in history buffer */
+     287        5454 :             ret = dlt_buffer_push3(&(daemon->client_ringbuffer), data1, size1, data2, size2, 0, 0);
+     288        5454 :             if (ret < DLT_RETURN_OK) {
+     289           0 :                 dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_BUFFER_FULL);
+     290             :             }
+     291             :         }
+     292        5454 :         if (daemon->state == DLT_DAEMON_STATE_BUFFER_FULL) {
+     293           0 :             daemon->overflow_counter += 1;
+     294           0 :             if (daemon->overflow_counter == 1)
+     295           0 :                 dlt_vlog(LOG_INFO, "%s: Buffer is full! Messages will be discarded.\n", __func__);
+     296             : 
+     297           0 :             return DLT_DAEMON_ERROR_BUFFER_FULL;
+     298             :         }
+     299             :     } else {
+     300         415 :         if ((daemon->overflow_counter > 0) &&
+     301           0 :             (daemon_local->client_connections > 0)) {
+     302           0 :             sent_message_overflow_cnt++;
+     303           0 :             if (sent_message_overflow_cnt >= 2) {
+     304           0 :                 sent_message_overflow_cnt--;
+     305             :             }
+     306             :             else {
+     307           0 :                 if (dlt_daemon_send_message_overflow(daemon, daemon_local,
+     308             :                                           verbose) == DLT_DAEMON_ERROR_OK) {
+     309           0 :                     dlt_vlog(LOG_WARNING,
+     310             :                              "%s: %u messages discarded! Now able to send messages to the client.\n",
+     311             :                              __func__,
+     312             :                              daemon->overflow_counter);
+     313           0 :                     daemon->overflow_counter = 0;
+     314           0 :                     sent_message_overflow_cnt--;
+     315             :                 }
+     316             :             }
+     317             :         }
+     318             :     }
+     319             : 
+     320             :     return DLT_DAEMON_ERROR_OK;
+     321             : 
+     322             : }
+     323             : 
+     324        5809 : int dlt_daemon_client_send_message_to_all_client(DltDaemon *daemon,
+     325             :                                        DltDaemonLocal *daemon_local,
+     326             :                                        int verbose)
+     327             : {
+     328             :     static char text[DLT_DAEMON_TEXTSIZE];
+     329             :     char * ecu_ptr = NULL;
+     330             : 
+     331        5809 :     PRINT_FUNCTION_VERBOSE(verbose);
+     332             : 
+     333        5809 :     if ((daemon == NULL) || (daemon_local == NULL)) {
+     334           0 :         dlt_vlog(LOG_ERR, "%s: invalid arguments\n", __func__);
+     335           0 :         return DLT_DAEMON_ERROR_UNKNOWN;
+     336             :     }
+     337             : 
+     338             :     /* set overwrite ecu id */
+     339        5809 :     if ((daemon_local->flags.evalue[0]) &&
+     340           0 :         (strncmp(daemon_local->msg.headerextra.ecu,
+     341             :                  DLT_DAEMON_ECU_ID, DLT_ID_SIZE) == 0)) {
+     342             :         /* Set header extra parameters */
+     343           0 :         dlt_set_id(daemon_local->msg.headerextra.ecu, daemon->ecuid);
+     344             : 
+     345             :         /*msg.headerextra.seid = 0; */
+     346           0 :         if (dlt_message_set_extraparameters(&(daemon_local->msg), 0)) {
+     347           0 :             dlt_vlog(LOG_WARNING,
+     348             :                      "%s: failed to set message extra parameters.\n", __func__);
+     349           0 :             return DLT_DAEMON_ERROR_UNKNOWN;
+     350             :         }
+     351             : 
+     352             :         /* Correct value of timestamp, this was changed by dlt_message_set_extraparameters() */
+     353           0 :         daemon_local->msg.headerextra.tmsp =
+     354           0 :                         DLT_BETOH_32(daemon_local->msg.headerextra.tmsp);
+     355             :     }
+     356             : 
+     357             :     /* prepare storage header */
+     358        5809 :     if (DLT_IS_HTYP_WEID(daemon_local->msg.standardheader->htyp)) {
+     359        5809 :         ecu_ptr = daemon_local->msg.headerextra.ecu;
+     360             :     } else {
+     361           0 :         ecu_ptr = daemon->ecuid;
+     362             :     }
+     363             : 
+     364        5809 :     if (dlt_set_storageheader(daemon_local->msg.storageheader, ecu_ptr)) {
+     365           0 :         dlt_vlog(LOG_WARNING,
+     366             :                  "%s: failed to set storage header with header type: 0x%x\n",
+     367           0 :                  __func__, daemon_local->msg.standardheader->htyp);
+     368           0 :         return DLT_DAEMON_ERROR_UNKNOWN;
+     369             :     }
+     370             : 
+     371             :     /* if no filter set or filter is matching display message */
+     372        5809 :     if (daemon_local->flags.xflag) {
+     373           0 :         if (DLT_RETURN_OK !=
+     374           0 :             dlt_message_print_hex(&(daemon_local->msg), text,
+     375             :                                   DLT_DAEMON_TEXTSIZE, verbose))
+     376           0 :             dlt_log(LOG_WARNING, "dlt_message_print_hex() failed!\n");
+     377        5809 :     } else if (daemon_local->flags.aflag) {
+     378           0 :         if (DLT_RETURN_OK !=
+     379           0 :             dlt_message_print_ascii(&(daemon_local->msg), text,
+     380             :                                     DLT_DAEMON_TEXTSIZE, verbose))
+     381           0 :             dlt_log(LOG_WARNING, "dlt_message_print_ascii() failed!\n");
+     382        5809 :     } else if (daemon_local->flags.sflag) {
+     383           0 :         if (DLT_RETURN_OK !=
+     384           0 :             dlt_message_print_header(&(daemon_local->msg), text,
+     385             :                                      DLT_DAEMON_TEXTSIZE, verbose))
+     386           0 :             dlt_log(LOG_WARNING, "dlt_message_print_header() failed!\n");
+     387             :     }
+     388             : 
+     389             :     /* send message to client or write to log file */
+     390        5809 :     return dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL, daemon, daemon_local,
+     391        5809 :                 daemon_local->msg.headerbuffer, sizeof(DltStorageHeader),
+     392             :                 daemon_local->msg.headerbuffer + sizeof(DltStorageHeader),
+     393        5809 :                 (int) (daemon_local->msg.headersize - sizeof(DltStorageHeader)),
+     394        5809 :                 daemon_local->msg.databuffer, (int) daemon_local->msg.datasize, verbose);
+     395             : 
+     396             : }
+     397             : 
+     398          21 : int dlt_daemon_client_send_control_message(int sock,
+     399             :                                            DltDaemon *daemon,
+     400             :                                            DltDaemonLocal *daemon_local,
+     401             :                                            DltMessage *msg,
+     402             :                                            char *apid,
+     403             :                                            char *ctid,
+     404             :                                            int verbose)
+     405             : {
+     406             :     int ret;
+     407             :     int32_t len;
+     408             : 
+     409          21 :     PRINT_FUNCTION_VERBOSE(verbose);
+     410             : 
+     411          21 :     if ((daemon == 0) || (msg == 0) || (apid == 0) || (ctid == 0))
+     412             :         return DLT_DAEMON_ERROR_UNKNOWN;
+     413             : 
+     414             :     /* prepare storage header */
+     415          21 :     msg->storageheader = (DltStorageHeader *)msg->headerbuffer;
+     416             : 
+     417          21 :     if (dlt_set_storageheader(msg->storageheader, daemon->ecuid) == DLT_RETURN_ERROR)
+     418             :         return DLT_DAEMON_ERROR_UNKNOWN;
+     419             : 
+     420             :     /* prepare standard header */
+     421          21 :     msg->standardheader = (DltStandardHeader *)(msg->headerbuffer + sizeof(DltStorageHeader));
+     422          21 :     msg->standardheader->htyp = DLT_HTYP_WEID | DLT_HTYP_WTMS | DLT_HTYP_UEH | DLT_HTYP_PROTOCOL_VERSION1;
+     423             : 
+     424             : #if (BYTE_ORDER == BIG_ENDIAN)
+     425             :     msg->standardheader->htyp = (msg->standardheader->htyp | DLT_HTYP_MSBF);
+     426             : #endif
+     427             : 
+     428          21 :     msg->standardheader->mcnt = 0;
+     429             : 
+     430             :     /* Set header extra parameters */
+     431          21 :     dlt_set_id(msg->headerextra.ecu, daemon->ecuid);
+     432             : 
+     433             :     /*msg->headerextra.seid = 0; */
+     434             : 
+     435          21 :     msg->headerextra.tmsp = dlt_uptime();
+     436             : 
+     437          21 :     dlt_message_set_extraparameters(msg, verbose);
+     438             : 
+     439             :     /* prepare extended header */
+     440          21 :     msg->extendedheader =
+     441          21 :         (DltExtendedHeader *)(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+     442          21 :                               DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp));
+     443          21 :     msg->extendedheader->msin = DLT_MSIN_CONTROL_RESPONSE;
+     444             : 
+     445          21 :     msg->extendedheader->noar = 1; /* number of arguments */
+     446             : 
+     447          21 :     if (strcmp(apid, "") == 0)
+     448          21 :         dlt_set_id(msg->extendedheader->apid, DLT_DAEMON_CTRL_APID);       /* application id */
+     449             :     else
+     450           0 :         dlt_set_id(msg->extendedheader->apid, apid);
+     451             : 
+     452          21 :     if (strcmp(ctid, "") == 0)
+     453          21 :         dlt_set_id(msg->extendedheader->ctid, DLT_DAEMON_CTRL_CTID);       /* context id */
+     454             :     else
+     455           0 :         dlt_set_id(msg->extendedheader->ctid, ctid);
+     456             : 
+     457             :     /* prepare length information */
+     458          21 :     msg->headersize = (uint32_t) (sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) +
+     459          21 :         DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp));
+     460             : 
+     461          21 :     len = (int32_t) (msg->headersize - sizeof(DltStorageHeader) + msg->datasize);
+     462             : 
+     463          21 :     if (len > UINT16_MAX) {
+     464           0 :         dlt_log(LOG_WARNING, "Huge control message discarded!\n");
+     465           0 :         return DLT_DAEMON_ERROR_UNKNOWN;
+     466             :     }
+     467             : 
+     468          21 :     msg->standardheader->len = DLT_HTOBE_16(((uint16_t)len));
+     469             : 
+     470          21 :     if ((ret =
+     471          21 :              dlt_daemon_client_send(sock, daemon, daemon_local, msg->headerbuffer, sizeof(DltStorageHeader),
+     472             :                                     msg->headerbuffer + sizeof(DltStorageHeader),
+     473          21 :                                     (int) (msg->headersize - sizeof(DltStorageHeader)),
+     474          21 :                                     msg->databuffer, (int) msg->datasize, verbose))) {
+     475           0 :         dlt_log(LOG_DEBUG, "dlt_daemon_control_send_control_message: DLT message send to all failed!.\n");
+     476           0 :         return ret;
+     477             :     }
+     478             : 
+     479             :     return DLT_DAEMON_ERROR_OK;
+     480             : }
+     481             : 
+     482          12 : int dlt_daemon_client_process_control(int sock,
+     483             :                                       DltDaemon *daemon,
+     484             :                                       DltDaemonLocal *daemon_local,
+     485             :                                       DltMessage *msg,
+     486             :                                       int verbose)
+     487             : {
+     488             :     uint32_t id, id_tmp = 0;
+     489             :     DltStandardHeaderExtra extra;
+     490             : 
+     491          12 :     PRINT_FUNCTION_VERBOSE(verbose);
+     492             : 
+     493          12 :     if ((daemon == NULL) || (daemon_local == NULL) || (msg == NULL))
+     494             :         return -1;
+     495             : 
+     496          12 :     if (msg->datasize < (int32_t)sizeof(uint32_t))
+     497             :         return -1;
+     498             : 
+     499          12 :     extra = msg->headerextra;
+     500             : 
+     501             :     /* check if the message needs to be forwarded */
+     502          12 :     if (daemon_local->flags.gatewayMode == 1) {
+     503           0 :         if (strncmp(daemon_local->flags.evalue, extra.ecu, DLT_ID_SIZE) != 0)
+     504           0 :             return dlt_gateway_forward_control_message(&daemon_local->pGateway,
+     505             :                                                        daemon_local,
+     506             :                                                        msg,
+     507             :                                                        extra.ecu,
+     508             :                                                        verbose);
+     509             :     }
+     510             : 
+     511          12 :     id_tmp = *((uint32_t *)(msg->databuffer));
+     512          12 :     id = DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp);
+     513             : 
+     514          12 :     if ((id > DLT_SERVICE_ID) && (id < DLT_SERVICE_ID_CALLSW_CINJECTION)) {
+     515             :         /* Control message handling */
+     516          12 :         switch (id) {
+     517           1 :         case DLT_SERVICE_ID_SET_LOG_LEVEL:
+     518             :         {
+     519           1 :             dlt_daemon_control_set_log_level(sock, daemon, daemon_local, msg, verbose);
+     520           1 :             break;
+     521             :         }
+     522           0 :         case DLT_SERVICE_ID_SET_TRACE_STATUS:
+     523             :         {
+     524           0 :             dlt_daemon_control_set_trace_status(sock, daemon, daemon_local, msg, verbose);
+     525           0 :             break;
+     526             :         }
+     527           4 :         case DLT_SERVICE_ID_GET_LOG_INFO:
+     528             :         {
+     529           4 :             dlt_daemon_control_get_log_info(sock, daemon, daemon_local, msg, verbose);
+     530           4 :             break;
+     531             :         }
+     532           1 :         case DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL:
+     533             :         {
+     534           1 :             dlt_daemon_control_get_default_log_level(sock, daemon, daemon_local, verbose);
+     535           1 :             break;
+     536             :         }
+     537           0 :         case DLT_SERVICE_ID_STORE_CONFIG:
+     538             :         {
+     539           0 :             if (dlt_daemon_applications_save(daemon, daemon->runtime_application_cfg, verbose) == 0) {
+     540           0 :                 if (dlt_daemon_contexts_save(daemon, daemon->runtime_context_cfg, verbose) == 0) {
+     541           0 :                     dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK,
+     542             :                                                         verbose);
+     543             :                 }
+     544             :                 else {
+     545             :                     /* Delete saved files */
+     546           0 :                     dlt_daemon_control_reset_to_factory_default(daemon,
+     547             :                                                                 daemon->runtime_application_cfg,
+     548             :                                                                 daemon->runtime_context_cfg,
+     549             :                                                                 daemon_local->flags.contextLogLevel,
+     550             :                                                                 daemon_local->flags.contextTraceStatus,
+     551             :                                                                 daemon_local->flags.enforceContextLLAndTS,
+     552             :                                                                 verbose);
+     553           0 :                     dlt_daemon_control_service_response(sock,
+     554             :                                                         daemon,
+     555             :                                                         daemon_local,
+     556             :                                                         id,
+     557             :                                                         DLT_SERVICE_RESPONSE_ERROR,
+     558             :                                                         verbose);
+     559             :                 }
+     560             :             }
+     561             :             else {
+     562           0 :                 dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR,
+     563             :                                                     verbose);
+     564             :             }
+     565             : 
+     566             :             break;
+     567             :         }
+     568           0 :         case DLT_SERVICE_ID_RESET_TO_FACTORY_DEFAULT:
+     569             :         {
+     570           0 :             dlt_daemon_control_reset_to_factory_default(daemon,
+     571           0 :                                                         daemon->runtime_application_cfg,
+     572           0 :                                                         daemon->runtime_context_cfg,
+     573             :                                                         daemon_local->flags.contextLogLevel,
+     574             :                                                         daemon_local->flags.contextTraceStatus,
+     575             :                                                         daemon_local->flags.enforceContextLLAndTS,
+     576             :                                                         verbose);
+     577           0 :             dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+     578           0 :             break;
+     579             :         }
+     580           0 :         case DLT_SERVICE_ID_SET_COM_INTERFACE_STATUS:
+     581             :         {
+     582           0 :             dlt_daemon_control_service_response(sock,
+     583             :                                                 daemon,
+     584             :                                                 daemon_local,
+     585             :                                                 id,
+     586             :                                                 DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+     587             :                                                 verbose);
+     588           0 :             break;
+     589             :         }
+     590           0 :         case DLT_SERVICE_ID_SET_COM_INTERFACE_MAX_BANDWIDTH:
+     591             :         {
+     592           0 :             dlt_daemon_control_service_response(sock,
+     593             :                                                 daemon,
+     594             :                                                 daemon_local,
+     595             :                                                 id,
+     596             :                                                 DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+     597             :                                                 verbose);
+     598           0 :             break;
+     599             :         }
+     600           0 :         case DLT_SERVICE_ID_SET_VERBOSE_MODE:
+     601             :         {
+     602           0 :             dlt_daemon_control_service_response(sock,
+     603             :                                                 daemon,
+     604             :                                                 daemon_local,
+     605             :                                                 id,
+     606             :                                                 DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+     607             :                                                 verbose);
+     608           0 :             break;
+     609             :         }
+     610           0 :         case DLT_SERVICE_ID_SET_MESSAGE_FILTERING:
+     611             :         {
+     612           0 :             dlt_daemon_control_service_response(sock,
+     613             :                                                 daemon,
+     614             :                                                 daemon_local,
+     615             :                                                 id,
+     616             :                                                 DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+     617             :                                                 verbose);
+     618           0 :             break;
+     619             :         }
+     620           0 :         case DLT_SERVICE_ID_SET_TIMING_PACKETS:
+     621             :         {
+     622           0 :             dlt_daemon_control_set_timing_packets(sock, daemon, daemon_local, msg, verbose);
+     623           0 :             break;
+     624             :         }
+     625           0 :         case DLT_SERVICE_ID_GET_LOCAL_TIME:
+     626             :         {
+     627             :             /* Send response with valid timestamp (TMSP) field */
+     628           0 :             dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+     629           0 :             break;
+     630             :         }
+     631           0 :         case DLT_SERVICE_ID_USE_ECU_ID:
+     632             :         {
+     633           0 :             dlt_daemon_control_service_response(sock,
+     634             :                                                 daemon,
+     635             :                                                 daemon_local,
+     636             :                                                 id,
+     637             :                                                 DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+     638             :                                                 verbose);
+     639           0 :             break;
+     640             :         }
+     641           0 :         case DLT_SERVICE_ID_USE_SESSION_ID:
+     642             :         {
+     643           0 :             dlt_daemon_control_service_response(sock,
+     644             :                                                 daemon,
+     645             :                                                 daemon_local,
+     646             :                                                 id,
+     647             :                                                 DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+     648             :                                                 verbose);
+     649           0 :             break;
+     650             :         }
+     651           0 :         case DLT_SERVICE_ID_USE_TIMESTAMP:
+     652             :         {
+     653           0 :             dlt_daemon_control_service_response(sock,
+     654             :                                                 daemon,
+     655             :                                                 daemon_local,
+     656             :                                                 id,
+     657             :                                                 DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+     658             :                                                 verbose);
+     659           0 :             break;
+     660             :         }
+     661           0 :         case DLT_SERVICE_ID_USE_EXTENDED_HEADER:
+     662             :         {
+     663           0 :             dlt_daemon_control_service_response(sock,
+     664             :                                                 daemon,
+     665             :                                                 daemon_local,
+     666             :                                                 id,
+     667             :                                                 DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+     668             :                                                 verbose);
+     669           0 :             break;
+     670             :         }
+     671           0 :         case DLT_SERVICE_ID_SET_DEFAULT_LOG_LEVEL:
+     672             :         {
+     673           0 :             dlt_daemon_control_set_default_log_level(sock, daemon, daemon_local, msg, verbose);
+     674           0 :             break;
+     675             :         }
+     676           0 :         case DLT_SERVICE_ID_SET_DEFAULT_TRACE_STATUS:
+     677             :         {
+     678           0 :             dlt_daemon_control_set_default_trace_status(sock, daemon, daemon_local, msg, verbose);
+     679           0 :             break;
+     680             :         }
+     681           4 :         case DLT_SERVICE_ID_GET_SOFTWARE_VERSION:
+     682             :         {
+     683           4 :             dlt_daemon_control_get_software_version(sock, daemon, daemon_local, verbose);
+     684           4 :             break;
+     685             :         }
+     686           0 :         case DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW:
+     687             :         {
+     688           0 :             dlt_daemon_control_message_buffer_overflow(sock, daemon, daemon_local, daemon->overflow_counter, "",
+     689             :                                                        verbose);
+     690           0 :             break;
+     691             :         }
+     692           2 :         case DLT_SERVICE_ID_OFFLINE_LOGSTORAGE:
+     693             :         {
+     694           2 :             dlt_daemon_control_service_logstorage(sock, daemon, daemon_local, msg, verbose);
+     695           2 :             break;
+     696             :         }
+     697           0 :         case DLT_SERVICE_ID_PASSIVE_NODE_CONNECT:
+     698             :         {
+     699           0 :             dlt_daemon_control_passive_node_connect(sock,
+     700             :                                                     daemon,
+     701             :                                                     daemon_local,
+     702             :                                                     msg,
+     703             :                                                     verbose);
+     704           0 :             break;
+     705             :         }
+     706           0 :         case DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS:
+     707             :         {
+     708           0 :             dlt_daemon_control_passive_node_connect_status(sock,
+     709             :                                                            daemon,
+     710             :                                                            daemon_local,
+     711             :                                                            verbose);
+     712           0 :             break;
+     713             :         }
+     714           0 :         case DLT_SERVICE_ID_SET_ALL_LOG_LEVEL:
+     715             :         {
+     716           0 :             dlt_daemon_control_set_all_log_level(sock, daemon, daemon_local, msg, verbose);
+     717           0 :             break;
+     718             :         }
+     719           0 :         case DLT_SERVICE_ID_SET_ALL_TRACE_STATUS:
+     720             :         {
+     721           0 :             dlt_daemon_control_set_all_trace_status(sock, daemon, daemon_local, msg, verbose);
+     722           0 :             break;
+     723             :         }
+     724           0 :         default:
+     725             :         {
+     726           0 :             dlt_daemon_control_service_response(sock,
+     727             :                                                 daemon,
+     728             :                                                 daemon_local,
+     729             :                                                 id,
+     730             :                                                 DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+     731             :                                                 verbose);
+     732           0 :             break;
+     733             :         }
+     734             :         }
+     735             :     }
+     736             :     else {
+     737             :         /* Injection handling */
+     738           0 :         dlt_daemon_control_callsw_cinjection(sock, daemon, daemon_local, msg, verbose);
+     739             :     }
+     740             : 
+     741             :     return 0;
+     742             : }
+     743             : 
+     744           4 : void dlt_daemon_control_get_software_version(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
+     745             : {
+     746             :     DltMessage msg;
+     747             :     uint32_t len;
+     748             :     DltServiceGetSoftwareVersionResponse *resp;
+     749             : 
+     750           4 :     PRINT_FUNCTION_VERBOSE(verbose);
+     751             : 
+     752           4 :     if (daemon == 0)
+     753           0 :         return;
+     754             : 
+     755             :     /* initialise new message */
+     756           4 :     if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR) {
+     757           0 :         dlt_daemon_control_service_response(sock,
+     758             :                                             daemon,
+     759             :                                             daemon_local,
+     760             :                                             DLT_SERVICE_ID_GET_SOFTWARE_VERSION,
+     761             :                                             DLT_SERVICE_RESPONSE_ERROR,
+     762             :                                             verbose);
+     763           0 :         return;
+     764             :     }
+     765             : 
+     766             :     /* prepare payload of data */
+     767           4 :     len = (uint32_t) strlen(daemon->ECUVersionString);
+     768             : 
+     769             :     /* msg.datasize = sizeof(serviceID) + sizeof(status) + sizeof(length) + len */
+     770           4 :     msg.datasize = (uint32_t) (sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint32_t) + len);
+     771             : 
+     772           4 :     if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
+     773           0 :         free(msg.databuffer);
+     774           0 :         msg.databuffer = 0;
+     775             :     }
+     776             : 
+     777           4 :     if (msg.databuffer == 0) {
+     778           4 :         msg.databuffer = (uint8_t *)malloc(msg.datasize);
+     779           4 :         msg.databuffersize = msg.datasize;
+     780             :     }
+     781             : 
+     782           4 :     if (msg.databuffer == 0) {
+     783           0 :         dlt_daemon_control_service_response(sock,
+     784             :                                             daemon,
+     785             :                                             daemon_local,
+     786             :                                             DLT_SERVICE_ID_GET_SOFTWARE_VERSION,
+     787             :                                             DLT_SERVICE_RESPONSE_ERROR,
+     788             :                                             verbose);
+     789           0 :         return;
+     790             :     }
+     791             : 
+     792             :     resp = (DltServiceGetSoftwareVersionResponse *)msg.databuffer;
+     793           4 :     resp->service_id = DLT_SERVICE_ID_GET_SOFTWARE_VERSION;
+     794           4 :     resp->status = DLT_SERVICE_RESPONSE_OK;
+     795           4 :     resp->length = len;
+     796           4 :     memcpy(msg.databuffer + msg.datasize - len, daemon->ECUVersionString, len);
+     797             : 
+     798             :     /* send message */
+     799           4 :     dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose);
+     800             : 
+     801             :     /* free message */
+     802           4 :     dlt_message_free(&msg, 0);
+     803             : }
+     804             : 
+     805           1 : void dlt_daemon_control_get_default_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
+     806             : {
+     807             :     DltMessage msg;
+     808             :     DltServiceGetDefaultLogLevelResponse *resp;
+     809             : 
+     810           1 :     PRINT_FUNCTION_VERBOSE(verbose);
+     811             : 
+     812           1 :     if (daemon == 0)
+     813           0 :         return;
+     814             : 
+     815             :     /* initialise new message */
+     816           1 :     if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR) {
+     817           0 :         dlt_daemon_control_service_response(sock,
+     818             :                                             daemon,
+     819             :                                             daemon_local,
+     820             :                                             DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL,
+     821             :                                             DLT_SERVICE_RESPONSE_ERROR,
+     822             :                                             verbose);
+     823           0 :         return;
+     824             :     }
+     825             : 
+     826           1 :     msg.datasize = sizeof(DltServiceGetDefaultLogLevelResponse);
+     827             : 
+     828           1 :     if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
+     829           0 :         free(msg.databuffer);
+     830           0 :         msg.databuffer = 0;
+     831             :     }
+     832             : 
+     833           1 :     if (msg.databuffer == 0) {
+     834           1 :         msg.databuffer = (uint8_t *)malloc(msg.datasize);
+     835           1 :         msg.databuffersize = msg.datasize;
+     836             :     }
+     837             : 
+     838           1 :     if (msg.databuffer == 0) {
+     839           0 :         dlt_daemon_control_service_response(sock,
+     840             :                                             daemon,
+     841             :                                             daemon_local,
+     842             :                                             DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL,
+     843             :                                             DLT_SERVICE_RESPONSE_ERROR,
+     844             :                                             verbose);
+     845           0 :         return;
+     846             :     }
+     847             : 
+     848             :     resp = (DltServiceGetDefaultLogLevelResponse *)msg.databuffer;
+     849           1 :     resp->service_id = DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL;
+     850           1 :     resp->status = DLT_SERVICE_RESPONSE_OK;
+     851           1 :     resp->log_level = (uint8_t) daemon->default_log_level;
+     852             : 
+     853             :     /* send message */
+     854           1 :     dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose);
+     855             : 
+     856             :     /* free message */
+     857           1 :     dlt_message_free(&msg, 0);
+     858             : }
+     859             : 
+     860           4 : void dlt_daemon_control_get_log_info(int sock,
+     861             :                                      DltDaemon *daemon,
+     862             :                                      DltDaemonLocal *daemon_local,
+     863             :                                      DltMessage *msg,
+     864             :                                      int verbose)
+     865             : {
+     866             :     DltServiceGetLogInfoRequest *req;
+     867             :     DltMessage resp;
+     868             :     DltDaemonContext *context = 0;
+     869             :     DltDaemonApplication *application = 0;
+     870             : 
+     871             :     int num_applications = 0, num_contexts = 0;
+     872           4 :     uint16_t count_app_ids = 0, count_con_ids = 0;
+     873             : 
+     874             : #if (DLT_DEBUG_GETLOGINFO == 1)
+     875             :     char buf[255];
+     876             : #endif
+     877             : 
+     878             :     int32_t i, j;
+     879             :     size_t offset = 0;
+     880             :     char *apid = 0;
+     881             :     int8_t ll, ts;
+     882             :     uint16_t len;
+     883             :     int8_t value;
+     884             :     size_t sizecont = 0;
+     885             :     int offset_base;
+     886             : 
+     887             :     uint32_t sid;
+     888             : 
+     889             :     DltDaemonRegisteredUsers *user_list = NULL;
+     890             : 
+     891           4 :     PRINT_FUNCTION_VERBOSE(verbose);
+     892             : 
+     893           4 :     if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
+     894           0 :         return;
+     895             : 
+     896           4 :     if (dlt_check_rcv_data_size(msg->datasize, sizeof(DltServiceGetLogInfoRequest)) < 0)
+     897             :         return;
+     898             : 
+     899           4 :     user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+     900             : 
+     901           4 :     if (user_list == NULL)
+     902             :         return;
+     903             : 
+     904             :     /* prepare pointer to message request */
+     905           4 :     req = (DltServiceGetLogInfoRequest *)(msg->databuffer);
+     906             : 
+     907             :     /* initialise new message */
+     908           4 :     if (dlt_message_init(&resp, 0) == DLT_RETURN_ERROR) {
+     909           0 :         dlt_daemon_control_service_response(sock,
+     910             :                                             daemon,
+     911             :                                             daemon_local,
+     912             :                                             DLT_SERVICE_ID_GET_LOG_INFO,
+     913             :                                             DLT_SERVICE_RESPONSE_ERROR,
+     914             :                                             verbose);
+     915           0 :         return;
+     916             :     }
+     917             : 
+     918             :     /* check request */
+     919           4 :     if ((req->options < 3) || (req->options > 7)) {
+     920           0 :         dlt_daemon_control_service_response(sock,
+     921             :                                             daemon,
+     922             :                                             daemon_local,
+     923             :                                             DLT_SERVICE_ID_GET_LOG_INFO,
+     924             :                                             DLT_SERVICE_RESPONSE_ERROR,
+     925             :                                             verbose);
+     926           0 :         return;
+     927             :     }
+     928             : 
+     929           4 :     if (req->apid[0] != '\0') {
+     930           0 :         application = dlt_daemon_application_find(daemon,
+     931           0 :                                                   req->apid,
+     932             :                                                   daemon->ecuid,
+     933             :                                                   verbose);
+     934             : 
+     935           0 :         if (application) {
+     936             :             num_applications = 1;
+     937             : 
+     938           0 :             if (req->ctid[0] != '\0') {
+     939           0 :                 context = dlt_daemon_context_find(daemon,
+     940             :                                                   req->apid,
+     941           0 :                                                   req->ctid,
+     942             :                                                   daemon->ecuid,
+     943             :                                                   verbose);
+     944             : 
+     945           0 :                 num_contexts = ((context) ? 1 : 0);
+     946             :             }
+     947             :             else {
+     948           0 :                 num_contexts = application->num_contexts;
+     949             :             }
+     950             :         }
+     951             :         else {
+     952             :             num_applications = 0;
+     953             :             num_contexts = 0;
+     954             :         }
+     955             :     }
+     956             :     else {
+     957             :         /* Request all applications and contexts */
+     958           4 :         num_applications = user_list->num_applications;
+     959           4 :         num_contexts = user_list->num_contexts;
+     960             :     }
+     961             : 
+     962             :     /* prepare payload of data */
+     963             : 
+     964             :     /* Calculate maximum size for a response */
+     965             :     resp.datasize = sizeof(uint32_t) /* SID */ + sizeof(int8_t) /* status*/ + sizeof(ID4) /* DLT_DAEMON_REMO_STRING */;
+     966             : 
+     967             :     sizecont = sizeof(uint32_t) /* context_id */;
+     968             : 
+     969             :     /* Add additional size for response of Mode 4, 6, 7 */
+     970           4 :     if ((req->options == 4) || (req->options == 6) || (req->options == 7))
+     971             :         sizecont += sizeof(int8_t); /* log level */
+     972             : 
+     973             :     /* Add additional size for response of Mode 5, 6, 7 */
+     974           4 :     if ((req->options == 5) || (req->options == 6) || (req->options == 7))
+     975           4 :         sizecont += sizeof(int8_t); /* trace status */
+     976             : 
+     977           4 :     resp.datasize += (uint32_t) (((uint32_t) num_applications * (sizeof(uint32_t) /* app_id */ + sizeof(uint16_t) /* count_con_ids */)) +
+     978           4 :         ((size_t) num_contexts * sizecont));
+     979             : 
+     980           4 :     resp.datasize += (uint32_t) sizeof(uint16_t) /* count_app_ids */;
+     981             : 
+     982             :     /* Add additional size for response of Mode 7 */
+     983           4 :     if (req->options == 7) {
+     984           4 :         if (req->apid[0] != '\0') {
+     985           0 :             if (req->ctid[0] != '\0') {
+     986             :                 /* One application, one context */
+     987             :                 /* context = dlt_daemon_context_find(daemon, req->apid, req->ctid, verbose); */
+     988           0 :                 if (context) {
+     989           0 :                     resp.datasize += (uint32_t) sizeof(uint16_t) /* len_context_description */;
+     990             : 
+     991           0 :                     if (context->context_description != 0)
+     992           0 :                         resp.datasize += (uint32_t) strlen(context->context_description); /* context_description */
+     993             :                 }
+     994             :             }
+     995             :             else
+     996             :             /* One application, all contexts */
+     997           0 :             if ((user_list->applications) && (application)) {
+     998             :                 /* Calculate start offset within contexts[] */
+     999             :                 offset_base = 0;
+    1000             : 
+    1001           0 :                 for (i = 0; i < (application - (user_list->applications)); i++)
+    1002           0 :                     offset_base += user_list->applications[i].num_contexts;
+    1003             : 
+    1004             :                 /* Iterate over all contexts belonging to this application */
+    1005           0 :                 for (j = 0; j < application->num_contexts; j++) {
+    1006             : 
+    1007           0 :                     context = &(user_list->contexts[offset_base + j]);
+    1008             : 
+    1009           0 :                     if (context) {
+    1010           0 :                         resp.datasize += (uint32_t) sizeof(uint16_t) /* len_context_description */;
+    1011             : 
+    1012           0 :                         if (context->context_description != 0)
+    1013           0 :                             resp.datasize += (uint32_t) strlen(context->context_description);   /* context_description */
+    1014             :                     }
+    1015             :                 }
+    1016             :             }
+    1017             : 
+    1018             :             /* Space for application description */
+    1019           0 :             if (application) {
+    1020           0 :                 resp.datasize += (uint32_t) sizeof(uint16_t) /* len_app_description */;
+    1021             : 
+    1022           0 :                 if (application->application_description != 0)
+    1023           0 :                     resp.datasize += (uint32_t) strlen(application->application_description); /* app_description */
+    1024             :             }
+    1025             :         }
+    1026             :         else {
+    1027             :             /* All applications, all contexts */
+    1028           4 :             for (i = 0; i < user_list->num_contexts; i++) {
+    1029           0 :                 resp.datasize += (uint32_t) sizeof(uint16_t) /* len_context_description */;
+    1030             : 
+    1031           0 :                 if (user_list->contexts[i].context_description != 0)
+    1032           0 :                     resp.datasize +=
+    1033           0 :                         (uint32_t) strlen(user_list->contexts[i].context_description);
+    1034             :             }
+    1035             : 
+    1036           4 :             for (i = 0; i < user_list->num_applications; i++) {
+    1037           0 :                 resp.datasize += (uint32_t) sizeof(uint16_t) /* len_app_description */;
+    1038             : 
+    1039           0 :                 if (user_list->applications[i].application_description != 0)
+    1040           0 :                     resp.datasize += (uint32_t) strlen(user_list->applications[i].application_description); /* app_description */
+    1041             :             }
+    1042             :         }
+    1043             :     }
+    1044             : 
+    1045           4 :     if (verbose)
+    1046           0 :         dlt_vlog(LOG_DEBUG,
+    1047             :                  "Allocate %u bytes for response msg databuffer\n",
+    1048             :                  resp.datasize);
+    1049             : 
+    1050             :     /* Allocate buffer for response message */
+    1051           4 :     resp.databuffer = (uint8_t *)malloc(resp.datasize);
+    1052           4 :     resp.databuffersize = resp.datasize;
+    1053             : 
+    1054           4 :     if (resp.databuffer == 0) {
+    1055           0 :         dlt_daemon_control_service_response(sock,
+    1056             :                                             daemon,
+    1057             :                                             daemon_local,
+    1058             :                                             DLT_SERVICE_ID_GET_LOG_INFO,
+    1059             :                                             DLT_SERVICE_RESPONSE_ERROR,
+    1060             :                                             verbose);
+    1061           0 :         return;
+    1062             :     }
+    1063             : 
+    1064             :     memset(resp.databuffer, 0, resp.datasize);
+    1065             :     /* Preparation finished */
+    1066             : 
+    1067             :     /* Prepare response */
+    1068           4 :     sid = DLT_SERVICE_ID_GET_LOG_INFO;
+    1069             :     memcpy(resp.databuffer, &sid, sizeof(uint32_t));
+    1070             :     offset += sizeof(uint32_t);
+    1071             : 
+    1072           4 :     value = (int8_t) (((num_applications != 0) && (num_contexts != 0)) ? req->options : 8); /* 8 = no matching context found */
+    1073             : 
+    1074           4 :     memcpy(resp.databuffer + offset, &value, sizeof(int8_t));
+    1075             :     offset += sizeof(int8_t);
+    1076             : 
+    1077           4 :     count_app_ids = (uint16_t) num_applications;
+    1078             : 
+    1079           4 :     if (count_app_ids != 0) {
+    1080           0 :         memcpy(resp.databuffer + offset, &count_app_ids, sizeof(uint16_t));
+    1081             :         offset += sizeof(uint16_t);
+    1082             : 
+    1083             : #if (DLT_DEBUG_GETLOGINFO == 1)
+    1084             :         dlt_vlog(LOG_DEBUG, "#apid: %d \n", count_app_ids);
+    1085             : #endif
+    1086             : 
+    1087           0 :         for (i = 0; i < count_app_ids; i++) {
+    1088           0 :             if (req->apid[0] != '\0') {
+    1089           0 :                 apid = req->apid;
+    1090             :             }
+    1091             :             else {
+    1092           0 :                 if (user_list->applications)
+    1093           0 :                     apid = user_list->applications[i].apid;
+    1094             :                 else
+    1095             :                     /* This should never occur! */
+    1096             :                     apid = 0;
+    1097             :             }
+    1098             : 
+    1099           0 :             application = dlt_daemon_application_find(daemon,
+    1100             :                                                       apid,
+    1101             :                                                       daemon->ecuid,
+    1102             :                                                       verbose);
+    1103             : 
+    1104           0 :             if ((user_list->applications) && (application)) {
+    1105             :                 /* Calculate start offset within contexts[] */
+    1106             :                 offset_base = 0;
+    1107             : 
+    1108           0 :                 for (j = 0; j < (application - (user_list->applications)); j++)
+    1109           0 :                     offset_base += user_list->applications[j].num_contexts;
+    1110             : 
+    1111           0 :                 dlt_set_id((char *)(resp.databuffer + offset), apid);
+    1112           0 :                 offset += sizeof(ID4);
+    1113             : 
+    1114             : #if (DLT_DEBUG_GETLOGINFO == 1)
+    1115             :                 dlt_print_id(buf, apid);
+    1116             :                 dlt_vlog(LOG_DEBUG, "apid: %s\n", buf);
+    1117             : #endif
+    1118             : 
+    1119           0 :                 if (req->apid[0] != '\0')
+    1120           0 :                     count_con_ids = (uint16_t) num_contexts;
+    1121             :                 else
+    1122           0 :                     count_con_ids = (uint16_t) application->num_contexts;
+    1123             : 
+    1124           0 :                 memcpy(resp.databuffer + offset, &count_con_ids, sizeof(uint16_t));
+    1125           0 :                 offset += sizeof(uint16_t);
+    1126             : 
+    1127             : #if (DLT_DEBUG_GETLOGINFO == 1)
+    1128             :                 dlt_vlog(LOG_DEBUG, "#ctid: %d \n", count_con_ids);
+    1129             : #endif
+    1130             : 
+    1131           0 :                 for (j = 0; j < count_con_ids; j++) {
+    1132             : #if (DLT_DEBUG_GETLOGINFO == 1)
+    1133             :                     dlt_vlog(LOG_DEBUG, "j: %d \n", j);
+    1134             : #endif
+    1135             : 
+    1136           0 :                     if (!((count_con_ids == 1) && (req->apid[0] != '\0') &&
+    1137           0 :                           (req->ctid[0] != '\0')))
+    1138           0 :                         context = &(user_list->contexts[offset_base + j]);
+    1139             : 
+    1140             :                     /* else: context was already searched and found
+    1141             :                      *       (one application (found) with one context (found))*/
+    1142             : 
+    1143           0 :                     if ((context) &&
+    1144           0 :                         ((req->ctid[0] == '\0') || ((req->ctid[0] != '\0') &&
+    1145           0 :                                                     (memcmp(context->ctid, req->ctid, DLT_ID_SIZE) == 0)))
+    1146             :                         ) {
+    1147           0 :                         dlt_set_id((char *)(resp.databuffer + offset), context->ctid);
+    1148           0 :                         offset += sizeof(ID4);
+    1149             : 
+    1150             : #if (DLT_DEBUG_GETLOGINFO == 1)
+    1151             :                         dlt_print_id(buf, context->ctid);
+    1152             :                         dlt_vlog(LOG_DEBUG, "ctid: %s \n", buf);
+    1153             : #endif
+    1154             : 
+    1155             :                         /* Mode 4, 6, 7 */
+    1156           0 :                         if ((req->options == 4) || (req->options == 6) || (req->options == 7)) {
+    1157           0 :                             ll = context->log_level;
+    1158           0 :                             memcpy(resp.databuffer + offset, &ll, sizeof(int8_t));
+    1159           0 :                             offset += sizeof(int8_t);
+    1160             :                         }
+    1161             : 
+    1162             :                         /* Mode 5, 6, 7 */
+    1163           0 :                         if ((req->options == 5) || (req->options == 6) || (req->options == 7)) {
+    1164           0 :                             ts = context->trace_status;
+    1165           0 :                             memcpy(resp.databuffer + offset, &ts, sizeof(int8_t));
+    1166           0 :                             offset += sizeof(int8_t);
+    1167             :                         }
+    1168             : 
+    1169             :                         /* Mode 7 */
+    1170           0 :                         if (req->options == 7) {
+    1171           0 :                             if (context->context_description) {
+    1172           0 :                                 len = (uint16_t) strlen(context->context_description);
+    1173           0 :                                 memcpy(resp.databuffer + offset, &len, sizeof(uint16_t));
+    1174           0 :                                 offset += sizeof(uint16_t);
+    1175           0 :                                 memcpy(resp.databuffer + offset, context->context_description,
+    1176           0 :                                        strlen(context->context_description));
+    1177           0 :                                 offset += strlen(context->context_description);
+    1178             :                             }
+    1179             :                             else {
+    1180           0 :                                 len = 0;
+    1181           0 :                                 memcpy(resp.databuffer + offset, &len, sizeof(uint16_t));
+    1182           0 :                                 offset += sizeof(uint16_t);
+    1183             :                             }
+    1184             :                         }
+    1185             : 
+    1186             : #if (DLT_DEBUG_GETLOGINFO == 1)
+    1187             :                         dlt_vlog(LOG_DEBUG, "ll=%d ts=%d \n", (int32_t)ll,
+    1188             :                                  (int32_t)ts);
+    1189             : #endif
+    1190             :                     }
+    1191             : 
+    1192             : #if (DLT_DEBUG_GETLOGINFO == 1)
+    1193             :                     dlt_log(LOG_DEBUG, "\n");
+    1194             : #endif
+    1195             :                 }
+    1196             : 
+    1197             :                 /* Mode 7 */
+    1198           0 :                 if (req->options == 7) {
+    1199           0 :                     if (application->application_description) {
+    1200           0 :                         len = (uint16_t) strlen(application->application_description);
+    1201           0 :                         memcpy(resp.databuffer + offset, &len, sizeof(uint16_t));
+    1202           0 :                         offset += sizeof(uint16_t);
+    1203           0 :                         memcpy(resp.databuffer + offset, application->application_description,
+    1204           0 :                                strlen(application->application_description));
+    1205           0 :                         offset += strlen(application->application_description);
+    1206             :                     }
+    1207             :                     else {
+    1208           0 :                         len = 0;
+    1209           0 :                         memcpy(resp.databuffer + offset, &len, sizeof(uint16_t));
+    1210           0 :                         offset += sizeof(uint16_t);
+    1211             :                     }
+    1212             :                 }
+    1213             :             } /* if (application) */
+    1214             : 
+    1215             :         } /* for (i=0;i<count_app_ids;i++) */
+    1216             : 
+    1217             :     } /* if (count_app_ids!=0) */
+    1218             : 
+    1219           4 :     dlt_set_id((char *)(resp.databuffer + offset), DLT_DAEMON_REMO_STRING);
+    1220             : 
+    1221             :     /* send message */
+    1222           4 :     dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &resp, "", "", verbose);
+    1223             : 
+    1224             :     /* free message */
+    1225           4 :     dlt_message_free(&resp, 0);
+    1226             : }
+    1227             : 
+    1228           0 : int dlt_daemon_control_message_buffer_overflow(int sock,
+    1229             :                                                DltDaemon *daemon,
+    1230             :                                                DltDaemonLocal *daemon_local,
+    1231             :                                                unsigned int overflow_counter,
+    1232             :                                                char *apid,
+    1233             :                                                int verbose)
+    1234             : {
+    1235             :     int ret;
+    1236             :     DltMessage msg;
+    1237             :     DltServiceMessageBufferOverflowResponse *resp;
+    1238             : 
+    1239           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1240             : 
+    1241           0 :     if (daemon == 0)
+    1242             :         return DLT_DAEMON_ERROR_UNKNOWN;
+    1243             : 
+    1244             :     /* initialise new message */
+    1245           0 :     if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR) {
+    1246           0 :         dlt_daemon_control_service_response(sock,
+    1247             :                                             daemon,
+    1248             :                                             daemon_local,
+    1249             :                                             DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW,
+    1250             :                                             DLT_SERVICE_RESPONSE_ERROR,
+    1251             :                                             verbose);
+    1252           0 :         return DLT_DAEMON_ERROR_UNKNOWN;
+    1253             :     }
+    1254             : 
+    1255             :     /* prepare payload of data */
+    1256           0 :     msg.datasize = sizeof(DltServiceMessageBufferOverflowResponse);
+    1257             : 
+    1258           0 :     if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
+    1259           0 :         free(msg.databuffer);
+    1260           0 :         msg.databuffer = 0;
+    1261             :     }
+    1262             : 
+    1263           0 :     if (msg.databuffer == 0) {
+    1264           0 :         msg.databuffer = (uint8_t *)malloc(msg.datasize);
+    1265           0 :         msg.databuffersize = msg.datasize;
+    1266             :     }
+    1267             : 
+    1268           0 :     if (msg.databuffer == 0)
+    1269             :         return DLT_DAEMON_ERROR_UNKNOWN;
+    1270             : 
+    1271             :     resp = (DltServiceMessageBufferOverflowResponse *)msg.databuffer;
+    1272           0 :     resp->service_id = DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW;
+    1273           0 :     resp->status = DLT_SERVICE_RESPONSE_OK;
+    1274           0 :     resp->overflow = DLT_MESSAGE_BUFFER_OVERFLOW;
+    1275           0 :     resp->overflow_counter = overflow_counter;
+    1276             : 
+    1277             :     /* send message */
+    1278           0 :     if ((ret = dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, apid, "", verbose))) {
+    1279           0 :         dlt_message_free(&msg, 0);
+    1280           0 :         return ret;
+    1281             :     }
+    1282             : 
+    1283             :     /* free message */
+    1284           0 :     dlt_message_free(&msg, 0);
+    1285             : 
+    1286           0 :     return DLT_DAEMON_ERROR_OK;
+    1287             : }
+    1288             : 
+    1289           3 : void dlt_daemon_control_service_response(int sock,
+    1290             :                                          DltDaemon *daemon,
+    1291             :                                          DltDaemonLocal *daemon_local,
+    1292             :                                          uint32_t service_id,
+    1293             :                                          int8_t status,
+    1294             :                                          int verbose)
+    1295             : {
+    1296             :     DltMessage msg;
+    1297             :     DltServiceResponse *resp;
+    1298             : 
+    1299           3 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1300             : 
+    1301           3 :     if (daemon == 0)
+    1302           0 :         return;
+    1303             : 
+    1304             :     /* initialise new message */
+    1305           3 :     if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+    1306             :         return;
+    1307             : 
+    1308             :     /* prepare payload of data */
+    1309           3 :     msg.datasize = sizeof(DltServiceResponse);
+    1310             : 
+    1311           3 :     if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
+    1312           0 :         free(msg.databuffer);
+    1313           0 :         msg.databuffer = 0;
+    1314             :     }
+    1315             : 
+    1316           3 :     if (msg.databuffer == 0) {
+    1317           3 :         msg.databuffer = (uint8_t *)malloc(msg.datasize);
+    1318           3 :         msg.databuffersize = msg.datasize;
+    1319             :     }
+    1320             : 
+    1321           3 :     if (msg.databuffer == 0)
+    1322             :         return;
+    1323             : 
+    1324             :     resp = (DltServiceResponse *)msg.databuffer;
+    1325           3 :     resp->service_id = service_id;
+    1326           3 :     resp->status = (uint8_t) status;
+    1327             : 
+    1328             :     /* send message */
+    1329           3 :     dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose);
+    1330             : 
+    1331             :     /* free message */
+    1332           3 :     dlt_message_free(&msg, 0);
+    1333             : }
+    1334             : 
+    1335           0 : int dlt_daemon_control_message_unregister_context(int sock,
+    1336             :                                                   DltDaemon *daemon,
+    1337             :                                                   DltDaemonLocal *daemon_local,
+    1338             :                                                   char *apid,
+    1339             :                                                   char *ctid,
+    1340             :                                                   char *comid,
+    1341             :                                                   int verbose)
+    1342             : {
+    1343             :     DltMessage msg;
+    1344             :     DltServiceUnregisterContext *resp;
+    1345             : 
+    1346           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1347             : 
+    1348           0 :     if (daemon == 0)
+    1349             :         return -1;
+    1350             : 
+    1351             :     /* initialise new message */
+    1352           0 :     if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+    1353             :         return -1;
+    1354             : 
+    1355             :     /* prepare payload of data */
+    1356           0 :     msg.datasize = sizeof(DltServiceUnregisterContext);
+    1357             : 
+    1358           0 :     if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
+    1359           0 :         free(msg.databuffer);
+    1360           0 :         msg.databuffer = 0;
+    1361             :     }
+    1362             : 
+    1363           0 :     if (msg.databuffer == 0) {
+    1364           0 :         msg.databuffer = (uint8_t *)malloc(msg.datasize);
+    1365           0 :         msg.databuffersize = msg.datasize;
+    1366             :     }
+    1367             : 
+    1368           0 :     if (msg.databuffer == 0)
+    1369             :         return -1;
+    1370             : 
+    1371             :     resp = (DltServiceUnregisterContext *)msg.databuffer;
+    1372           0 :     resp->service_id = DLT_SERVICE_ID_UNREGISTER_CONTEXT;
+    1373           0 :     resp->status = DLT_SERVICE_RESPONSE_OK;
+    1374           0 :     dlt_set_id(resp->apid, apid);
+    1375           0 :     dlt_set_id(resp->ctid, ctid);
+    1376           0 :     dlt_set_id(resp->comid, comid);
+    1377             : 
+    1378             :     /* send message */
+    1379           0 :     if (dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose)) {
+    1380           0 :         dlt_message_free(&msg, 0);
+    1381           0 :         return -1;
+    1382             :     }
+    1383             : 
+    1384             :     /* free message */
+    1385           0 :     dlt_message_free(&msg, 0);
+    1386             : 
+    1387           0 :     return 0;
+    1388             : }
+    1389             : 
+    1390           9 : int dlt_daemon_control_message_connection_info(int sock,
+    1391             :                                                DltDaemon *daemon,
+    1392             :                                                DltDaemonLocal *daemon_local,
+    1393             :                                                uint8_t state,
+    1394             :                                                char *comid,
+    1395             :                                                int verbose)
+    1396             : {
+    1397             :     DltMessage msg;
+    1398             :     DltServiceConnectionInfo *resp;
+    1399             : 
+    1400           9 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1401             : 
+    1402           9 :     if (daemon == 0)
+    1403             :         return -1;
+    1404             : 
+    1405             :     /* initialise new message */
+    1406           9 :     if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+    1407             :         return -1;
+    1408             : 
+    1409             :     /* prepare payload of data */
+    1410           9 :     msg.datasize = sizeof(DltServiceConnectionInfo);
+    1411             : 
+    1412           9 :     if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
+    1413           0 :         free(msg.databuffer);
+    1414           0 :         msg.databuffer = 0;
+    1415             :     }
+    1416             : 
+    1417           9 :     if (msg.databuffer == 0) {
+    1418           9 :         msg.databuffer = (uint8_t *)malloc(msg.datasize);
+    1419           9 :         msg.databuffersize = msg.datasize;
+    1420             :     }
+    1421             : 
+    1422           9 :     if (msg.databuffer == 0)
+    1423             :         return -1;
+    1424             : 
+    1425             :     resp = (DltServiceConnectionInfo *)msg.databuffer;
+    1426           9 :     resp->service_id = DLT_SERVICE_ID_CONNECTION_INFO;
+    1427           9 :     resp->status = DLT_SERVICE_RESPONSE_OK;
+    1428           9 :     resp->state = state;
+    1429           9 :     dlt_set_id(resp->comid, comid);
+    1430             : 
+    1431             :     /* send message */
+    1432           9 :     if (dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose)) {
+    1433           0 :         dlt_message_free(&msg, 0);
+    1434           0 :         return -1;
+    1435             :     }
+    1436             : 
+    1437             :     /* free message */
+    1438           9 :     dlt_message_free(&msg, 0);
+    1439             : 
+    1440           9 :     return 0;
+    1441             : }
+    1442             : 
+    1443           0 : int dlt_daemon_control_message_timezone(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
+    1444             : {
+    1445             :     DltMessage msg;
+    1446             :     DltServiceTimezone *resp;
+    1447             : 
+    1448           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1449             : 
+    1450           0 :     if (daemon == 0)
+    1451             :         return -1;
+    1452             : 
+    1453             :     /* initialise new message */
+    1454           0 :     if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+    1455             :         return -1;
+    1456             : 
+    1457             :     /* prepare payload of data */
+    1458           0 :     msg.datasize = sizeof(DltServiceTimezone);
+    1459             : 
+    1460           0 :     if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
+    1461           0 :         free(msg.databuffer);
+    1462           0 :         msg.databuffer = 0;
+    1463             :     }
+    1464             : 
+    1465           0 :     if (msg.databuffer == 0) {
+    1466           0 :         msg.databuffer = (uint8_t *)malloc(msg.datasize);
+    1467           0 :         msg.databuffersize = msg.datasize;
+    1468             :     }
+    1469             : 
+    1470           0 :     if (msg.databuffer == 0)
+    1471             :         return -1;
+    1472             : 
+    1473             :     resp = (DltServiceTimezone *)msg.databuffer;
+    1474           0 :     resp->service_id = DLT_SERVICE_ID_TIMEZONE;
+    1475           0 :     resp->status = DLT_SERVICE_RESPONSE_OK;
+    1476             : 
+    1477           0 :     time_t t = time(NULL);
+    1478             :     struct tm lt;
+    1479           0 :     tzset();
+    1480           0 :     localtime_r(&t, &lt);
+    1481             : #if !defined(__CYGWIN__)
+    1482           0 :     resp->timezone = (int32_t)lt.tm_gmtoff;
+    1483             : #endif
+    1484           0 :     resp->isdst = (uint8_t)lt.tm_isdst;
+    1485             : 
+    1486             :     /* send message */
+    1487           0 :     if (dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose)) {
+    1488           0 :         dlt_message_free(&msg, 0);
+    1489           0 :         return -1;
+    1490             :     }
+    1491             : 
+    1492             :     /* free message */
+    1493           0 :     dlt_message_free(&msg, 0);
+    1494             : 
+    1495           0 :     return 0;
+    1496             : }
+    1497             : 
+    1498           0 : int dlt_daemon_control_message_marker(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
+    1499             : {
+    1500             :     DltMessage msg;
+    1501             :     DltServiceMarker *resp;
+    1502             : 
+    1503           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1504             : 
+    1505           0 :     if (daemon == 0)
+    1506             :         return -1;
+    1507             : 
+    1508             :     /* initialise new message */
+    1509           0 :     if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+    1510             :         return -1;
+    1511             : 
+    1512             :     /* prepare payload of data */
+    1513           0 :     msg.datasize = sizeof(DltServiceMarker);
+    1514             : 
+    1515           0 :     if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
+    1516           0 :         free(msg.databuffer);
+    1517           0 :         msg.databuffer = 0;
+    1518             :     }
+    1519             : 
+    1520           0 :     if (msg.databuffer == 0) {
+    1521           0 :         msg.databuffer = (uint8_t *)malloc(msg.datasize);
+    1522           0 :         msg.databuffersize = msg.datasize;
+    1523             :     }
+    1524             : 
+    1525           0 :     if (msg.databuffer == 0)
+    1526             :         return -1;
+    1527             : 
+    1528             :     resp = (DltServiceMarker *)msg.databuffer;
+    1529           0 :     resp->service_id = DLT_SERVICE_ID_MARKER;
+    1530           0 :     resp->status = DLT_SERVICE_RESPONSE_OK;
+    1531             : 
+    1532             :     /* send message */
+    1533           0 :     if (dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose)) {
+    1534           0 :         dlt_message_free(&msg, 0);
+    1535           0 :         return -1;
+    1536             :     }
+    1537             : 
+    1538             :     /* free message */
+    1539           0 :     dlt_message_free(&msg, 0);
+    1540             : 
+    1541           0 :     return 0;
+    1542             : }
+    1543             : 
+    1544           0 : void dlt_daemon_control_callsw_cinjection(int sock,
+    1545             :                                           DltDaemon *daemon,
+    1546             :                                           DltDaemonLocal *daemon_local,
+    1547             :                                           DltMessage *msg,
+    1548             :                                           int verbose)
+    1549             : {
+    1550             :     char apid[DLT_ID_SIZE], ctid[DLT_ID_SIZE];
+    1551             :     uint32_t id = 0, id_tmp = 0;
+    1552             :     uint8_t *ptr;
+    1553             :     DltDaemonContext *context;
+    1554             :     uint32_t data_length_inject = 0;
+    1555             :     uint32_t data_length_inject_tmp = 0;
+    1556             : 
+    1557             :     int32_t datalength;
+    1558             : 
+    1559             :     DltUserHeader userheader;
+    1560             :     DltUserControlMsgInjection usercontext;
+    1561             :     uint8_t *userbuffer;
+    1562             : 
+    1563           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1564             : 
+    1565           0 :     if ((daemon == NULL) || (daemon_local == NULL) || (msg == NULL) || (msg->databuffer == NULL))
+    1566           0 :         return;
+    1567             : 
+    1568           0 :     datalength = (int32_t) msg->datasize;
+    1569             :     ptr = msg->databuffer;
+    1570             : 
+    1571           0 :     DLT_MSG_READ_VALUE(id_tmp, ptr, datalength, uint32_t); /* Get service id */
+    1572           0 :     id = DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp);
+    1573             : 
+    1574             :     /* injectionMode is disabled */
+    1575           0 :     if (daemon_local->flags.injectionMode == 0) {
+    1576           0 :         dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_PERM_DENIED, verbose);
+    1577           0 :         return;
+    1578             :     }
+    1579             : 
+    1580             :     /* id is always less than DLT_DAEMON_INJECTION_MAX since its type is uinit32_t */
+    1581           0 :     if (id >= DLT_DAEMON_INJECTION_MIN) {
+    1582             :         /* This a a real SW-C injection call */
+    1583             :         data_length_inject = 0;
+    1584             :         data_length_inject_tmp = 0;
+    1585             : 
+    1586           0 :         DLT_MSG_READ_VALUE(data_length_inject_tmp, ptr, datalength, uint32_t); /* Get data length */
+    1587           0 :         data_length_inject = DLT_ENDIAN_GET_32(msg->standardheader->htyp, data_length_inject_tmp);
+    1588             : 
+    1589             :         /* Get context handle for apid, ctid (and seid) */
+    1590             :         /* Warning: seid is ignored in this implementation! */
+    1591           0 :         if (DLT_IS_HTYP_UEH(msg->standardheader->htyp)) {
+    1592           0 :             dlt_set_id(apid, msg->extendedheader->apid);
+    1593           0 :             dlt_set_id(ctid, msg->extendedheader->ctid);
+    1594             :         }
+    1595             :         else {
+    1596             :             /* No extended header, and therefore no apid and ctid available */
+    1597           0 :             dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+    1598           0 :             return;
+    1599             :         }
+    1600             : 
+    1601             :         /* At this point, apid and ctid is available */
+    1602           0 :         context = dlt_daemon_context_find(daemon,
+    1603             :                                           apid,
+    1604             :                                           ctid,
+    1605           0 :                                           daemon->ecuid,
+    1606             :                                           verbose);
+    1607             : 
+    1608           0 :         if (context == 0) {
+    1609             :             /* dlt_log(LOG_INFO,"No context found!\n"); */
+    1610           0 :             dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+    1611           0 :             return;
+    1612             :         }
+    1613             : 
+    1614             :         /* Send user message to handle, specified in context */
+    1615           0 :         if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_INJECTION) < DLT_RETURN_OK) {
+    1616           0 :             dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+    1617           0 :             return;
+    1618             :         }
+    1619             : 
+    1620           0 :         usercontext.log_level_pos = context->log_level_pos;
+    1621             : 
+    1622           0 :         if (data_length_inject > (uint32_t) msg->databuffersize) {
+    1623           0 :             dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+    1624           0 :             return;
+    1625             :         }
+    1626             : 
+    1627           0 :         userbuffer = malloc(data_length_inject);
+    1628             : 
+    1629           0 :         if (userbuffer == 0) {
+    1630           0 :             dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+    1631           0 :             return;
+    1632             :         }
+    1633             : 
+    1634           0 :         usercontext.data_length_inject = (uint32_t) data_length_inject;
+    1635           0 :         usercontext.service_id = id;
+    1636             : 
+    1637             :         memcpy(userbuffer, ptr, (size_t) data_length_inject);  /* Copy received injection to send buffer */
+    1638             : 
+    1639             :         /* write to FIFO */
+    1640             :         DltReturnValue ret =
+    1641           0 :             dlt_user_log_out3_with_timeout(context->user_handle, &(userheader), sizeof(DltUserHeader),
+    1642             :                               &(usercontext), sizeof(DltUserControlMsgInjection),
+    1643             :                               userbuffer, (size_t) data_length_inject);
+    1644             : 
+    1645           0 :         if (ret < DLT_RETURN_OK) {
+    1646           0 :             if (ret == DLT_RETURN_PIPE_ERROR) {
+    1647             :                 /* Close connection */
+    1648           0 :                 close(context->user_handle);
+    1649           0 :                 context->user_handle = DLT_FD_INIT;
+    1650             :             }
+    1651             : 
+    1652           0 :             dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+    1653             :         }
+    1654             :         else {
+    1655           0 :             dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+    1656             :         }
+    1657             : 
+    1658           0 :         free(userbuffer);
+    1659             :         userbuffer = 0;
+    1660             : 
+    1661             :     }
+    1662             :     else {
+    1663             :         /* Invalid ID */
+    1664           0 :         dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+    1665             :                                             verbose);
+    1666             :     }
+    1667             : }
+    1668             : 
+    1669           0 : void dlt_daemon_send_log_level(int sock,
+    1670             :                                DltDaemon *daemon,
+    1671             :                                DltDaemonLocal *daemon_local,
+    1672             :                                DltDaemonContext *context,
+    1673             :                                int8_t loglevel,
+    1674             :                                int verbose)
+    1675             : {
+    1676           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1677             : 
+    1678             :     int32_t id = DLT_SERVICE_ID_SET_LOG_LEVEL;
+    1679             :     int8_t old_log_level = 0;
+    1680             : 
+    1681           0 :     old_log_level = context->log_level;
+    1682           0 :     context->log_level = loglevel; /* No endianess conversion necessary*/
+    1683             : 
+    1684           0 :     if ((context->user_handle >= DLT_FD_MINIMUM) &&
+    1685           0 :         (dlt_daemon_user_send_log_level(daemon, context, verbose) == 0)) {
+    1686           0 :         dlt_daemon_control_service_response(sock, daemon, daemon_local, (uint32_t) id, DLT_SERVICE_RESPONSE_OK, verbose);
+    1687             :     }
+    1688             :     else {
+    1689           0 :         dlt_log(LOG_ERR, "Log level could not be sent!\n");
+    1690           0 :         context->log_level = old_log_level;
+    1691           0 :         dlt_daemon_control_service_response(sock, daemon, daemon_local, (uint32_t) id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+    1692             :     }
+    1693           0 : }
+    1694             : 
+    1695           0 : void dlt_daemon_find_multiple_context_and_send_log_level(int sock,
+    1696             :                                                          DltDaemon *daemon,
+    1697             :                                                          DltDaemonLocal *daemon_local,
+    1698             :                                                          int8_t app_flag,
+    1699             :                                                          char *str,
+    1700             :                                                          int8_t len,
+    1701             :                                                          int8_t loglevel,
+    1702             :                                                          int verbose)
+    1703             : {
+    1704           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1705             : 
+    1706             :     int count = 0;
+    1707             :     DltDaemonContext *context = NULL;
+    1708           0 :     char src_str[DLT_ID_SIZE + 1] = { 0 };
+    1709             :     int ret = 0;
+    1710             :     DltDaemonRegisteredUsers *user_list = NULL;
+    1711             : 
+    1712           0 :     if (daemon == 0) {
+    1713           0 :         dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
+    1714           0 :         return;
+    1715             :     }
+    1716             : 
+    1717           0 :     user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+    1718             : 
+    1719           0 :     if (user_list == NULL)
+    1720             :         return;
+    1721             : 
+    1722           0 :     for (count = 0; count < user_list->num_contexts; count++) {
+    1723           0 :         context = &(user_list->contexts[count]);
+    1724             : 
+    1725           0 :         if (context) {
+    1726           0 :             if (app_flag == 1)
+    1727           0 :                 strncpy(src_str, context->apid, DLT_ID_SIZE);
+    1728             :             else
+    1729           0 :                 strncpy(src_str, context->ctid, DLT_ID_SIZE);
+    1730             : 
+    1731           0 :             ret = strncmp(src_str, str, len);
+    1732             : 
+    1733           0 :             if (ret == 0)
+    1734           0 :                 dlt_daemon_send_log_level(sock, daemon, daemon_local, context, loglevel, verbose);
+    1735           0 :             else if ((ret > 0) && (app_flag == 1))
+    1736             :                 break;
+    1737             :             else
+    1738           0 :                 continue;
+    1739             :         }
+    1740             :     }
+    1741             : }
+    1742             : 
+    1743           1 : void dlt_daemon_control_set_log_level(int sock,
+    1744             :                                       DltDaemon *daemon,
+    1745             :                                       DltDaemonLocal *daemon_local,
+    1746             :                                       DltMessage *msg,
+    1747             :                                       int verbose)
+    1748             : {
+    1749           1 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1750             : 
+    1751           1 :     char apid[DLT_ID_SIZE + 1] = { 0 };
+    1752           1 :     char ctid[DLT_ID_SIZE + 1] = { 0 };
+    1753             :     DltServiceSetLogLevel *req = NULL;
+    1754             :     DltDaemonContext *context = NULL;
+    1755             :     int8_t apid_length = 0;
+    1756             :     int8_t ctid_length = 0;
+    1757             : 
+    1758           1 :     if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
+    1759           0 :         return;
+    1760             : 
+    1761           1 :     if (dlt_check_rcv_data_size(msg->datasize, sizeof(DltServiceSetLogLevel)) < 0)
+    1762             :         return;
+    1763             : 
+    1764           1 :     req = (DltServiceSetLogLevel *)(msg->databuffer);
+    1765             : 
+    1766           1 :     if (daemon_local->flags.enforceContextLLAndTS)
+    1767           0 :         req->log_level = (uint8_t) getStatus(req->log_level, daemon_local->flags.contextLogLevel);
+    1768             : 
+    1769           1 :     dlt_set_id(apid, req->apid);
+    1770           1 :     dlt_set_id(ctid, req->ctid);
+    1771           1 :     apid_length = (int8_t) strlen(apid);
+    1772           1 :     ctid_length = (int8_t) strlen(ctid);
+    1773             : 
+    1774           1 :     if ((apid_length != 0) && (apid[apid_length - 1] == '*') && (ctid[0] == 0)) { /*apid provided having '*' in it and ctid is null*/
+    1775           0 :         dlt_daemon_find_multiple_context_and_send_log_level(sock,
+    1776             :                                                             daemon,
+    1777             :                                                             daemon_local,
+    1778             :                                                             1,
+    1779             :                                                             apid,
+    1780           0 :                                                             (int8_t) (apid_length - 1),
+    1781           0 :                                                             (int8_t) req->log_level,
+    1782             :                                                             verbose);
+    1783             :     }
+    1784           1 :     else if ((ctid_length != 0) && (ctid[ctid_length - 1] == '*') && (apid[0] == 0)) /*ctid provided is having '*' in it and apid is null*/
+    1785             :     {
+    1786           0 :         dlt_daemon_find_multiple_context_and_send_log_level(sock,
+    1787             :                                                             daemon,
+    1788             :                                                             daemon_local,
+    1789             :                                                             0,
+    1790             :                                                             ctid,
+    1791           0 :                                                             (int8_t) (ctid_length - 1),
+    1792           0 :                                                             (int8_t) req->log_level,
+    1793             :                                                             verbose);
+    1794             :     }
+    1795           1 :     else if ((apid_length != 0) && (apid[apid_length - 1] != '*') && (ctid[0] == 0)) /*only app id case*/
+    1796             :     {
+    1797           0 :         dlt_daemon_find_multiple_context_and_send_log_level(sock,
+    1798             :                                                             daemon,
+    1799             :                                                             daemon_local,
+    1800             :                                                             1,
+    1801             :                                                             apid,
+    1802             :                                                             DLT_ID_SIZE,
+    1803           0 :                                                             (int8_t) req->log_level,
+    1804             :                                                             verbose);
+    1805             :     }
+    1806           1 :     else if ((ctid_length != 0) && (ctid[ctid_length - 1] != '*') && (apid[0] == 0)) /*only context id case*/
+    1807             :     {
+    1808           0 :         dlt_daemon_find_multiple_context_and_send_log_level(sock,
+    1809             :                                                             daemon,
+    1810             :                                                             daemon_local,
+    1811             :                                                             0,
+    1812             :                                                             ctid,
+    1813             :                                                             DLT_ID_SIZE,
+    1814           0 :                                                             (int8_t) req->log_level,
+    1815             :                                                             verbose);
+    1816             :     }
+    1817             :     else {
+    1818           1 :         context = dlt_daemon_context_find(daemon,
+    1819             :                                           apid,
+    1820             :                                           ctid,
+    1821           1 :                                           daemon->ecuid,
+    1822             :                                           verbose);
+    1823             : 
+    1824             :         /* Set log level */
+    1825           1 :         if (context != 0) {
+    1826           0 :             dlt_daemon_send_log_level(sock, daemon, daemon_local, context, (int8_t) req->log_level, verbose);
+    1827             :         }
+    1828             :         else {
+    1829           1 :             dlt_vlog(LOG_ERR, "Could not set log level: %d. Context [%.4s:%.4s] not found:", req->log_level, apid,
+    1830             :                      ctid);
+    1831           1 :             dlt_daemon_control_service_response(sock,
+    1832             :                                                 daemon,
+    1833             :                                                 daemon_local,
+    1834             :                                                 DLT_SERVICE_ID_SET_LOG_LEVEL,
+    1835             :                                                 DLT_SERVICE_RESPONSE_ERROR,
+    1836             :                                                 verbose);
+    1837             :         }
+    1838             :     }
+    1839             : }
+    1840             : 
+    1841             : 
+    1842           0 : void dlt_daemon_send_trace_status(int sock,
+    1843             :                                   DltDaemon *daemon,
+    1844             :                                   DltDaemonLocal *daemon_local,
+    1845             :                                   DltDaemonContext *context,
+    1846             :                                   int8_t tracestatus,
+    1847             :                                   int verbose)
+    1848             : {
+    1849           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1850             : 
+    1851             :     int32_t id = DLT_SERVICE_ID_SET_TRACE_STATUS;
+    1852             :     int8_t old_trace_status = 0;
+    1853             : 
+    1854           0 :     old_trace_status = context->trace_status;
+    1855           0 :     context->trace_status = tracestatus; /* No endianess conversion necessary*/
+    1856             : 
+    1857           0 :     if ((context->user_handle >= DLT_FD_MINIMUM) &&
+    1858           0 :         (dlt_daemon_user_send_log_level(daemon, context, verbose) == 0)) {
+    1859           0 :         dlt_daemon_control_service_response(sock, daemon, daemon_local, (uint32_t) id, DLT_SERVICE_RESPONSE_OK, verbose);
+    1860             :     }
+    1861             :     else {
+    1862           0 :         dlt_log(LOG_ERR, "Trace status could not be sent!\n");
+    1863           0 :         context->trace_status = old_trace_status;
+    1864           0 :         dlt_daemon_control_service_response(sock, daemon, daemon_local, (uint32_t) id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+    1865             :     }
+    1866           0 : }
+    1867             : 
+    1868           0 : void dlt_daemon_find_multiple_context_and_send_trace_status(int sock,
+    1869             :                                                             DltDaemon *daemon,
+    1870             :                                                             DltDaemonLocal *daemon_local,
+    1871             :                                                             int8_t app_flag,
+    1872             :                                                             char *str,
+    1873             :                                                             int8_t len,
+    1874             :                                                             int8_t tracestatus,
+    1875             :                                                             int verbose)
+    1876             : {
+    1877           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1878             : 
+    1879             :     int count = 0;
+    1880             :     DltDaemonContext *context = NULL;
+    1881           0 :     char src_str[DLT_ID_SIZE + 1] = { 0 };
+    1882             :     int ret = 0;
+    1883             :     DltDaemonRegisteredUsers *user_list = NULL;
+    1884             : 
+    1885           0 :     if (daemon == 0) {
+    1886           0 :         dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
+    1887           0 :         return;
+    1888             :     }
+    1889             : 
+    1890           0 :     user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+    1891             : 
+    1892           0 :     if (user_list == NULL)
+    1893             :         return;
+    1894             : 
+    1895           0 :     for (count = 0; count < user_list->num_contexts; count++) {
+    1896           0 :         context = &(user_list->contexts[count]);
+    1897             : 
+    1898           0 :         if (context) {
+    1899           0 :             if (app_flag == 1)
+    1900           0 :                 strncpy(src_str, context->apid, DLT_ID_SIZE);
+    1901             :             else
+    1902           0 :                 strncpy(src_str, context->ctid, DLT_ID_SIZE);
+    1903             : 
+    1904           0 :             ret = strncmp(src_str, str, len);
+    1905             : 
+    1906           0 :             if (ret == 0)
+    1907           0 :                 dlt_daemon_send_trace_status(sock, daemon, daemon_local, context, tracestatus, verbose);
+    1908           0 :             else if ((ret > 0) && (app_flag == 1))
+    1909             :                 break;
+    1910             :             else
+    1911           0 :                 continue;
+    1912             :         }
+    1913             :     }
+    1914             : }
+    1915             : 
+    1916           0 : void dlt_daemon_control_set_trace_status(int sock,
+    1917             :                                          DltDaemon *daemon,
+    1918             :                                          DltDaemonLocal *daemon_local,
+    1919             :                                          DltMessage *msg,
+    1920             :                                          int verbose)
+    1921             : {
+    1922           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1923             : 
+    1924           0 :     char apid[DLT_ID_SIZE + 1] = { 0 };
+    1925           0 :     char ctid[DLT_ID_SIZE + 1] = { 0 };
+    1926             :     DltServiceSetLogLevel *req = NULL;
+    1927             :     DltDaemonContext *context = NULL;
+    1928             :     int8_t apid_length = 0;
+    1929             :     int8_t ctid_length = 0;
+    1930             : 
+    1931           0 :     if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
+    1932           0 :         return;
+    1933             : 
+    1934           0 :     if (dlt_check_rcv_data_size(msg->datasize, sizeof(DltServiceSetLogLevel)) < 0)
+    1935             :         return;
+    1936             : 
+    1937           0 :     req = (DltServiceSetLogLevel *)(msg->databuffer);
+    1938             : 
+    1939           0 :     if (daemon_local->flags.enforceContextLLAndTS)
+    1940           0 :         req->log_level = (uint8_t) getStatus(req->log_level, daemon_local->flags.contextTraceStatus);
+    1941             : 
+    1942           0 :     dlt_set_id(apid, req->apid);
+    1943           0 :     dlt_set_id(ctid, req->ctid);
+    1944           0 :     apid_length = (int8_t) strlen(apid);
+    1945           0 :     ctid_length = (int8_t) strlen(ctid);
+    1946             : 
+    1947           0 :     if ((apid_length != 0) && (apid[apid_length - 1] == '*') && (ctid[0] == 0)) { /*apid provided having '*' in it and ctid is null*/
+    1948           0 :         dlt_daemon_find_multiple_context_and_send_trace_status(sock,
+    1949             :                                                                daemon,
+    1950             :                                                                daemon_local,
+    1951             :                                                                1,
+    1952             :                                                                apid,
+    1953           0 :                                                                (int8_t) (apid_length - 1),
+    1954           0 :                                                                (int8_t) req->log_level,
+    1955             :                                                                verbose);
+    1956             :     }
+    1957           0 :     else if ((ctid_length != 0) && (ctid[ctid_length - 1] == '*') && (apid[0] == 0)) /*ctid provided is having '*' in it and apid is null*/
+    1958             : 
+    1959             :     {
+    1960           0 :         dlt_daemon_find_multiple_context_and_send_trace_status(sock,
+    1961             :                                                                daemon,
+    1962             :                                                                daemon_local,
+    1963             :                                                                0,
+    1964             :                                                                ctid,
+    1965           0 :                                                                (int8_t) (ctid_length - 1),
+    1966           0 :                                                                (int8_t) req->log_level,
+    1967             :                                                                verbose);
+    1968             :     }
+    1969           0 :     else if ((apid_length != 0) && (apid[apid_length - 1] != '*') && (ctid[0] == 0)) /*only app id case*/
+    1970             :     {
+    1971           0 :         dlt_daemon_find_multiple_context_and_send_trace_status(sock,
+    1972             :                                                                daemon,
+    1973             :                                                                daemon_local,
+    1974             :                                                                1,
+    1975             :                                                                apid,
+    1976             :                                                                DLT_ID_SIZE,
+    1977           0 :                                                                (int8_t) req->log_level,
+    1978             :                                                                verbose);
+    1979             :     }
+    1980           0 :     else if ((ctid_length != 0) && (ctid[ctid_length - 1] != '*') && (apid[0] == 0)) /*only context id case*/
+    1981             :     {
+    1982           0 :         dlt_daemon_find_multiple_context_and_send_trace_status(sock,
+    1983             :                                                                daemon,
+    1984             :                                                                daemon_local,
+    1985             :                                                                0,
+    1986             :                                                                ctid,
+    1987             :                                                                DLT_ID_SIZE,
+    1988           0 :                                                                (int8_t) req->log_level,
+    1989             :                                                                verbose);
+    1990             :     }
+    1991             :     else {
+    1992           0 :         context = dlt_daemon_context_find(daemon, apid, ctid, daemon->ecuid, verbose);
+    1993             : 
+    1994             :         /* Set trace status */
+    1995           0 :         if (context != 0) {
+    1996           0 :             dlt_daemon_send_trace_status(sock, daemon, daemon_local, context, (int8_t) req->log_level, verbose);
+    1997             :         }
+    1998             :         else {
+    1999           0 :             dlt_vlog(LOG_ERR,
+    2000             :                      "Could not set trace status: %d. Context [%.4s:%.4s] not found:",
+    2001           0 :                      req->log_level,
+    2002             :                      apid,
+    2003             :                      ctid);
+    2004           0 :             dlt_daemon_control_service_response(sock,
+    2005             :                                                 daemon,
+    2006             :                                                 daemon_local,
+    2007             :                                                 DLT_SERVICE_ID_SET_LOG_LEVEL,
+    2008             :                                                 DLT_SERVICE_RESPONSE_ERROR,
+    2009             :                                                 verbose);
+    2010             :         }
+    2011             :     }
+    2012             : }
+    2013             : 
+    2014           0 : void dlt_daemon_control_set_default_log_level(int sock,
+    2015             :                                               DltDaemon *daemon,
+    2016             :                                               DltDaemonLocal *daemon_local,
+    2017             :                                               DltMessage *msg,
+    2018             :                                               int verbose)
+    2019             : {
+    2020           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2021             : 
+    2022             :     DltServiceSetDefaultLogLevel *req;
+    2023             :     uint32_t id = DLT_SERVICE_ID_SET_DEFAULT_LOG_LEVEL;
+    2024             : 
+    2025           0 :     if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
+    2026             :         return;
+    2027             : 
+    2028           0 :     if (dlt_check_rcv_data_size(msg->datasize, sizeof(DltServiceSetDefaultLogLevel)) < 0)
+    2029             :         return;
+    2030             : 
+    2031           0 :     req = (DltServiceSetDefaultLogLevel *)(msg->databuffer);
+    2032             : 
+    2033             :     /* No endianess conversion necessary */
+    2034           0 :     if (/*(req->log_level>=0) &&*/
+    2035           0 :         (req->log_level <= DLT_LOG_VERBOSE)) {
+    2036           0 :         if (daemon_local->flags.enforceContextLLAndTS)
+    2037           0 :             daemon->default_log_level = getStatus(req->log_level, daemon_local->flags.contextLogLevel);
+    2038             :         else
+    2039           0 :             daemon->default_log_level = (int8_t) req->log_level; /* No endianess conversion necessary */
+    2040             : 
+    2041             :         /* Send Update to all contexts using the default log level */
+    2042           0 :         dlt_daemon_user_send_default_update(daemon, verbose);
+    2043             : 
+    2044           0 :         dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+    2045             :     }
+    2046             :     else {
+    2047           0 :         dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+    2048             :     }
+    2049             : }
+    2050             : 
+    2051           0 : void dlt_daemon_control_set_all_log_level(int sock,
+    2052             :                                           DltDaemon *daemon,
+    2053             :                                           DltDaemonLocal *daemon_local,
+    2054             :                                           DltMessage *msg,
+    2055             :                                           int verbose)
+    2056             : {
+    2057           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2058             : 
+    2059             :     DltServiceSetDefaultLogLevel *req = NULL;
+    2060             :     uint32_t id = DLT_SERVICE_ID_SET_ALL_LOG_LEVEL;
+    2061             :     int8_t loglevel = 0;
+    2062             : 
+    2063           0 :     if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL)) {
+    2064           0 :         dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
+    2065           0 :         return;
+    2066             :     }
+    2067             : 
+    2068           0 :     if (dlt_check_rcv_data_size(msg->datasize, sizeof(DltServiceSetDefaultLogLevel)) < 0)
+    2069             :         return;
+    2070             : 
+    2071           0 :     req = (DltServiceSetDefaultLogLevel *)(msg->databuffer);
+    2072             : 
+    2073             :     /* No endianess conversion necessary */
+    2074           0 :     if ((req != NULL) && ((req->log_level <= DLT_LOG_VERBOSE) || (req->log_level == (uint8_t)DLT_LOG_DEFAULT))) {
+    2075           0 :         loglevel = (int8_t) req->log_level;
+    2076             : 
+    2077             :         /* Send Update to all contexts using the new log level */
+    2078           0 :         dlt_daemon_user_send_all_log_level_update(
+    2079             :             daemon,
+    2080             :             daemon_local->flags.enforceContextLLAndTS,
+    2081           0 :             (int8_t)daemon_local->flags.contextLogLevel,
+    2082             :             loglevel,
+    2083             :             verbose);
+    2084             : 
+    2085           0 :         dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+    2086             :     }
+    2087             :     else {
+    2088           0 :         dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+    2089             :     }
+    2090             : }
+    2091             : 
+    2092           0 : void dlt_daemon_control_set_default_trace_status(int sock,
+    2093             :                                                  DltDaemon *daemon,
+    2094             :                                                  DltDaemonLocal *daemon_local,
+    2095             :                                                  DltMessage *msg,
+    2096             :                                                  int verbose)
+    2097             : {
+    2098           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2099             : 
+    2100             :     /* Payload of request message */
+    2101             :     DltServiceSetDefaultLogLevel *req;
+    2102             :     uint32_t id = DLT_SERVICE_ID_SET_DEFAULT_TRACE_STATUS;
+    2103             : 
+    2104           0 :     if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
+    2105             :         return;
+    2106             : 
+    2107           0 :     if (dlt_check_rcv_data_size(msg->datasize, sizeof(DltServiceSetDefaultLogLevel)) < 0)
+    2108             :         return;
+    2109             : 
+    2110           0 :     req = (DltServiceSetDefaultLogLevel *)(msg->databuffer);
+    2111             : 
+    2112             :     /* No endianess conversion necessary */
+    2113           0 :     if ((req->log_level == DLT_TRACE_STATUS_OFF) ||
+    2114             :         (req->log_level == DLT_TRACE_STATUS_ON)) {
+    2115           0 :         if (daemon_local->flags.enforceContextLLAndTS)
+    2116           0 :             daemon->default_trace_status = getStatus(req->log_level, daemon_local->flags.contextTraceStatus);
+    2117             :         else
+    2118           0 :             daemon->default_trace_status = (int8_t) req->log_level; /* No endianess conversion necessary*/
+    2119             : 
+    2120             :         /* Send Update to all contexts using the default trace status */
+    2121           0 :         dlt_daemon_user_send_default_update(daemon, verbose);
+    2122             : 
+    2123           0 :         dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+    2124             :     }
+    2125             :     else {
+    2126           0 :         dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+    2127             :     }
+    2128             : }
+    2129             : 
+    2130           0 : void dlt_daemon_control_set_all_trace_status(int sock,
+    2131             :                                              DltDaemon *daemon,
+    2132             :                                              DltDaemonLocal *daemon_local,
+    2133             :                                              DltMessage *msg,
+    2134             :                                              int verbose)
+    2135             : {
+    2136           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2137             : 
+    2138             :     DltServiceSetDefaultLogLevel *req = NULL;
+    2139             :     uint32_t id = DLT_SERVICE_ID_SET_ALL_TRACE_STATUS;
+    2140             :     int8_t tracestatus = 0;
+    2141             : 
+    2142           0 :     if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL)) {
+    2143           0 :         dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
+    2144           0 :         return;
+    2145             :     }
+    2146             : 
+    2147           0 :     if (dlt_check_rcv_data_size(msg->datasize, sizeof(DltServiceSetDefaultLogLevel)) < 0)
+    2148             :         return;
+    2149             : 
+    2150           0 :     req = (DltServiceSetDefaultLogLevel *)(msg->databuffer);
+    2151             : 
+    2152             :     /* No endianess conversion necessary */
+    2153           0 :     if ((req != NULL) &&
+    2154           0 :         ((req->log_level <= DLT_TRACE_STATUS_ON) || (req->log_level == (uint8_t)DLT_TRACE_STATUS_DEFAULT))) {
+    2155           0 :         if (daemon_local->flags.enforceContextLLAndTS)
+    2156           0 :             tracestatus = getStatus(req->log_level, daemon_local->flags.contextTraceStatus);
+    2157             :         else
+    2158           0 :             tracestatus = (int8_t) req->log_level; /* No endianess conversion necessary */
+    2159             : 
+    2160             :         /* Send Update to all contexts using the new log level */
+    2161           0 :         dlt_daemon_user_send_all_trace_status_update(daemon, tracestatus, verbose);
+    2162             : 
+    2163           0 :         dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+    2164             :     }
+    2165             :     else {
+    2166           0 :         dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+    2167             :     }
+    2168             : }
+    2169             : 
+    2170           0 : void dlt_daemon_control_set_timing_packets(int sock,
+    2171             :                                            DltDaemon *daemon,
+    2172             :                                            DltDaemonLocal *daemon_local,
+    2173             :                                            DltMessage *msg,
+    2174             :                                            int verbose)
+    2175             : {
+    2176           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2177             : 
+    2178             :     DltServiceSetVerboseMode *req;  /* request uses same struct as set verbose mode */
+    2179             :     uint32_t id = DLT_SERVICE_ID_SET_TIMING_PACKETS;
+    2180             : 
+    2181           0 :     if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
+    2182             :         return;
+    2183             : 
+    2184           0 :     if (dlt_check_rcv_data_size(msg->datasize, sizeof(DltServiceSetVerboseMode)) < 0)
+    2185             :         return;
+    2186             : 
+    2187           0 :     req = (DltServiceSetVerboseMode *)(msg->databuffer);
+    2188             : 
+    2189           0 :     if ((req->new_status == 0) || (req->new_status == 1)) {
+    2190           0 :         daemon->timingpackets = req->new_status;
+    2191             : 
+    2192           0 :         dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+    2193             :     }
+    2194             :     else {
+    2195           0 :         dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+    2196             :     }
+    2197             : }
+    2198             : 
+    2199           0 : void dlt_daemon_control_message_time(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
+    2200             : {
+    2201             :     DltMessage msg;
+    2202             :     int32_t len;
+    2203             : 
+    2204           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2205             : 
+    2206           0 :     if (daemon == 0)
+    2207           0 :         return;
+    2208             : 
+    2209             :     /* initialise new message */
+    2210           0 :     if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+    2211             :         return;
+    2212             : 
+    2213             :     /* send message */
+    2214             : 
+    2215             :     /* prepare storage header */
+    2216           0 :     msg.storageheader = (DltStorageHeader *)msg.headerbuffer;
+    2217           0 :     dlt_set_storageheader(msg.storageheader, daemon->ecuid);
+    2218             : 
+    2219             :     /* prepare standard header */
+    2220           0 :     msg.standardheader = (DltStandardHeader *)(msg.headerbuffer + sizeof(DltStorageHeader));
+    2221           0 :     msg.standardheader->htyp = DLT_HTYP_WEID | DLT_HTYP_WTMS | DLT_HTYP_UEH | DLT_HTYP_PROTOCOL_VERSION1;
+    2222             : 
+    2223             : #if (BYTE_ORDER == BIG_ENDIAN)
+    2224             :     msg.standardheader->htyp = (msg.standardheader->htyp | DLT_HTYP_MSBF);
+    2225             : #endif
+    2226             : 
+    2227           0 :     msg.standardheader->mcnt = 0;
+    2228             : 
+    2229             :     /* Set header extra parameters */
+    2230           0 :     dlt_set_id(msg.headerextra.ecu, daemon->ecuid);
+    2231           0 :     msg.headerextra.tmsp = dlt_uptime();
+    2232             : 
+    2233           0 :     dlt_message_set_extraparameters(&msg, verbose);
+    2234             : 
+    2235             :     /* prepare extended header */
+    2236           0 :     msg.extendedheader =
+    2237           0 :         (DltExtendedHeader *)(msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+    2238           0 :                               DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp));
+    2239           0 :     msg.extendedheader->msin = DLT_MSIN_CONTROL_TIME;
+    2240             : 
+    2241           0 :     msg.extendedheader->noar = 0;                  /* number of arguments */
+    2242           0 :     dlt_set_id(msg.extendedheader->apid, "");       /* application id */
+    2243           0 :     dlt_set_id(msg.extendedheader->ctid, "");       /* context id */
+    2244             : 
+    2245             :     /* prepare length information */
+    2246           0 :     msg.headersize = (uint32_t) (sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) +
+    2247           0 :         DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp));
+    2248             : 
+    2249           0 :     len = (int32_t) (msg.headersize - sizeof(DltStorageHeader) + msg.datasize);
+    2250             : 
+    2251           0 :     if (len > UINT16_MAX) {
+    2252           0 :         dlt_log(LOG_WARNING, "Huge control message discarded!\n");
+    2253             : 
+    2254             :         /* free message */
+    2255           0 :         dlt_message_free(&msg, 0);
+    2256             : 
+    2257           0 :         return;
+    2258             :     }
+    2259             : 
+    2260           0 :     msg.standardheader->len = DLT_HTOBE_16(((uint16_t)len));
+    2261             : 
+    2262             :     /* Send message, ignore return value */
+    2263           0 :     dlt_daemon_client_send(sock, daemon, daemon_local, msg.headerbuffer,
+    2264             :                            sizeof(DltStorageHeader),
+    2265             :                            msg.headerbuffer + sizeof(DltStorageHeader),
+    2266             :                            (int) msg.headersize - (int) sizeof(DltStorageHeader),
+    2267           0 :                            msg.databuffer, (int) msg.datasize, verbose);
+    2268             : 
+    2269             :     /* free message */
+    2270           0 :     dlt_message_free(&msg, 0);
+    2271             : }
+    2272             : 
+    2273          11 : int dlt_daemon_process_one_s_timer(DltDaemon *daemon,
+    2274             :                                    DltDaemonLocal *daemon_local,
+    2275             :                                    DltReceiver *receiver,
+    2276             :                                    int verbose)
+    2277             : {
+    2278          11 :     uint64_t expir = 0;
+    2279             :     ssize_t res = 0;
+    2280             : 
+    2281          11 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2282             : 
+    2283          11 :     if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
+    2284           0 :         dlt_vlog(LOG_ERR, "%s: invalid parameters", __func__);
+    2285           0 :         return -1;
+    2286             :     }
+    2287             : 
+    2288          11 :     res = read(receiver->fd, &expir, sizeof(expir));
+    2289             : 
+    2290          11 :     if (res < 0) {
+    2291           0 :         dlt_vlog(LOG_WARNING, "%s: Fail to read timer (%s)\n", __func__,
+    2292           0 :                  strerror(errno));
+    2293             :         /* Activity received on timer_wd, but unable to read the fd:
+    2294             :          * let's go on sending notification */
+    2295             :     }
+    2296             : 
+    2297          11 :     if ((daemon->state == DLT_DAEMON_STATE_SEND_BUFFER) ||
+    2298             :         (daemon->state == DLT_DAEMON_STATE_BUFFER_FULL)) {
+    2299           0 :         if (dlt_daemon_send_ringbuffer_to_client(daemon,
+    2300             :                                                  daemon_local,
+    2301             :                                                  daemon_local->flags.vflag))
+    2302           0 :             dlt_log(LOG_DEBUG,
+    2303             :                     "Can't send contents of ring buffer to clients\n");
+    2304             :     }
+    2305             : 
+    2306          11 :     if ((daemon->timingpackets) &&
+    2307           0 :         (daemon->state == DLT_DAEMON_STATE_SEND_DIRECT))
+    2308           0 :         dlt_daemon_control_message_time(DLT_DAEMON_SEND_TO_ALL,
+    2309             :                                         daemon,
+    2310             :                                         daemon_local,
+    2311             :                                         daemon_local->flags.vflag);
+    2312             : 
+    2313          11 :     dlt_log(LOG_DEBUG, "Timer timingpacket\n");
+    2314             : 
+    2315          11 :     return 0;
+    2316             : }
+    2317             : 
+    2318           0 : int dlt_daemon_process_sixty_s_timer(DltDaemon *daemon,
+    2319             :                                      DltDaemonLocal *daemon_local,
+    2320             :                                      DltReceiver *receiver,
+    2321             :                                      int verbose)
+    2322             : {
+    2323           0 :     uint64_t expir = 0;
+    2324             :     ssize_t res = 0;
+    2325             : 
+    2326           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2327             : 
+    2328           0 :     if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
+    2329           0 :         dlt_vlog(LOG_ERR, "%s: invalid parameters", __func__);
+    2330           0 :         return -1;
+    2331             :     }
+    2332             : 
+    2333           0 :     res = read(receiver->fd, &expir, sizeof(expir));
+    2334             : 
+    2335           0 :     if (res < 0) {
+    2336           0 :         dlt_vlog(LOG_WARNING, "%s: Fail to read timer (%s)\n", __func__,
+    2337           0 :                  strerror(errno));
+    2338             :         /* Activity received on timer_wd, but unable to read the fd:
+    2339             :          * let's go on sending notification */
+    2340             :     }
+    2341             : 
+    2342           0 :     if (daemon_local->flags.sendECUSoftwareVersion > 0)
+    2343           0 :         dlt_daemon_control_get_software_version(DLT_DAEMON_SEND_TO_ALL,
+    2344             :                                                 daemon,
+    2345             :                                                 daemon_local,
+    2346             :                                                 daemon_local->flags.vflag);
+    2347             : 
+    2348           0 :     if (daemon_local->flags.sendTimezone > 0) {
+    2349             :         /* send timezone information */
+    2350           0 :         time_t t = time(NULL);
+    2351             :         struct tm lt;
+    2352             : 
+    2353             :         /*Added memset to avoid compiler warning for near initialization */
+    2354             :         memset((void *)&lt, 0, sizeof(lt));
+    2355           0 :         tzset();
+    2356           0 :         localtime_r(&t, &lt);
+    2357             : 
+    2358           0 :         dlt_daemon_control_message_timezone(DLT_DAEMON_SEND_TO_ALL,
+    2359             :                                             daemon,
+    2360             :                                             daemon_local,
+    2361             :                                             daemon_local->flags.vflag);
+    2362             :     }
+    2363             : 
+    2364           0 :     dlt_log(LOG_DEBUG, "Timer ecuversion\n");
+    2365             : 
+    2366           0 :     return 0;
+    2367             : }
+    2368             : 
+    2369             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+    2370             : int dlt_daemon_process_systemd_timer(DltDaemon *daemon,
+    2371             :                                      DltDaemonLocal *daemon_local,
+    2372             :                                      DltReceiver *receiver,
+    2373             :                                      int verbose)
+    2374             : {
+    2375             :     uint64_t expir = 0;
+    2376             :     ssize_t res = -1;
+    2377             : 
+    2378             :     PRINT_FUNCTION_VERBOSE(verbose);
+    2379             : 
+    2380             :     if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
+    2381             :         dlt_vlog(LOG_ERR, "%s: invalid parameters", __func__);
+    2382             :         return res;
+    2383             :     }
+    2384             : 
+    2385             :     res = read(receiver->fd, &expir, sizeof(expir));
+    2386             : 
+    2387             :     if (res < 0) {
+    2388             :         dlt_vlog(LOG_WARNING, "Failed to read timer_wd; %s\n", strerror(errno));
+    2389             :         /* Activity received on timer_wd, but unable to read the fd:
+    2390             :          * let's go on sending notification */
+    2391             :     }
+    2392             : 
+    2393             : #ifdef DLT_SYSTEMD_WATCHDOG_ENFORCE_MSG_RX_ENABLE
+    2394             :     if (!daemon->received_message_since_last_watchdog_interval) {
+    2395             :       dlt_log(LOG_WARNING, "No new messages received since last watchdog timer run\n");
+    2396             :       return 0;
+    2397             :     }
+    2398             :     daemon->received_message_since_last_watchdog_interval = 0;
+    2399             : #endif
+    2400             : 
+    2401             :     if (sd_notify(0, "WATCHDOG=1") < 0)
+    2402             :         dlt_log(LOG_CRIT, "Could not reset systemd watchdog\n");
+    2403             : 
+    2404             :     dlt_log(LOG_DEBUG, "Timer watchdog\n");
+    2405             : 
+    2406             :     return 0;
+    2407             : }
+    2408             : #else
+    2409           0 : int dlt_daemon_process_systemd_timer(DltDaemon *daemon,
+    2410             :                                      DltDaemonLocal *daemon_local,
+    2411             :                                      DltReceiver *receiver,
+    2412             :                                      int verbose)
+    2413             : {
+    2414             :     (void)daemon;
+    2415             :     (void)daemon_local;
+    2416             :     (void)receiver;
+    2417             :     (void)verbose;
+    2418             : 
+    2419           0 :     dlt_log(LOG_DEBUG, "Timer watchdog not enabled\n");
+    2420             : 
+    2421           0 :     return -1;
+    2422             : }
+    2423             : #endif
+    2424             : 
+    2425           2 : void dlt_daemon_control_service_logstorage(int sock,
+    2426             :                                            DltDaemon *daemon,
+    2427             :                                            DltDaemonLocal *daemon_local,
+    2428             :                                            DltMessage *msg,
+    2429             :                                            int verbose)
+    2430             : {
+    2431             :     DltServiceOfflineLogstorage *req = NULL;
+    2432             :     int ret = 0;
+    2433             :     unsigned int connection_type = 0;
+    2434             :     DltLogStorage *device = NULL;
+    2435             :     int device_index = -1;
+    2436             :     uint32_t i = 0;
+    2437             : 
+    2438             :     int tmp_errno = 0;
+    2439             : 
+    2440           2 :     struct stat daemon_mpoint_st = {0};
+    2441             :     int daemon_st_status = 0;
+    2442             : 
+    2443           2 :     struct stat req_mpoint_st = {0};
+    2444             :     int req_st_status = 0;
+    2445             : 
+    2446           2 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2447             : 
+    2448           2 :     if ((daemon == NULL) || (msg == NULL) || (daemon_local == NULL)) {
+    2449           0 :         dlt_vlog(LOG_ERR,
+    2450             :                  "%s: Invalid function parameters\n",
+    2451             :                  __func__);
+    2452           0 :         return;
+    2453             :     }
+    2454             : 
+    2455           2 :     if ((daemon_local->flags.offlineLogstorageMaxDevices <= 0) || (msg->databuffer == NULL)) {
+    2456           0 :         dlt_daemon_control_service_response(sock,
+    2457             :                                             daemon,
+    2458             :                                             daemon_local,
+    2459             :                                             DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2460             :                                             DLT_SERVICE_RESPONSE_ERROR,
+    2461             :                                             verbose);
+    2462             : 
+    2463           0 :         dlt_log(LOG_INFO,
+    2464             :                 "Logstorage functionality not enabled or MAX device set is 0\n");
+    2465           0 :         return;
+    2466             :     }
+    2467             : 
+    2468           2 :     if (dlt_check_rcv_data_size(msg->datasize, sizeof(DltServiceOfflineLogstorage)) < 0)
+    2469             :         return;
+    2470             : 
+    2471           2 :     req = (DltServiceOfflineLogstorage *)(msg->databuffer);
+    2472             : 
+    2473           2 :     if(req->connection_type != DLT_OFFLINE_LOGSTORAGE_SYNC_CACHES) {
+    2474           0 :         req_st_status = stat(req->mount_point, &req_mpoint_st);
+    2475           0 :         tmp_errno = errno;
+    2476           0 :         if (req_st_status < 0) {
+    2477           0 :             dlt_daemon_control_service_response(sock,
+    2478             :                                                 daemon,
+    2479             :                                                 daemon_local,
+    2480             :                                                 DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2481             :                                                 DLT_SERVICE_RESPONSE_ERROR,
+    2482             :                                                 verbose);
+    2483             : 
+    2484           0 :             dlt_vlog(LOG_WARNING,
+    2485             :                      "%s: Failed to stat requested mount point [%s] with error [%s]\n",
+    2486             :                      __func__, req->mount_point, strerror(tmp_errno));
+    2487           0 :             return;
+    2488             :         }
+    2489             :     }
+    2490             : 
+    2491           4 :     for (i = 0; i < (uint32_t) daemon_local->flags.offlineLogstorageMaxDevices; i++) {
+    2492           2 :         connection_type = daemon->storage_handle[i].connection_type;
+    2493             : 
+    2494             :         memset(&daemon_mpoint_st, 0, sizeof(struct stat));
+    2495           2 :         if (strlen(daemon->storage_handle[i].device_mount_point) > 1) {
+    2496           0 :             daemon_st_status = stat(daemon->storage_handle[i].device_mount_point,
+    2497             :                     &daemon_mpoint_st);
+    2498           0 :             tmp_errno = errno;
+    2499             : 
+    2500           0 :             if (daemon_st_status < 0) {
+    2501           0 :                 dlt_daemon_control_service_response(sock,
+    2502             :                                                     daemon,
+    2503             :                                                     daemon_local,
+    2504             :                                                     DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2505             :                                                     DLT_SERVICE_RESPONSE_ERROR,
+    2506             :                                                     verbose);
+    2507           0 :                 dlt_vlog(LOG_WARNING,
+    2508             :                         "%s: Failed to stat daemon mount point [%s] with error [%s]\n",
+    2509           0 :                         __func__, daemon->storage_handle[i].device_mount_point,
+    2510             :                         strerror(tmp_errno));
+    2511           0 :                 return;
+    2512             :             }
+    2513             : 
+    2514             :             /* Check if the requested device path is already used as log storage device */
+    2515           0 :             if (req_mpoint_st.st_dev == daemon_mpoint_st.st_dev &&
+    2516           0 :                     req_mpoint_st.st_ino == daemon_mpoint_st.st_ino) {
+    2517           0 :                 device_index = (int) i;
+    2518           0 :                 break;
+    2519             :             }
+    2520             :         }
+    2521             : 
+    2522             :         /* Get first available device index here */
+    2523           2 :         if ((connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) &&
+    2524           2 :             (device_index == -1))
+    2525           0 :             device_index = (int) i;
+    2526             :     }
+    2527             : 
+    2528             :     /* It might be possible to sync all caches of all devices */
+    2529           2 :     if ((req->connection_type == DLT_OFFLINE_LOGSTORAGE_SYNC_CACHES) &&
+    2530           2 :         (strlen(req->mount_point) == 0)) {
+    2531             :         /* It is expected to receive an empty mount point to sync all Logstorage
+    2532             :          * devices in this case. */
+    2533             :     }
+    2534           0 :     else if (device_index == -1) {
+    2535           0 :         dlt_daemon_control_service_response(sock,
+    2536             :                                             daemon,
+    2537             :                                             daemon_local,
+    2538             :                                             DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2539             :                                             DLT_SERVICE_RESPONSE_ERROR,
+    2540             :                                             verbose);
+    2541           0 :         dlt_log(LOG_WARNING, "MAX devices already in use  \n");
+    2542           0 :         return;
+    2543             :     }
+    2544             : 
+    2545             :     /* Check for device connection request from log storage ctrl app  */
+    2546           2 :     device = &daemon->storage_handle[device_index];
+    2547             : 
+    2548           2 :     if (req->connection_type == DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) {
+    2549           0 :         ret = dlt_logstorage_device_connected(device, req->mount_point);
+    2550             : 
+    2551           0 :         if (ret == 1) {
+    2552           0 :             dlt_daemon_control_service_response(sock,
+    2553             :                                                 daemon,
+    2554             :                                                 daemon_local,
+    2555             :                                                 DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2556             :                                                 DLT_SERVICE_RESPONSE_WARNING,
+    2557             :                                                 verbose);
+    2558           0 :             return;
+    2559             :         }
+    2560           0 :         else if (ret != 0)
+    2561             :         {
+    2562           0 :             dlt_daemon_control_service_response(sock,
+    2563             :                                                 daemon,
+    2564             :                                                 daemon_local,
+    2565             :                                                 DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2566             :                                                 DLT_SERVICE_RESPONSE_ERROR,
+    2567             :                                                 verbose);
+    2568           0 :             return;
+    2569             :         }
+    2570             : 
+    2571           0 :         dlt_daemon_control_service_response(sock,
+    2572             :                                             daemon,
+    2573             :                                             daemon_local,
+    2574             :                                             DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2575             :                                             DLT_SERVICE_RESPONSE_OK,
+    2576             :                                             verbose);
+    2577             : 
+    2578             :         /* Update maintain logstorage loglevel if necessary */
+    2579           0 :         if (daemon->storage_handle[device_index].maintain_logstorage_loglevel != DLT_MAINTAIN_LOGSTORAGE_LOGLEVEL_UNDEF)
+    2580             :         {
+    2581           0 :             daemon->maintain_logstorage_loglevel = daemon->storage_handle[device_index].maintain_logstorage_loglevel;
+    2582             :         }
+    2583             : 
+    2584             :         /* Check if log level of running application needs an update */
+    2585           0 :         dlt_daemon_logstorage_update_application_loglevel(daemon,
+    2586             :                                                           daemon_local,
+    2587             :                                                           device_index,
+    2588             :                                                           verbose);
+    2589             : 
+    2590             :     }
+    2591             :     /* Check for device disconnection request from log storage ctrl app  */
+    2592           2 :     else if (req->connection_type == DLT_OFFLINE_LOGSTORAGE_DEVICE_DISCONNECTED)
+    2593             :     {
+    2594             :         /* Check if log level of running application needs to be reset */
+    2595           0 :         dlt_daemon_logstorage_reset_application_loglevel(
+    2596             :             daemon,
+    2597             :             daemon_local,
+    2598             :             device_index,
+    2599             :             (int) daemon_local->flags.offlineLogstorageMaxDevices,
+    2600             :             verbose);
+    2601             : 
+    2602           0 :         dlt_logstorage_device_disconnected(&(daemon->storage_handle[device_index]),
+    2603             :                                            DLT_LOGSTORAGE_SYNC_ON_DEVICE_DISCONNECT);
+    2604             : 
+    2605           0 :         dlt_daemon_control_service_response(sock,
+    2606             :                                             daemon,
+    2607             :                                             daemon_local,
+    2608             :                                             DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2609             :                                             DLT_SERVICE_RESPONSE_OK,
+    2610             :                                             verbose);
+    2611             : 
+    2612             :     }
+    2613             :     /* Check for cache synchronization request from log storage ctrl app */
+    2614           2 :     else if (req->connection_type == DLT_OFFLINE_LOGSTORAGE_SYNC_CACHES)
+    2615             :     {
+    2616             :         ret = 0;
+    2617             : 
+    2618           2 :         if (device_index == -1) { /* sync all Logstorage devices */
+    2619             : 
+    2620           4 :             for (i = 0; i < (uint32_t) daemon_local->flags.offlineLogstorageMaxDevices; i++)
+    2621           2 :                 if (daemon->storage_handle[i].connection_type ==
+    2622             :                     DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED)
+    2623           2 :                     ret = dlt_daemon_logstorage_sync_cache(
+    2624             :                         daemon,
+    2625             :                         daemon_local,
+    2626           2 :                         daemon->storage_handle[i].device_mount_point,
+    2627             :                         verbose);
+    2628             :         }
+    2629             :         else {
+    2630             :             /* trigger logstorage to sync caches */
+    2631           0 :             ret = dlt_daemon_logstorage_sync_cache(daemon,
+    2632             :                                                    daemon_local,
+    2633           0 :                                                    req->mount_point,
+    2634             :                                                    verbose);
+    2635             :         }
+    2636             : 
+    2637           2 :         if (ret == 0)
+    2638           2 :             dlt_daemon_control_service_response(sock,
+    2639             :                                                 daemon,
+    2640             :                                                 daemon_local,
+    2641             :                                                 DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2642             :                                                 DLT_SERVICE_RESPONSE_OK,
+    2643             :                                                 verbose);
+    2644             :         else
+    2645           0 :             dlt_daemon_control_service_response(sock,
+    2646             :                                                 daemon,
+    2647             :                                                 daemon_local,
+    2648             :                                                 DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2649             :                                                 DLT_SERVICE_RESPONSE_ERROR,
+    2650             :                                                 verbose);
+    2651             :     }
+    2652             :     else {
+    2653           0 :         dlt_daemon_control_service_response(sock,
+    2654             :                                             daemon,
+    2655             :                                             daemon_local,
+    2656             :                                             DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2657             :                                             DLT_SERVICE_RESPONSE_ERROR,
+    2658             :                                             verbose);
+    2659             :     }
+    2660             : }
+    2661             : 
+    2662           0 : void dlt_daemon_control_passive_node_connect(int sock,
+    2663             :                                              DltDaemon *daemon,
+    2664             :                                              DltDaemonLocal *daemon_local,
+    2665             :                                              DltMessage *msg,
+    2666             :                                              int verbose)
+    2667             : {
+    2668           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2669             : 
+    2670             :     DltServicePassiveNodeConnect *req;
+    2671             :     uint32_t id = DLT_SERVICE_ID_PASSIVE_NODE_CONNECT;
+    2672             : 
+    2673           0 :     if ((daemon == NULL) || (daemon_local == NULL) || (msg == NULL) ||
+    2674           0 :         (msg->databuffer == NULL))
+    2675             :         return;
+    2676             : 
+    2677             :     /* return error, if gateway mode not enabled*/
+    2678           0 :     if (daemon_local->flags.gatewayMode == 0) {
+    2679           0 :         dlt_log(LOG_WARNING,
+    2680             :                 "Received passive node connection status request, "
+    2681             :                 "but GatewayMode is disabled\n");
+    2682             : 
+    2683           0 :         dlt_daemon_control_service_response(
+    2684             :             sock,
+    2685             :             daemon,
+    2686             :             daemon_local,
+    2687             :             DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS,
+    2688             :             DLT_SERVICE_RESPONSE_ERROR,
+    2689             :             verbose);
+    2690             : 
+    2691           0 :         return;
+    2692             :     }
+    2693             : 
+    2694           0 :     if (dlt_check_rcv_data_size(msg->datasize, sizeof(DltServicePassiveNodeConnect)) < 0)
+    2695             :         return;
+    2696             : 
+    2697           0 :     req = (DltServicePassiveNodeConnect *)msg->databuffer;
+    2698             : 
+    2699           0 :     if (dlt_gateway_process_on_demand_request(&daemon_local->pGateway,
+    2700             :                                               daemon_local,
+    2701           0 :                                               req->node_id,
+    2702           0 :                                               (int) req->connection_status,
+    2703             :                                               verbose) < 0)
+    2704           0 :         dlt_daemon_control_service_response(sock,
+    2705             :                                             daemon,
+    2706             :                                             daemon_local,
+    2707             :                                             id,
+    2708             :                                             DLT_SERVICE_RESPONSE_ERROR,
+    2709             :                                             verbose);
+    2710             :     else
+    2711           0 :         dlt_daemon_control_service_response(sock,
+    2712             :                                             daemon,
+    2713             :                                             daemon_local,
+    2714             :                                             id,
+    2715             :                                             DLT_SERVICE_RESPONSE_OK,
+    2716             :                                             verbose);
+    2717             : }
+    2718             : 
+    2719           0 : void dlt_daemon_control_passive_node_connect_status(int sock,
+    2720             :                                                     DltDaemon *daemon,
+    2721             :                                                     DltDaemonLocal *daemon_local,
+    2722             :                                                     int verbose)
+    2723             : {
+    2724             :     DltMessage msg;
+    2725             :     DltServicePassiveNodeConnectionInfo *resp;
+    2726             :     DltGatewayConnection *con = NULL;
+    2727             :     unsigned int i = 0;
+    2728             : 
+    2729           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2730             : 
+    2731           0 :     if ((daemon == NULL) || (daemon_local == NULL))
+    2732           0 :         return;
+    2733             : 
+    2734           0 :     if (dlt_message_init(&msg, verbose) == -1)
+    2735             :         return;
+    2736             : 
+    2737             :     /* return error, if gateway mode not enabled*/
+    2738           0 :     if (daemon_local->flags.gatewayMode == 0) {
+    2739           0 :         dlt_log(LOG_WARNING,
+    2740             :                 "Received passive node connection status request, "
+    2741             :                 "but GatewayMode is disabled\n");
+    2742             : 
+    2743           0 :         dlt_daemon_control_service_response(
+    2744             :             sock,
+    2745             :             daemon,
+    2746             :             daemon_local,
+    2747             :             DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS,
+    2748             :             DLT_SERVICE_RESPONSE_ERROR,
+    2749             :             verbose);
+    2750             : 
+    2751           0 :         return;
+    2752             :     }
+    2753             : 
+    2754             :     /* prepare payload of data */
+    2755           0 :     msg.datasize = sizeof(DltServicePassiveNodeConnectionInfo);
+    2756             : 
+    2757           0 :     if (msg.databuffer && (msg.databuffersize < msg.datasize))
+    2758           0 :         msg.databuffer = NULL;
+    2759             : 
+    2760           0 :     if (msg.databuffer == NULL) {
+    2761           0 :         msg.databuffer = (uint8_t *)malloc(msg.datasize);
+    2762             : 
+    2763           0 :         if (msg.databuffer == NULL) {
+    2764           0 :             dlt_log(LOG_CRIT, "Cannot allocate memory for message response\n");
+    2765           0 :             return;
+    2766             :         }
+    2767             : 
+    2768           0 :         msg.databuffersize = msg.datasize;
+    2769             :     }
+    2770             : 
+    2771           0 :     resp = (DltServicePassiveNodeConnectionInfo *)msg.databuffer;
+    2772             :     memset(resp, 0, msg.datasize);
+    2773           0 :     resp->service_id = DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS;
+    2774             :     resp->status = DLT_SERVICE_RESPONSE_OK;
+    2775           0 :     resp->num_connections = (uint32_t) daemon_local->pGateway.num_connections;
+    2776             : 
+    2777           0 :     for (i = 0; i < resp->num_connections; i++) {
+    2778           0 :         if ((i * DLT_ID_SIZE) > DLT_ENTRY_MAX) {
+    2779           0 :             dlt_log(LOG_ERR,
+    2780             :                     "Maximal message size reached. Skip further information\n");
+    2781           0 :             break;
+    2782             :         }
+    2783             : 
+    2784           0 :         con = &daemon_local->pGateway.connections[i];
+    2785             : 
+    2786           0 :         resp->connection_status[i] = con->status;
+    2787           0 :         memcpy(&resp->node_id[i * DLT_ID_SIZE], con->ecuid, DLT_ID_SIZE);
+    2788             :     }
+    2789             : 
+    2790           0 :     dlt_daemon_client_send_control_message(sock,
+    2791             :                                            daemon,
+    2792             :                                            daemon_local,
+    2793             :                                            &msg,
+    2794             :                                            "",
+    2795             :                                            "",
+    2796             :                                            verbose);
+    2797             :     /* free message */
+    2798           0 :     dlt_message_free(&msg, verbose);
+    2799             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_common.c.func-sort-c.html b/dlt_lcov_report/daemon/dlt_daemon_common.c.func-sort-c.html new file mode 100644 index 000000000..8b86e1db4 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_common.c.func-sort-c.html @@ -0,0 +1,200 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_common.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_common.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:35162356.3 %
Date:2024-12-05 09:07:13Functions:233271.9 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_applications_save0
dlt_daemon_cmp_apid0
dlt_daemon_configuration_save0
dlt_daemon_contexts_load0
dlt_daemon_contexts_save0
dlt_daemon_control_reset_to_factory_default0
dlt_daemon_user_send_all_log_level_update0
dlt_daemon_user_send_all_trace_status_update0
dlt_daemon_user_send_default_update0
dlt_daemon_user_send_all_log_state5
dlt_daemon_application_del6
dlt_daemon_applications_load9
dlt_daemon_configuration_load9
dlt_daemon_free9
dlt_daemon_init_runtime_configuration9
dlt_daemon_user_send_log_state9
dlt_daemon_application_add10
dlt_daemon_applications_clear10
dlt_daemon_contexts_clear10
dlt_daemon_application_reset_user_handle15
dlt_daemon_applications_invalidate_fd15
dlt_daemon_contexts_invalidate_fd15
dlt_daemon_change_state16
dlt_daemon_init17
dlt_daemon_init_user_information18
dlt_daemon_context_del37
dlt_daemon_context_add41
dlt_daemon_user_send_log_level41
dlt_daemon_application_find149
dlt_daemon_context_find157
dlt_daemon_cmp_apid_ctid471
dlt_daemon_find_users_list474
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_common.c.func.html b/dlt_lcov_report/daemon/dlt_daemon_common.c.func.html new file mode 100644 index 000000000..306314ff0 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_common.c.func.html @@ -0,0 +1,200 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_common.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_common.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:35162356.3 %
Date:2024-12-05 09:07:13Functions:233271.9 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_application_add10
dlt_daemon_application_del6
dlt_daemon_application_find149
dlt_daemon_application_reset_user_handle15
dlt_daemon_applications_clear10
dlt_daemon_applications_invalidate_fd15
dlt_daemon_applications_load9
dlt_daemon_applications_save0
dlt_daemon_change_state16
dlt_daemon_cmp_apid0
dlt_daemon_cmp_apid_ctid471
dlt_daemon_configuration_load9
dlt_daemon_configuration_save0
dlt_daemon_context_add41
dlt_daemon_context_del37
dlt_daemon_context_find157
dlt_daemon_contexts_clear10
dlt_daemon_contexts_invalidate_fd15
dlt_daemon_contexts_load0
dlt_daemon_contexts_save0
dlt_daemon_control_reset_to_factory_default0
dlt_daemon_find_users_list474
dlt_daemon_free9
dlt_daemon_init17
dlt_daemon_init_runtime_configuration9
dlt_daemon_init_user_information18
dlt_daemon_user_send_all_log_level_update0
dlt_daemon_user_send_all_log_state5
dlt_daemon_user_send_all_trace_status_update0
dlt_daemon_user_send_default_update0
dlt_daemon_user_send_log_level41
dlt_daemon_user_send_log_state9
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_common.c.gcov.html b/dlt_lcov_report/daemon/dlt_daemon_common.c.gcov.html new file mode 100644 index 000000000..413156bbd --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_common.c.gcov.html @@ -0,0 +1,2159 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_common.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_common.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:35162356.3 %
Date:2024-12-05 09:07:13Functions:233271.9 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2011-2015, BMW AG
+       5             :  *
+       6             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       7             :  *
+       8             :  * This Source Code Form is subject to the terms of the
+       9             :  * Mozilla Public License (MPL), v. 2.0.
+      10             :  * If a copy of the MPL was not distributed with this file,
+      11             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      12             :  *
+      13             :  * For further information see http://www.covesa.org/.
+      14             :  */
+      15             : 
+      16             : /*!
+      17             :  * \author Alexander Wenzel <alexander.aw.wenzel@bmw.de>
+      18             :  *
+      19             :  * \copyright Copyright © 2011-2015 BMW AG. \n
+      20             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      21             :  *
+      22             :  * \file dlt_daemon_common.c
+      23             :  */
+      24             : 
+      25             : /*******************************************************************************
+      26             : **                                                                            **
+      27             : **  SRC-MODULE: dlt_daemon_common.c                                           **
+      28             : **                                                                            **
+      29             : **  TARGET    : linux                                                         **
+      30             : **                                                                            **
+      31             : **  PROJECT   : DLT                                                           **
+      32             : **                                                                            **
+      33             : **  AUTHOR    : Alexander Wenzel Alexander.AW.Wenzel@bmw.de                   **
+      34             : **              Markus Klein                                                  **
+      35             : **                                                                            **
+      36             : **  PURPOSE   :                                                               **
+      37             : **                                                                            **
+      38             : **  REMARKS   :                                                               **
+      39             : **                                                                            **
+      40             : **  PLATFORM DEPENDANT [yes/no]: yes                                          **
+      41             : **                                                                            **
+      42             : **  TO BE CHANGED BY USER [yes/no]: no                                        **
+      43             : **                                                                            **
+      44             : *******************************************************************************/
+      45             : 
+      46             : /*******************************************************************************
+      47             : **                      Author Identity                                       **
+      48             : ********************************************************************************
+      49             : **                                                                            **
+      50             : ** Initials     Name                       Company                            **
+      51             : ** --------     -------------------------  ---------------------------------- **
+      52             : **  aw          Alexander Wenzel           BMW                                **
+      53             : **  mk          Markus Klein               Fraunhofer ESK                     **
+      54             : *******************************************************************************/
+      55             : 
+      56             : /*******************************************************************************
+      57             : **                      Revision Control History                              **
+      58             : *******************************************************************************/
+      59             : 
+      60             : /*
+      61             :  * $LastChangedRevision: 1670 $
+      62             :  * $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
+      63             :  * $LastChangedBy$
+      64             :  * Initials    Date         Comment
+      65             :  * aw          13.01.2010   initial
+      66             :  */
+      67             : 
+      68             : #include <stdbool.h>
+      69             : #include <stdio.h>
+      70             : #include <stdlib.h>
+      71             : #include <string.h>
+      72             : #include <syslog.h>
+      73             : #include <errno.h>
+      74             : #include <unistd.h>
+      75             : #include <fcntl.h>
+      76             : 
+      77             : #include <sys/socket.h> /* send() */
+      78             : 
+      79             : #include "dlt_types.h"
+      80             : #include "dlt_log.h"
+      81             : #include "dlt_daemon_common.h"
+      82             : #include "dlt_daemon_common_cfg.h"
+      83             : #include "dlt_user_shared.h"
+      84             : #include "dlt_user_shared_cfg.h"
+      85             : #include "dlt-daemon.h"
+      86             : 
+      87             : #include "dlt_daemon_socket.h"
+      88             : #include "dlt_daemon_serial.h"
+      89             : 
+      90             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+      91             : #   include <systemd/sd-daemon.h>
+      92             : #endif
+      93             : 
+      94             : char *app_recv_buffer = NULL; /* pointer to receiver buffer for application msges */
+      95             : 
+      96           0 : static int dlt_daemon_cmp_apid(const void *m1, const void *m2)
+      97             : {
+      98         132 :     if ((m1 == NULL) || (m2 == NULL))
+      99             :         return -1;
+     100             : 
+     101             :     DltDaemonApplication *mi1 = (DltDaemonApplication *)m1;
+     102             :     DltDaemonApplication *mi2 = (DltDaemonApplication *)m2;
+     103             : 
+     104         132 :     return memcmp(mi1->apid, mi2->apid, DLT_ID_SIZE);
+     105             : }
+     106             : 
+     107         471 : static int dlt_daemon_cmp_apid_ctid(const void *m1, const void *m2)
+     108             : {
+     109         471 :     if ((m1 == NULL) || (m2 == NULL))
+     110             :         return -1;
+     111             : 
+     112             :     int ret, cmp;
+     113             :     DltDaemonContext *mi1 = (DltDaemonContext *)m1;
+     114             :     DltDaemonContext *mi2 = (DltDaemonContext *)m2;
+     115             : 
+     116         471 :     cmp = memcmp(mi1->apid, mi2->apid, DLT_ID_SIZE);
+     117             : 
+     118         471 :     if (cmp < 0)
+     119             :         ret = -1;
+     120         471 :     else if (cmp == 0)
+     121         471 :         ret = memcmp(mi1->ctid, mi2->ctid, DLT_ID_SIZE);
+     122             :     else
+     123             :         ret = 1;
+     124             : 
+     125             :     return ret;
+     126             : }
+     127             : 
+     128         474 : DltDaemonRegisteredUsers *dlt_daemon_find_users_list(DltDaemon *daemon,
+     129             :                                                      char *ecu,
+     130             :                                                      int verbose)
+     131             : {
+     132         474 :     PRINT_FUNCTION_VERBOSE(verbose);
+     133             : 
+     134             :     int i = 0;
+     135             : 
+     136         474 :     if ((daemon == NULL) || (ecu == NULL)) {
+     137           0 :         dlt_vlog(LOG_ERR, "%s: Wrong parameters", __func__);
+     138           0 :         return (DltDaemonRegisteredUsers *)NULL;
+     139             :     }
+     140             : 
+     141         476 :     for (i = 0; i < daemon->num_user_lists; i++)
+     142         444 :         if (strncmp(ecu, daemon->user_list[i].ecu, DLT_ID_SIZE) == 0)
+     143         442 :             return &daemon->user_list[i];
+     144             : 
+     145          32 :     dlt_vlog(LOG_ERR, "Cannot find user list for ECU: %4s\n", ecu);
+     146          32 :     return (DltDaemonRegisteredUsers *)NULL;
+     147             : }
+     148             : 
+     149             : #ifdef DLT_LOG_LEVEL_APP_CONFIG
+     150             : 
+     151             : static int dlt_daemon_cmp_log_settings(const void *lhs, const void *rhs) {
+     152             :     if ((lhs == NULL) || (rhs == NULL))
+     153             :         return -1;
+     154             : 
+     155             :     DltDaemonContextLogSettings *settings1 = (DltDaemonContextLogSettings *)lhs;
+     156             :     DltDaemonContextLogSettings *settings2 = (DltDaemonContextLogSettings *)rhs;
+     157             : 
+     158             :     int cmp = memcmp(settings1->apid, settings2->apid, DLT_ID_SIZE);
+     159             : 
+     160             :     if (cmp < 0)
+     161             :         return -1;
+     162             :     else if (cmp == 0)
+     163             :         return memcmp(settings1->ctid, settings2->ctid, DLT_ID_SIZE);
+     164             :     else
+     165             :         return 1;
+     166             : }
+     167             : 
+     168             : /**
+     169             :  * Find configuration for app/ctx id specific log settings configuration
+     170             :  * @param daemon pointer to dlt daemon struct
+     171             :  * @param apid application id to use
+     172             :  * @param ctid context id to use, can be NULL
+     173             :  * @return pointer to log settings if found, otherwise NULL
+     174             :  */
+     175             : DltDaemonContextLogSettings *dlt_daemon_find_configured_app_id_ctx_id_settings(
+     176             :     const DltDaemon *daemon, const char *apid, const char *ctid) {
+     177             :     DltDaemonContextLogSettings *app_id_settings = NULL;
+     178             :     for (int i = 0; i < daemon->num_app_id_log_level_settings; ++i) {
+     179             :         DltDaemonContextLogSettings *settings = &daemon->app_id_log_level_settings[i];
+     180             : 
+     181             :         if (strncmp(apid, settings->apid, DLT_ID_SIZE) != 0) {
+     182             :             if (app_id_settings != NULL)
+     183             :                 return app_id_settings;
+     184             :             continue;
+     185             :         }
+     186             : 
+     187             :         if (strlen(settings->ctid) == 0) {
+     188             :             app_id_settings = settings;
+     189             :         }
+     190             : 
+     191             :         if (ctid == NULL || strlen(ctid) == 0) {
+     192             :             if (app_id_settings != NULL) {
+     193             :                 return app_id_settings;
+     194             :             }
+     195             :         } else {
+     196             :             if (strncmp(ctid, settings->ctid, DLT_ID_SIZE) == 0) {
+     197             :                 return settings;
+     198             :             }
+     199             :         }
+     200             :     }
+     201             : 
+     202             :     return app_id_settings;
+     203             : }
+     204             : 
+     205             : /**
+     206             :  * Find configured log levels in a given DltDaemonApplication for the passed context id.
+     207             :  * @param app The application settings which contain the previously loaded ap id settings
+     208             :  * @param ctid The context id to find.
+     209             :  * @return Pointer to DltDaemonApplicationLogSettings containing the log level
+     210             :  *         for the requested application or NULL if none found.
+     211             :  */
+     212             : DltDaemonContextLogSettings *dlt_daemon_find_app_log_level_config(
+     213             :     const DltDaemonApplication *const app, const char *const ctid) {
+     214             : 
+     215             :     if (NULL == ctid)
+     216             :         return NULL;
+     217             : 
+     218             :     DltDaemonContextLogSettings settings;
+     219             :     memcpy(settings.apid, app->apid, DLT_ID_SIZE);
+     220             :     memcpy(settings.ctid, ctid, DLT_ID_SIZE);
+     221             : 
+     222             :     DltDaemonContextLogSettings* log_settings = NULL;
+     223             :     log_settings =
+     224             :         (DltDaemonContextLogSettings *)bsearch(
+     225             :             &settings, app->context_log_level_settings,
+     226             :             (size_t)app->num_context_log_level_settings,
+     227             :             sizeof(DltDaemonContextLogSettings),
+     228             :             dlt_daemon_cmp_log_settings);
+     229             :     return log_settings;
+     230             : }
+     231             : 
+     232             : #endif
+     233             : 
+     234             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+     235             : int dlt_daemon_compare_trace_load_settings(const void *a, const void *b) {
+     236             :     const DltTraceLoadSettings *s1 = (const DltTraceLoadSettings *)a;
+     237             :     const DltTraceLoadSettings *s2 = (const DltTraceLoadSettings *)b;
+     238             : 
+     239             :     int cmp = strncmp(s1->apid, s2->apid, DLT_ID_SIZE);
+     240             :     if (cmp != 0) {
+     241             :         return cmp;
+     242             :     }
+     243             : 
+     244             :     return strncmp(s1->ctid, s2->ctid, DLT_ID_SIZE);
+     245             : }
+     246             : 
+     247             : DltReturnValue dlt_daemon_find_preconfigured_trace_load_settings(
+     248             :     DltDaemon *const daemon, const char *apid, const char *ctid, DltTraceLoadSettings **settings, int *num_settings, int verbose)
+     249             : {
+     250             :     PRINT_FUNCTION_VERBOSE(verbose);
+     251             :     int i;
+     252             :     *num_settings = 0;
+     253             :     *settings = NULL;
+     254             : 
+     255             :     if ((daemon == NULL) || (apid == NULL)) {
+     256             :         dlt_vlog(LOG_ERR, "%s: Wrong parameters", __func__);
+     257             :         return DLT_RETURN_WRONG_PARAMETER;
+     258             :     }
+     259             : 
+     260             :     if (NULL == daemon->preconfigured_trace_load_settings || daemon->preconfigured_trace_load_settings_count == 0) {
+     261             :         return DLT_RETURN_OK;
+     262             :     }
+     263             : 
+     264             :     for (i = 0; i < daemon->preconfigured_trace_load_settings_count; ++i) {
+     265             :         // check if we can exit already, the trace load settings are sorted
+     266             :         // and if the apid does not match anymore, but we already have settings
+     267             :         // means we collected all settings
+     268             :         if (strncmp(apid, daemon->preconfigured_trace_load_settings[i].apid, DLT_ID_SIZE) != 0) {
+     269             :             if ((*num_settings) != 0)
+     270             :                 break;
+     271             :             continue;
+     272             :         }
+     273             : 
+     274             :         // If a ctid is passed, we only want to return entries where both match
+     275             :         if (ctid != NULL && strlen(ctid) > 0) {
+     276             :             if (strncmp(ctid, daemon->preconfigured_trace_load_settings[i].ctid, DLT_ID_SIZE) != 0) {
+     277             :                 continue;
+     278             :             }
+     279             :         }
+     280             : 
+     281             :         // Reallocate memory for the settings array with an additional slot for the new setting
+     282             :         DltTraceLoadSettings *temp = realloc(*settings, (*num_settings + 1) * sizeof(DltTraceLoadSettings));
+     283             :         if (temp == NULL) {
+     284             :             dlt_vlog(LOG_ERR, "Failed to allocate memory for trace load settings\n");
+     285             :             free(*settings); // Free any previously allocated memory
+     286             :             *settings = NULL;
+     287             :             *num_settings = 0;
+     288             :             return DLT_RETURN_ERROR;
+     289             :         }
+     290             :         *settings = temp;
+     291             :         // Copy preconfigured trace load settings into the app settings
+     292             :         (*settings)[*num_settings] = daemon->preconfigured_trace_load_settings[i];
+     293             :         (*num_settings)++;
+     294             :     }
+     295             : 
+     296             :     qsort(*settings, (size_t)*num_settings, sizeof(DltTraceLoadSettings),
+     297             :           dlt_daemon_compare_trace_load_settings);
+     298             :     return DLT_RETURN_OK;
+     299             : }
+     300             : #endif
+     301             : 
+     302           9 : int dlt_daemon_init_runtime_configuration(DltDaemon *daemon, const char *runtime_directory, int verbose)
+     303             : {
+     304           9 :     PRINT_FUNCTION_VERBOSE(verbose);
+     305             :     size_t append_length = 0;
+     306             : 
+     307           9 :     if (daemon == NULL)
+     308             :         return DLT_RETURN_ERROR;
+     309             : 
+     310             :     /* Default */
+     311           9 :     daemon->mode = DLT_USER_MODE_EXTERNAL;
+     312             : 
+     313           9 :     if (runtime_directory == NULL)
+     314             :         return DLT_RETURN_ERROR;
+     315             : 
+     316             :     /* prepare filenames for configuration */
+     317             :     append_length = PATH_MAX - sizeof(DLT_RUNTIME_APPLICATION_CFG);
+     318             : 
+     319           9 :     if (runtime_directory[0]) {
+     320           0 :         strncpy(daemon->runtime_application_cfg, runtime_directory, append_length);
+     321           0 :         daemon->runtime_application_cfg[append_length] = 0;
+     322             :     }
+     323             :     else {
+     324           9 :         strncpy(daemon->runtime_application_cfg, DLT_RUNTIME_DEFAULT_DIRECTORY, append_length);
+     325           9 :         daemon->runtime_application_cfg[append_length] = 0;
+     326             :     }
+     327             : 
+     328           9 :     strcat(daemon->runtime_application_cfg, DLT_RUNTIME_APPLICATION_CFG); /* strcat uncritical here, because max length already checked */
+     329             : 
+     330             :     append_length = PATH_MAX - sizeof(DLT_RUNTIME_CONTEXT_CFG);
+     331             : 
+     332           9 :     if (runtime_directory[0]) {
+     333           0 :         strncpy(daemon->runtime_context_cfg, runtime_directory, append_length);
+     334           0 :         daemon->runtime_context_cfg[append_length] = 0;
+     335             :     }
+     336             :     else {
+     337           9 :         strncpy(daemon->runtime_context_cfg, DLT_RUNTIME_DEFAULT_DIRECTORY, append_length);
+     338           9 :         daemon->runtime_context_cfg[append_length] = 0;
+     339             :     }
+     340             : 
+     341           9 :     strcat(daemon->runtime_context_cfg, DLT_RUNTIME_CONTEXT_CFG); /* strcat uncritical here, because max length already checked */
+     342             : 
+     343             :     append_length = PATH_MAX - sizeof(DLT_RUNTIME_CONFIGURATION);
+     344             : 
+     345           9 :     if (runtime_directory[0]) {
+     346           0 :         strncpy(daemon->runtime_configuration, runtime_directory, append_length);
+     347           0 :         daemon->runtime_configuration[append_length] = 0;
+     348             :     }
+     349             :     else {
+     350           9 :         strncpy(daemon->runtime_configuration, DLT_RUNTIME_DEFAULT_DIRECTORY, append_length);
+     351           9 :         daemon->runtime_configuration[append_length] = 0;
+     352             :     }
+     353             : 
+     354           9 :     strcat(daemon->runtime_configuration, DLT_RUNTIME_CONFIGURATION); /* strcat uncritical here, because max length already checked */
+     355             : 
+     356           9 :     return DLT_RETURN_OK;
+     357             : }
+     358             : 
+     359          17 : int dlt_daemon_init(DltDaemon *daemon,
+     360             :                     unsigned long RingbufferMinSize,
+     361             :                     unsigned long RingbufferMaxSize,
+     362             :                     unsigned long RingbufferStepSize,
+     363             :                     const char *runtime_directory,
+     364             :                     int InitialContextLogLevel,
+     365             :                     int InitialContextTraceStatus,
+     366             :                     int ForceLLTS,
+     367             :                     int verbose)
+     368             : {
+     369          17 :     PRINT_FUNCTION_VERBOSE(verbose);
+     370             : 
+     371          17 :     if ((daemon == NULL) || (runtime_directory == NULL))
+     372             :         return -1;
+     373             : 
+     374          17 :     daemon->user_list = NULL;
+     375          17 :     daemon->num_user_lists = 0;
+     376             : 
+     377          17 :     daemon->default_log_level = (int8_t) InitialContextLogLevel;
+     378          17 :     daemon->default_trace_status = (int8_t) InitialContextTraceStatus;
+     379          17 :     daemon->force_ll_ts = (int8_t) ForceLLTS;
+     380             : 
+     381          17 :     daemon->overflow_counter = 0;
+     382             : 
+     383          17 :     daemon->runtime_context_cfg_loaded = 0;
+     384             : 
+     385          17 :     daemon->connectionState = 0; /* no logger connected */
+     386             : 
+     387          17 :     daemon->state = DLT_DAEMON_STATE_INIT; /* initial logging state */
+     388             : 
+     389             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+     390             :     daemon->preconfigured_trace_load_settings = NULL;
+     391             :     daemon->bytes_sent = 0;
+     392             :     daemon->bytes_recv = 0;
+     393             : #endif
+     394             : 
+     395          17 :     daemon->sendserialheader = 0;
+     396          17 :     daemon->timingpackets = 0;
+     397             : 
+     398          17 :     dlt_set_id(daemon->ecuid, "");
+     399             : 
+     400             :     /* initialize ring buffer for client connection */
+     401          17 :     dlt_vlog(LOG_INFO, "Ringbuffer configuration: %lu/%lu/%lu\n",
+     402             :              RingbufferMinSize, RingbufferMaxSize, RingbufferStepSize);
+     403             : 
+     404          17 :     if (dlt_buffer_init_dynamic(&(daemon->client_ringbuffer),
+     405             :                                 (uint32_t) RingbufferMinSize,
+     406             :                                 (uint32_t) RingbufferMaxSize,
+     407             :                                 (uint32_t) RingbufferStepSize) < DLT_RETURN_OK)
+     408             :         return -1;
+     409             : 
+     410          17 :     daemon->storage_handle = NULL;
+     411             : #ifdef DLT_SYSTEMD_WATCHDOG_ENFORCE_MSG_RX_ENABLE
+     412             :     daemon->received_message_since_last_watchdog_interval = 0;
+     413             : #endif
+     414          17 :     return 0;
+     415             : }
+     416             : 
+     417           9 : int dlt_daemon_free(DltDaemon *daemon, int verbose)
+     418             : {
+     419             :     int i = 0;
+     420             :     DltDaemonRegisteredUsers *user_list = NULL;
+     421             : 
+     422           9 :     PRINT_FUNCTION_VERBOSE(verbose);
+     423             : 
+     424           9 :     if ((daemon == NULL) || (daemon->user_list == NULL))
+     425             :         return -1;
+     426             : 
+     427             :     /* free all registered user information */
+     428          19 :     for (i = 0; i < daemon->num_user_lists; i++) {
+     429          10 :         user_list = &daemon->user_list[i];
+     430             : 
+     431          10 :         if (user_list != NULL) {
+     432             :             /* ignore return values */
+     433          10 :             dlt_daemon_contexts_clear(daemon, user_list->ecu, verbose);
+     434          10 :             dlt_daemon_applications_clear(daemon, user_list->ecu, verbose);
+     435             :         }
+     436             :     }
+     437             : 
+     438           9 :     free(daemon->user_list);
+     439             : 
+     440             : #ifdef DLT_LOG_LEVEL_APP_CONFIG
+     441             :     if (daemon->app_id_log_level_settings != NULL) {
+     442             :       free(daemon->app_id_log_level_settings);
+     443             :     }
+     444             : #endif
+     445             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+     446             :     if (daemon->preconfigured_trace_load_settings != NULL) {
+     447             :         free(daemon->preconfigured_trace_load_settings);
+     448             :         daemon->preconfigured_trace_load_settings = NULL;
+     449             :     }
+     450             :     pthread_rwlock_destroy(&trace_load_rw_lock);
+     451             : #endif
+     452             : 
+     453           9 :     if (app_recv_buffer)
+     454           9 :         free(app_recv_buffer);
+     455             : 
+     456             :     /* free ringbuffer */
+     457           9 :     dlt_buffer_free_dynamic(&(daemon->client_ringbuffer));
+     458             : 
+     459           9 :     return 0;
+     460             : }
+     461             : 
+     462          18 : int dlt_daemon_init_user_information(DltDaemon *daemon,
+     463             :                                      DltGateway *gateway,
+     464             :                                      int gateway_mode,
+     465             :                                      int verbose)
+     466             : {
+     467             :     int nodes = 1;
+     468             :     int i = 1;
+     469             : 
+     470          18 :     PRINT_FUNCTION_VERBOSE(verbose);
+     471             : 
+     472          18 :     if ((daemon == NULL) || ((gateway_mode == 1) && (gateway == NULL)))
+     473             :         return DLT_RETURN_ERROR;
+     474             : 
+     475          18 :     if (gateway_mode == 0) {
+     476             :         /* initialize application list */
+     477          17 :         daemon->user_list = calloc((size_t) nodes, sizeof(DltDaemonRegisteredUsers));
+     478             : 
+     479          17 :         if (daemon->user_list == NULL) {
+     480           0 :             dlt_log(LOG_ERR, "Allocating memory for user information");
+     481           0 :             return DLT_RETURN_ERROR;
+     482             :         }
+     483             : 
+     484          17 :         dlt_set_id(daemon->user_list[0].ecu, daemon->ecuid);
+     485          17 :         daemon->num_user_lists = 1;
+     486             :     }
+     487             :     else { /* gateway is active */
+     488           1 :         nodes += gateway->num_connections;
+     489             : 
+     490             :         /* initialize application list */
+     491           1 :         daemon->user_list = calloc((size_t) nodes, sizeof(DltDaemonRegisteredUsers));
+     492             : 
+     493           1 :         if (daemon->user_list == NULL) {
+     494           0 :             dlt_log(LOG_ERR, "Allocating memory for user information");
+     495           0 :             return DLT_RETURN_ERROR;
+     496             :         }
+     497             : 
+     498           1 :         dlt_set_id(daemon->user_list[0].ecu, daemon->ecuid);
+     499           1 :         daemon->num_user_lists = nodes;
+     500             : 
+     501           2 :         for (i = 1; i < nodes; i++)
+     502           1 :             dlt_set_id(daemon->user_list[i].ecu, gateway->connections[i - 1].ecuid);
+     503             :     }
+     504             : 
+     505             :     return DLT_RETURN_OK;
+     506             : }
+     507             : 
+     508          15 : int dlt_daemon_applications_invalidate_fd(DltDaemon *daemon,
+     509             :                                           char *ecu,
+     510             :                                           int fd,
+     511             :                                           int verbose)
+     512             : {
+     513             :     int i;
+     514             :     DltDaemonRegisteredUsers *user_list = NULL;
+     515             : 
+     516          15 :     PRINT_FUNCTION_VERBOSE(verbose);
+     517             : 
+     518          15 :     if ((daemon == NULL) || (ecu == NULL))
+     519             :         return DLT_RETURN_ERROR;
+     520             : 
+     521          15 :     user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+     522             : 
+     523          15 :     if (user_list != NULL) {
+     524          26 :         for (i = 0; i < user_list->num_applications; i++)
+     525          11 :             if (user_list->applications[i].user_handle == fd)
+     526           0 :                 user_list->applications[i].user_handle = DLT_FD_INIT;
+     527             : 
+     528             :         return DLT_RETURN_OK;
+     529             :     }
+     530             : 
+     531             :     return DLT_RETURN_ERROR;
+     532             : }
+     533             : 
+     534          10 : int dlt_daemon_applications_clear(DltDaemon *daemon, char *ecu, int verbose)
+     535             : {
+     536             :     int i;
+     537             :     DltDaemonRegisteredUsers *user_list = NULL;
+     538             : 
+     539          10 :     PRINT_FUNCTION_VERBOSE(verbose);
+     540             : 
+     541          10 :     if ((daemon == NULL) || (daemon->user_list == NULL) || (ecu == NULL))
+     542             :         return DLT_RETURN_WRONG_PARAMETER;
+     543             : 
+     544          10 :     user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+     545             : 
+     546          10 :     if (user_list == NULL)
+     547             :         return DLT_RETURN_ERROR;
+     548             : 
+     549          11 :     for (i = 0; i < user_list->num_applications; i++)
+     550           1 :         if (user_list->applications[i].application_description != NULL) {
+     551             : 
+     552             : #ifdef DLT_LOG_LEVEL_APP_CONFIG
+     553             :             if (user_list->applications[i].context_log_level_settings)
+     554             :                 free(user_list->applications[i].context_log_level_settings);
+     555             : #endif
+     556             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+     557             :             if (user_list->applications[i].trace_load_settings) {
+     558             :                 free(user_list->applications[i].trace_load_settings);
+     559             :                 user_list->applications[i].trace_load_settings = NULL;
+     560             :                 user_list->applications[i].trace_load_settings_count = 0;
+     561             :             }
+     562             : #endif
+     563           1 :             free(user_list->applications[i].application_description);
+     564           1 :             user_list->applications[i].application_description = NULL;
+     565             :         }
+     566             : 
+     567          10 :     if (user_list->applications != NULL)
+     568           7 :         free(user_list->applications);
+     569             : 
+     570          10 :     user_list->applications = NULL;
+     571          10 :     user_list->num_applications = 0;
+     572             : 
+     573          10 :     return 0;
+     574             : }
+     575             : 
+     576          15 : static void dlt_daemon_application_reset_user_handle(DltDaemon *daemon,
+     577             :                                                      DltDaemonApplication *application,
+     578             :                                                      int verbose)
+     579             : {
+     580             :     DltDaemonRegisteredUsers *user_list;
+     581             :     DltDaemonContext *context;
+     582             :     int i;
+     583             : 
+     584          15 :     if (application->user_handle == DLT_FD_INIT)
+     585             :         return;
+     586             : 
+     587           6 :     user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+     588           6 :     if (user_list != NULL) {
+     589           6 :         for (i = 0; i < user_list->num_contexts; i++) {
+     590           0 :             context = &user_list->contexts[i];
+     591           0 :             if (context->user_handle == application->user_handle)
+     592           0 :                 context->user_handle = DLT_FD_INIT;
+     593             :         }
+     594             :     }
+     595             : 
+     596           6 :     if (application->owns_user_handle)
+     597           6 :         close(application->user_handle);
+     598             : 
+     599           6 :     application->user_handle = DLT_FD_INIT;
+     600           6 :     application->owns_user_handle = false;
+     601             : }
+     602             : 
+     603          10 : DltDaemonApplication *dlt_daemon_application_add(DltDaemon *daemon,
+     604             :                                                  char *apid,
+     605             :                                                  pid_t pid,
+     606             :                                                  char *description,
+     607             :                                                  int fd,
+     608             :                                                  char *ecu,
+     609             :                                                  int verbose)
+     610             : {
+     611             :     DltDaemonApplication *application;
+     612             :     DltDaemonApplication *old;
+     613             :     int new_application;
+     614             :     int dlt_user_handle;
+     615             :     bool owns_user_handle;
+     616             :     DltDaemonRegisteredUsers *user_list = NULL;
+     617             : #ifdef DLT_DAEMON_USE_FIFO_IPC
+     618             :     (void)fd;  /* To avoid compiler warning : unused variable */
+     619             :     char filename[DLT_DAEMON_COMMON_TEXTBUFSIZE];
+     620             : #endif
+     621             : 
+     622          10 :     if ((daemon == NULL) || (apid == NULL) || (apid[0] == '\0') || (ecu == NULL))
+     623             :         return (DltDaemonApplication *)NULL;
+     624             : 
+     625          10 :     user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+     626             : 
+     627          10 :     if (user_list == NULL)
+     628             :         return (DltDaemonApplication *)NULL;
+     629             : 
+     630          10 :     if (user_list->applications == NULL) {
+     631          10 :         user_list->applications = (DltDaemonApplication *)
+     632          10 :             malloc(sizeof(DltDaemonApplication) * DLT_DAEMON_APPL_ALLOC_SIZE);
+     633             : 
+     634          10 :         if (user_list->applications == NULL)
+     635             :             return (DltDaemonApplication *)NULL;
+     636             :     }
+     637             : 
+     638             :     new_application = 0;
+     639             : 
+     640             :     /* Check if application [apid] is already available */
+     641          10 :     application = dlt_daemon_application_find(daemon, apid, ecu, verbose);
+     642             : 
+     643          10 :     if (application == NULL) {
+     644          10 :         user_list->num_applications += 1;
+     645             : 
+     646          10 :         if (user_list->num_applications != 0) {
+     647          10 :             if ((user_list->num_applications % DLT_DAEMON_APPL_ALLOC_SIZE) == 0) {
+     648             :                 /* allocate memory in steps of DLT_DAEMON_APPL_ALLOC_SIZE, e.g. 100 */
+     649           0 :                 old = user_list->applications;
+     650           0 :                 user_list->applications = (DltDaemonApplication *)
+     651           0 :                     malloc(sizeof(DltDaemonApplication) *
+     652           0 :                            ((user_list->num_applications / DLT_DAEMON_APPL_ALLOC_SIZE) + 1) *
+     653             :                            DLT_DAEMON_APPL_ALLOC_SIZE);
+     654             : 
+     655           0 :                 if (user_list->applications == NULL) {
+     656           0 :                     user_list->applications = old;
+     657           0 :                     user_list->num_applications -= 1;
+     658           0 :                     return (DltDaemonApplication *)NULL;
+     659             :                 }
+     660             : 
+     661           0 :                 memcpy(user_list->applications,
+     662             :                        old,
+     663           0 :                        sizeof(DltDaemonApplication) * user_list->num_applications);
+     664           0 :                 free(old);
+     665             :             }
+     666             :         }
+     667             : 
+     668          10 :         application = &(user_list->applications[user_list->num_applications - 1]);
+     669             : 
+     670          10 :         dlt_set_id(application->apid, apid);
+     671          10 :         application->pid = 0;
+     672          10 :         application->application_description = NULL;
+     673          10 :         application->num_contexts = 0;
+     674          10 :         application->user_handle = DLT_FD_INIT;
+     675          10 :         application->owns_user_handle = false;
+     676             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+     677             :         application->trace_load_settings = NULL;
+     678             :         application->trace_load_settings_count = 0;
+     679             : #endif
+     680             : 
+     681             :         new_application = 1;
+     682             : 
+     683             :     }
+     684           0 :     else if ((pid != application->pid) && (application->pid != 0))
+     685             :     {
+     686             : 
+     687           0 :         dlt_vlog(LOG_WARNING,
+     688             :                  "Duplicate registration of ApplicationID: '%.4s'; registering from PID %d, existing from PID %d\n",
+     689             :                  apid,
+     690             :                  pid,
+     691             :                  application->pid);
+     692             :     }
+     693             : 
+     694             :     /* Store application description and pid of application */
+     695          10 :     if (application->application_description) {
+     696           0 :         free(application->application_description);
+     697           0 :         application->application_description = NULL;
+     698             :     }
+     699             : 
+     700          10 :     if (description != NULL) {
+     701          10 :         application->application_description = malloc(strlen(description) + 1);
+     702             : 
+     703          10 :         if (application->application_description) {
+     704          10 :             memcpy(application->application_description, description, strlen(description) + 1);
+     705             :         } else {
+     706           0 :             dlt_log(LOG_ERR, "Cannot allocate memory to store application description\n");
+     707           0 :             free(application);
+     708           0 :             return (DltDaemonApplication *)NULL;
+     709             :         }
+     710             :     }
+     711             : 
+     712          10 :     if (application->pid != pid) {
+     713           9 :         dlt_daemon_application_reset_user_handle(daemon, application, verbose);
+     714           9 :         application->pid = 0;
+     715             :     }
+     716             : 
+     717             :     /* open user pipe only if it is not yet opened */
+     718          10 :     if ((application->user_handle == DLT_FD_INIT) && (pid != 0)) {
+     719             :         dlt_user_handle = DLT_FD_INIT;
+     720             :         owns_user_handle = false;
+     721             : 
+     722             : #if defined DLT_DAEMON_USE_UNIX_SOCKET_IPC || defined DLT_DAEMON_VSOCK_IPC_ENABLE
+     723             :         if (fd >= DLT_FD_MINIMUM) {
+     724             :             dlt_user_handle = fd;
+     725             :             owns_user_handle = false;
+     726             :         }
+     727             : #endif
+     728             : #ifdef DLT_DAEMON_USE_FIFO_IPC
+     729             :         if (dlt_user_handle < DLT_FD_MINIMUM) {
+     730             :             snprintf(filename,
+     731             :                      DLT_DAEMON_COMMON_TEXTBUFSIZE,
+     732             :                      "%s/dltpipes/dlt%d",
+     733             :                      dltFifoBaseDir,
+     734             :                      pid);
+     735             : 
+     736             :             dlt_user_handle = open(filename, O_WRONLY | O_NONBLOCK);
+     737             : 
+     738           9 :             if (dlt_user_handle < 0) {
+     739           0 :                 int prio = (errno == ENOENT) ? LOG_INFO : LOG_WARNING;
+     740           0 :                 dlt_vlog(prio, "open() failed to %s, errno=%d (%s)!\n", filename, errno, strerror(errno));
+     741             :             } else {
+     742             :                 owns_user_handle = true;
+     743             :             }
+     744             :         }
+     745             : #endif
+     746             :         /* check if file descriptor was already used, and make it invalid if it
+     747             :         * is reused. This prevents sending messages to wrong file descriptor */
+     748           9 :         dlt_daemon_applications_invalidate_fd(daemon, ecu, dlt_user_handle, verbose);
+     749           9 :         dlt_daemon_contexts_invalidate_fd(daemon, ecu, dlt_user_handle, verbose);
+     750             : 
+     751           9 :         application->user_handle = dlt_user_handle;
+     752           9 :         application->owns_user_handle = owns_user_handle;
+     753           9 :         application->pid = pid;
+     754             :     }
+     755             : 
+     756             :     /* Sort */
+     757          10 :     if (new_application) {
+     758          10 :         qsort(user_list->applications,
+     759          10 :               (size_t) user_list->num_applications,
+     760             :               sizeof(DltDaemonApplication),
+     761             :               dlt_daemon_cmp_apid);
+     762             : 
+     763             :         /* Find new position of application with apid*/
+     764          10 :         application = dlt_daemon_application_find(daemon, apid, ecu, verbose);
+     765             :     }
+     766             : 
+     767             : #ifdef DLT_LOG_LEVEL_APP_CONFIG
+     768             :     application->num_context_log_level_settings = 0;
+     769             :     application->context_log_level_settings = NULL;
+     770             : #endif
+     771             : #if DLT_TRACE_LOAD_CTRL_ENABLE
+     772             :     if (application->trace_load_settings == NULL) {
+     773             :         DltTraceLoadSettings* pre_configured_trace_load_settings = NULL;
+     774             :         int num_settings = 0;
+     775             :         DltReturnValue find_trace_settings_return_value = dlt_daemon_find_preconfigured_trace_load_settings(
+     776             :             daemon,
+     777             :             application->apid,
+     778             :             NULL /*load settings for all contexts*/,
+     779             :             &pre_configured_trace_load_settings,
+     780             :             &num_settings,
+     781             :             verbose);
+     782             : 
+     783             :         DltTraceLoadSettings *app_level = NULL;
+     784             :         if ((find_trace_settings_return_value == DLT_RETURN_OK) &&
+     785             :             (pre_configured_trace_load_settings != NULL) &&
+     786             :             (num_settings != 0)) {
+     787             :             application->trace_load_settings = pre_configured_trace_load_settings;
+     788             :             application->trace_load_settings_count = num_settings;
+     789             :             app_level = dlt_find_runtime_trace_load_settings(
+     790             :                 application->trace_load_settings,
+     791             :                 application->trace_load_settings_count, application->apid,
+     792             :                 NULL);
+     793             :         }
+     794             : 
+     795             :         // app is not configured, set daemon defaults
+     796             :         if (app_level == NULL) {
+     797             :             DltTraceLoadSettings *temp = realloc(application->trace_load_settings,
+     798             :                                                  (application->trace_load_settings_count + 1) *
+     799             :                                                      sizeof(DltTraceLoadSettings));
+     800             : 
+     801             :             if (temp != NULL) {
+     802             :                 application->trace_load_settings = temp;
+     803             :                 ++application->trace_load_settings_count;
+     804             : 
+     805             :                 app_level = &application->trace_load_settings[application->trace_load_settings_count - 1];
+     806             :                 memset(app_level, 0, sizeof(DltTraceLoadSettings));
+     807             :                 app_level[0].hard_limit = DLT_TRACE_LOAD_DAEMON_HARD_LIMIT_DEFAULT;
+     808             :                 app_level[0].soft_limit = DLT_TRACE_LOAD_DAEMON_SOFT_LIMIT_DEFAULT;
+     809             :                 memcpy(&app_level[0].apid, apid, DLT_ID_SIZE);
+     810             :                 memset(&app_level[0].tl_stat, 0, sizeof(DltTraceLoadStat));
+     811             :             } else {
+     812             :                 dlt_vlog(DLT_LOG_FATAL, "Failed to allocate memory for trace load settings\n");
+     813             :             }
+     814             : 
+     815             :             // We inserted the application id at the end, to make sure
+     816             :             // Lookups are working properly later on, we have to sort the list again.
+     817             :             qsort(application->trace_load_settings,
+     818             :                   (size_t)application->trace_load_settings_count,
+     819             :                   sizeof(DltTraceLoadSettings),
+     820             :                   dlt_daemon_compare_trace_load_settings);
+     821             :         }
+     822             :     }
+     823             : 
+     824             : #endif
+     825             : 
+     826             :     return application;
+     827             : }
+     828             : 
+     829           6 : int dlt_daemon_application_del(DltDaemon *daemon,
+     830             :                                DltDaemonApplication *application,
+     831             :                                char *ecu,
+     832             :                                int verbose)
+     833             : {
+     834             :     int pos;
+     835             :     DltDaemonRegisteredUsers *user_list = NULL;
+     836             : 
+     837           6 :     PRINT_FUNCTION_VERBOSE(verbose);
+     838             : 
+     839           6 :     if ((daemon == NULL) || (application == NULL) || (ecu == NULL))
+     840             :         return -1;
+     841             : 
+     842           6 :     user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+     843             : 
+     844           6 :     if (user_list == NULL)
+     845             :         return -1;
+     846             : 
+     847           6 :     if (user_list->num_applications > 0) {
+     848           6 :         dlt_daemon_application_reset_user_handle(daemon, application, verbose);
+     849             : 
+     850             :         /* Free description of application to be deleted */
+     851           6 :         if (application->application_description) {
+     852           6 :             free(application->application_description);
+     853           6 :             application->application_description = NULL;
+     854             :         }
+     855             : 
+     856             : #if DLT_TRACE_LOAD_CTRL_ENABLE
+     857             :         if (application->trace_load_settings != NULL) {
+     858             :             free(application->trace_load_settings);
+     859             :             application->trace_load_settings = NULL;
+     860             :             application->trace_load_settings_count = 0;
+     861             :         }
+     862             : #endif
+     863           6 :         pos = (int) (application - (user_list->applications));
+     864             : 
+     865             :         /* move all applications above pos to pos */
+     866           6 :         memmove(&(user_list->applications[pos]),
+     867           6 :                 &(user_list->applications[pos + 1]),
+     868           6 :                 sizeof(DltDaemonApplication) * ((user_list->num_applications - 1) - pos));
+     869             : 
+     870             :         /* Clear last application */
+     871           6 :         memset(&(user_list->applications[user_list->num_applications - 1]),
+     872             :                0,
+     873             :                sizeof(DltDaemonApplication));
+     874             : 
+     875           6 :         user_list->num_applications--;
+     876             :     }
+     877             : 
+     878             :     return 0;
+     879             : }
+     880             : 
+     881         149 : DltDaemonApplication *dlt_daemon_application_find(DltDaemon *daemon,
+     882             :                                                   char *apid,
+     883             :                                                   char *ecu,
+     884             :                                                   int verbose)
+     885             : {
+     886             :     DltDaemonApplication application;
+     887             :     DltDaemonRegisteredUsers *user_list = NULL;
+     888             : 
+     889         149 :     PRINT_FUNCTION_VERBOSE(verbose);
+     890             : 
+     891         149 :     if ((daemon == NULL) || (daemon->user_list == NULL) || (apid == NULL) ||
+     892         149 :         (apid[0] == '\0') || (ecu == NULL))
+     893             :         return (DltDaemonApplication *)NULL;
+     894             : 
+     895         149 :     user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+     896             : 
+     897         149 :     if ((user_list == NULL) || (user_list->num_applications == 0))
+     898             :         return (DltDaemonApplication *)NULL;
+     899             : 
+     900             :     /* Check, if apid is smaller than smallest apid or greater than greatest apid */
+     901         132 :     if ((memcmp(apid, user_list->applications[0].apid, DLT_ID_SIZE) < 0) ||
+     902         132 :         (memcmp(apid,
+     903         132 :                 user_list->applications[user_list->num_applications - 1].apid,
+     904             :                 DLT_ID_SIZE) > 0))
+     905             :         return (DltDaemonApplication *)NULL;
+     906             : 
+     907         132 :     dlt_set_id(application.apid, apid);
+     908         132 :     return (DltDaemonApplication *)bsearch(&application,
+     909         132 :                                            user_list->applications,
+     910         132 :                                            (size_t) user_list->num_applications,
+     911             :                                            sizeof(DltDaemonApplication),
+     912             :                                            dlt_daemon_cmp_apid);
+     913             : }
+     914             : 
+     915           9 : int dlt_daemon_applications_load(DltDaemon *daemon, const char *filename, int verbose)
+     916             : {
+     917             :     FILE *fd;
+     918             :     ID4 apid;
+     919             :     char buf[DLT_DAEMON_COMMON_TEXTBUFSIZE];
+     920             :     char *ret;
+     921             :     char *pb;
+     922             : 
+     923           9 :     PRINT_FUNCTION_VERBOSE(verbose);
+     924             : 
+     925           9 :     if ((daemon == NULL) || (filename == NULL) || (filename[0] == '\0'))
+     926             :         return -1;
+     927             : 
+     928           9 :     fd = fopen(filename, "r");
+     929             : 
+     930           9 :     if (fd == NULL) {
+     931           9 :         dlt_vlog(LOG_WARNING,
+     932             :                  "%s: cannot open file %s: %s\n",
+     933             :                  __func__,
+     934             :                  filename,
+     935           9 :                  strerror(errno));
+     936             : 
+     937           9 :         return -1;
+     938             :     }
+     939             : 
+     940           0 :     while (!feof(fd)) {
+     941             :         /* Clear buf */
+     942             :         memset(buf, 0, sizeof(buf));
+     943             : 
+     944             :         /* Get line */
+     945             :         ret = fgets(buf, sizeof(buf), fd);
+     946             : 
+     947           0 :         if (NULL == ret) {
+     948             :             /* fgets always null pointer if the last byte of the file is a new line
+     949             :              * We need to check here if there was an error or was it feof.*/
+     950           0 :             if (ferror(fd)) {
+     951           0 :                 dlt_vlog(LOG_WARNING,
+     952             :                          "%s: fgets(buf,sizeof(buf),fd) returned NULL. %s\n",
+     953             :                          __func__,
+     954           0 :                          strerror(errno));
+     955           0 :                 fclose(fd);
+     956           0 :                 return -1;
+     957             :             }
+     958           0 :             else if (feof(fd))
+     959             :             {
+     960           0 :                 fclose(fd);
+     961           0 :                 return 0;
+     962             :             }
+     963             :             else {
+     964           0 :                 dlt_vlog(LOG_WARNING,
+     965             :                          "%s: fgets(buf,sizeof(buf),fd) returned NULL. Unknown error.\n",
+     966             :                          __func__);
+     967           0 :                 fclose(fd);
+     968           0 :                 return -1;
+     969             :             }
+     970             :         }
+     971             : 
+     972           0 :         if (strcmp(buf, "") != 0) {
+     973             :             /* Split line */
+     974           0 :             pb = strtok(buf, ":");
+     975             : 
+     976           0 :             if (pb != NULL) {
+     977           0 :                 dlt_set_id(apid, pb);
+     978           0 :                 pb = strtok(NULL, ":");
+     979             : 
+     980           0 :                 if (pb != NULL) {
+     981             :                     /* pb contains now the description */
+     982             :                     /* pid is unknown at loading time */
+     983           0 :                     if (dlt_daemon_application_add(daemon,
+     984             :                                                    apid,
+     985             :                                                    0,
+     986             :                                                    pb,
+     987             :                                                    -1,
+     988           0 :                                                    daemon->ecuid,
+     989             :                                                    verbose) == 0) {
+     990           0 :                         dlt_vlog(LOG_WARNING,
+     991             :                                  "%s: dlt_daemon_application_add failed for %4s\n",
+     992             :                                  __func__,
+     993             :                                  apid);
+     994           0 :                         fclose(fd);
+     995           0 :                         return -1;
+     996             :                     }
+     997             :                 }
+     998             :             }
+     999             :         }
+    1000             :     }
+    1001             : 
+    1002           0 :     fclose(fd);
+    1003             : 
+    1004           0 :     return 0;
+    1005             : }
+    1006             : 
+    1007           0 : int dlt_daemon_applications_save(DltDaemon *daemon, const char *filename, int verbose)
+    1008             : {
+    1009             :     FILE *fd;
+    1010             :     int i;
+    1011             : 
+    1012             :     char apid[DLT_ID_SIZE + 1]; /* DLT_ID_SIZE+1, because the 0-termination is required here */
+    1013             :     DltDaemonRegisteredUsers *user_list = NULL;
+    1014             : 
+    1015           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1016             : 
+    1017           0 :     if ((daemon == NULL) || (filename == NULL) || (filename[0] == '\0'))
+    1018             :         return -1;
+    1019             : 
+    1020             :     memset(apid, 0, sizeof(apid));
+    1021             : 
+    1022           0 :     user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+    1023             : 
+    1024           0 :     if (user_list == NULL)
+    1025             :         return -1;
+    1026             : 
+    1027           0 :     if ((user_list->applications != NULL) && (user_list->num_applications > 0)) {
+    1028           0 :         fd = fopen(filename, "w");
+    1029             : 
+    1030           0 :         if (fd != NULL) {
+    1031           0 :             for (i = 0; i < user_list->num_applications; i++) {
+    1032           0 :                 dlt_set_id(apid, user_list->applications[i].apid);
+    1033             : 
+    1034           0 :                 if ((user_list->applications[i].application_description) &&
+    1035           0 :                     (user_list->applications[i].application_description[0] != '\0'))
+    1036             :                     fprintf(fd,
+    1037             :                             "%s:%s:\n",
+    1038             :                             apid,
+    1039             :                             user_list->applications[i].application_description);
+    1040             :                 else
+    1041             :                     fprintf(fd, "%s::\n", apid);
+    1042             :             }
+    1043             : 
+    1044           0 :             fclose(fd);
+    1045             :         }
+    1046             :         else {
+    1047           0 :             dlt_vlog(LOG_ERR, "%s: open %s failed! No application information stored.\n",
+    1048             :                      __func__,
+    1049             :                      filename);
+    1050             :         }
+    1051             :     }
+    1052             : 
+    1053             :     return 0;
+    1054             : }
+    1055             : 
+    1056          41 : DltDaemonContext *dlt_daemon_context_add(DltDaemon *daemon,
+    1057             :                                          char *apid,
+    1058             :                                          char *ctid,
+    1059             :                                          int8_t log_level,
+    1060             :                                          int8_t trace_status,
+    1061             :                                          int log_level_pos,
+    1062             :                                          int user_handle,
+    1063             :                                          char *description,
+    1064             :                                          char *ecu,
+    1065             :                                          int verbose)
+    1066             : {
+    1067             :     DltDaemonApplication *application;
+    1068             :     DltDaemonContext *context;
+    1069             :     DltDaemonContext *old;
+    1070             :     int new_context = 0;
+    1071             :     DltDaemonRegisteredUsers *user_list = NULL;
+    1072             : 
+    1073          41 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1074             : 
+    1075          41 :     if ((daemon == NULL) || (apid == NULL) || (apid[0] == '\0') ||
+    1076          41 :         (ctid == NULL) || (ctid[0] == '\0') || (ecu == NULL))
+    1077             :         return (DltDaemonContext *)NULL;
+    1078             : 
+    1079          41 :     if ((log_level < DLT_LOG_DEFAULT) || (log_level > DLT_LOG_VERBOSE))
+    1080             :         return (DltDaemonContext *)NULL;
+    1081             : 
+    1082          41 :     if ((trace_status < DLT_TRACE_STATUS_DEFAULT) || (trace_status > DLT_TRACE_STATUS_ON))
+    1083             :         return (DltDaemonContext *)NULL;
+    1084             : 
+    1085          41 :     user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+    1086             : 
+    1087          41 :     if (user_list == NULL)
+    1088             :         return (DltDaemonContext *)NULL;
+    1089             : 
+    1090          41 :     if (user_list->contexts == NULL) {
+    1091          10 :         user_list->contexts = (DltDaemonContext *)calloc(1, sizeof(DltDaemonContext) * DLT_DAEMON_CONTEXT_ALLOC_SIZE);
+    1092             : 
+    1093          10 :         if (user_list->contexts == NULL)
+    1094             :             return (DltDaemonContext *)NULL;
+    1095             :     }
+    1096             : 
+    1097             :     /* Check if application [apid] is available */
+    1098          41 :     application = dlt_daemon_application_find(daemon, apid, ecu, verbose);
+    1099             : 
+    1100          41 :     if (application == NULL)
+    1101             :         return (DltDaemonContext *)NULL;
+    1102             : 
+    1103             :     /* Check if context [apid, ctid] is already available */
+    1104          41 :     context = dlt_daemon_context_find(daemon, apid, ctid, ecu, verbose);
+    1105             : 
+    1106          41 :     if (context == NULL) {
+    1107          41 :         user_list->num_contexts += 1;
+    1108             : 
+    1109          41 :         if (user_list->num_contexts != 0) {
+    1110          41 :             if ((user_list->num_contexts % DLT_DAEMON_CONTEXT_ALLOC_SIZE) == 0) {
+    1111             :                 /* allocate memory for context in steps of DLT_DAEMON_CONTEXT_ALLOC_SIZE, e.g 100 */
+    1112           0 :                 old = user_list->contexts;
+    1113           0 :                 user_list->contexts = (DltDaemonContext *)calloc(1, (size_t) sizeof(DltDaemonContext) *
+    1114           0 :                                                                  ((user_list->num_contexts /
+    1115           0 :                                                                    DLT_DAEMON_CONTEXT_ALLOC_SIZE) + 1) *
+    1116             :                                                                  DLT_DAEMON_CONTEXT_ALLOC_SIZE);
+    1117             : 
+    1118           0 :                 if (user_list->contexts == NULL) {
+    1119           0 :                     user_list->contexts = old;
+    1120           0 :                     user_list->num_contexts -= 1;
+    1121           0 :                     return (DltDaemonContext *)NULL;
+    1122             :                 }
+    1123             : 
+    1124           0 :                 memcpy(user_list->contexts,
+    1125             :                        old,
+    1126           0 :                        (size_t) sizeof(DltDaemonContext) * user_list->num_contexts);
+    1127           0 :                 free(old);
+    1128             :             }
+    1129             :         }
+    1130             : 
+    1131          41 :         context = &(user_list->contexts[user_list->num_contexts - 1]);
+    1132             :         memset(context, 0, sizeof(DltDaemonContext));
+    1133             : 
+    1134          41 :         dlt_set_id(context->apid, apid);
+    1135          41 :         dlt_set_id(context->ctid, ctid);
+    1136             : 
+    1137          41 :         application->num_contexts++;
+    1138             :         new_context = 1;
+    1139             :     }
+    1140             : 
+    1141             :     /* Set context description */
+    1142          41 :     if (context->context_description) {
+    1143           0 :         free(context->context_description);
+    1144           0 :         context->context_description = NULL;
+    1145             :     }
+    1146             : 
+    1147          41 :     if (description != NULL) {
+    1148          41 :         context->context_description = malloc(strlen(description) + 1);
+    1149             : 
+    1150          41 :         if (context->context_description) {
+    1151          41 :             memcpy(context->context_description, description, strlen(description) + 1);
+    1152             :         }
+    1153             :     }
+    1154             : 
+    1155             : #ifdef DLT_LOG_LEVEL_APP_CONFIG
+    1156             :     /* configure initial log level */
+    1157             :     DltDaemonContextLogSettings *settings = NULL;
+    1158             :     settings = dlt_daemon_find_configured_app_id_ctx_id_settings(
+    1159             :             daemon, context->apid, ctid);
+    1160             : 
+    1161             :     if (settings != NULL) {
+    1162             :         /* set log level */
+    1163             :         log_level = settings->log_level;
+    1164             : 
+    1165             :         DltDaemonContextLogSettings *ct_settings = NULL;
+    1166             :         ct_settings = dlt_daemon_find_app_log_level_config(application, ctid);
+    1167             : 
+    1168             :         /* ct_settings != null: context and app id combination already exists */
+    1169             :         if (ct_settings == NULL) {
+    1170             :           /* copy the configuration into the DltDaemonApplication for faster access later */
+    1171             :           DltDaemonContextLogSettings *tmp =
+    1172             :               realloc(application->context_log_level_settings,
+    1173             :                       (++application->num_context_log_level_settings) *
+    1174             :                           sizeof(DltDaemonContextLogSettings));
+    1175             :           application->context_log_level_settings = tmp;
+    1176             : 
+    1177             :           ct_settings =
+    1178             :               &application->context_log_level_settings[application->num_context_log_level_settings - 1];
+    1179             :           memcpy(ct_settings, settings, sizeof(DltDaemonContextLogSettings));
+    1180             :           memcpy(ct_settings->ctid, ctid, DLT_ID_SIZE);
+    1181             :       }
+    1182             :     }
+    1183             : #endif
+    1184             : 
+    1185          41 :     if ((strncmp(daemon->ecuid, ecu, DLT_ID_SIZE) == 0) && (daemon->force_ll_ts)) {
+    1186             : #ifdef DLT_LOG_LEVEL_APP_CONFIG
+    1187             :         if (log_level > daemon->default_log_level && settings == NULL)
+    1188             : #else
+    1189           0 :         if (log_level > daemon->default_log_level)
+    1190             : #endif
+    1191             :             log_level = daemon->default_log_level;
+    1192             : 
+    1193           0 :         if (trace_status > daemon->default_trace_status)
+    1194             :             trace_status = daemon->default_trace_status;
+    1195             : 
+    1196           0 :         dlt_vlog(LOG_NOTICE,
+    1197             :             "Adapting ll_ts for context: %.4s:%.4s with %i %i\n",
+    1198             :             apid,
+    1199             :             ctid,
+    1200             :             log_level,
+    1201             :             trace_status);
+    1202             :     }
+    1203             : 
+    1204             :     /* Store log level and trace status,
+    1205             :      * if this is a new context, or
+    1206             :      * if this is an old context and the runtime cfg was not loaded */
+    1207          41 :     if ((new_context == 1) ||
+    1208           0 :         ((new_context == 0) && (daemon->runtime_context_cfg_loaded == 0))) {
+    1209          41 :         context->log_level = log_level;
+    1210          41 :         context->trace_status = trace_status;
+    1211             :     }
+    1212             : 
+    1213          41 :     context->log_level_pos = log_level_pos;
+    1214          41 :     context->user_handle = user_handle;
+    1215             : 
+    1216             :     /* In case a context is loaded from runtime config file,
+    1217             :      * the user_handle is 0 and we mark that context as predefined.
+    1218             :      */
+    1219          41 :     if (context->user_handle == 0)
+    1220           0 :         context->predefined = true;
+    1221             :     else
+    1222          41 :         context->predefined = false;
+    1223             : 
+    1224             :     /* Sort */
+    1225          41 :     if (new_context) {
+    1226          41 :         qsort(user_list->contexts,
+    1227          41 :               (size_t) user_list->num_contexts,
+    1228             :               sizeof(DltDaemonContext),
+    1229             :               dlt_daemon_cmp_apid_ctid);
+    1230             : 
+    1231             :         /* Find new position of context with apid, ctid */
+    1232          41 :         context = dlt_daemon_context_find(daemon, apid, ctid, ecu, verbose);
+    1233             :     }
+    1234             : 
+    1235             :     return context;
+    1236             : }
+    1237             : 
+    1238             : #ifdef DLT_LOG_LEVEL_APP_CONFIG
+    1239             : static void dlt_daemon_free_context_log_settings(
+    1240             :     DltDaemonApplication *application,
+    1241             :     DltDaemonContext *context)
+    1242             : {
+    1243             :     DltDaemonContextLogSettings *ct_settings;
+    1244             :     int i;
+    1245             :     int skipped = 0;
+    1246             : 
+    1247             :     ct_settings = dlt_daemon_find_app_log_level_config(application, context->ctid);
+    1248             :     if (ct_settings == NULL) {
+    1249             :         return;
+    1250             :     }
+    1251             : 
+    1252             :     /* move all data forward */
+    1253             :     for (i = 0; i < application->num_context_log_level_settings; ++i) {
+    1254             :         /* skip given context to delete it */
+    1255             :         if (i + skipped < application->num_context_log_level_settings &&
+    1256             :             strncmp(application->context_log_level_settings[i+skipped].ctid, context->ctid, DLT_ID_SIZE) == 0) {
+    1257             :             ++skipped;
+    1258             :             continue;
+    1259             :         }
+    1260             : 
+    1261             :         memcpy(&application->context_log_level_settings[i-skipped],
+    1262             :                 &application->context_log_level_settings[i],
+    1263             :                 sizeof(DltDaemonContextLogSettings));
+    1264             :     }
+    1265             : 
+    1266             :     application->num_context_log_level_settings -= skipped;
+    1267             : 
+    1268             :     /* if size is equal to zero, and ptr is not NULL, then realloc is equivalent to free(ptr) */
+    1269             :     application->context_log_level_settings = realloc(application->context_log_level_settings,
+    1270             :             sizeof(DltDaemonContextLogSettings) * (application->num_context_log_level_settings));
+    1271             : 
+    1272             : }
+    1273             : #endif
+    1274             : 
+    1275          37 : int dlt_daemon_context_del(DltDaemon *daemon,
+    1276             :                            DltDaemonContext *context,
+    1277             :                            char *ecu,
+    1278             :                            int verbose)
+    1279             : {
+    1280             :     int pos;
+    1281             :     DltDaemonApplication *application;
+    1282             :     DltDaemonRegisteredUsers *user_list = NULL;
+    1283             : 
+    1284          37 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1285             : 
+    1286          37 :     if ((daemon == NULL) || (context == NULL) || (ecu == NULL))
+    1287             :         return -1;
+    1288             : 
+    1289          37 :     user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+    1290             : 
+    1291          37 :     if (user_list == NULL)
+    1292             :         return -1;
+    1293             : 
+    1294          37 :     if (user_list->num_contexts > 0) {
+    1295          37 :         application = dlt_daemon_application_find(daemon, context->apid, ecu, verbose);
+    1296             : 
+    1297             : #ifdef DLT_LOG_LEVEL_APP_CONFIG
+    1298             :         dlt_daemon_free_context_log_settings(application, context);
+    1299             : #endif
+    1300             :         /* Free description of context to be deleted */
+    1301          37 :         if (context->context_description) {
+    1302          37 :             free(context->context_description);
+    1303          37 :             context->context_description = NULL;
+    1304             :         }
+    1305             : 
+    1306          37 :         pos = (int) (context - (user_list->contexts));
+    1307             : 
+    1308             :         /* move all contexts above pos to pos */
+    1309          37 :         memmove(&(user_list->contexts[pos]),
+    1310          37 :                 &(user_list->contexts[pos + 1]),
+    1311          37 :                 sizeof(DltDaemonContext) * ((user_list->num_contexts - 1) - pos));
+    1312             : 
+    1313             :         /* Clear last context */
+    1314          37 :         memset(&(user_list->contexts[user_list->num_contexts - 1]),
+    1315             :                0,
+    1316             :                sizeof(DltDaemonContext));
+    1317             : 
+    1318          37 :         user_list->num_contexts--;
+    1319             : 
+    1320             :         /* Check if application [apid] is available */
+    1321          37 :         if (application != NULL)
+    1322          37 :             application->num_contexts--;
+    1323             :     }
+    1324             : 
+    1325             :     return 0;
+    1326             : }
+    1327             : 
+    1328         157 : DltDaemonContext *dlt_daemon_context_find(DltDaemon *daemon,
+    1329             :                                           char *apid,
+    1330             :                                           char *ctid,
+    1331             :                                           char *ecu,
+    1332             :                                           int verbose)
+    1333             : {
+    1334             :     DltDaemonContext context;
+    1335             :     DltDaemonRegisteredUsers *user_list = NULL;
+    1336             : 
+    1337         157 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1338             : 
+    1339         157 :     if ((daemon == NULL) || (apid == NULL) || (apid[0] == '\0') ||
+    1340         157 :         (ctid == NULL) || (ctid[0] == '\0') || (ecu == NULL))
+    1341             :         return (DltDaemonContext *)NULL;
+    1342             : 
+    1343         157 :     user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+    1344             : 
+    1345         157 :     if ((user_list == NULL) || (user_list->num_contexts == 0))
+    1346             :         return (DltDaemonContext *)NULL;
+    1347             : 
+    1348             :     /* Check, if apid is smaller than smallest apid or greater than greatest apid */
+    1349         112 :     if ((memcmp(apid, user_list->contexts[0].apid, DLT_ID_SIZE) < 0) ||
+    1350         112 :         (memcmp(apid,
+    1351         112 :                 user_list->contexts[user_list->num_contexts - 1].apid,
+    1352             :                 DLT_ID_SIZE) > 0))
+    1353             :         return (DltDaemonContext *)NULL;
+    1354             : 
+    1355         112 :     dlt_set_id(context.apid, apid);
+    1356         112 :     dlt_set_id(context.ctid, ctid);
+    1357             : 
+    1358         112 :     return (DltDaemonContext *)bsearch(&context,
+    1359         112 :                                        user_list->contexts,
+    1360         112 :                                        (size_t) user_list->num_contexts,
+    1361             :                                        sizeof(DltDaemonContext),
+    1362             :                                        dlt_daemon_cmp_apid_ctid);
+    1363             : }
+    1364             : 
+    1365          15 : int dlt_daemon_contexts_invalidate_fd(DltDaemon *daemon,
+    1366             :                                       char *ecu,
+    1367             :                                       int fd,
+    1368             :                                       int verbose)
+    1369             : {
+    1370             :     int i;
+    1371             :     DltDaemonRegisteredUsers *user_list = NULL;
+    1372             : 
+    1373          15 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1374             : 
+    1375          15 :     if ((daemon == NULL) || (ecu == NULL))
+    1376             :         return -1;
+    1377             : 
+    1378          15 :     user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+    1379             : 
+    1380          15 :     if (user_list != NULL) {
+    1381          39 :         for (i = 0; i < user_list->num_contexts; i++)
+    1382          24 :             if (user_list->contexts[i].user_handle == fd)
+    1383           0 :                 user_list->contexts[i].user_handle = DLT_FD_INIT;
+    1384             : 
+    1385             :         return 0;
+    1386             :     }
+    1387             : 
+    1388             :     return -1;
+    1389             : }
+    1390             : 
+    1391          10 : int dlt_daemon_contexts_clear(DltDaemon *daemon, char *ecu, int verbose)
+    1392             : {
+    1393             :     int i;
+    1394             :     DltDaemonRegisteredUsers *users = NULL;
+    1395             : 
+    1396          10 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1397             : 
+    1398          10 :     if ((daemon == NULL) || (ecu == NULL))
+    1399             :         return DLT_RETURN_WRONG_PARAMETER;
+    1400             : 
+    1401          10 :     users = dlt_daemon_find_users_list(daemon, ecu, verbose);
+    1402             : 
+    1403          10 :     if (users == NULL)
+    1404             :         return DLT_RETURN_ERROR;
+    1405             : 
+    1406          11 :     for (i = 0; i < users->num_contexts; i++)
+    1407           1 :         if (users->contexts[i].context_description != NULL) {
+    1408           1 :             free(users->contexts[i].context_description);
+    1409           1 :             users->contexts[i].context_description = NULL;
+    1410             :         }
+    1411             : 
+    1412          10 :     if (users->contexts) {
+    1413           7 :         free(users->contexts);
+    1414           7 :         users->contexts = NULL;
+    1415             :     }
+    1416             : 
+    1417          11 :     for (i = 0; i < users->num_applications; i++)
+    1418           1 :         users->applications[i].num_contexts = 0;
+    1419             : 
+    1420          10 :     users->num_contexts = 0;
+    1421             : 
+    1422          10 :     return 0;
+    1423             : }
+    1424             : 
+    1425           0 : int dlt_daemon_contexts_load(DltDaemon *daemon, const char *filename, int verbose)
+    1426             : {
+    1427             :     FILE *fd;
+    1428             :     ID4 apid, ctid;
+    1429             :     char buf[DLT_DAEMON_COMMON_TEXTBUFSIZE];
+    1430             :     char *ret;
+    1431             :     char *pb;
+    1432             :     int ll, ts;
+    1433             : 
+    1434           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1435             : 
+    1436           0 :     if ((daemon == NULL) || (filename == NULL) || (filename[0] == '\0'))
+    1437             :         return -1;
+    1438             : 
+    1439           0 :     fd = fopen(filename, "r");
+    1440             : 
+    1441           0 :     if (fd == NULL) {
+    1442           0 :         dlt_vlog(LOG_WARNING,
+    1443             :                  "DLT runtime-context load, cannot open file %s: %s\n",
+    1444             :                  filename,
+    1445           0 :                  strerror(errno));
+    1446             : 
+    1447           0 :         return -1;
+    1448             :     }
+    1449             : 
+    1450           0 :     while (!feof(fd)) {
+    1451             :         /* Clear buf */
+    1452             :         memset(buf, 0, sizeof(buf));
+    1453             : 
+    1454             :         /* Get line */
+    1455             :         ret = fgets(buf, sizeof(buf), fd);
+    1456             : 
+    1457           0 :         if (NULL == ret) {
+    1458             :             /* fgets always returns null pointer if the last byte of the file is a new line.
+    1459             :              * We need to check here if there was an error or was it feof.*/
+    1460           0 :             if (ferror(fd)) {
+    1461           0 :                 dlt_vlog(LOG_WARNING,
+    1462             :                          "%s fgets(buf,sizeof(buf),fd) returned NULL. %s\n",
+    1463             :                          __func__,
+    1464           0 :                          strerror(errno));
+    1465           0 :                 fclose(fd);
+    1466           0 :                 return -1;
+    1467             :             }
+    1468           0 :             else if (feof(fd))
+    1469             :             {
+    1470           0 :                 fclose(fd);
+    1471           0 :                 return 0;
+    1472             :             }
+    1473             :             else {
+    1474           0 :                 dlt_vlog(LOG_WARNING,
+    1475             :                          "%s fgets(buf,sizeof(buf),fd) returned NULL. Unknown error.\n",
+    1476             :                          __func__);
+    1477           0 :                 fclose(fd);
+    1478           0 :                 return -1;
+    1479             :             }
+    1480             :         }
+    1481             : 
+    1482           0 :         if (strcmp(buf, "") != 0) {
+    1483             :             /* Split line */
+    1484           0 :             pb = strtok(buf, ":");
+    1485             : 
+    1486           0 :             if (pb != NULL) {
+    1487           0 :                 dlt_set_id(apid, pb);
+    1488           0 :                 pb = strtok(NULL, ":");
+    1489             : 
+    1490           0 :                 if (pb != NULL) {
+    1491           0 :                     dlt_set_id(ctid, pb);
+    1492           0 :                     pb = strtok(NULL, ":");
+    1493             : 
+    1494           0 :                     if (pb != NULL) {
+    1495           0 :                         sscanf(pb, "%d", &ll);
+    1496           0 :                         pb = strtok(NULL, ":");
+    1497             : 
+    1498           0 :                         if (pb != NULL) {
+    1499           0 :                             sscanf(pb, "%d", &ts);
+    1500           0 :                             pb = strtok(NULL, ":");
+    1501             : 
+    1502           0 :                             if (pb != NULL) {
+    1503             :                                 /* pb contains now the description */
+    1504             : 
+    1505             :                                 /* log_level_pos, and user_handle are unknown at loading time */
+    1506           0 :                                 if (dlt_daemon_context_add(daemon,
+    1507             :                                                            apid,
+    1508             :                                                            ctid,
+    1509           0 :                                                            (int8_t)ll,
+    1510           0 :                                                            (int8_t)ts,
+    1511             :                                                            0,
+    1512             :                                                            0,
+    1513             :                                                            pb,
+    1514           0 :                                                            daemon->ecuid,
+    1515             :                                                            verbose) == NULL) {
+    1516           0 :                                     dlt_vlog(LOG_WARNING,
+    1517             :                                              "%s dlt_daemon_context_add failed\n",
+    1518             :                                              __func__);
+    1519           0 :                                     fclose(fd);
+    1520           0 :                                     return -1;
+    1521             :                                 }
+    1522             :                             }
+    1523             :                         }
+    1524             :                     }
+    1525             :                 }
+    1526             :             }
+    1527             :         }
+    1528             :     }
+    1529             : 
+    1530           0 :     fclose(fd);
+    1531             : 
+    1532           0 :     return 0;
+    1533             : }
+    1534             : 
+    1535           0 : int dlt_daemon_contexts_save(DltDaemon *daemon, const char *filename, int verbose)
+    1536             : {
+    1537             :     FILE *fd;
+    1538             :     int i;
+    1539             : 
+    1540             :     char apid[DLT_ID_SIZE + 1], ctid[DLT_ID_SIZE + 1]; /* DLT_ID_SIZE+1, because the 0-termination is required here */
+    1541             :     DltDaemonRegisteredUsers *user_list = NULL;
+    1542             : 
+    1543           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1544             : 
+    1545           0 :     if ((daemon == NULL) || (filename == NULL) || (filename[0] == '\0'))
+    1546             :         return -1;
+    1547             : 
+    1548           0 :     user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+    1549             : 
+    1550           0 :     if (user_list == NULL)
+    1551             :         return -1;
+    1552             : 
+    1553             :     memset(apid, 0, sizeof(apid));
+    1554             :     memset(ctid, 0, sizeof(ctid));
+    1555             : 
+    1556           0 :     if ((user_list->contexts) && (user_list->num_contexts > 0)) {
+    1557           0 :         fd = fopen(filename, "w");
+    1558             : 
+    1559           0 :         if (fd != NULL) {
+    1560           0 :             for (i = 0; i < user_list->num_contexts; i++) {
+    1561           0 :                 dlt_set_id(apid, user_list->contexts[i].apid);
+    1562           0 :                 dlt_set_id(ctid, user_list->contexts[i].ctid);
+    1563             : 
+    1564           0 :                 if ((user_list->contexts[i].context_description) &&
+    1565           0 :                     (user_list->contexts[i].context_description[0] != '\0'))
+    1566           0 :                     fprintf(fd, "%s:%s:%d:%d:%s:\n", apid, ctid,
+    1567           0 :                             (int)(user_list->contexts[i].log_level),
+    1568           0 :                             (int)(user_list->contexts[i].trace_status),
+    1569             :                             user_list->contexts[i].context_description);
+    1570             :                 else
+    1571           0 :                     fprintf(fd, "%s:%s:%d:%d::\n", apid, ctid,
+    1572           0 :                             (int)(user_list->contexts[i].log_level),
+    1573           0 :                             (int)(user_list->contexts[i].trace_status));
+    1574             :             }
+    1575             : 
+    1576           0 :             fclose(fd);
+    1577             :         }
+    1578             :         else {
+    1579           0 :             dlt_vlog(LOG_ERR,
+    1580             :                      "%s: Cannot open %s. No context information stored\n",
+    1581             :                      __func__,
+    1582             :                      filename);
+    1583             :         }
+    1584             :     }
+    1585             : 
+    1586             :     return 0;
+    1587             : }
+    1588             : 
+    1589           0 : int dlt_daemon_configuration_save(DltDaemon *daemon, const char *filename, int verbose)
+    1590             : {
+    1591             :     FILE *fd;
+    1592             : 
+    1593           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1594             : 
+    1595           0 :     if ((daemon == NULL) || (filename == NULL) || (filename[0] == '\0'))
+    1596             :         return -1;
+    1597             : 
+    1598           0 :     fd = fopen(filename, "w");
+    1599             : 
+    1600           0 :     if (fd != NULL) {
+    1601             :         fprintf(fd, "# 0 = off, 1 = external, 2 = internal, 3 = both\n");
+    1602           0 :         fprintf(fd, "LoggingMode = %d\n", daemon->mode);
+    1603             : 
+    1604           0 :         fclose(fd);
+    1605             :     }
+    1606             : 
+    1607             :     return 0;
+    1608             : }
+    1609             : 
+    1610           9 : int dlt_daemon_configuration_load(DltDaemon *daemon, const char *filename, int verbose)
+    1611             : {
+    1612           9 :     if ((daemon == NULL) || (filename == NULL))
+    1613             :         return -1;
+    1614             : 
+    1615             :     FILE *pFile;
+    1616             :     char line[1024];
+    1617             :     char token[1024];
+    1618             :     char value[1024];
+    1619             :     char *pch;
+    1620             : 
+    1621           9 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1622             : 
+    1623           9 :     pFile = fopen (filename, "r");
+    1624             : 
+    1625           9 :     if (pFile != NULL) {
+    1626             :         while (1) {
+    1627             :             /* fetch line from configuration file */
+    1628          18 :             if (fgets (line, 1024, pFile) != NULL) {
+    1629           9 :                 pch = strtok (line, " =\r\n");
+    1630           9 :                 token[0] = 0;
+    1631           9 :                 value[0] = 0;
+    1632             : 
+    1633          18 :                 while (pch != NULL) {
+    1634           9 :                     if (strcmp(pch, "#") == 0)
+    1635             :                         break;
+    1636             : 
+    1637           9 :                     if (token[0] == 0) {
+    1638             :                         strncpy(token, pch, sizeof(token) - 1);
+    1639           9 :                         token[sizeof(token) - 1] = 0;
+    1640             :                     }
+    1641             :                     else {
+    1642             :                         strncpy(value, pch, sizeof(value) - 1);
+    1643           0 :                         value[sizeof(value) - 1] = 0;
+    1644           0 :                         break;
+    1645             :                     }
+    1646             : 
+    1647           9 :                     pch = strtok (NULL, " =\r\n");
+    1648             :                 }
+    1649             : 
+    1650           9 :                 if (token[0] && value[0]) {
+    1651             :                     /* parse arguments here */
+    1652           0 :                     if (strcmp(token, "LoggingMode") == 0) {
+    1653           0 :                         daemon->mode = atoi(value);
+    1654           0 :                         dlt_vlog(LOG_INFO, "Runtime Option: %s=%d\n", token,
+    1655             :                                  daemon->mode);
+    1656             :                     }
+    1657             :                     else {
+    1658           0 :                         dlt_vlog(LOG_WARNING, "Unknown option: %s=%s\n", token,
+    1659             :                                  value);
+    1660             :                     }
+    1661             :                 }
+    1662             :             }
+    1663             :             else {
+    1664             :                 break;
+    1665             :             }
+    1666             :         }
+    1667             : 
+    1668           9 :         fclose (pFile);
+    1669             :     }
+    1670             :     else {
+    1671           0 :         dlt_vlog(LOG_INFO, "Cannot open configuration file: %s\n", filename);
+    1672             :     }
+    1673             : 
+    1674             :     return 0;
+    1675             : }
+    1676             : 
+    1677          41 : int dlt_daemon_user_send_log_level(DltDaemon *daemon, DltDaemonContext *context, int verbose)
+    1678             : {
+    1679             :     DltUserHeader userheader;
+    1680             :     DltUserControlMsgLogLevel usercontext;
+    1681             :     DltReturnValue ret;
+    1682             :     DltDaemonApplication *app;
+    1683             : 
+    1684          41 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1685             : 
+    1686          41 :     if ((daemon == NULL) || (context == NULL)) {
+    1687           0 :         dlt_vlog(LOG_ERR, "NULL parameter in %s", __func__);
+    1688           0 :         return -1;
+    1689             :     }
+    1690             : 
+    1691          41 :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_LOG_LEVEL) < DLT_RETURN_OK) {
+    1692           0 :         dlt_vlog(LOG_ERR, "Failed to set userheader in %s", __func__);
+    1693           0 :         return -1;
+    1694             :     }
+    1695             : 
+    1696          41 :     if ((context->storage_log_level != DLT_LOG_DEFAULT) &&
+    1697          34 :         (daemon->maintain_logstorage_loglevel != DLT_MAINTAIN_LOGSTORAGE_LOGLEVEL_OFF))
+    1698          32 :             usercontext.log_level = (uint8_t) (context->log_level >
+    1699             :                 context->storage_log_level ? context->log_level : context->storage_log_level);
+    1700             :     else /* Storage log level is not updated (is DEFAULT) then  no device is yet connected so ignore */
+    1701           9 :         usercontext.log_level =
+    1702           9 :             (uint8_t) ((context->log_level == DLT_LOG_DEFAULT) ? daemon->default_log_level : context->log_level);
+    1703             : 
+    1704          41 :     usercontext.trace_status =
+    1705          41 :         (uint8_t) ((context->trace_status == DLT_TRACE_STATUS_DEFAULT) ? daemon->default_trace_status : context->trace_status);
+    1706             : 
+    1707          41 :     usercontext.log_level_pos = context->log_level_pos;
+    1708             : 
+    1709          41 :     dlt_vlog(LOG_NOTICE, "Send log-level to context: %.4s:%.4s [%i -> %i] [%i -> %i]\n",
+    1710          41 :              context->apid,
+    1711          41 :              context->ctid,
+    1712          41 :              context->log_level,
+    1713          41 :              usercontext.log_level,
+    1714             :              context->trace_status,
+    1715             :              usercontext.trace_status);
+    1716             : 
+    1717             :     /* log to FIFO */
+    1718          41 :     errno = 0;
+    1719          41 :     ret = dlt_user_log_out2_with_timeout(context->user_handle,
+    1720             :                             &(userheader), sizeof(DltUserHeader),
+    1721             :                             &(usercontext), sizeof(DltUserControlMsgLogLevel));
+    1722             : 
+    1723          41 :     if (ret < DLT_RETURN_OK) {
+    1724           0 :         dlt_vlog(LOG_ERR, "Failed to send data to application in %s: %s",
+    1725             :                  __func__,
+    1726           0 :                  errno != 0 ? strerror(errno) : "Unknown error");
+    1727             : 
+    1728           0 :         if (errno == EPIPE) {
+    1729           0 :             app = dlt_daemon_application_find(daemon, context->apid, daemon->ecuid, verbose);
+    1730           0 :             if (app != NULL)
+    1731           0 :                 dlt_daemon_application_reset_user_handle(daemon, app, verbose);
+    1732             :         }
+    1733             :     }
+    1734             : 
+    1735          41 :     return (ret == DLT_RETURN_OK) ? DLT_RETURN_OK : DLT_RETURN_ERROR;
+    1736             : }
+    1737             : 
+    1738           9 : int dlt_daemon_user_send_log_state(DltDaemon *daemon, DltDaemonApplication *app, int verbose)
+    1739             : {
+    1740             :     DltUserHeader userheader;
+    1741             :     DltUserControlMsgLogState logstate;
+    1742             :     DltReturnValue ret;
+    1743             : 
+    1744           9 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1745             : 
+    1746           9 :     if ((daemon == NULL) || (app == NULL))
+    1747             :         return -1;
+    1748             : 
+    1749           9 :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_LOG_STATE) < DLT_RETURN_OK)
+    1750             :         return -1;
+    1751             : 
+    1752           9 :     logstate.log_state = daemon->connectionState;
+    1753             : 
+    1754             :     /* log to FIFO */
+    1755           9 :     ret = dlt_user_log_out2_with_timeout(app->user_handle,
+    1756             :                             &(userheader), sizeof(DltUserHeader),
+    1757             :                             &(logstate), sizeof(DltUserControlMsgLogState));
+    1758             : 
+    1759           9 :     if (ret < DLT_RETURN_OK) {
+    1760           0 :         if (errno == EPIPE)
+    1761           0 :             dlt_daemon_application_reset_user_handle(daemon, app, verbose);
+    1762             :     }
+    1763             : 
+    1764           9 :     return (ret == DLT_RETURN_OK) ? DLT_RETURN_OK : DLT_RETURN_ERROR;
+    1765             : }
+    1766             : 
+    1767           0 : void dlt_daemon_control_reset_to_factory_default(DltDaemon *daemon,
+    1768             :                                                  const char *filename,
+    1769             :                                                  const char *filename1,
+    1770             :                                                  int InitialContextLogLevel,
+    1771             :                                                  int InitialContextTraceStatus,
+    1772             :                                                  int InitialEnforceLlTsStatus,
+    1773             :                                                  int verbose)
+    1774             : {
+    1775             :     FILE *fd;
+    1776             : 
+    1777           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1778             : 
+    1779           0 :     if ((daemon == NULL) || (filename == NULL) || (filename1 == NULL)) {
+    1780           0 :         dlt_log(LOG_WARNING, "Wrong parameter: Null pointer\n");
+    1781           0 :         return;
+    1782             :     }
+    1783             : 
+    1784           0 :     if ((filename[0] == '\0') || (filename1[0] == '\0')) {
+    1785           0 :         dlt_log(LOG_WARNING, "Wrong parameter: Empty string\n");
+    1786           0 :         return;
+    1787             :     }
+    1788             : 
+    1789             :     /* Check for runtime cfg file and delete it, if available */
+    1790           0 :     fd = fopen(filename, "r");
+    1791             : 
+    1792           0 :     if (fd != NULL) {
+    1793             :         /* Close and delete file */
+    1794           0 :         fclose(fd);
+    1795           0 :         if (unlink(filename) != 0) {
+    1796           0 :             dlt_vlog(LOG_WARNING, "%s: unlink() failed: %s\n",
+    1797           0 :                     __func__, strerror(errno));
+    1798             :         }
+    1799             :     }
+    1800             : 
+    1801           0 :     fd = fopen(filename1, "r");
+    1802             : 
+    1803           0 :     if (fd != NULL) {
+    1804             :         /* Close and delete file */
+    1805           0 :         fclose(fd);
+    1806           0 :         if (unlink(filename1) != 0) {
+    1807           0 :             dlt_vlog(LOG_WARNING, "%s: unlink() failed: %s\n",
+    1808           0 :                     __func__, strerror(errno));
+    1809             :         }
+    1810             :     }
+    1811             : 
+    1812           0 :     daemon->default_log_level = (int8_t) InitialContextLogLevel;
+    1813           0 :     daemon->default_trace_status = (int8_t) InitialContextTraceStatus;
+    1814           0 :     daemon->force_ll_ts = (int8_t) InitialEnforceLlTsStatus;
+    1815             : 
+    1816             :     /* Reset all other things (log level, trace status, etc.
+    1817             :      *                         to default values             */
+    1818             : 
+    1819             :     /* Inform user libraries about changed default log level/trace status */
+    1820           0 :     dlt_daemon_user_send_default_update(daemon, verbose);
+    1821             : }
+    1822             : 
+    1823           0 : void dlt_daemon_user_send_default_update(DltDaemon *daemon, int verbose)
+    1824             : {
+    1825             :     int32_t count;
+    1826             :     DltDaemonContext *context;
+    1827             :     DltDaemonRegisteredUsers *user_list = NULL;
+    1828             : 
+    1829           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1830             : 
+    1831           0 :     if (daemon == NULL) {
+    1832           0 :         dlt_log(LOG_WARNING, "Wrong parameter: Null pointer\n");
+    1833           0 :         return;
+    1834             :     }
+    1835             : 
+    1836           0 :     user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+    1837             : 
+    1838           0 :     if (user_list == NULL)
+    1839             :         return;
+    1840             : 
+    1841           0 :     for (count = 0; count < user_list->num_contexts; count++) {
+    1842           0 :         context = &(user_list->contexts[count]);
+    1843             : 
+    1844           0 :         if (context != NULL) {
+    1845           0 :             if ((context->log_level == DLT_LOG_DEFAULT) ||
+    1846           0 :                 (context->trace_status == DLT_TRACE_STATUS_DEFAULT)) {
+    1847           0 :                 if (context->user_handle >= DLT_FD_MINIMUM)
+    1848           0 :                     if (dlt_daemon_user_send_log_level(daemon,
+    1849             :                                                        context,
+    1850             :                                                        verbose) == -1)
+    1851           0 :                         dlt_vlog(LOG_WARNING, "Cannot update default of %.4s:%.4s\n", context->apid, context->ctid);
+    1852             :             }
+    1853             :         }
+    1854             :     }
+    1855             : }
+    1856             : 
+    1857           0 : void dlt_daemon_user_send_all_log_level_update(DltDaemon *daemon,
+    1858             :                                                int enforce_context_ll_and_ts,
+    1859             :                                                int8_t context_log_level,
+    1860             :                                                int8_t log_level,
+    1861             :                                                int verbose)
+    1862             : {
+    1863             :     int32_t count = 0;
+    1864             :     DltDaemonContext *context = NULL;
+    1865             :     DltDaemonRegisteredUsers *user_list = NULL;
+    1866             : 
+    1867           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1868             : 
+    1869           0 :     if (daemon == NULL)
+    1870             :         return;
+    1871             : 
+    1872           0 :     user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+    1873             : 
+    1874           0 :     if (user_list == NULL)
+    1875             :         return;
+    1876             : 
+    1877           0 :     for (count = 0; count < user_list->num_contexts; count++) {
+    1878           0 :         context = &(user_list->contexts[count]);
+    1879             : 
+    1880           0 :         if (context) {
+    1881           0 :             if (context->user_handle >= DLT_FD_MINIMUM) {
+    1882           0 :                 context->log_level = log_level;
+    1883             : 
+    1884           0 :                 if (enforce_context_ll_and_ts) {
+    1885             : #ifdef DLT_LOG_LEVEL_APP_CONFIG
+    1886             :                     DltDaemonContextLogSettings *settings =
+    1887             :                         dlt_daemon_find_configured_app_id_ctx_id_settings(
+    1888             :                             daemon, context->apid, context->ctid);
+    1889             :                     if (settings != NULL) {
+    1890             :                         if (log_level > settings->log_level) {
+    1891             :                           context->log_level = settings->log_level;
+    1892             :                         }
+    1893             :                     } else
+    1894             : #endif
+    1895           0 :                     if (log_level > context_log_level) {
+    1896           0 :                         context->log_level = (int8_t)context_log_level;
+    1897             :                     }
+    1898             :                 }
+    1899             : 
+    1900           0 :                 if (dlt_daemon_user_send_log_level(daemon,
+    1901             :                                                    context,
+    1902             :                                                    verbose) == -1)
+    1903           0 :                     dlt_vlog(LOG_WARNING,
+    1904             :                              "Cannot send log level %.4s:%.4s -> %i\n",
+    1905           0 :                              context->apid,
+    1906           0 :                              context->ctid,
+    1907           0 :                              context->log_level);
+    1908             :             }
+    1909             :         }
+    1910             :     }
+    1911             : }
+    1912             : 
+    1913           0 : void dlt_daemon_user_send_all_trace_status_update(DltDaemon *daemon, int8_t trace_status, int verbose)
+    1914             : {
+    1915             :     int32_t count = 0;
+    1916             :     DltDaemonContext *context = NULL;
+    1917             :     DltDaemonRegisteredUsers *user_list = NULL;
+    1918             : 
+    1919           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1920             : 
+    1921           0 :     if (daemon == NULL)
+    1922             :         return;
+    1923             : 
+    1924           0 :     user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+    1925             : 
+    1926           0 :     if (user_list == NULL)
+    1927             :         return;
+    1928             : 
+    1929           0 :     dlt_vlog(LOG_NOTICE, "All trace status is updated -> %i\n", trace_status);
+    1930             : 
+    1931           0 :     for (count = 0; count < user_list->num_contexts; count++) {
+    1932           0 :         context = &(user_list->contexts[count]);
+    1933             : 
+    1934           0 :         if (context) {
+    1935           0 :             if (context->user_handle >= DLT_FD_MINIMUM) {
+    1936           0 :                 context->trace_status = trace_status;
+    1937             : 
+    1938           0 :                 if (dlt_daemon_user_send_log_level(daemon, context, verbose) == -1)
+    1939           0 :                     dlt_vlog(LOG_WARNING,
+    1940             :                              "Cannot send trace status %.4s:%.4s -> %i\n",
+    1941           0 :                              context->apid,
+    1942           0 :                              context->ctid,
+    1943           0 :                              context->trace_status);
+    1944             :             }
+    1945             :         }
+    1946             :     }
+    1947             : }
+    1948             : 
+    1949           5 : void dlt_daemon_user_send_all_log_state(DltDaemon *daemon, int verbose)
+    1950             : {
+    1951             :     int32_t count;
+    1952             :     DltDaemonApplication *app;
+    1953             :     DltDaemonRegisteredUsers *user_list = NULL;
+    1954             : 
+    1955           5 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1956             : 
+    1957           5 :     if (daemon == NULL) {
+    1958           0 :         dlt_log(LOG_WARNING, "Wrong parameter: Null pointer\n");
+    1959           0 :         return;
+    1960             :     }
+    1961             : 
+    1962           5 :     user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+    1963             : 
+    1964           5 :     if (user_list == NULL)
+    1965             :         return;
+    1966             : 
+    1967           7 :     for (count = 0; count < user_list->num_applications; count++) {
+    1968           2 :         app = &(user_list->applications[count]);
+    1969             : 
+    1970           2 :         if (app != NULL) {
+    1971           2 :             if (app->user_handle >= DLT_FD_MINIMUM)
+    1972           2 :                 if (dlt_daemon_user_send_log_state(daemon, app, verbose) == -1)
+    1973           0 :                     dlt_vlog(LOG_WARNING, "Cannot send log state to Apid: %.4s, PID: %d\n", app->apid, app->pid);
+    1974             :         }
+    1975             :     }
+    1976             : }
+    1977             : 
+    1978          16 : void dlt_daemon_change_state(DltDaemon *daemon, DltDaemonState newState)
+    1979             : {
+    1980          16 :     switch (newState) {
+    1981           0 :     case DLT_DAEMON_STATE_INIT:
+    1982           0 :         dlt_log(LOG_INFO, "Switched to init state.\n");
+    1983           0 :         daemon->state = DLT_DAEMON_STATE_INIT;
+    1984           0 :         break;
+    1985          12 :     case DLT_DAEMON_STATE_BUFFER:
+    1986          12 :         dlt_log(LOG_INFO, "Switched to buffer state for socket connections.\n");
+    1987          12 :         daemon->state = DLT_DAEMON_STATE_BUFFER;
+    1988          12 :         break;
+    1989           0 :     case DLT_DAEMON_STATE_BUFFER_FULL:
+    1990           0 :         dlt_log(LOG_INFO, "Switched to buffer full state.\n");
+    1991           0 :         daemon->state = DLT_DAEMON_STATE_BUFFER_FULL;
+    1992           0 :         break;
+    1993           2 :     case DLT_DAEMON_STATE_SEND_BUFFER:
+    1994           2 :         dlt_log(LOG_INFO, "Switched to send buffer state for socket connections.\n");
+    1995           2 :         daemon->state = DLT_DAEMON_STATE_SEND_BUFFER;
+    1996           2 :         break;
+    1997           2 :     case DLT_DAEMON_STATE_SEND_DIRECT:
+    1998           2 :         dlt_log(LOG_INFO, "Switched to send direct state.\n");
+    1999           2 :         daemon->state = DLT_DAEMON_STATE_SEND_DIRECT;
+    2000           2 :         break;
+    2001             :     }
+    2002          16 : }
+    2003             : 
+    2004             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+    2005             : void dlt_daemon_trigger_systemd_watchdog_if_necessary(unsigned int* last_trigger_time, unsigned int watchdog_trigger_interval) {
+    2006             :     unsigned int uptime = dlt_uptime();
+    2007             :     if ((uptime - *last_trigger_time) / 10000 >= watchdog_trigger_interval) {
+    2008             :         if (sd_notify(0, "WATCHDOG=1") < 0)
+    2009             :             dlt_vlog(LOG_WARNING, "%s: Could not reset systemd watchdog\n", __func__);
+    2010             :         *last_trigger_time = uptime;
+    2011             :     }
+    2012             : }
+    2013             : #endif
+    2014             : 
+    2015             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+    2016             : int dlt_daemon_user_send_trace_load_config(DltDaemon *const daemon, DltDaemonApplication *app, const int verbose)
+    2017             : {
+    2018             :     DltUserHeader userheader;
+    2019             :     DltUserControlMsgTraceSettingMsg* trace_load_settings_user_msg;
+    2020             :     uint32_t trace_load_settings_count;
+    2021             :     DltReturnValue ret;
+    2022             : 
+    2023             : 
+    2024             :     PRINT_FUNCTION_VERBOSE(verbose);
+    2025             : 
+    2026             :     if ((daemon == NULL) || (app == NULL)) return -1;
+    2027             : 
+    2028             :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_TRACE_LOAD) < DLT_RETURN_OK) return -1;
+    2029             : 
+    2030             :     DltTraceLoadSettings* app_settings = app->trace_load_settings;
+    2031             : 
+    2032             :     if (app_settings != NULL) {
+    2033             :         trace_load_settings_count = app->trace_load_settings_count;
+    2034             :         trace_load_settings_user_msg = malloc(sizeof(DltUserControlMsgTraceSettingMsg) * trace_load_settings_count);
+    2035             :         for (uint32_t i = 0U; i < trace_load_settings_count; i++) {
+    2036             :             // App id is not transmitted as the user library only
+    2037             :             // has one application ID
+    2038             :             memcpy(trace_load_settings_user_msg[i].ctid, app_settings[i].ctid, DLT_ID_SIZE);
+    2039             :             trace_load_settings_user_msg[i].soft_limit = app_settings[i].soft_limit;
+    2040             :             trace_load_settings_user_msg[i].hard_limit = app_settings[i].hard_limit;
+    2041             : 
+    2042             :             if (app_settings[i].ctid[0] == '\0') {
+    2043             :                 dlt_vlog(LOG_NOTICE, "Sending trace load config to app %.4s, soft limit %u, hard limit %u\n",
+    2044             :                          app->apid,
+    2045             :                          app_settings[i].soft_limit,
+    2046             :                          app_settings[i].hard_limit);
+    2047             :             } else {
+    2048             :                 dlt_vlog(LOG_NOTICE, "Sending trace load config to app %.4s, ctid %.4s, soft limit %u, hard limit %u\n",
+    2049             :                          app->apid,
+    2050             :                          app_settings[i].ctid,
+    2051             :                          app_settings[i].soft_limit,
+    2052             :                          app_settings[i].hard_limit);
+    2053             :             }
+    2054             : 
+    2055             :         }
+    2056             :     }
+    2057             :     else {
+    2058             :         dlt_vlog(LOG_INFO,
+    2059             :                  "No trace load settings for application %s, setting daemon defaults.\n", app->apid);
+    2060             : 
+    2061             :         trace_load_settings_count = 1;
+    2062             :         trace_load_settings_user_msg = malloc(sizeof(DltUserControlMsgTraceSettingMsg));
+    2063             : 
+    2064             :         memset(trace_load_settings_user_msg, 0, sizeof(DltTraceLoadSettings));
+    2065             :         trace_load_settings_user_msg[0].soft_limit = DLT_TRACE_LOAD_DAEMON_SOFT_LIMIT_DEFAULT;
+    2066             :         trace_load_settings_user_msg[0].hard_limit = DLT_TRACE_LOAD_DAEMON_HARD_LIMIT_DEFAULT;
+    2067             :     }
+    2068             : 
+    2069             :     /* log to FIFO */
+    2070             :     ret = dlt_user_log_out3_with_timeout(app->user_handle,
+    2071             :                                          &(userheader), sizeof(DltUserHeader),
+    2072             :                                          &(trace_load_settings_count), sizeof(uint32_t),
+    2073             :                                          trace_load_settings_user_msg, sizeof(DltUserControlMsgTraceSettingMsg) * trace_load_settings_count);
+    2074             : 
+    2075             :     if (ret < DLT_RETURN_OK && errno == EPIPE) {
+    2076             :         dlt_daemon_application_reset_user_handle(daemon, app, verbose);
+    2077             :     }
+    2078             : 
+    2079             :     free(trace_load_settings_user_msg);
+    2080             : 
+    2081             :     return ret;
+    2082             : }
+    2083             : #endif
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_connection.c.func-sort-c.html b/dlt_lcov_report/daemon/dlt_daemon_connection.c.func-sort-c.html new file mode 100644 index 000000000..a922c8a1c --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_connection.c.func-sort-c.html @@ -0,0 +1,104 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_connection.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_connection.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:10211588.7 %
Date:2024-12-05 09:07:13Functions:88100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_connection_get_next2
dlt_connection_create47
dlt_connection_destroy48
dlt_connection_get_receiver48
dlt_connection_destroy_receiver49
dlt_connection_send_multiple219
dlt_connection_send436
dlt_connection_get_callback1557
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_connection.c.func.html b/dlt_lcov_report/daemon/dlt_daemon_connection.c.func.html new file mode 100644 index 000000000..3311569c7 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_connection.c.func.html @@ -0,0 +1,104 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_connection.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_connection.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:10211588.7 %
Date:2024-12-05 09:07:13Functions:88100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_connection_create47
dlt_connection_destroy48
dlt_connection_destroy_receiver49
dlt_connection_get_callback1557
dlt_connection_get_next2
dlt_connection_get_receiver48
dlt_connection_send436
dlt_connection_send_multiple219
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_connection.c.gcov.html b/dlt_lcov_report/daemon/dlt_daemon_connection.c.gcov.html new file mode 100644 index 000000000..62fa19cf8 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_connection.c.gcov.html @@ -0,0 +1,517 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_connection.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_connection.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:10211588.7 %
Date:2024-12-05 09:07:13Functions:88100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2015 Advanced Driver Information Technology.
+       5             :  * This code is developed by Advanced Driver Information Technology.
+       6             :  * Copyright of Advanced Driver Information Technology, Bosch and DENSO.
+       7             :  *
+       8             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       9             :  *
+      10             :  * This Source Code Form is subject to the terms of the
+      11             :  * Mozilla Public License (MPL), v. 2.0.
+      12             :  * If a copy of the MPL was not distributed with this file,
+      13             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      14             :  *
+      15             :  * For further information see http://www.covesa.org/.
+      16             :  */
+      17             : 
+      18             : /*!
+      19             :  * \author
+      20             :  * Frederic Berat <fberat@de.adit-jv.com>
+      21             :  *
+      22             :  * \copyright Copyright © 2015 Advanced Driver Information Technology. \n
+      23             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      24             :  *
+      25             :  * \file dlt_daemon_connection.c
+      26             :  */
+      27             : 
+      28             : #include <errno.h>
+      29             : #include <stdio.h>
+      30             : #include <stdlib.h>
+      31             : #include <string.h>
+      32             : #include <unistd.h>
+      33             : 
+      34             : #include <sys/socket.h>
+      35             : #include <syslog.h>
+      36             : #include <sys/stat.h>
+      37             : #include <sys/types.h>
+      38             : 
+      39             : #include "dlt_daemon_connection_types.h"
+      40             : #include "dlt_daemon_connection.h"
+      41             : #include "dlt_daemon_event_handler_types.h"
+      42             : #include "dlt_daemon_event_handler.h"
+      43             : #include "dlt-daemon.h"
+      44             : #include "dlt-daemon_cfg.h"
+      45             : #include "dlt_daemon_common.h"
+      46             : #include "dlt_common.h"
+      47             : #include "dlt_log.h"
+      48             : #include "dlt_gateway.h"
+      49             : #include "dlt_daemon_socket.h"
+      50             : 
+      51             : static DltConnectionId connectionId;
+      52             : extern char *app_recv_buffer;
+      53             : 
+      54             : /** @brief Generic sending function.
+      55             :  *
+      56             :  * We manage different type of connection which have similar send/write
+      57             :  * functions. We can then abstract the data transfer using this function,
+      58             :  * moreover as we often transfer data to different kind of connection
+      59             :  * within the same loop.
+      60             :  *
+      61             :  * @param conn The connection structure.
+      62             :  * @param msg The message buffer to be sent
+      63             :  * @param msg_size The length of the message to be sent
+      64             :  *
+      65             :  * @return DLT_DAEMON_ERROR_OK on success, DLT_DAEMON_ERROR_SEND_FAILED
+      66             :  *         on send failure, DLT_DAEMON_ERROR_UNKNOWN otherwise.
+      67             :  *         errno is appropriately set.
+      68             :  */
+      69         436 : DLT_STATIC int dlt_connection_send(DltConnection *conn,
+      70             :                                    void *msg,
+      71             :                                    size_t msg_size)
+      72             : {
+      73             :     DltConnectionType type = DLT_CONNECTION_TYPE_MAX;
+      74             :     int ret = 0;
+      75             : 
+      76         436 :     if ((conn != NULL) && (conn->receiver != NULL))
+      77         436 :         type = conn->type;
+      78             : 
+      79         436 :     switch (type) {
+      80           1 :     case DLT_CONNECTION_CLIENT_MSG_SERIAL:
+      81             : 
+      82           1 :         if (write(conn->receiver->fd, msg, msg_size) > 0)
+      83           1 :             return DLT_DAEMON_ERROR_OK;
+      84             : 
+      85             :         return DLT_DAEMON_ERROR_UNKNOWN;
+      86             : 
+      87         434 :     case DLT_CONNECTION_CLIENT_MSG_TCP:
+      88         434 :         ret = dlt_daemon_socket_sendreliable(conn->receiver->fd,
+      89             :                                              msg,
+      90             :                                              msg_size);
+      91         434 :         return ret;
+      92             :     default:
+      93             :         return DLT_DAEMON_ERROR_UNKNOWN;
+      94             :     }
+      95             : }
+      96             : 
+      97             : /** @brief Send up to two messages through a connection.
+      98             :  *
+      99             :  * We often need to send 2 messages through a specific connection, plus
+     100             :  * the serial header. This function groups these different calls.
+     101             :  *
+     102             :  * @param con The connection to send the messages through.
+     103             :  * @param data1 The first message to be sent.
+     104             :  * @param size1 The size of the first message.
+     105             :  * @param data2 The second message to be send.
+     106             :  * @param size2 The second message size.
+     107             :  * @param sendserialheader Whether we need or not to send the serial header.
+     108             :  *
+     109             :  * @return DLT_DAEMON_ERROR_OK on success, -1 otherwise. errno is properly set.
+     110             :  */
+     111         219 : int dlt_connection_send_multiple(DltConnection *con,
+     112             :                                  void *data1,
+     113             :                                  int size1,
+     114             :                                  void *data2,
+     115             :                                  int size2,
+     116             :                                  int sendserialheader)
+     117             : {
+     118             :     int ret = 0;
+     119             : 
+     120         219 :     if (con == NULL)
+     121             :         return DLT_DAEMON_ERROR_UNKNOWN;
+     122             : 
+     123         218 :     if (sendserialheader)
+     124           1 :         ret = dlt_connection_send(con,
+     125             :                                   (void *)dltSerialHeader,
+     126             :                                   sizeof(dltSerialHeader));
+     127             : 
+     128         218 :     if ((data1 != NULL) && (ret == DLT_RETURN_OK))
+     129         218 :         ret = dlt_connection_send(con, data1, size1);
+     130             : 
+     131         218 :     if ((data2 != NULL) && (ret == DLT_RETURN_OK))
+     132         214 :         ret = dlt_connection_send(con, data2, size2);
+     133             : 
+     134             :     return ret;
+     135             : }
+     136             : 
+     137             : /** @brief Get the next connection filtered with a type mask.
+     138             :  *
+     139             :  * In some cases we need the next connection available of a specific type or
+     140             :  * specific different types. This function returns the next available connection
+     141             :  * that is of one of the types included in the mask. The current connection can
+     142             :  * be returned.
+     143             :  *
+     144             :  * @param current The current connection pointer.
+     145             :  * @param type_mask A bit mask representing the connection types to be filtered.
+     146             :  *
+     147             :  * @return The next available connection of the considered types or NULL.
+     148             :  */
+     149           2 : DltConnection *dlt_connection_get_next(DltConnection *current, int type_mask)
+     150             : {
+     151           3 :     while (current && !((1 << current->type) & type_mask))
+     152           1 :         current = current->next;
+     153             : 
+     154           2 :     return current;
+     155             : }
+     156             : 
+     157          49 : DLT_STATIC void dlt_connection_destroy_receiver(DltConnection *con)
+     158             : {
+     159          49 :     if (!con)
+     160             :         return;
+     161             : 
+     162          49 :     switch (con->type) {
+     163             :     case DLT_CONNECTION_GATEWAY:
+     164             :         /* We rely on the gateway for clean-up */
+     165             :         break;
+     166           9 :     case DLT_CONNECTION_APP_MSG:
+     167           9 :         dlt_receiver_free_global_buffer(con->receiver);
+     168           9 :         free(con->receiver);
+     169           9 :         con->receiver = NULL;
+     170           9 :         break;
+     171          36 :     default:
+     172          36 :         (void)dlt_receiver_free(con->receiver);
+     173          36 :         free(con->receiver);
+     174          36 :         con->receiver = NULL;
+     175          36 :         break;
+     176             :     }
+     177             : }
+     178             : 
+     179             : /** @brief Get the receiver structure associated to a connection.
+     180             :  *
+     181             :  * The receiver structure is sometimes needed while handling the event.
+     182             :  * This behavior is mainly due to the fact that it's not intended to modify
+     183             :  * the whole design of the daemon while implementing the new event handling.
+     184             :  * Based on the connection type provided, this function returns the pointer
+     185             :  * to the DltReceiver structure corresponding.
+     186             :  *
+     187             :  * @param daemon_local Structure where to take the DltReceiver pointer from.
+     188             :  * @param type Type of the connection.
+     189             :  * @param fd File descriptor
+     190             :  *
+     191             :  * @return DltReceiver structure or NULL if none corresponds to the type.
+     192             :  */
+     193          48 : DLT_STATIC DltReceiver *dlt_connection_get_receiver(DltDaemonLocal *daemon_local,
+     194             :                                                     DltConnectionType type,
+     195             :                                                     int fd)
+     196             : {
+     197             :     DltReceiver *ret = NULL;
+     198             :     DltReceiverType receiver_type = DLT_RECEIVE_FD;
+     199             :     struct stat statbuf;
+     200             : 
+     201          48 :     switch (type) {
+     202          25 :     case DLT_CONNECTION_CONTROL_CONNECT:
+     203             :     /* FALL THROUGH */
+     204             :     case DLT_CONNECTION_CONTROL_MSG:
+     205             :     /* FALL THROUGH */
+     206             :     case DLT_CONNECTION_CLIENT_CONNECT:
+     207             :     /* FALL THROUGH */
+     208             :     case DLT_CONNECTION_CLIENT_MSG_TCP:
+     209          25 :         ret = calloc(1, sizeof(DltReceiver));
+     210             : 
+     211          25 :         if (ret)
+     212          25 :             dlt_receiver_init(ret, fd, DLT_RECEIVE_SOCKET, DLT_DAEMON_RCVBUFSIZESOCK);
+     213             : 
+     214             :         break;
+     215           1 :     case DLT_CONNECTION_CLIENT_MSG_SERIAL:
+     216           1 :         ret = calloc(1, sizeof(DltReceiver));
+     217             : 
+     218           1 :         if (ret)
+     219           1 :             dlt_receiver_init(ret, fd, DLT_RECEIVE_FD, DLT_DAEMON_RCVBUFSIZESERIAL);
+     220             : 
+     221             :         break;
+     222           9 :     case DLT_CONNECTION_APP_MSG:
+     223           9 :         ret = calloc(1, sizeof(DltReceiver));
+     224             : 
+     225             :         receiver_type = DLT_RECEIVE_FD;
+     226             : 
+     227           9 :         if (fstat(fd, &statbuf) == 0) {
+     228           9 :             if (S_ISSOCK(statbuf.st_mode))
+     229             :                 receiver_type = DLT_RECEIVE_SOCKET;
+     230             :         } else {
+     231           0 :             dlt_vlog(LOG_WARNING,
+     232             :                      "Failed to determine receive type for DLT_CONNECTION_APP_MSG, using \"FD\"\n");
+     233             :         }
+     234             : 
+     235           9 :         if (ret)
+     236           9 :             dlt_receiver_init_global_buffer(ret, fd, receiver_type, &app_recv_buffer);
+     237             : 
+     238             :         break;
+     239             : #if defined DLT_DAEMON_USE_UNIX_SOCKET_IPC || defined DLT_DAEMON_VSOCK_IPC_ENABLE
+     240             :     case DLT_CONNECTION_APP_CONNECT:
+     241             :     /* FALL THROUGH */
+     242             : #endif
+     243          10 :     case DLT_CONNECTION_ONE_S_TIMER:
+     244             :     /* FALL THROUGH */
+     245             :     case DLT_CONNECTION_SIXTY_S_TIMER:
+     246             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+     247             :     /* FALL THROUGH */
+     248             :     case DLT_CONNECTION_SYSTEMD_TIMER:
+     249             : #endif
+     250             :     /* FALL THROUGH */
+     251             :     case DLT_CONNECTION_GATEWAY_TIMER:
+     252          10 :         ret = calloc(1, sizeof(DltReceiver));
+     253             : 
+     254          10 :         if (ret)
+     255          10 :             dlt_receiver_init(ret, fd, DLT_RECEIVE_FD, DLT_DAEMON_RCVBUFSIZE);
+     256             : 
+     257             :         break;
+     258           3 :     case DLT_CONNECTION_GATEWAY:
+     259             :         /* We rely on the gateway for init */
+     260           3 :         ret = dlt_gateway_get_connection_receiver(&daemon_local->pGateway, fd);
+     261           3 :         break;
+     262             :     default:
+     263             :         ret = NULL;
+     264             :     }
+     265             : 
+     266          48 :     return ret;
+     267             : }
+     268             : 
+     269             : /** @brief Get the callback from a specific connection.
+     270             :  *
+     271             :  * The callback retrieved that way is used to handle event for this connection.
+     272             :  * It as been chosen to proceed that way instead of having the callback directly
+     273             :  * in the structure in order to have some way to check that the structure is
+     274             :  * still valid, or at least gracefully handle errors instead of crashing.
+     275             :  *
+     276             :  * @param con The connection to retrieve the callback from.
+     277             :  *
+     278             :  * @return Function pointer or NULL.
+     279             :  */
+     280        1557 : void *dlt_connection_get_callback(DltConnection *con)
+     281             : {
+     282             :     void *ret = NULL;
+     283             :     DltConnectionType type = DLT_CONNECTION_TYPE_MAX;
+     284             : 
+     285        1557 :     if (con)
+     286        1557 :         type = con->type;
+     287             : 
+     288        1557 :     switch (type) {
+     289             :     case DLT_CONNECTION_CLIENT_CONNECT:
+     290             :         ret = dlt_daemon_process_client_connect;
+     291             :         break;
+     292          11 :     case DLT_CONNECTION_CLIENT_MSG_TCP:
+     293             :         ret = dlt_daemon_process_client_messages;
+     294          11 :         break;
+     295           0 :     case DLT_CONNECTION_CLIENT_MSG_SERIAL:
+     296             :         ret = dlt_daemon_process_client_messages_serial;
+     297           0 :         break;
+     298             : #if defined DLT_DAEMON_USE_UNIX_SOCKET_IPC || defined DLT_DAEMON_VSOCK_IPC_ENABLE
+     299             :     case DLT_CONNECTION_APP_CONNECT:
+     300             :         ret = dlt_daemon_process_app_connect;
+     301             :         break;
+     302             : #endif
+     303        1523 :     case DLT_CONNECTION_APP_MSG:
+     304             :         ret = dlt_daemon_process_user_messages;
+     305        1523 :         break;
+     306          11 :     case DLT_CONNECTION_ONE_S_TIMER:
+     307             :         ret = dlt_daemon_process_one_s_timer;
+     308          11 :         break;
+     309           0 :     case DLT_CONNECTION_SIXTY_S_TIMER:
+     310             :         ret = dlt_daemon_process_sixty_s_timer;
+     311           0 :         break;
+     312             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+     313             :     case DLT_CONNECTION_SYSTEMD_TIMER:
+     314             :         ret = dlt_daemon_process_systemd_timer;
+     315             :         break;
+     316             : #endif
+     317           2 :     case DLT_CONNECTION_CONTROL_CONNECT:
+     318             :         ret = dlt_daemon_process_control_connect;
+     319           2 :         break;
+     320           4 :     case DLT_CONNECTION_CONTROL_MSG:
+     321             :         ret = dlt_daemon_process_control_messages;
+     322           4 :         break;
+     323           2 :     case DLT_CONNECTION_GATEWAY:
+     324             :         ret = dlt_gateway_process_passive_node_messages;
+     325           2 :         break;
+     326           0 :     case DLT_CONNECTION_GATEWAY_TIMER:
+     327             :         ret = dlt_gateway_process_gateway_timer;
+     328           0 :         break;
+     329           0 :     default:
+     330             :         ret = NULL;
+     331             :     }
+     332             : 
+     333        1557 :     return ret;
+     334             : }
+     335             : 
+     336             : /** @brief Destroys a connection.
+     337             :  *
+     338             :  * This function closes and frees the corresponding connection. This is expected
+     339             :  * to be called by the connection owner: the DltEventHandler.
+     340             :  * Ownership of the connection is given during the registration to
+     341             :  * the DltEventHandler.
+     342             :  *
+     343             :  * @param to_destroy Connection to be destroyed.
+     344             :  */
+     345          48 : void dlt_connection_destroy(DltConnection *to_destroy)
+     346             : {
+     347          48 :     to_destroy->id = 0;
+     348          48 :     close(to_destroy->receiver->fd);
+     349          48 :     dlt_connection_destroy_receiver(to_destroy);
+     350          48 :     free(to_destroy);
+     351          48 : }
+     352             : 
+     353             : /** @brief Creates a connection and registers it to the DltEventHandler.
+     354             :  *
+     355             :  * The function will allocate memory for the connection, and give the pointer
+     356             :  * to the DltEventHandler in order to register it for incoming events.
+     357             :  * The connection is then destroyed later on, once it's not needed anymore or
+     358             :  * it the event handler is destroyed.
+     359             :  *
+     360             :  * @param daemon_local Structure were some needed information is.
+     361             :  * @param evh DltEventHandler to register the connection to.
+     362             :  * @param fd File descriptor of the connection.
+     363             :  * @param mask Event list bit mask.
+     364             :  * @param type Connection type.
+     365             :  *
+     366             :  * @return 0 On success, -1 otherwise.
+     367             :  */
+     368          47 : int dlt_connection_create(DltDaemonLocal *daemon_local,
+     369             :                           DltEventHandler *evh,
+     370             :                           int fd,
+     371             :                           int mask,
+     372             :                           DltConnectionType type)
+     373             : {
+     374             :     DltConnection *temp = NULL;
+     375             : 
+     376          47 :     if (fd < 0)
+     377             :         /* Nothing to do */
+     378             :         return 0;
+     379             : 
+     380          47 :     if (dlt_event_handler_find_connection(evh, fd) != NULL)
+     381             :         /* No need for the same client to be registered twice
+     382             :          * for the same event.
+     383             :          * TODO: If another mask can be expected,
+     384             :          * we need it to update the poll event here.
+     385             :          */
+     386             :         return 0;
+     387             : 
+     388          47 :     temp = (DltConnection *)malloc(sizeof(DltConnection));
+     389             : 
+     390          47 :     if (temp == NULL) {
+     391           0 :         dlt_log(LOG_CRIT, "Allocation of client handle failed\n");
+     392           0 :         return -1;
+     393             :     }
+     394             : 
+     395             :     memset(temp, 0, sizeof(DltConnection));
+     396             : 
+     397          47 :     temp->receiver = dlt_connection_get_receiver(daemon_local, type, fd);
+     398             : 
+     399          47 :     if (!temp->receiver) {
+     400           0 :         dlt_vlog(LOG_CRIT, "Unable to get receiver from %u connection.\n",
+     401             :                  type);
+     402           0 :         free(temp);
+     403           0 :         return -1;
+     404             :     }
+     405             : 
+     406             :     struct timeval timeout;
+     407          47 :     timeout.tv_sec = 5;
+     408          47 :     timeout.tv_usec = 0;
+     409             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+     410             :     char *watchdogUSec = getenv("WATCHDOG_USEC");
+     411             :     if (watchdogUSec) {
+     412             :         timeout.tv_sec = atoi(watchdogUSec) / 1000000;
+     413             :         timeout.tv_usec = atoi(watchdogUSec) % 1000000;
+     414             :     }
+     415             : #endif
+     416             : 
+     417          47 :     if (setsockopt (temp->receiver->fd, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof timeout) < 0)  {
+     418          20 :         dlt_vlog(LOG_WARNING, "Unable to set send timeout %s.\n", strerror(errno));
+     419             :         // as this function is used for non socket connection as well
+     420             :         // we only can return an error here if it is a socket
+     421          20 :         if (errno != ENOTSOCK) {
+     422           1 :             free(temp);
+     423           1 :             return -1;
+     424             :         }
+     425             :     }
+     426             : 
+     427             :     /* We are single threaded no need for protection. */
+     428          46 :     temp->id = connectionId++;
+     429             : 
+     430          46 :     if (!temp->id)
+     431             :         /* Skipping 0 */
+     432          10 :         temp->id = connectionId++;
+     433             : 
+     434          46 :     temp->type = type;
+     435          46 :     temp->status = ACTIVE;
+     436             : 
+     437             :     /* Now give the ownership of the newly created connection
+     438             :      * to the event handler, by registering for events.
+     439             :      */
+     440          46 :     return dlt_event_handler_register_connection(evh, daemon_local, temp, mask);
+     441             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_event_handler.c.func-sort-c.html b/dlt_lcov_report/daemon/dlt_daemon_event_handler.c.func-sort-c.html new file mode 100644 index 000000000..129c385b4 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_event_handler.c.func-sort-c.html @@ -0,0 +1,116 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_event_handler.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_event_handler.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:12515083.3 %
Date:2024-12-05 09:07:13Functions:1111100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_add_connection6
dlt_event_handler_disable_fd7
dlt_event_handler_unregister_connection7
dlt_event_handler_cleanup_connections10
dlt_daemon_prepare_event_handling16
dlt_daemon_remove_connection47
dlt_event_handler_enable_fd49
dlt_event_handler_register_connection49
dlt_connection_check_activate57
dlt_event_handler_find_connection1122
dlt_daemon_handle_event1570
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_event_handler.c.func.html b/dlt_lcov_report/daemon/dlt_daemon_event_handler.c.func.html new file mode 100644 index 000000000..a4c91115c --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_event_handler.c.func.html @@ -0,0 +1,116 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_event_handler.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_event_handler.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:12515083.3 %
Date:2024-12-05 09:07:13Functions:1111100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_connection_check_activate57
dlt_daemon_add_connection6
dlt_daemon_handle_event1570
dlt_daemon_prepare_event_handling16
dlt_daemon_remove_connection47
dlt_event_handler_cleanup_connections10
dlt_event_handler_disable_fd7
dlt_event_handler_enable_fd49
dlt_event_handler_find_connection1122
dlt_event_handler_register_connection49
dlt_event_handler_unregister_connection7
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_event_handler.c.gcov.html b/dlt_lcov_report/daemon/dlt_daemon_event_handler.c.gcov.html new file mode 100644 index 000000000..87b9e1e62 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_event_handler.c.gcov.html @@ -0,0 +1,614 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_event_handler.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_event_handler.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:12515083.3 %
Date:2024-12-05 09:07:13Functions:1111100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2015 Advanced Driver Information Technology.
+       5             :  * This code is developed by Advanced Driver Information Technology.
+       6             :  * Copyright of Advanced Driver Information Technology, Bosch and DENSO.
+       7             :  *
+       8             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       9             :  *
+      10             :  * This Source Code Form is subject to the terms of the
+      11             :  * Mozilla Public License (MPL), v. 2.0.
+      12             :  * If a copy of the MPL was not distributed with this file,
+      13             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      14             :  *
+      15             :  * For further information see http://www.covesa.org/.
+      16             :  */
+      17             : 
+      18             : /*!
+      19             :  * \author
+      20             :  * Frederic Berat <fberat@de.adit-jv.com>
+      21             :  *
+      22             :  * \copyright Copyright © 2015 Advanced Driver Information Technology. \n
+      23             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      24             :  *
+      25             :  * \file dlt_daemon_event_handler.c
+      26             :  */
+      27             : 
+      28             : #include <stdio.h>
+      29             : #include <stdlib.h>
+      30             : #include <string.h>
+      31             : #include <errno.h>
+      32             : 
+      33             : #include <poll.h>
+      34             : #include <syslog.h>
+      35             : 
+      36             : #include "dlt_common.h"
+      37             : #include "dlt_log.h"
+      38             : 
+      39             : #include "dlt-daemon.h"
+      40             : #include "dlt-daemon_cfg.h"
+      41             : #include "dlt_daemon_common.h"
+      42             : #include "dlt_daemon_connection.h"
+      43             : #include "dlt_daemon_connection_types.h"
+      44             : #include "dlt_daemon_event_handler.h"
+      45             : #include "dlt_daemon_event_handler_types.h"
+      46             : #include "dlt_daemon_common.h"
+      47             : 
+      48             : /**
+      49             :  * \def DLT_EV_TIMEOUT_MSEC
+      50             :  * The maximum amount of time to wait for a poll event.
+      51             :  * Set to 1 second to avoid unnecessary wake ups.
+      52             :  */
+      53             : #define DLT_EV_TIMEOUT_MSEC 1000
+      54             : #define DLT_EV_BASE_FD      16
+      55             : 
+      56             : #define DLT_EV_MASK_REJECTED (POLLERR | POLLNVAL)
+      57             : 
+      58             : /** @brief Initialize a pollfd structure
+      59             :  *
+      60             :  * That ensures that no event will be mis-watched.
+      61             :  *
+      62             :  * @param pfd The element to initialize
+      63             :  */
+      64             : static void init_poll_fd(struct pollfd *pfd)
+      65             : {
+      66         293 :     pfd->fd = -1;
+      67         293 :     pfd->events = 0;
+      68         293 :     pfd->revents = 0;
+      69           7 : }
+      70             : 
+      71             : /** @brief Prepare the event handler
+      72             :  *
+      73             :  * This will create the base poll file descriptor list.
+      74             :  *
+      75             :  * @param ev The event handler to prepare.
+      76             :  *
+      77             :  * @return 0 on success, -1 otherwise.
+      78             :  */
+      79          16 : int dlt_daemon_prepare_event_handling(DltEventHandler *ev)
+      80             : {
+      81             :     int i = 0;
+      82             : 
+      83          16 :     if (ev == NULL)
+      84             :         return DLT_RETURN_ERROR;
+      85             : 
+      86          15 :     ev->pfd = calloc(DLT_EV_BASE_FD, sizeof(struct pollfd));
+      87             : 
+      88          15 :     if (ev->pfd == NULL) {
+      89           0 :         dlt_log(LOG_CRIT, "Creation of poll instance failed!\n");
+      90           0 :         return -1;
+      91             :     }
+      92             : 
+      93         255 :     for (i = 0; i < DLT_EV_BASE_FD; i++)
+      94         240 :         init_poll_fd(&ev->pfd[i]);
+      95             : 
+      96          15 :     ev->nfds = 0;
+      97          15 :     ev->max_nfds = DLT_EV_BASE_FD;
+      98             : 
+      99          15 :     return 0;
+     100             : }
+     101             : 
+     102             : /** @brief Enable a file descriptor to be watched
+     103             :  *
+     104             :  * Adds a file descriptor to the descriptor list. If the list is to small,
+     105             :  * increase its size.
+     106             :  *
+     107             :  * @param ev The event handler structure, containing the list
+     108             :  * @param fd The file descriptor to add
+     109             :  * @param mask The mask of event to be watched
+     110             :  */
+     111          49 : static void dlt_event_handler_enable_fd(DltEventHandler *ev, int fd, int mask)
+     112             : {
+     113          49 :     if (ev->max_nfds <= ev->nfds) {
+     114           2 :         int i = ev->nfds;
+     115           2 :         int max = 2 * ev->max_nfds;
+     116           2 :         struct pollfd *tmp = realloc(ev->pfd, max * sizeof(*ev->pfd));
+     117             : 
+     118           2 :         if (!tmp) {
+     119           0 :             dlt_log(LOG_CRIT,
+     120             :                     "Unable to register new fd for the event handler.\n");
+     121           0 :             return;
+     122             :         }
+     123             : 
+     124           2 :         ev->pfd = tmp;
+     125           2 :         ev->max_nfds = max;
+     126             : 
+     127           2 :         for (; i < max; i++)
+     128           0 :             init_poll_fd(&ev->pfd[i]);
+     129             :     }
+     130             : 
+     131          49 :     ev->pfd[ev->nfds].fd = fd;
+     132          49 :     ev->pfd[ev->nfds].events = mask;
+     133          49 :     ev->nfds++;
+     134             : }
+     135             : 
+     136             : /** @brief Disable a file descriptor for watching
+     137             :  *
+     138             :  * The file descriptor is removed from the descriptor list, the list is
+     139             :  * compressed during the process.
+     140             :  *
+     141             :  * @param ev The event handler structure containing the list
+     142             :  * @param fd The file descriptor to be removed
+     143             :  */
+     144           7 : static void dlt_event_handler_disable_fd(DltEventHandler *ev, int fd)
+     145             : {
+     146             :     unsigned int i = 0;
+     147             :     unsigned int j = 0;
+     148           7 :     unsigned int nfds = ev->nfds;
+     149             : 
+     150          36 :     for (; i < nfds; i++, j++) {
+     151          29 :         if (ev->pfd[i].fd == fd) {
+     152             :             init_poll_fd(&ev->pfd[i]);
+     153           7 :             j++;
+     154           7 :             ev->nfds--;
+     155             :         }
+     156             : 
+     157          29 :         if (i == j)
+     158          22 :             continue;
+     159             : 
+     160             :         /* Compressing the table */
+     161           7 :         if (i < ev->nfds) {
+     162           0 :             ev->pfd[i].fd = ev->pfd[j].fd;
+     163           0 :             ev->pfd[i].events = ev->pfd[j].events;
+     164           0 :             ev->pfd[i].revents = ev->pfd[j].revents;
+     165             :         }
+     166             :         else {
+     167             :             init_poll_fd(&ev->pfd[i]);
+     168             :         }
+     169             :     }
+     170           7 : }
+     171             : 
+     172             : /** @brief Catch and process incoming events.
+     173             :  *
+     174             :  * This function waits for events on all connections. Once an event raise,
+     175             :  * the callback for the specific connection is called, or the connection is
+     176             :  * destroyed if a hangup occurs.
+     177             :  *
+     178             :  * @param daemon Structure to be passed to the callback.
+     179             :  * @param daemon_local Structure containing needed information.
+     180             :  * @param pEvent Event handler structure.
+     181             :  *
+     182             :  * @return 0 on success, -1 otherwise. May be interrupted.
+     183             :  */
+     184        1570 : int dlt_daemon_handle_event(DltEventHandler *pEvent,
+     185             :                             DltDaemon *daemon,
+     186             :                             DltDaemonLocal *daemon_local)
+     187             : {
+     188             :     int ret = 0;
+     189             :     unsigned int i = 0;
+     190             :     int (*callback)(DltDaemon *, DltDaemonLocal *, DltReceiver *, int) = NULL;
+     191             : 
+     192        1570 :     if ((pEvent == NULL) || (daemon == NULL) || (daemon_local == NULL))
+     193             :         return DLT_RETURN_ERROR;
+     194             : 
+     195        1569 :     ret = poll(pEvent->pfd, pEvent->nfds, DLT_EV_TIMEOUT_MSEC);
+     196             : 
+     197        1569 :     if (ret <= 0) {
+     198             :         /* We are not interested in EINTR has it comes
+     199             :          * either from timeout or signal.
+     200             :          */
+     201          10 :         if (errno == EINTR)
+     202             :             ret = 0;
+     203             : 
+     204           1 :         if (ret < 0)
+     205           0 :             dlt_vlog(LOG_CRIT, "poll() failed: %s\n", strerror(errno));
+     206             : 
+     207          10 :         return ret;
+     208             :     }
+     209             : 
+     210             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+     211             :     unsigned int start_time = dlt_uptime();
+     212             : #endif
+     213             : 
+     214        8044 :     for (i = 0; i < pEvent->nfds; i++) {
+     215             :         int fd = 0;
+     216             :         DltConnection *con = NULL;
+     217             :         DltConnectionType type = DLT_CONNECTION_TYPE_MAX;
+     218             : 
+     219        6485 :         if (pEvent->pfd[i].revents == 0)
+     220        4926 :             continue;
+     221             : 
+     222        1559 :         con = dlt_event_handler_find_connection(pEvent, pEvent->pfd[i].fd);
+     223             : 
+     224        1559 :         if (con && con->receiver) {
+     225        1559 :             type = con->type;
+     226        1559 :             fd = con->receiver->fd;
+     227             :         }
+     228             :         else { /* connection might have been destroyed in the meanwhile */
+     229           0 :             dlt_event_handler_disable_fd(pEvent, pEvent->pfd[i].fd);
+     230           0 :             continue;
+     231             :         }
+     232             : 
+     233             :         /* First of all handle error events */
+     234        1559 :         if (pEvent->pfd[i].revents & DLT_EV_MASK_REJECTED) {
+     235             :             /* An error occurred, we need to clean-up the concerned event
+     236             :              */
+     237           2 :             if (type == DLT_CONNECTION_CLIENT_MSG_TCP)
+     238             :                 /* To transition to BUFFER state if this is final TCP client connection,
+     239             :                  * call dedicated function. this function also calls
+     240             :                  * dlt_event_handler_unregister_connection() inside the function.
+     241             :                  */
+     242           2 :                 dlt_daemon_close_socket(fd, daemon, daemon_local, 0);
+     243             :             else
+     244           0 :                 dlt_event_handler_unregister_connection(pEvent,
+     245             :                                                         daemon_local,
+     246             :                                                         fd);
+     247             : 
+     248           2 :             continue;
+     249             :         }
+     250             : 
+     251             :         /* Get the function to be used to handle the event */
+     252        1557 :         callback = dlt_connection_get_callback(con);
+     253             : 
+     254        1557 :         if (!callback) {
+     255           0 :             dlt_vlog(LOG_CRIT, "Unable to find function for %u handle type.\n",
+     256             :                      type);
+     257             :             /* keep handling remaining events */
+     258           0 :             continue;
+     259             :         }
+     260             : 
+     261             :         /* From now on, callback is correct */
+     262        1557 :         if (callback(daemon,
+     263             :                      daemon_local,
+     264             :                      con->receiver,
+     265             :                      daemon_local->flags.vflag) == -1) {
+     266           0 :             dlt_vlog(LOG_CRIT, "Processing from %u handle type failed!\n",
+     267             :                      type);
+     268           0 :             return -1;
+     269             :         }
+     270             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+     271             :         dlt_daemon_trigger_systemd_watchdog_if_necessary(&start_time, daemon->watchdog_trigger_interval);
+     272             : #endif
+     273             :     }
+     274             : 
+     275             :     return 0;
+     276             : }
+     277             : 
+     278             : /** @brief Find connection with a specific \a fd in the connection list.
+     279             :  *
+     280             :  * There can be only one event per \a fd. We can then find a specific connection
+     281             :  * based on this \a fd. That allows to check if a specific \a fd has already been
+     282             :  * registered.
+     283             :  *
+     284             :  * @param ev The event handler structure where the list of connection is.
+     285             :  * @param fd The file descriptor of the connection to be found.
+     286             :  *
+     287             :  * @return The found connection pointer, NULL otherwise.
+     288             :  */
+     289        1122 : DltConnection *dlt_event_handler_find_connection(DltEventHandler *ev, int fd)
+     290             : {
+     291        2686 :     DltConnection *temp = ev->connections;
+     292             : 
+     293        5077 :     while (temp != NULL) {
+     294        5029 :         if ((temp->receiver != NULL) && (temp->receiver->fd == fd))
+     295        1074 :             return temp;
+     296        2391 :         temp = temp->next;
+     297             :     }
+     298             : 
+     299             :     return temp;
+     300             : }
+     301             : 
+     302             : /** @brief Remove a connection from the list and destroy it.
+     303             :  *
+     304             :  * This function will first look for the connection in the event handler list,
+     305             :  * remove it from the list and then destroy it.
+     306             :  *
+     307             :  * @param ev The event handler structure where the list of connection is.
+     308             :  * @param to_remove The connection to remove from the list.
+     309             :  *
+     310             :  * @return 0 on success, -1 if the connection is not found.
+     311             :  */
+     312          47 : DLT_STATIC int dlt_daemon_remove_connection(DltEventHandler *ev,
+     313             :                                             DltConnection *to_remove)
+     314             : {
+     315          47 :     if ((ev == NULL) || (to_remove == NULL))
+     316             :         return DLT_RETURN_ERROR;
+     317             : 
+     318          47 :     DltConnection *curr = ev->connections;
+     319             :     DltConnection *prev = curr;
+     320             : 
+     321             :     /* Find the address where to_remove value is registered */
+     322          70 :     while (curr && (curr != to_remove)) {
+     323             :         prev = curr;
+     324          23 :         curr = curr->next;
+     325             :     }
+     326             : 
+     327          47 :     if (!curr) {
+     328             :         /* Must not be possible as we check for existence before */
+     329           0 :         dlt_log(LOG_CRIT, "Connection not found for removal.\n");
+     330           0 :         return -1;
+     331             :     }
+     332          47 :     else if (curr == ev->connections)
+     333             :     {
+     334          41 :         ev->connections = curr->next;
+     335             :     }
+     336             :     else {
+     337           6 :         prev->next = curr->next;
+     338             :     }
+     339             : 
+     340             :     /* Now we can destroy our pointer */
+     341          47 :     dlt_connection_destroy(to_remove);
+     342             : 
+     343          47 :     return 0;
+     344             : }
+     345             : 
+     346             : /** @brief Destroy the connection list.
+     347             :  *
+     348             :  * This function runs through the connection list and destroy them one by one.
+     349             :  *
+     350             :  * @param ev Pointer to the event handler structure.
+     351             :  */
+     352          10 : void dlt_event_handler_cleanup_connections(DltEventHandler *ev)
+     353             : {
+     354             :     unsigned int i = 0;
+     355             : 
+     356          10 :     if (ev == NULL)
+     357             :         /* Nothing to do. */
+     358             :         return;
+     359             : 
+     360          50 :     while (ev->connections != NULL)
+     361             :         /* We don really care on failure */
+     362          40 :         (void)dlt_daemon_remove_connection(ev, ev->connections);
+     363             : 
+     364          49 :     for (i = 0; i < ev->nfds; i++)
+     365          39 :         init_poll_fd(&ev->pfd[i]);
+     366             : 
+     367          10 :     free(ev->pfd);
+     368             : }
+     369             : 
+     370             : /** @brief Add a new connection to the list.
+     371             :  *
+     372             :  * The connection is added at the tail of the list.
+     373             :  *
+     374             :  * @param ev The event handler structure where the connection list is.
+     375             :  * @param connection The connection to be added.
+     376             :  */
+     377           6 : DLT_STATIC void dlt_daemon_add_connection(DltEventHandler *ev,
+     378             :                                           DltConnection *connection)
+     379             : {
+     380             : 
+     381          50 :     DltConnection **temp = &ev->connections;
+     382             : 
+     383         143 :     while (*temp != NULL)
+     384          93 :         temp = &(*temp)->next;
+     385             : 
+     386          50 :     *temp = connection;
+     387           6 : }
+     388             : 
+     389             : /** @brief Check for connection activation
+     390             :  *
+     391             :  * If the connection is active and it's not allowed anymore or it the user
+     392             :  * ask for deactivation, the connection will be deactivated.
+     393             :  * If the connection is inactive, the user asks for activation and it's
+     394             :  * allowed for it to be activated, the connection will be activated.
+     395             :  *
+     396             :  * @param evhdl The event handler structure.
+     397             :  * @param con The connection to act on
+     398             :  * @param activation_type The type of activation requested ((DE)ACTIVATE)
+     399             :  *
+     400             :  * @return 0 on success, -1 otherwise
+     401             :  */
+     402          57 : int dlt_connection_check_activate(DltEventHandler *evhdl,
+     403             :                                   DltConnection *con,
+     404             :                                   int activation_type)
+     405             : {
+     406          57 :     if (!evhdl || !con || !con->receiver) {
+     407           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameters.\n", __func__);
+     408           1 :         return -1;
+     409             :     }
+     410             : 
+     411          56 :     switch (con->status) {
+     412           7 :     case ACTIVE:
+     413             : 
+     414           7 :         if (activation_type == DEACTIVATE) {
+     415           7 :             dlt_vlog(LOG_INFO, "Deactivate connection type: %u\n", con->type);
+     416             : 
+     417           7 :             dlt_event_handler_disable_fd(evhdl, con->receiver->fd);
+     418             : 
+     419           7 :             if (con->type == DLT_CONNECTION_CLIENT_CONNECT)
+     420           0 :                 con->receiver->fd = -1;
+     421             : 
+     422           7 :             con->status = INACTIVE;
+     423             :         }
+     424             : 
+     425             :         break;
+     426          49 :     case INACTIVE:
+     427             : 
+     428          49 :         if (activation_type == ACTIVATE) {
+     429          49 :             dlt_vlog(LOG_INFO, "Activate connection type: %u\n", con->type);
+     430             : 
+     431          49 :             dlt_event_handler_enable_fd(evhdl,
+     432          49 :                                         con->receiver->fd,
+     433             :                                         con->ev_mask);
+     434             : 
+     435          49 :             con->status = ACTIVE;
+     436             :         }
+     437             : 
+     438             :         break;
+     439           0 :     default:
+     440           0 :         dlt_vlog(LOG_ERR, "Unknown connection status: %u\n", con->status);
+     441           0 :         return -1;
+     442             :     }
+     443             : 
+     444             :     return 0;
+     445             : }
+     446             : 
+     447             : /** @brief Registers a connection for event handling and takes its ownership.
+     448             :  *
+     449             :  * As we add the connection to the list of connection, we take its ownership.
+     450             :  * That's the only place where the connection pointer is stored.
+     451             :  * The connection is then used to create a new event trigger.
+     452             :  * If the connection is of type DLT_CONNECTION_CLIENT_MSG_TCP, we increase
+     453             :  * the daemon_local->client_connections counter. TODO: Move this counter inside
+     454             :  * the event handler structure.
+     455             :  *
+     456             :  * @param evhdl The event handler structure where the connection list is.
+     457             :  * @param daemon_local Structure containing needed information.
+     458             :  * @param connection The connection to be registered.
+     459             :  * @param mask The bit mask of event to be registered.
+     460             :  *
+     461             :  * @return 0 on success, -1 otherwise.
+     462             :  */
+     463          49 : int dlt_event_handler_register_connection(DltEventHandler *evhdl,
+     464             :                                           DltDaemonLocal *daemon_local,
+     465             :                                           DltConnection *connection,
+     466             :                                           int mask)
+     467             : {
+     468          49 :     if (!evhdl || !connection || !connection->receiver) {
+     469           1 :         dlt_log(LOG_ERR, "Wrong parameters when registering connection.\n");
+     470           1 :         return -1;
+     471             :     }
+     472             : 
+     473           4 :     dlt_daemon_add_connection(evhdl, connection);
+     474             : 
+     475          48 :     if ((connection->type == DLT_CONNECTION_CLIENT_MSG_TCP) ||
+     476             :         (connection->type == DLT_CONNECTION_CLIENT_MSG_SERIAL))
+     477           4 :         daemon_local->client_connections++;
+     478             : 
+     479             :     /* On creation the connection is not active by default */
+     480          48 :     connection->status = INACTIVE;
+     481             : 
+     482          48 :     connection->next = NULL;
+     483          48 :     connection->ev_mask = mask;
+     484             : 
+     485          48 :     return dlt_connection_check_activate(evhdl,
+     486             :                                          connection,
+     487             :                                          ACTIVATE);
+     488             : }
+     489             : 
+     490             : /** @brief Unregisters a connection from the event handler and destroys it.
+     491             :  *
+     492             :  * We first look for the connection to be unregistered, delete the event
+     493             :  * corresponding and then destroy the connection.
+     494             :  * If the connection is of type DLT_CONNECTION_CLIENT_MSG_TCP, we decrease
+     495             :  * the daemon_local->client_connections counter. TODO: Move this counter inside
+     496             :  * the event handler structure.
+     497             :  *
+     498             :  * @param evhdl The event handler structure where the connection list is.
+     499             :  * @param daemon_local Structure containing needed information.
+     500             :  * @param fd The file descriptor of the connection to be unregistered.
+     501             :  *
+     502             :  * @return 0 on success, -1 otherwise.
+     503             :  */
+     504           7 : int dlt_event_handler_unregister_connection(DltEventHandler *evhdl,
+     505             :                                             DltDaemonLocal *daemon_local,
+     506             :                                             int fd)
+     507             : {
+     508           7 :     if ((evhdl == NULL) || (daemon_local == NULL))
+     509             :         return DLT_RETURN_ERROR;
+     510             : 
+     511             :     /* Look for the pointer in the client list.
+     512             :      * There shall be only one event handler with the same fd.
+     513             :      */
+     514           2 :     DltConnection *temp = dlt_event_handler_find_connection(evhdl, fd);
+     515             : 
+     516           7 :     if (!temp) {
+     517           1 :         dlt_log(LOG_ERR, "Connection not found for unregistration.\n");
+     518           1 :         return -1;
+     519             :     }
+     520             : 
+     521           6 :     if ((temp->type == DLT_CONNECTION_CLIENT_MSG_TCP) ||
+     522             :         (temp->type == DLT_CONNECTION_CLIENT_MSG_SERIAL)) {
+     523           3 :         daemon_local->client_connections--;
+     524             : 
+     525           3 :         if (daemon_local->client_connections < 0) {
+     526           0 :             daemon_local->client_connections = 0;
+     527           0 :             dlt_log(LOG_CRIT, "Unregistering more client than registered!\n");
+     528             :         }
+     529             :     }
+     530             : 
+     531           6 :     if (dlt_connection_check_activate(evhdl,
+     532             :                                       temp,
+     533             :                                       DEACTIVATE) < 0)
+     534           0 :         dlt_log(LOG_ERR, "Unable to unregister event.\n");
+     535             : 
+     536             :     /* Cannot fail as far as dlt_daemon_find_connection succeed */
+     537           6 :     return dlt_daemon_remove_connection(evhdl, temp);
+     538             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_offline_logstorage.c.func-sort-c.html b/dlt_lcov_report/daemon/dlt_daemon_offline_logstorage.c.func-sort-c.html new file mode 100644 index 000000000..b5289b0d1 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_offline_logstorage.c.func-sort-c.html @@ -0,0 +1,164 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_offline_logstorage.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_offline_logstorage.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:20533261.7 %
Date:2024-12-05 09:07:13Functions:192382.6 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_logstorage_force_reset_level0
dlt_daemon_logstorage_update_passive_node_context0
dlt_logstorage_split_ctid0
dlt_logstorage_split_ecuid0
dlt_daemon_logstorage_reset_log_level1
dlt_logstorage_split_apid1
dlt_logstorage_split_apid_ctid1
dlt_logstorage_split_ecuid_apid1
dlt_daemon_logstorage_reset_application_loglevel2
dlt_daemon_logstorage_send_log_level2
dlt_daemon_logstorage_sync_cache4
dlt_logstorage_update_all_contexts4
dlt_daemon_logstorage_get_device5
dlt_daemon_logstorage_cleanup8
dlt_daemon_logstorage_setup_internal_storage8
dlt_daemon_logstorage_set_logstorage_cache_size10
dlt_daemon_logstorage_update_application_loglevel10
dlt_logstorage_split_multi34
dlt_daemon_logstorage_get_loglevel35
dlt_logstorage_update_context_loglevel37
dlt_logstorage_update_context38
dlt_logstorage_split_key42
dlt_daemon_logstorage_write5841
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_offline_logstorage.c.func.html b/dlt_lcov_report/daemon/dlt_daemon_offline_logstorage.c.func.html new file mode 100644 index 000000000..b6d11bb80 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_offline_logstorage.c.func.html @@ -0,0 +1,164 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_offline_logstorage.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_offline_logstorage.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:20533261.7 %
Date:2024-12-05 09:07:13Functions:192382.6 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_logstorage_cleanup8
dlt_daemon_logstorage_force_reset_level0
dlt_daemon_logstorage_get_device5
dlt_daemon_logstorage_get_loglevel35
dlt_daemon_logstorage_reset_application_loglevel2
dlt_daemon_logstorage_reset_log_level1
dlt_daemon_logstorage_send_log_level2
dlt_daemon_logstorage_set_logstorage_cache_size10
dlt_daemon_logstorage_setup_internal_storage8
dlt_daemon_logstorage_sync_cache4
dlt_daemon_logstorage_update_application_loglevel10
dlt_daemon_logstorage_update_passive_node_context0
dlt_daemon_logstorage_write5841
dlt_logstorage_split_apid1
dlt_logstorage_split_apid_ctid1
dlt_logstorage_split_ctid0
dlt_logstorage_split_ecuid0
dlt_logstorage_split_ecuid_apid1
dlt_logstorage_split_key42
dlt_logstorage_split_multi34
dlt_logstorage_update_all_contexts4
dlt_logstorage_update_context38
dlt_logstorage_update_context_loglevel37
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_offline_logstorage.c.gcov.html b/dlt_lcov_report/daemon/dlt_daemon_offline_logstorage.c.gcov.html new file mode 100644 index 000000000..b7bcba894 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_offline_logstorage.c.gcov.html @@ -0,0 +1,1342 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_offline_logstorage.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_offline_logstorage.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:20533261.7 %
Date:2024-12-05 09:07:13Functions:192382.6 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /**
+       2             :  * Copyright (C) 2013 - 2018  Advanced Driver Information Technology.
+       3             :  * This code is developed by Advanced Driver Information Technology.
+       4             :  * Copyright of Advanced Driver Information Technology, Bosch and DENSO.
+       5             :  *
+       6             :  * DLT offline log storage functionality source file.
+       7             :  *
+       8             :  * \copyright
+       9             :  * This Source Code Form is subject to the terms of the
+      10             :  * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
+      11             :  * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+      12             :  *
+      13             :  *
+      14             :  * \author Syed Hameed <shameed@jp.adit-jv.com> ADIT 2013 - 2015
+      15             :  * \author Christoph Lipka <clipka@jp.adit-jv.com> ADIT 2015
+      16             :  *
+      17             :  * \file: dlt_daemon_offline_logstorage.c
+      18             :  * For further information see http://www.covesa.org/.
+      19             :  */
+      20             : 
+      21             : #include <stdio.h>
+      22             : #include <stdlib.h>
+      23             : #include <string.h>
+      24             : #include <syslog.h>
+      25             : 
+      26             : #include "dlt_daemon_offline_logstorage.h"
+      27             : #include "dlt_daemon_offline_logstorage_internal.h"
+      28             : #include "dlt_gateway_types.h"
+      29             : #include "dlt_gateway.h"
+      30             : 
+      31             : /**
+      32             :  * dlt_logstorage_split_ecuid
+      33             :  *
+      34             :  * Split keys with ECU ID alone
+      35             :  *
+      36             :  * @param key            Key
+      37             :  * @param len            Key length
+      38             :  * @param ecuid          ECU ID from key stored here
+      39             :  * @param apid           Application ID as .* stored here
+      40             :  * @param ctid           Context id as .* stored here
+      41             :  * @return               0 on success -1 on error
+      42             :  */
+      43           0 : DLT_STATIC DltReturnValue dlt_logstorage_split_ecuid(char *key,
+      44             :                                                      int len,
+      45             :                                                      char *ecuid,
+      46             :                                                      char *apid,
+      47             :                                                      char *ctid)
+      48             : {
+      49           0 :     if ((len > (DLT_ID_SIZE + 2)) || (len < 2))
+      50             :         return DLT_RETURN_ERROR;
+      51             : 
+      52           0 :     memcpy(ecuid, key, (len - 2));
+      53             :     memcpy(apid, ".*", 2);
+      54             :     memcpy(ctid, ".*", 2);
+      55             : 
+      56           0 :     return DLT_RETURN_OK;
+      57             : }
+      58             : 
+      59             : unsigned int g_logstorage_cache_max;
+      60             : /**
+      61             :  * dlt_logstorage_split_ctid
+      62             :  *
+      63             :  * Split keys with Context ID alone
+      64             :  *
+      65             :  * @param key            Key
+      66             :  * @param len            Key length
+      67             :  * @param apid           Application ID as .* stored here
+      68             :  * @param ctid           Context id from key stored here
+      69             :  * @return               0 on success -1 on error
+      70             :  */
+      71           0 : DLT_STATIC DltReturnValue dlt_logstorage_split_ctid(char *key,
+      72             :                                                     int len,
+      73             :                                                     char *apid,
+      74             :                                                     char *ctid)
+      75             : {
+      76           0 :     if ((len > (DLT_ID_SIZE + 2)) || (len < 1))
+      77             :         return DLT_RETURN_ERROR;
+      78             : 
+      79           0 :     strncpy(ctid, (key + 2), (len - 1));
+      80             :     memcpy(apid, ".*", 2);
+      81             : 
+      82           0 :     return DLT_RETURN_OK;
+      83             : }
+      84             : 
+      85             : /**
+      86             :  * dlt_logstorage_split_apid
+      87             :  *
+      88             :  * Split keys with Application ID alone
+      89             :  *
+      90             :  * @param key            Key
+      91             :  * @param len            Key length
+      92             :  * @param apid           Application ID from key is stored here
+      93             :  * @param ctid           Context id as .* stored here
+      94             :  * @return               0 on success -1 on error
+      95             :  */
+      96           1 : DLT_STATIC DltReturnValue dlt_logstorage_split_apid(char *key,
+      97             :                                                     int len,
+      98             :                                                     char *apid,
+      99             :                                                     char *ctid)
+     100             : {
+     101           1 :     if ((len > (DLT_ID_SIZE + 2)) || (len < 2))
+     102             :         return DLT_RETURN_ERROR;
+     103             : 
+     104           1 :     strncpy(apid, key + 1, (len - 2));
+     105             :     memcpy(ctid, ".*", 2);
+     106             : 
+     107           1 :     return DLT_RETURN_OK;
+     108             : }
+     109             : 
+     110             : /**
+     111             :  * dlt_logstorage_split_apid_ctid
+     112             :  *
+     113             :  * Split keys with Application ID and Context ID
+     114             :  *
+     115             :  * @param key            Key
+     116             :  * @param len            Key length
+     117             :  * @param apid           Application ID from key is stored here
+     118             :  * @param ctid           CContext id from key is stored here
+     119             :  * @return               0 on success -1 on error
+     120             :  */
+     121           1 : DLT_STATIC DltReturnValue dlt_logstorage_split_apid_ctid(char *key,
+     122             :                                                          int len,
+     123             :                                                          char *apid,
+     124             :                                                          char *ctid)
+     125             : {
+     126             :     char *tok = NULL;
+     127             : 
+     128           1 :     if (len > DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN)
+     129             :         return DLT_RETURN_ERROR;
+     130             : 
+     131             :     /* copy apid and ctid */
+     132           1 :     tok = strtok(key, ":");
+     133             : 
+     134           1 :     if (tok != NULL)
+     135             :         strncpy(apid, tok, DLT_ID_SIZE);
+     136             :     else
+     137             :         return DLT_RETURN_ERROR;
+     138             : 
+     139           1 :     tok = strtok(NULL, ":");
+     140             : 
+     141           1 :     if (tok != NULL)
+     142             :         strncpy(ctid, tok, DLT_ID_SIZE);
+     143             :     else
+     144             :         return DLT_RETURN_ERROR;
+     145             : 
+     146           1 :     return DLT_RETURN_OK;
+     147             : }
+     148             : 
+     149             : /**
+     150             :  * dlt_logstorage_split_ecuid_apid
+     151             :  *
+     152             :  * Split keys with ECU ID and Application ID
+     153             :  *
+     154             :  * @param key            Key
+     155             :  * @param len            Key length
+     156             :  * @param ecuid          ECU ID from key stored here
+     157             :  * @param apid           Application ID from key is stored here
+     158             :  * @param ctid           Context id as .* stored here
+     159             :  * @return               0 on success -1 on error
+     160             :  */
+     161           1 : DLT_STATIC DltReturnValue dlt_logstorage_split_ecuid_apid(char *key,
+     162             :                                                           int len,
+     163             :                                                           char *ecuid,
+     164             :                                                           char *apid,
+     165             :                                                           char *ctid)
+     166             : {
+     167             :     char *tok = NULL;
+     168             : 
+     169           1 :     if (len > DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN)
+     170             :         return DLT_RETURN_ERROR;
+     171             : 
+     172             :     /* copy apid and ctid */
+     173           1 :     tok = strtok(key, ":");
+     174             : 
+     175           1 :     if (tok != NULL)
+     176             :         strncpy(ecuid, tok, DLT_ID_SIZE);
+     177             :     else
+     178             :         return DLT_RETURN_ERROR;
+     179             : 
+     180           1 :     tok = strtok(NULL, ":");
+     181             : 
+     182           1 :     if (tok != NULL)
+     183             :         strncpy(apid, tok, DLT_ID_SIZE);
+     184             :     else
+     185             :         return DLT_RETURN_ERROR;
+     186             : 
+     187             :     memcpy(ctid, ".*", 2);
+     188             : 
+     189           1 :     return DLT_RETURN_OK;
+     190             : }
+     191             : 
+     192             : /**
+     193             :  * dlt_logstorage_split_multi
+     194             :  *
+     195             :  * Prepares keys with application ID alone, will use ecuid if provided
+     196             :  * (ecuid\:apid\:\:) or (\:apid\:\:)
+     197             :  *
+     198             :  * @param key            Prepared key stored here
+     199             :  * @param len            Key length
+     200             :  * @param ecuid          ECU ID
+     201             :  * @param apid           Application ID
+     202             :  * @param ctid           Context ID
+     203             :  * @return               None
+     204             :  */
+     205          34 : DLT_STATIC DltReturnValue dlt_logstorage_split_multi(char *key,
+     206             :                                                      int len,
+     207             :                                                      char *ecuid,
+     208             :                                                      char *apid,
+     209             :                                                      char *ctid)
+     210             : {
+     211             :     char *tok = NULL;
+     212             : 
+     213          34 :     if (len > DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN)
+     214             :         return DLT_RETURN_ERROR;
+     215             : 
+     216          34 :     tok = strtok(key, ":");
+     217             : 
+     218          34 :     if (tok == NULL)
+     219             :         return DLT_RETURN_ERROR;
+     220             : 
+     221          34 :     len = strlen(tok);
+     222             : 
+     223          34 :     if (key[len + 1] == ':') {
+     224             :         strncpy(ecuid, tok, DLT_ID_SIZE);
+     225             : 
+     226           0 :         tok = strtok(NULL, ":");
+     227             : 
+     228           0 :         if (tok != NULL)
+     229             :             strncpy(ctid, tok, DLT_ID_SIZE);
+     230             : 
+     231             :         memcpy(apid, ".*", 2);
+     232             :     }
+     233             :     else {
+     234             :         strncpy(ecuid, tok, DLT_ID_SIZE);
+     235          34 :         tok = strtok(NULL, ":");
+     236             : 
+     237          34 :         if (tok != NULL)
+     238             :             strncpy(apid, tok, DLT_ID_SIZE);
+     239             : 
+     240          34 :         tok = strtok(NULL, ":");
+     241             : 
+     242          34 :         if (tok != NULL)
+     243             :             strncpy(ctid, tok, DLT_ID_SIZE);
+     244             :     }
+     245             : 
+     246             :     return DLT_RETURN_OK;
+     247             : }
+     248             : 
+     249             : /**
+     250             :  * dlt_logstorage_split_key
+     251             :  *
+     252             :  * Split a given key into apid and ctid.
+     253             :  * If APID\: - apid = APID and ctid = .*
+     254             :  * If \:CTID - ctid = CTID and apid = .*
+     255             :  * Else apid = APID and ctid = CTID
+     256             :  *
+     257             :  * @param key      Given key of filter hash map
+     258             :  * @param apid     Application id
+     259             :  * @param ctid     Context id
+     260             :  * @param ecuid    ECU id
+     261             :  * @return         0 on success, -1 on error
+     262             :  */
+     263          42 : DLT_STATIC DltReturnValue dlt_logstorage_split_key(char *key, char *apid,
+     264             :                                                    char *ctid, char *ecuid)
+     265             : {
+     266             :     int len = 0;
+     267             :     char *sep = NULL;
+     268             : 
+     269          42 :     if ((key == NULL) || (apid == NULL) || (ctid == NULL) || (ecuid == NULL))
+     270             :         return DLT_RETURN_WRONG_PARAMETER;
+     271             : 
+     272          37 :     len = strlen(key);
+     273             : 
+     274          37 :     sep = strchr (key, ':');
+     275             : 
+     276          37 :     if (sep == NULL)
+     277             :         return DLT_RETURN_WRONG_PARAMETER;
+     278             : 
+     279             :     /* key is ecuid only ecuid::*/
+     280          37 :     if ((key[len - 1] == ':') && (key[len - 2] == ':'))
+     281           0 :         return dlt_logstorage_split_ecuid(key, len, ecuid, apid, ctid);
+     282             :     /* key is context id only  ::apid*/
+     283          37 :     else if ((key[0] == ':') && (key[1] == ':'))
+     284           0 :         return dlt_logstorage_split_ctid(key, len, apid, ctid);
+     285             :     /* key is application id only :apid: */
+     286          37 :     else if ((key[0] == ':') && (key[len - 1] == ':'))
+     287           1 :         return dlt_logstorage_split_apid(key, len, apid, ctid);
+     288             :     /* key is :apid:ctid */
+     289          36 :     else if ((key[0] == ':') && (key[len - 1] != ':'))
+     290           1 :         return dlt_logstorage_split_apid_ctid(key, len, apid, ctid);
+     291             :     /* key is ecuid:apid: */
+     292          35 :     else if ((key[0] != ':') && (key[len - 1] == ':'))
+     293           1 :         return dlt_logstorage_split_ecuid_apid(key, len, ecuid, apid, ctid);
+     294             :     /* key is either ecuid::ctid or ecuid:apid:ctid */
+     295             :     else
+     296          34 :         return dlt_logstorage_split_multi(key, len, ecuid, apid, ctid);
+     297             : }
+     298             : 
+     299             : /**
+     300             :  * Forward SET_LOG_LEVEL request to passive node
+     301             :  *
+     302             :  * @param daemon_local  pointer to DltDaemonLocal structure
+     303             :  * @param apid          Application ID
+     304             :  * @param ctid          Context ID
+     305             :  * @param ecuid         ECU ID
+     306             :  * @param loglevel      requested log level
+     307             :  * @param verbose       verbosity flag
+     308             :  */
+     309           0 : DLT_STATIC DltReturnValue dlt_daemon_logstorage_update_passive_node_context(
+     310             :     DltDaemonLocal *daemon_local,
+     311             :     char *apid,
+     312             :     char *ctid,
+     313             :     char *ecuid,
+     314             :     int loglevel,
+     315             :     int verbose)
+     316             : {
+     317           0 :     DltServiceSetLogLevel req = { 0 };
+     318           0 :     DltPassiveControlMessage ctrl = { 0 };
+     319             :     DltGatewayConnection *con = NULL;
+     320             : 
+     321           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+     322             : 
+     323           0 :     if ((daemon_local == NULL) || (apid == NULL) || (ctid == NULL) || (ecuid == NULL) ||
+     324           0 :         (loglevel > DLT_LOG_VERBOSE) || (loglevel < DLT_LOG_DEFAULT)) {
+     325           0 :         dlt_vlog(LOG_ERR, "%s: Wrong parameter\n", __func__);
+     326           0 :         return DLT_RETURN_WRONG_PARAMETER;
+     327             :     }
+     328             : 
+     329           0 :     con = dlt_gateway_get_connection(&daemon_local->pGateway, ecuid, verbose);
+     330             : 
+     331           0 :     if (con == NULL) {
+     332           0 :         dlt_vlog(LOG_ERR,
+     333             :                  "Failed to fond connection to passive node %s\n",
+     334             :                  ecuid);
+     335           0 :         return DLT_RETURN_ERROR;
+     336             :     }
+     337             : 
+     338           0 :     ctrl.id = DLT_SERVICE_ID_SET_LOG_LEVEL;
+     339           0 :     ctrl.type = CONTROL_MESSAGE_ON_DEMAND;
+     340             : 
+     341           0 :     dlt_set_id(req.apid, apid);
+     342           0 :     dlt_set_id(req.ctid, ctid);
+     343             : 
+     344           0 :     req.log_level = loglevel;
+     345             : 
+     346           0 :     if (dlt_gateway_send_control_message(con, &ctrl, (void *)&req, verbose) != 0) {
+     347           0 :         dlt_vlog(LOG_ERR,
+     348             :                  "Failed to forward SET_LOG_LEVEL message to passive node %s\n",
+     349             :                  ecuid);
+     350             : 
+     351           0 :         return DLT_RETURN_ERROR;
+     352             :     }
+     353             : 
+     354             :     return DLT_RETURN_OK;
+     355             : }
+     356             : 
+     357             : /**
+     358             :  * dlt_daemon_logstorage_send_log_level
+     359             :  *
+     360             :  * Send new log level for the provided context, if ecuid is not daemon ecuid
+     361             :  * update log level of passive node
+     362             :  *
+     363             :  * @param daemon            DltDaemon structure
+     364             :  * @param daemon_local      DltDaemonLocal structure
+     365             :  * @param context           DltDaemonContext structure
+     366             :  * @param ecuid             ECU id
+     367             :  * @param loglevel          log level to be set to context
+     368             :  * @param verbose           If set to true verbose information is printed out
+     369             :  * @return                  0 on success, -1 on error
+     370             :  */
+     371           2 : DLT_STATIC DltReturnValue dlt_daemon_logstorage_send_log_level(DltDaemon *daemon,
+     372             :                                                                DltDaemonLocal *daemon_local,
+     373             :                                                                DltDaemonContext *context,
+     374             :                                                                char *ecuid,
+     375             :                                                                int loglevel,
+     376             :                                                                int verbose)
+     377             : {
+     378             :     int old_log_level = -1;
+     379             :     int ll = DLT_LOG_DEFAULT;
+     380             : 
+     381           2 :     if ((daemon == NULL) || (daemon_local == NULL) || (ecuid == NULL) ||
+     382           2 :         (context == NULL) || (loglevel > DLT_LOG_VERBOSE) || (loglevel < DLT_LOG_DEFAULT)) {
+     383           0 :         dlt_vlog(LOG_ERR, "%s: Wrong parameter\n", __func__);
+     384           0 :         return DLT_RETURN_WRONG_PARAMETER;
+     385             :     }
+     386             : 
+     387           2 :     if (strncmp(ecuid, daemon->ecuid, DLT_ID_SIZE) == 0) {
+     388           2 :         old_log_level = context->storage_log_level;
+     389             : 
+     390           2 :         context->storage_log_level = DLT_OFFLINE_LOGSTORAGE_MAX(loglevel,
+     391             :                                                                 context->storage_log_level);
+     392             : 
+     393           2 :         if (context->storage_log_level > old_log_level) {
+     394           2 :             if (dlt_daemon_user_send_log_level(daemon, context, verbose) == -1) {
+     395           0 :                 dlt_log(LOG_ERR, "Unable to update log level\n");
+     396           0 :                 return DLT_RETURN_ERROR;
+     397             :             }
+     398             :         }
+     399             :     }
+     400             :     else {
+     401             : 
+     402           0 :         old_log_level = context->log_level;
+     403             : 
+     404           0 :         ll = DLT_OFFLINE_LOGSTORAGE_MAX(loglevel, context->log_level);
+     405             : 
+     406           0 :         if (ll > old_log_level)
+     407           0 :             return dlt_daemon_logstorage_update_passive_node_context(daemon_local,
+     408           0 :                                                                      context->apid,
+     409           0 :                                                                      context->ctid,
+     410             :                                                                      ecuid,
+     411             :                                                                      ll,
+     412             :                                                                      verbose);
+     413             :     }
+     414             : 
+     415             :     return DLT_RETURN_OK;
+     416             : }
+     417             : 
+     418             : /**
+     419             :  * dlt_daemon_logstorage_reset_log_level
+     420             :  *
+     421             :  * The log levels are reset if log level provided is -1 (not sent to
+     422             :  * application in this case). Reset and sent to application if current log level
+     423             :  * provided is 0.
+     424             :  *
+     425             :  * @param daemon            DltDaemon structure
+     426             :  * @param daemon_local      DltDaemonLocal structure
+     427             :  * @param context           DltDaemonContext structure
+     428             :  * @param ecuid             ECU ID
+     429             :  * @param loglevel          log level to be set to context
+     430             :  * @param verbose           If set to true verbose information is printed out
+     431             :  * @return                  0 on success, -1 on error
+     432             :  */
+     433           1 : DLT_STATIC DltReturnValue dlt_daemon_logstorage_reset_log_level(DltDaemon *daemon,
+     434             :                                                                 DltDaemonLocal *daemon_local,
+     435             :                                                                 DltDaemonContext *context,
+     436             :                                                                 char *ecuid,
+     437             :                                                                 int loglevel,
+     438             :                                                                 int verbose)
+     439             : {
+     440           1 :     if ((daemon == NULL) || (daemon_local == NULL) || (ecuid == NULL) ||
+     441           1 :         (context == NULL) || (loglevel > DLT_LOG_VERBOSE) || (loglevel < DLT_LOG_DEFAULT)) {
+     442           0 :         dlt_vlog(LOG_ERR, "%s: Wrong parameter\n", __func__);
+     443           0 :         return DLT_RETURN_WRONG_PARAMETER;
+     444             :     }
+     445             : 
+     446             :     /* Set storage level to -1, to clear log levels */
+     447           1 :     context->storage_log_level = DLT_LOG_DEFAULT;
+     448             : 
+     449           1 :     if (loglevel == DLT_DAEMON_LOGSTORAGE_RESET_SEND_LOGLEVEL) {
+     450           1 :         if (strncmp(ecuid, daemon->ecuid, DLT_ID_SIZE) == 0) {
+     451           1 :             if (dlt_daemon_user_send_log_level(daemon,
+     452             :                                                context,
+     453             :                                                verbose) == DLT_RETURN_ERROR) {
+     454           0 :                 dlt_log(LOG_ERR, "Unable to update log level\n");
+     455           0 :                 return DLT_RETURN_ERROR;
+     456             :             }
+     457             :         }
+     458             :         else { /* forward set log level to passive node */
+     459           0 :             return dlt_daemon_logstorage_update_passive_node_context(daemon_local,
+     460           0 :                                                                      context->apid,
+     461           0 :                                                                      context->ctid,
+     462             :                                                                      ecuid,
+     463             :                                                                      DLT_LOG_DEFAULT,
+     464             :                                                                      verbose);
+     465             :         }
+     466             :     }
+     467             : 
+     468             :     return DLT_RETURN_OK;
+     469             : }
+     470             : 
+     471             : /**
+     472             :  * dlt_daemon_logstorage_force_reset_level
+     473             :  *
+     474             :  * Force resetting of log level since have no data provided by passive node.
+     475             :  *
+     476             :  * @param daemon            DltDaemon structure
+     477             :  * @param daemon_local      DltDaemonLocal structure
+     478             :  * @param apid              Application ID
+     479             :  * @param ctid              Context ID
+     480             :  * @param ecuid             ECU ID
+     481             :  * @param loglevel          log level to be set to context
+     482             :  * @param verbose           If set to true verbose information is printed out
+     483             :  * @return                  0 on success, -1 on error
+     484             :  */
+     485           0 : DLT_STATIC DltReturnValue dlt_daemon_logstorage_force_reset_level(DltDaemon *daemon,
+     486             :                                                                   DltDaemonLocal *daemon_local,
+     487             :                                                                   char *apid,
+     488             :                                                                   char *ctid,
+     489             :                                                                   char *ecuid,
+     490             :                                                                   int loglevel,
+     491             :                                                                   int verbose)
+     492             : {
+     493             :     int ll = DLT_LOG_DEFAULT;
+     494             :     int num = 0;
+     495             :     int i = 0;
+     496           0 :     DltLogStorageFilterConfig *config[DLT_CONFIG_FILE_SECTIONS_MAX] = { 0 };
+     497             : 
+     498           0 :     if ((daemon == NULL) || (daemon_local == NULL) || (ecuid == NULL) ||
+     499           0 :         (apid == NULL) || (ctid == NULL) || (loglevel > DLT_LOG_VERBOSE) || (loglevel < DLT_LOG_DEFAULT)) {
+     500           0 :         dlt_vlog(LOG_ERR, "%s: Wrong parameter\n", __func__);
+     501           0 :         return DLT_RETURN_WRONG_PARAMETER;
+     502             :     }
+     503             : 
+     504           0 :     for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++) {
+     505           0 :         num = dlt_logstorage_get_config(&(daemon->storage_handle[i]), config, apid, ctid, ecuid);
+     506             : 
+     507           0 :         if (num > 0)
+     508             :             break; /* found config */
+     509             :     }
+     510             : 
+     511           0 :     if ((num == 0) || (config[0] == NULL)) {
+     512           0 :         dlt_vlog(LOG_ERR,
+     513             :                  "%s: No information about APID: %s, CTID: %s, ECU: %s in Logstorage configuration\n",
+     514             :                  __func__, apid, ctid, ecuid);
+     515           0 :         return DLT_RETURN_ERROR;
+     516             :     }
+     517             : 
+     518           0 :     if (loglevel == DLT_DAEMON_LOGSTORAGE_RESET_SEND_LOGLEVEL)
+     519           0 :         ll = config[0]->reset_log_level;
+     520             :     else
+     521           0 :         ll = config[0]->log_level;
+     522             : 
+     523           0 :     return dlt_daemon_logstorage_update_passive_node_context(daemon_local, apid,
+     524             :                                                              ctid, ecuid, ll, verbose);
+     525             : 
+     526             : }
+     527             : 
+     528             : /**
+     529             :  * dlt_logstorage_update_all_contexts
+     530             :  *
+     531             :  * Update log level of all contexts of the application by updating the daemon
+     532             :  * internal table. The compare flags (cmp_flag) indicates if Id has to be
+     533             :  * compared with application id or Context id of the daemon internal table.
+     534             :  * The log levels are reset if current log level provided is -1 (not sent to
+     535             :  * application in this case). Reset and sent to application if current log level
+     536             :  * provided is 0.
+     537             :  *
+     538             :  * @param daemon            DltDaemon structure
+     539             :  * @param daemon_local      DltDaemonLocal structure
+     540             :  * @param id                application id or context id
+     541             :  * @param curr_log_level    log level to be set to context
+     542             :  * @param cmp_flag          compare flag
+     543             :  * @param ecuid             ecu id where application runs
+     544             :  * @param verbose           If set to true verbose information is printed out
+     545             :  * @return                  0 on success, -1 on error
+     546             :  */
+     547           4 : DltReturnValue dlt_logstorage_update_all_contexts(DltDaemon *daemon,
+     548             :                                                   DltDaemonLocal *daemon_local,
+     549             :                                                   char *id,
+     550             :                                                   int curr_log_level,
+     551             :                                                   int cmp_flag,
+     552             :                                                   char *ecuid,
+     553             :                                                   int verbose)
+     554             : {
+     555             :     DltDaemonRegisteredUsers *user_list = NULL;
+     556             :     int i = 0;
+     557           4 :     char tmp_id[DLT_ID_SIZE + 1] = { '\0' };
+     558             : 
+     559           4 :     if ((daemon == NULL) || (daemon_local == NULL) || (id == NULL) ||
+     560           3 :         (ecuid == NULL) || (cmp_flag <= DLT_DAEMON_LOGSTORAGE_CMP_MIN) ||
+     561             :         (cmp_flag >= DLT_DAEMON_LOGSTORAGE_CMP_MAX)) {
+     562           1 :         dlt_vlog(LOG_ERR, "Wrong parameter in function %s\n", __func__);
+     563           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     564             :     }
+     565             : 
+     566           3 :     user_list = dlt_daemon_find_users_list(daemon, ecuid, verbose);
+     567             : 
+     568           3 :     if (user_list == NULL)
+     569             :         return DLT_RETURN_ERROR;
+     570             : 
+     571           3 :     for (i = 0; i < user_list->num_contexts; i++) {
+     572           0 :         if (cmp_flag == DLT_DAEMON_LOGSTORAGE_CMP_APID)
+     573           0 :             dlt_set_id(tmp_id, user_list->contexts[i].apid);
+     574           0 :         else if (cmp_flag == DLT_DAEMON_LOGSTORAGE_CMP_CTID)
+     575           0 :             dlt_set_id(tmp_id, user_list->contexts[i].ctid);
+     576             :         else
+     577             :             /* this is for the case when both apid and ctid are wildcard */
+     578           0 :             dlt_set_id(tmp_id, ".*");
+     579             : 
+     580           0 :         if (strncmp(id, tmp_id, DLT_ID_SIZE) == 0) {
+     581           0 :             if (curr_log_level > 0)
+     582           0 :                 dlt_daemon_logstorage_send_log_level(daemon,
+     583             :                                                      daemon_local,
+     584           0 :                                                      &user_list->contexts[i],
+     585             :                                                      ecuid,
+     586             :                                                      curr_log_level,
+     587             :                                                      verbose);
+     588             :             else /* The request is to reset log levels */
+     589           0 :                 dlt_daemon_logstorage_reset_log_level(daemon,
+     590             :                                                       daemon_local,
+     591           0 :                                                       &user_list->contexts[i],
+     592             :                                                       ecuid,
+     593             :                                                       curr_log_level,
+     594             :                                                       verbose);
+     595             :         }
+     596             :     }
+     597             : 
+     598             :     return DLT_RETURN_OK;
+     599             : }
+     600             : 
+     601             : /**
+     602             :  * dlt_logstorage_update_context
+     603             :  *
+     604             :  * Update log level of a context by updating the daemon internal table
+     605             :  * The log levels are reset if current log level provided is -1 (not sent to
+     606             :  * application in this case)
+     607             :  * Reset and sent to application if current log level provided is 0
+     608             :  *
+     609             :  * @param daemon            DltDaemon structure
+     610             :  * @param daemon_local      DltDaemonLocal structure
+     611             :  * @param apid              application id
+     612             :  * @param ctid              context id
+     613             :  * @param ecuid             ecu id
+     614             :  * @param curr_log_level    log level to be set to context
+     615             :  * @param verbose           If set to true verbose information is printed out
+     616             :  * @return                  0 on success, -1 on error
+     617             :  */
+     618          38 : DltReturnValue dlt_logstorage_update_context(DltDaemon *daemon,
+     619             :                                              DltDaemonLocal *daemon_local,
+     620             :                                              char *apid,
+     621             :                                              char *ctid,
+     622             :                                              char *ecuid,
+     623             :                                              int curr_log_level,
+     624             :                                              int verbose)
+     625             : {
+     626             :     DltDaemonContext *context = NULL;
+     627             : 
+     628          38 :     if ((daemon == NULL) || (daemon_local == NULL) || (apid == NULL)
+     629          37 :         || (ctid == NULL) || (ecuid == NULL)) {
+     630           1 :         dlt_vlog(LOG_ERR, "Wrong parameter in function %s\n", __func__);
+     631           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     632             :     }
+     633             : 
+     634          37 :     context = dlt_daemon_context_find(daemon, apid, ctid, ecuid, verbose);
+     635             : 
+     636          37 :     if (context != NULL) {
+     637           3 :         if (curr_log_level > 0)
+     638           2 :             return dlt_daemon_logstorage_send_log_level(daemon,
+     639             :                                                         daemon_local,
+     640             :                                                         context,
+     641             :                                                         ecuid,
+     642             :                                                         curr_log_level,
+     643             :                                                         verbose);
+     644             :         else /* The request is to reset log levels */
+     645           1 :             return dlt_daemon_logstorage_reset_log_level(daemon,
+     646             :                                                          daemon_local,
+     647             :                                                          context,
+     648             :                                                          ecuid,
+     649             :                                                          curr_log_level,
+     650             :                                                          verbose);
+     651             :     }
+     652             :     else {
+     653          34 :         if (strncmp(ecuid, daemon->ecuid, DLT_ID_SIZE) != 0) {
+     654             :             /* we intentionally have no data provided by passive node. */
+     655             :             /* We blindly send the log level or reset log level */
+     656           0 :             return dlt_daemon_logstorage_force_reset_level(daemon,
+     657             :                                                            daemon_local,
+     658             :                                                            apid,
+     659             :                                                            ctid,
+     660             :                                                            ecuid,
+     661             :                                                            curr_log_level,
+     662             :                                                            verbose);
+     663             :         }
+     664             :         else {
+     665          34 :             dlt_vlog(LOG_WARNING,
+     666             :                      "%s: No information about APID: %s, CTID: %s, ECU: %s\n",
+     667             :                      __func__,
+     668             :                      apid,
+     669             :                      ctid,
+     670             :                      ecuid);
+     671          34 :             return DLT_RETURN_ERROR;
+     672             : 
+     673             :         }
+     674             :     }
+     675             : 
+     676             :     return DLT_RETURN_OK;
+     677             : }
+     678             : 
+     679             : /**
+     680             :  * dlt_logstorage_update_context_loglevel
+     681             :  *
+     682             :  * Update all contexts or particular context depending provided key
+     683             :  *
+     684             :  * @param daemon            Pointer to DLT Daemon structure
+     685             :  * @param daemon_local      Pointer to DLT Daemon Local structure
+     686             :  * @param key               Filter key stored in Hash Map
+     687             :  * @param curr_log_level    log level to be set to context
+     688             :  * @param verbose           If set to true verbose information is printed out
+     689             :  * @return                  0 on success, -1 on error
+     690             :  */
+     691          37 : DltReturnValue dlt_logstorage_update_context_loglevel(DltDaemon *daemon,
+     692             :                                                       DltDaemonLocal *daemon_local,
+     693             :                                                       char *key,
+     694             :                                                       int curr_log_level,
+     695             :                                                       int verbose)
+     696             : {
+     697             :     int cmp_flag = 0;
+     698          37 :     char apid[DLT_ID_SIZE + 1] = { '\0' };
+     699          37 :     char ctid[DLT_ID_SIZE + 1] = { '\0' };
+     700          37 :     char ecuid[DLT_ID_SIZE + 1] = { '\0' };
+     701             : 
+     702          37 :     PRINT_FUNCTION_VERBOSE(verbose);
+     703             : 
+     704          37 :     if ((daemon == NULL) || (daemon_local == NULL) || (key == NULL))
+     705             :         return DLT_RETURN_WRONG_PARAMETER;
+     706             : 
+     707          36 :     if (dlt_logstorage_split_key(key, apid, ctid, ecuid) != 0) {
+     708           0 :         dlt_log(LOG_ERR,
+     709             :                 "Error while updating application log levels (split key)\n");
+     710           0 :         return DLT_RETURN_ERROR;
+     711             :     }
+     712             : 
+     713          36 :     if (ecuid[0] == '\0') /* ECU id was not specified in filter configuration */
+     714           2 :         dlt_set_id(ecuid, daemon->ecuid);
+     715             : 
+     716             :     /* check wildcard for both apid and ctid first of all */
+     717          36 :     if (strcmp(ctid, ".*") == 0 && strcmp(apid, ".*") == 0) {
+     718             :         cmp_flag = DLT_DAEMON_LOGSTORAGE_CMP_ECID;
+     719             : 
+     720           0 :         if (dlt_logstorage_update_all_contexts(daemon,
+     721             :                                                daemon_local,
+     722             :                                                apid,
+     723             :                                                curr_log_level,
+     724             :                                                cmp_flag,
+     725             :                                                ecuid,
+     726             :                                                verbose) != 0)
+     727           0 :             return DLT_RETURN_ERROR;
+     728             :     }
+     729          36 :     else if (strcmp(ctid, ".*") == 0) {
+     730             :         cmp_flag = DLT_DAEMON_LOGSTORAGE_CMP_APID;
+     731             : 
+     732           1 :         if (dlt_logstorage_update_all_contexts(daemon,
+     733             :                                                daemon_local,
+     734             :                                                apid,
+     735             :                                                curr_log_level,
+     736             :                                                cmp_flag,
+     737             :                                                ecuid,
+     738             :                                                verbose) != 0)
+     739           0 :             return DLT_RETURN_ERROR;
+     740             :     }
+     741             :     /* wildcard for application id, find all contexts with context id */
+     742          35 :     else if (strcmp(apid, ".*") == 0)
+     743             :     {
+     744             :         cmp_flag = DLT_DAEMON_LOGSTORAGE_CMP_CTID;
+     745             : 
+     746           0 :         if (dlt_logstorage_update_all_contexts(daemon,
+     747             :                                                daemon_local,
+     748             :                                                ctid,
+     749             :                                                curr_log_level,
+     750             :                                                cmp_flag,
+     751             :                                                ecuid,
+     752             :                                                verbose) != 0)
+     753           0 :             return DLT_RETURN_ERROR;
+     754             :     }
+     755             :     /* In case of given application id, context id pair, call available context
+     756             :      * find function */
+     757          35 :     else if (dlt_logstorage_update_context(daemon,
+     758             :                                            daemon_local,
+     759             :                                            apid,
+     760             :                                            ctid,
+     761             :                                            ecuid,
+     762             :                                            curr_log_level,
+     763             :                                            verbose) != 0)
+     764             :     {
+     765          34 :         return DLT_RETURN_ERROR;
+     766             :     }
+     767             : 
+     768             :     return DLT_RETURN_OK;
+     769             : }
+     770             : 
+     771             : /**
+     772             :  * dlt_daemon_logstorage_reset_application_loglevel
+     773             :  *
+     774             :  * Reset storage log level of all running applications
+     775             :  * 2 steps for resetting
+     776             :  * 1. Setup storage_loglevel of all contexts configured for the requested device
+     777             :  *    to -1
+     778             :  * 2. Re-run update log level for all other configured devices
+     779             :  *
+     780             :  * @param daemon        Pointer to DLT Daemon structure
+     781             :  * @param daemon_local  Pointer to DLT Daemon local structure
+     782             :  * @param dev_num       Number of attached DLT Logstorage device
+     783             :  * @param max_device    Maximum storage devices setup by the daemon
+     784             :  * @param verbose       If set to true verbose information is printed out
+     785             :  */
+     786           2 : void dlt_daemon_logstorage_reset_application_loglevel(DltDaemon *daemon,
+     787             :                                                       DltDaemonLocal *daemon_local,
+     788             :                                                       int dev_num,
+     789             :                                                       int max_device,
+     790             :                                                       int verbose)
+     791             : {
+     792             :     DltLogStorage *handle = NULL;
+     793             :     DltLogStorageFilterList **tmp = NULL;
+     794             :     int i = 0;
+     795           2 :     char key[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = { '\0' };
+     796             :     unsigned int status;
+     797             :     int log_level = 0;
+     798             : 
+     799           2 :     PRINT_FUNCTION_VERBOSE(verbose);
+     800             : 
+     801           2 :     if ((daemon == NULL) || (daemon_local == NULL) ||
+     802           1 :         (daemon->storage_handle == NULL) || (dev_num < 0)) {
+     803           2 :         dlt_vlog(LOG_ERR,
+     804             :                  "Invalid function parameters used for %s\n",
+     805             :                  __func__);
+     806           2 :         return;
+     807             :     }
+     808             : 
+     809           0 :     handle = &(daemon->storage_handle[dev_num]);
+     810             : 
+     811           0 :     if ((handle->connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) ||
+     812           0 :         (handle->config_status != DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE))
+     813             :         return;
+     814             : 
+     815             :     /* for all filters (keys) check if application context are already running
+     816             :      * and log level need to be reset*/
+     817           0 :     tmp = &(handle->config_list);
+     818           0 :     while (*(tmp) != NULL)
+     819             :     {
+     820           0 :         for (i = 0; i < (*tmp)->num_keys; i++)
+     821             :         {
+     822             :             memset(key, 0, sizeof(key));
+     823             : 
+     824           0 :             strncpy(key, ((*tmp)->key_list
+     825           0 :                           + (i * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN)),
+     826             :                     DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN);
+     827             : 
+     828             :             /* dlt-daemon wants to reset loglevel if
+     829             :              * a logstorage device is disconnected.
+     830             :              */
+     831             :             log_level = DLT_DAEMON_LOGSTORAGE_RESET_LOGLEVEL;
+     832             : 
+     833           0 :             dlt_logstorage_update_context_loglevel(
+     834             :                     daemon,
+     835             :                     daemon_local,
+     836             :                     key,
+     837             :                     log_level,
+     838             :                     verbose);
+     839             :         }
+     840           0 :         tmp = &(*tmp)->next;
+     841             :     }
+     842             : 
+     843             :     /* Re-run update log level for all other configured devices */
+     844           0 :     for (i = 0; i < max_device; i++) {
+     845           0 :         status = daemon->storage_handle[i].config_status;
+     846             : 
+     847           0 :         if (i == dev_num)
+     848           0 :             continue;
+     849             : 
+     850           0 :         if (status == DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE)
+     851           0 :             dlt_daemon_logstorage_update_application_loglevel(daemon,
+     852             :                                                               daemon_local,
+     853             :                                                               i,
+     854             :                                                               verbose);
+     855             :     }
+     856             : 
+     857             :     return;
+     858             : }
+     859             : 
+     860             : /**
+     861             :  * dlt_daemon_logstorage_update_application_loglevel
+     862             :  *
+     863             :  * Update log level of all running applications with new filter configuration
+     864             :  * available due to newly attached DltLogstorage device. The log level is only
+     865             :  * updated when the current application log level is less than the log level
+     866             :  * obtained from the storage configuration file
+     867             :  *
+     868             :  * @param daemon        Pointer to DLT Daemon structure
+     869             :  * @param daemon_local  Pointer to DLT Daemon local structure
+     870             :  * @param dev_num       Number of attached DLT Logstorage device
+     871             :  * @param verbose       If set to true verbose information is printed out
+     872             :  */
+     873          10 : void dlt_daemon_logstorage_update_application_loglevel(DltDaemon *daemon,
+     874             :                                                        DltDaemonLocal *daemon_local,
+     875             :                                                        int dev_num,
+     876             :                                                        int verbose)
+     877             : {
+     878             :     DltLogStorage *handle = NULL;
+     879             :     DltLogStorageFilterList **tmp = NULL;
+     880          10 :     char key[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = { '\0' };
+     881             :     int i = 0;
+     882             :     int log_level = 0;
+     883             : 
+     884          10 :     PRINT_FUNCTION_VERBOSE(verbose);
+     885             : 
+     886          10 :     if ((daemon == NULL) || (daemon_local == NULL) || (dev_num < 0))
+     887             :     {
+     888           1 :         dlt_vlog(LOG_ERR,
+     889             :                  "Invalid function parameters used for %s\n",
+     890             :                  __func__);
+     891           1 :         return;
+     892             :     }
+     893             : 
+     894           9 :     handle = &(daemon->storage_handle[dev_num]);
+     895             : 
+     896           9 :     if ((handle->connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) ||
+     897           9 :         (handle->config_status != DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE))
+     898             :         return;
+     899             : 
+     900             :     /* for all filters (keys) check if application or context already running
+     901             :      * and log level need to be updated*/
+     902           9 :     tmp = &(handle->config_list);
+     903          44 :     while (*(tmp) != NULL)
+     904             :     {
+     905          70 :         for (i = 0; i < (*tmp)->num_keys; i++)
+     906             :         {
+     907             :             memset(key, 0, sizeof(key));
+     908             : 
+     909          35 :             strncpy(key, ((*tmp)->key_list
+     910          35 :                     + (i * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN)),
+     911             :                     DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN);
+     912             : 
+     913             :             /* Obtain storage configuration data */
+     914          35 :             log_level = dlt_logstorage_get_loglevel_by_key(handle, key);
+     915          35 :             if (log_level < 0)
+     916             :             {
+     917           0 :                 dlt_log(LOG_ERR, "Failed to get log level by key \n");
+     918           0 :                 return;
+     919             :             }
+     920             : 
+     921             :             /* Update context log level with storage configuration log level */
+     922          35 :             dlt_logstorage_update_context_loglevel(daemon,
+     923             :                                                 daemon_local,
+     924             :                                                 key,
+     925             :                                                 log_level,
+     926             :                                                 verbose);
+     927             :         }
+     928          35 :         tmp = &(*tmp)->next;
+     929             :     }
+     930             : 
+     931             :     return;
+     932             : }
+     933             : 
+     934             : /**
+     935             :  * dlt_daemon_logstorage_get_loglevel
+     936             :  *
+     937             :  * Obtain log level as a union of all configured storage devices and filters for
+     938             :  * the provided application id and context id
+     939             :  *
+     940             :  * @param daemon        Pointer to DLT Daemon structure
+     941             :  * @param max_device    Maximum storage devices setup by the daemon
+     942             :  * @param apid          Application ID
+     943             :  * @param ctid          Context ID
+     944             :  * @return              Log level on success, -1 on error
+     945             :  */
+     946          35 : int dlt_daemon_logstorage_get_loglevel(DltDaemon *daemon,
+     947             :                                        int max_device,
+     948             :                                        char *apid,
+     949             :                                        char *ctid)
+     950             : {
+     951          35 :     DltLogStorageFilterConfig *config[DLT_CONFIG_FILE_SECTIONS_MAX] = { 0 };
+     952             :     int i = 0;
+     953             :     int j = 0;
+     954             :     int8_t storage_loglevel = -1;
+     955             :     int8_t configured_loglevel = -1;
+     956             :     int num_config = 0;
+     957             : 
+     958          35 :     if ((daemon == NULL) || (max_device == 0) || (apid == NULL) || (ctid == NULL))
+     959             :         return DLT_RETURN_WRONG_PARAMETER;
+     960             : 
+     961          68 :     for (i = 0; i < max_device; i++)
+     962          34 :         if (daemon->storage_handle[i].config_status ==
+     963             :             DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE) {
+     964          34 :             num_config = dlt_logstorage_get_config(&(daemon->storage_handle[i]),
+     965             :                                                    config,
+     966             :                                                    apid,
+     967             :                                                    ctid,
+     968          34 :                                                    daemon->ecuid);
+     969             : 
+     970          34 :             if (num_config == 0) {
+     971           1 :                 dlt_log(LOG_DEBUG, "No valid filter configuration found\n");
+     972           1 :                 continue;
+     973             :             }
+     974             : 
+     975          66 :             for (j = 0; j < num_config; j++)
+     976             :             {
+     977          33 :                 if (config[j] == NULL)
+     978           0 :                     continue;
+     979             : 
+     980             :                 /* If logstorage configuration do not contain file name,
+     981             :                  * then it is non verbose control filter, so return level as in this filter */
+     982          33 :                 if (config[j]->file_name == NULL) {
+     983           0 :                     storage_loglevel = config[j]->log_level;
+     984           0 :                     break;
+     985             :                 }
+     986             : 
+     987          33 :                 configured_loglevel = config[j]->log_level;
+     988          33 :                 storage_loglevel = DLT_OFFLINE_LOGSTORAGE_MAX(
+     989             :                     configured_loglevel,
+     990             :                     storage_loglevel);
+     991             :             }
+     992             :         }
+     993             : 
+     994          34 :     return storage_loglevel;
+     995             : }
+     996             : 
+     997             : /**
+     998             :  * dlt_daemon_logstorage_write
+     999             :  *
+    1000             :  * Write log message to all attached storage device. If the called
+    1001             :  * dlt_logstorage_write function is not able to write to the device, DltDaemon
+    1002             :  * will disconnect this device.
+    1003             :  *
+    1004             :  * @param daemon        Pointer to Dlt Daemon structure
+    1005             :  * @param user_config   DltDaemon configuration
+    1006             :  * @param data1         message header buffer
+    1007             :  * @param size1         message header buffer size
+    1008             :  * @param data2         message extended header buffer
+    1009             :  * @param size2         message extended header size
+    1010             :  * @param data3         message data buffer
+    1011             :  * @param size3         message data size
+    1012             :  * @return              0 on success, -1 on error, 1 on disable network routing
+    1013             :  */
+    1014        5841 : int dlt_daemon_logstorage_write(DltDaemon *daemon,
+    1015             :                                  DltDaemonFlags *user_config,
+    1016             :                                  unsigned char *data1,
+    1017             :                                  int size1,
+    1018             :                                  unsigned char *data2,
+    1019             :                                  int size2,
+    1020             :                                  unsigned char *data3,
+    1021             :                                  int size3)
+    1022             : {
+    1023             :     int i = 0;
+    1024             :     int ret = 0;
+    1025             :     DltLogStorageUserConfig file_config;
+    1026             : 
+    1027        5841 :     if ((daemon == NULL) || (user_config == NULL) ||
+    1028        5840 :         (user_config->offlineLogstorageMaxDevices <= 0) || (data1 == NULL) ||
+    1029        5840 :         (data2 == NULL) || (data3 == NULL)) {
+    1030           1 :         dlt_vlog(LOG_DEBUG,
+    1031             :                  "%s: message type is not LOG. Skip storing.\n",
+    1032             :                  __func__);
+    1033           1 :         return -1;
+    1034             :         /* Log Level changed callback */
+    1035             :     }
+    1036             : 
+    1037             :     /* Copy user configuration */
+    1038        5840 :     file_config.logfile_timestamp = user_config->offlineLogstorageTimestamp;
+    1039        5840 :     file_config.logfile_delimiter = user_config->offlineLogstorageDelimiter;
+    1040        5840 :     file_config.logfile_maxcounter = user_config->offlineLogstorageMaxCounter;
+    1041        5840 :     file_config.logfile_optional_counter = user_config->offlineLogstorageOptionalCounter;
+    1042        5840 :     file_config.logfile_counteridxlen =
+    1043        5840 :         user_config->offlineLogstorageMaxCounterIdx;
+    1044             : 
+    1045       11680 :     for (i = 0; i < user_config->offlineLogstorageMaxDevices; i++) {
+    1046        5840 :         if (daemon->storage_handle[i].config_status ==
+    1047             :             DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE) {
+    1048        5840 :             int disable_nw = 0;
+    1049        5840 :             if ((ret = dlt_logstorage_write(&(daemon->storage_handle[i]),
+    1050             :                                      &file_config,
+    1051             :                                      data1,
+    1052             :                                      size1,
+    1053             :                                      data2,
+    1054             :                                      size2,
+    1055             :                                      data3,
+    1056             :                                      size3,
+    1057             :                                      &disable_nw)) < 0) {
+    1058           0 :                 dlt_log(LOG_ERR,
+    1059             :                         "dlt_daemon_logstorage_write: failed. "
+    1060             :                         "Disable storage device\n");
+    1061             :                 /* DLT_OFFLINE_LOGSTORAGE_MAX_ERRORS happened,
+    1062             :                  * therefore remove logstorage device */
+    1063           0 :                 dlt_logstorage_device_disconnected(
+    1064           0 :                     &(daemon->storage_handle[i]),
+    1065             :                     DLT_LOGSTORAGE_SYNC_ON_DEVICE_DISCONNECT);
+    1066             :             }
+    1067        5840 :             if (i == 0) {
+    1068        5840 :                 if (disable_nw == 1) {
+    1069             :                     ret = 1;
+    1070             :                 }
+    1071             :             } else {
+    1072           0 :                 dlt_vlog(LOG_WARNING,
+    1073             :                          "%s: DisableNetwork is not supported for more than one device yet\n",
+    1074             :                          __func__);
+    1075             :             }
+    1076             :         }
+    1077             :     }
+    1078             : 
+    1079             :     return ret;
+    1080             : }
+    1081             : 
+    1082             : /**
+    1083             :  * dlt_daemon_logstorage_setup_internal_storage
+    1084             :  *
+    1085             :  * Setup user defined path as offline log storage device
+    1086             :  *
+    1087             :  * @param daemon        Pointer to Dlt Daemon structure
+    1088             :  * @param daemon_local  Pointer to Dlt Daemon local structure
+    1089             :  * @param path          User configured internal storage path
+    1090             :  * @param verbose       If set to true verbose information is printed out
+    1091             :  * @return 0 on sucess, -1 otherwise
+    1092             :  */
+    1093           8 : int dlt_daemon_logstorage_setup_internal_storage(DltDaemon *daemon,
+    1094             :                                                  DltDaemonLocal *daemon_local,
+    1095             :                                                  char *path,
+    1096             :                                                  int verbose)
+    1097             : {
+    1098             :     int ret = 0;
+    1099             : 
+    1100           8 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1101             : 
+    1102           8 :     if ((path == NULL) || (daemon == NULL))
+    1103             :         return DLT_RETURN_WRONG_PARAMETER;
+    1104             : 
+    1105             :     /* connect internal storage device */
+    1106             :     /* Device index always used as 0 as it is setup on DLT daemon startup */
+    1107           7 :     ret = dlt_logstorage_device_connected(&(daemon->storage_handle[0]), path);
+    1108             : 
+    1109           7 :     if (ret != 0) {
+    1110           0 :         dlt_vlog(LOG_ERR, "%s: Device connect failed\n", __func__);
+    1111           0 :         return DLT_RETURN_ERROR;
+    1112             :     }
+    1113             : 
+    1114             :     /* check if log level of running application need an update */
+    1115           7 :     dlt_daemon_logstorage_update_application_loglevel(daemon,
+    1116             :                                                       daemon_local,
+    1117             :                                                       0,
+    1118             :                                                       verbose);
+    1119             : 
+    1120           7 :     if (daemon->storage_handle[0].maintain_logstorage_loglevel !=
+    1121             :             DLT_MAINTAIN_LOGSTORAGE_LOGLEVEL_UNDEF) {
+    1122           0 :         daemon->maintain_logstorage_loglevel =
+    1123             :                 daemon->storage_handle[0].maintain_logstorage_loglevel;
+    1124             : 
+    1125           0 :         dlt_vlog(LOG_DEBUG, "[%s] Startup with maintain loglevel: [%d]\n",
+    1126             :                         __func__,
+    1127             :                         daemon->storage_handle[0].maintain_logstorage_loglevel);
+    1128             :     }
+    1129             : 
+    1130             :     return ret;
+    1131             : }
+    1132             : 
+    1133          10 : void dlt_daemon_logstorage_set_logstorage_cache_size(unsigned int size)
+    1134             : {
+    1135             :     /* store given [KB] size in [Bytes] */
+    1136          10 :     g_logstorage_cache_max = size * 1024;
+    1137          10 : }
+    1138             : 
+    1139           8 : int dlt_daemon_logstorage_cleanup(DltDaemon *daemon,
+    1140             :                                   DltDaemonLocal *daemon_local,
+    1141             :                                   int verbose)
+    1142             : {
+    1143             :     int i = 0;
+    1144             : 
+    1145           8 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1146             : 
+    1147           8 :     if ((daemon == NULL) || (daemon_local == NULL) || (daemon->storage_handle == NULL))
+    1148             :         return DLT_RETURN_WRONG_PARAMETER;
+    1149             : 
+    1150          14 :     for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++)
+    1151             :         /* call disconnect on all currently connected devices */
+    1152           7 :         if (daemon->storage_handle[i].connection_type ==
+    1153             :             DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED)
+    1154             :         {
+    1155           6 :             (&daemon->storage_handle[i])->uconfig.logfile_counteridxlen =
+    1156           6 :                                         daemon_local->flags.offlineLogstorageMaxCounterIdx;
+    1157           6 :             (&daemon->storage_handle[i])->uconfig.logfile_delimiter =
+    1158           6 :                                         daemon_local->flags.offlineLogstorageDelimiter;
+    1159           6 :             (&daemon->storage_handle[i])->uconfig.logfile_maxcounter =
+    1160           6 :                                         daemon_local->flags.offlineLogstorageMaxCounter;
+    1161           6 :             (&daemon->storage_handle[i])->uconfig.logfile_timestamp =
+    1162           6 :                                         daemon_local->flags.offlineLogstorageTimestamp;
+    1163           6 :             (&daemon->storage_handle[i])->uconfig.logfile_optional_counter =
+    1164           6 :                                         daemon_local->flags.offlineLogstorageOptionalCounter;
+    1165             : 
+    1166           6 :             dlt_logstorage_device_disconnected(
+    1167             :                 &daemon->storage_handle[i],
+    1168             :                 DLT_LOGSTORAGE_SYNC_ON_DAEMON_EXIT);
+    1169             :         }
+    1170             : 
+    1171             :     return 0;
+    1172             : }
+    1173             : 
+    1174           4 : int dlt_daemon_logstorage_sync_cache(DltDaemon *daemon,
+    1175             :                                      DltDaemonLocal *daemon_local,
+    1176             :                                      char *mnt_point,
+    1177             :                                      int verbose)
+    1178             : {
+    1179             :     int i = 0;
+    1180             :     DltLogStorage *handle = NULL;
+    1181             : 
+    1182           4 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1183             : 
+    1184           4 :     if ((daemon == NULL) || (daemon_local == NULL) || (mnt_point == NULL))
+    1185             :         return DLT_RETURN_WRONG_PARAMETER;
+    1186             : 
+    1187           3 :     if (strlen(mnt_point) > 0) { /* mount point is given */
+    1188           3 :         handle = dlt_daemon_logstorage_get_device(daemon,
+    1189             :                                                   daemon_local,
+    1190             :                                                   mnt_point,
+    1191             :                                                   verbose);
+    1192             : 
+    1193           3 :         if (handle == NULL) {
+    1194             :             return DLT_RETURN_ERROR;
+    1195             :         }
+    1196             :         else {
+    1197           3 :             handle->uconfig.logfile_counteridxlen =
+    1198           3 :                 daemon_local->flags.offlineLogstorageMaxCounterIdx;
+    1199           3 :             handle->uconfig.logfile_delimiter =
+    1200           3 :                 daemon_local->flags.offlineLogstorageDelimiter;
+    1201           3 :             handle->uconfig.logfile_maxcounter =
+    1202           3 :                 daemon_local->flags.offlineLogstorageMaxCounter;
+    1203           3 :             handle->uconfig.logfile_timestamp =
+    1204           3 :                 daemon_local->flags.offlineLogstorageTimestamp;
+    1205           3 :             handle->uconfig.logfile_optional_counter =
+    1206           3 :                 daemon_local->flags.offlineLogstorageOptionalCounter;
+    1207             : 
+    1208           3 :             if (dlt_logstorage_sync_caches(handle) != 0)
+    1209           0 :                 return DLT_RETURN_ERROR;
+    1210             :         }
+    1211             :     }
+    1212             :     else { /* sync caches for all connected logstorage devices */
+    1213             : 
+    1214           0 :         for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++)
+    1215           0 :             if (daemon->storage_handle[i].connection_type ==
+    1216             :                 DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) {
+    1217           0 :                 daemon->storage_handle[i].uconfig.logfile_counteridxlen =
+    1218           0 :                     daemon_local->flags.offlineLogstorageMaxCounterIdx;
+    1219           0 :                 daemon->storage_handle[i].uconfig.logfile_delimiter =
+    1220           0 :                     daemon_local->flags.offlineLogstorageDelimiter;
+    1221           0 :                 daemon->storage_handle[i].uconfig.logfile_maxcounter =
+    1222           0 :                     daemon_local->flags.offlineLogstorageMaxCounter;
+    1223           0 :                 daemon->storage_handle[i].uconfig.logfile_timestamp =
+    1224           0 :                     daemon_local->flags.offlineLogstorageTimestamp;
+    1225           0 :                 daemon->storage_handle[i].uconfig.logfile_optional_counter =
+    1226           0 :                     daemon_local->flags.offlineLogstorageOptionalCounter;
+    1227             : 
+    1228           0 :                 if (dlt_logstorage_sync_caches(&daemon->storage_handle[i]) != 0)
+    1229             :                     return DLT_RETURN_ERROR;
+    1230             :             }
+    1231             :     }
+    1232             : 
+    1233             :     return 0;
+    1234             : }
+    1235             : 
+    1236           5 : DltLogStorage *dlt_daemon_logstorage_get_device(DltDaemon *daemon,
+    1237             :                                                 DltDaemonLocal *daemon_local,
+    1238             :                                                 char *mnt_point,
+    1239             :                                                 int verbose)
+    1240             : {
+    1241             :     int i = 0;
+    1242             :     int len = 0;
+    1243             :     int len1 = 0;
+    1244             :     int len2 = 0;
+    1245             : 
+    1246           5 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1247             : 
+    1248           5 :     if ((daemon == NULL) || (daemon_local == NULL) || (mnt_point == NULL))
+    1249             :         return NULL;
+    1250             : 
+    1251           4 :     len1 = strlen(mnt_point);
+    1252             : 
+    1253           4 :     for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++) {
+    1254           4 :         len2 = strlen(daemon->storage_handle[i].device_mount_point);
+    1255             : 
+    1256             :         /* Check if the requested device path is already used as log storage
+    1257             :          * device. Check for strlen first, to avoid comparison errors when
+    1258             :          * final '/' is given or not */
+    1259           4 :         len = len1 > len2 ? len2 : len1;
+    1260             : 
+    1261           4 :         if (strncmp(daemon->storage_handle[i].device_mount_point, mnt_point, len) == 0)
+    1262           4 :             return &daemon->storage_handle[i];
+    1263             :     }
+    1264             : 
+    1265             :     return NULL;
+    1266             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_serial.c.func-sort-c.html b/dlt_lcov_report/daemon/dlt_daemon_serial.c.func-sort-c.html new file mode 100644 index 000000000..9dbdb72a2 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_serial.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_serial.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_serial.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:080.0 %
Date:2024-12-05 09:07:13Functions:010.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_serial_send0
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_serial.c.func.html b/dlt_lcov_report/daemon/dlt_daemon_serial.c.func.html new file mode 100644 index 000000000..18870d52d --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_serial.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_serial.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_serial.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:080.0 %
Date:2024-12-05 09:07:13Functions:010.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_serial_send0
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_serial.c.gcov.html b/dlt_lcov_report/daemon/dlt_daemon_serial.c.gcov.html new file mode 100644 index 000000000..4175ce8b4 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_serial.c.gcov.html @@ -0,0 +1,174 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_serial.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_serial.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:080.0 %
Date:2024-12-05 09:07:13Functions:010.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2011-2015, BMW AG
+       5             :  *
+       6             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       7             :  *
+       8             :  * This Source Code Form is subject to the terms of the
+       9             :  * Mozilla Public License (MPL), v. 2.0.
+      10             :  * If a copy of the MPL was not distributed with this file,
+      11             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      12             :  *
+      13             :  * For further information see http://www.covesa.org/.
+      14             :  */
+      15             : 
+      16             : /*!
+      17             :  * \author Alexander Wenzel <alexander.aw.wenzel@bmw.de>
+      18             :  *
+      19             :  * \copyright Copyright © 2011-2015 BMW AG. \n
+      20             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      21             :  *
+      22             :  * \file dlt_daemon_serial.c
+      23             :  */
+      24             : 
+      25             : /*******************************************************************************
+      26             : **                                                                            **
+      27             : **  SRC-MODULE: dlt_daemon_serial.c                                           **
+      28             : **                                                                            **
+      29             : **  TARGET    : linux                                                         **
+      30             : **                                                                            **
+      31             : **  PROJECT   : DLT                                                           **
+      32             : **                                                                            **
+      33             : **  AUTHOR    : Alexander Wenzel Alexander.AW.Wenzel@bmw.de                   **
+      34             : **                                                                            **
+      35             : **  PURPOSE   :                                                               **
+      36             : **                                                                            **
+      37             : **  REMARKS   :                                                               **
+      38             : **                                                                            **
+      39             : **  PLATFORM DEPENDANT [yes/no]: yes                                          **
+      40             : **                                                                            **
+      41             : **  TO BE CHANGED BY USER [yes/no]: no                                        **
+      42             : **                                                                            **
+      43             : *******************************************************************************/
+      44             : 
+      45             : /*******************************************************************************
+      46             : **                      Author Identity                                       **
+      47             : ********************************************************************************
+      48             : **                                                                            **
+      49             : ** Initials     Name                       Company                            **
+      50             : ** --------     -------------------------  ---------------------------------- **
+      51             : **  aw          Alexander Wenzel           BMW                                **
+      52             : *******************************************************************************/
+      53             : 
+      54             : #include <stdio.h>
+      55             : #include <stdlib.h>
+      56             : #include <string.h>
+      57             : #include <syslog.h>
+      58             : #include <errno.h>
+      59             : #include <unistd.h>
+      60             : 
+      61             : #include <sys/socket.h> /* send() */
+      62             : 
+      63             : #include "dlt-daemon.h"
+      64             : 
+      65             : #include "dlt_types.h"
+      66             : 
+      67             : #include "dlt_daemon_serial.h"
+      68             : 
+      69           0 : int dlt_daemon_serial_send(int sock,
+      70             :                            void *data1,
+      71             :                            int size1,
+      72             :                            void *data2,
+      73             :                            int size2,
+      74             :                            char serialheader)
+      75             : {
+      76             :     /* Optional: Send serial header, if requested */
+      77           0 :     if (serialheader) {
+      78           0 :         if (0 > write(sock, dltSerialHeader, sizeof(dltSerialHeader))) {
+      79             :             return DLT_DAEMON_ERROR_SEND_FAILED;
+      80             :         }
+      81             :     }
+      82             : 
+      83             :     /* Send data */
+      84             : 
+      85           0 :     if (data1 && (size1 > 0)) {
+      86           0 :         if (0 > write(sock, data1, size1)) {
+      87             :             return DLT_DAEMON_ERROR_SEND_FAILED;
+      88             :         }
+      89             :     }
+      90             : 
+      91           0 :     if (data2 && (size2 > 0)) {
+      92           0 :         if (0 > write(sock, data2, size2)) {
+      93           0 :             return DLT_DAEMON_ERROR_SEND_FAILED;
+      94             :         }
+      95             :     }
+      96             : 
+      97             :     return DLT_DAEMON_ERROR_OK;
+      98             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_socket.c.func-sort-c.html b/dlt_lcov_report/daemon/dlt_daemon_socket.c.func-sort-c.html new file mode 100644 index 000000000..386db5ac5 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_socket.c.func-sort-c.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_socket.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_socket.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:315952.5 %
Date:2024-12-05 09:07:13Functions:4580.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_socket_close0
dlt_daemon_socket_get_send_qeue_max_size9
dlt_daemon_socket_open9
dlt_daemon_socket_send16
dlt_daemon_socket_sendreliable466
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_socket.c.func.html b/dlt_lcov_report/daemon/dlt_daemon_socket.c.func.html new file mode 100644 index 000000000..52198b78d --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_socket.c.func.html @@ -0,0 +1,92 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_socket.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_socket.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:315952.5 %
Date:2024-12-05 09:07:13Functions:4580.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_socket_close0
dlt_daemon_socket_get_send_qeue_max_size9
dlt_daemon_socket_open9
dlt_daemon_socket_send16
dlt_daemon_socket_sendreliable466
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_socket.c.gcov.html b/dlt_lcov_report/daemon/dlt_daemon_socket.c.gcov.html new file mode 100644 index 000000000..ce6416d8b --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_socket.c.gcov.html @@ -0,0 +1,323 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_socket.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_socket.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:315952.5 %
Date:2024-12-05 09:07:13Functions:4580.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2011-2015, BMW AG
+       5             :  *
+       6             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       7             :  *
+       8             :  * This Source Code Form is subject to the terms of the
+       9             :  * Mozilla Public License (MPL), v. 2.0.
+      10             :  * If a copy of the MPL was not distributed with this file,
+      11             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      12             :  *
+      13             :  * For further information see http://www.covesa.org/.
+      14             :  */
+      15             : 
+      16             : /*!
+      17             :  * \author
+      18             :  * Alexander Wenzel <alexander.aw.wenzel@bmw.de>
+      19             :  * Markus Klein <Markus.Klein@esk.fraunhofer.de>
+      20             :  * Mikko Rapeli <mikko.rapeli@bmw.de>
+      21             :  *
+      22             :  * \copyright Copyright © 2011-2015 BMW AG. \n
+      23             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      24             :  *
+      25             :  * \file dlt_daemon_socket.c
+      26             :  */
+      27             : 
+      28             : 
+      29             : #include <netdb.h>
+      30             : #include <ctype.h>
+      31             : #include <stdio.h>      /* for printf() and fprintf() */
+      32             : #include <sys/socket.h> /* for socket(), connect(), (), and recv() */
+      33             : #include <arpa/inet.h>  /* for sockaddr_in and inet_addr() */
+      34             : #include <stdlib.h>     /* for atoi() and exit() */
+      35             : #include <string.h>     /* for memset() */
+      36             : #include <unistd.h>     /* for close() */
+      37             : #include <signal.h>
+      38             : #include <syslog.h>
+      39             : #include <errno.h>
+      40             : #include <pthread.h>
+      41             : #include <sys/ioctl.h>
+      42             : 
+      43             : #ifdef linux
+      44             : #include <sys/timerfd.h>
+      45             : #endif
+      46             : #include <sys/time.h>
+      47             : #if defined(linux) && defined(__NR_statx)
+      48             : #include <linux/stat.h>
+      49             : #endif
+      50             : 
+      51             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+      52             : #include <systemd/sd-daemon.h>
+      53             : #endif
+      54             : 
+      55             : #include "dlt_types.h"
+      56             : #include "dlt_log.h"
+      57             : #include "dlt-daemon.h"
+      58             : #include "dlt-daemon_cfg.h"
+      59             : #include "dlt_daemon_common_cfg.h"
+      60             : 
+      61             : #include "dlt_daemon_socket.h"
+      62             : 
+      63           9 : int dlt_daemon_socket_open(int *sock, unsigned int servPort, char *ip)
+      64             : {
+      65           9 :     int yes = 1;
+      66             :     int ret_inet_pton = 1;
+      67             :     int lastErrno = 0;
+      68             : 
+      69             : #ifdef DLT_USE_IPv6
+      70             : 
+      71             :     /* create socket */
+      72           9 :     if ((*sock = socket(AF_INET6, SOCK_STREAM, 0)) == -1) {
+      73           0 :         lastErrno = errno;
+      74           0 :         dlt_vlog(LOG_ERR, "dlt_daemon_socket_open: socket() error %d: %s\n", lastErrno,
+      75             :                  strerror(lastErrno));
+      76           0 :         return -1;
+      77             :     }
+      78             : 
+      79             : #else
+      80             : 
+      81             :     if ((*sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
+      82             :         lastErrno = errno;
+      83             :         dlt_vlog(LOG_ERR, "dlt_daemon_socket_open: socket() error %d: %s\n", lastErrno,
+      84             :                  strerror(lastErrno));
+      85             :         return -1;
+      86             :     }
+      87             : 
+      88             : #endif
+      89             : 
+      90           9 :     dlt_vlog(LOG_INFO, "%s: Socket created\n", __FUNCTION__);
+      91             : 
+      92             :     /* setsockpt SO_REUSEADDR */
+      93           9 :     if (setsockopt(*sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) {
+      94           0 :         lastErrno = errno;
+      95           0 :         dlt_vlog(
+      96             :             LOG_ERR,
+      97             :             "dlt_daemon_socket_open: Setsockopt error %d in dlt_daemon_local_connection_init: %s\n",
+      98             :             lastErrno,
+      99             :             strerror(lastErrno));
+     100           0 :         return -1;
+     101             :     }
+     102             : 
+     103             :     /* bind */
+     104             : #ifdef DLT_USE_IPv6
+     105             :     struct sockaddr_in6 forced_addr;
+     106             :     memset(&forced_addr, 0, sizeof(forced_addr));
+     107           9 :     forced_addr.sin6_family = AF_INET6;
+     108           9 :     forced_addr.sin6_port = htons(servPort);
+     109             : 
+     110           9 :     if (0 == strcmp(ip, "0.0.0.0")) {
+     111           9 :         forced_addr.sin6_addr = in6addr_any;
+     112             :     } else {
+     113           0 :         ret_inet_pton = inet_pton(AF_INET6, ip, &forced_addr.sin6_addr);
+     114             :     }
+     115             : 
+     116             : #else
+     117             :     struct sockaddr_in forced_addr;
+     118             :     memset(&forced_addr, 0, sizeof(forced_addr));
+     119             :     forced_addr.sin_family = AF_INET;
+     120             :     forced_addr.sin_port = htons(servPort);
+     121             :     ret_inet_pton = inet_pton(AF_INET, ip, &forced_addr.sin_addr);
+     122             : #endif
+     123             : 
+     124             :     /* inet_pton returns 1 on success */
+     125           0 :     if (ret_inet_pton != 1) {
+     126           0 :         lastErrno = errno;
+     127           0 :         dlt_vlog(
+     128             :             LOG_WARNING,
+     129             :             "dlt_daemon_socket_open: inet_pton() error %d: %s. Cannot convert IP address: %s\n",
+     130             :             lastErrno,
+     131             :             strerror(lastErrno),
+     132             :             ip);
+     133           0 :         return -1;
+     134             :     }
+     135             : 
+     136           9 :     if (bind(*sock, (struct sockaddr *)&forced_addr, sizeof(forced_addr)) == -1) {
+     137           0 :         lastErrno = errno;     /*close() may set errno too */
+     138           0 :         close(*sock);
+     139           0 :         dlt_vlog(LOG_WARNING, "dlt_daemon_socket_open: bind() error %d: %s\n", lastErrno,
+     140             :                  strerror(lastErrno));
+     141           0 :         return -1;
+     142             :     }
+     143             : 
+     144             :     /*listen */
+     145           9 :     dlt_vlog(LOG_INFO, "%s: Listening on ip %s and port: %u\n", __FUNCTION__, ip, servPort);
+     146             : 
+     147             :     /* get socket buffer size */
+     148           9 :     dlt_vlog(LOG_INFO, "dlt_daemon_socket_open: Socket send queue size: %d\n",
+     149             :              dlt_daemon_socket_get_send_qeue_max_size(*sock));
+     150             : 
+     151           9 :     if (listen(*sock, 3) < 0) {
+     152           0 :         lastErrno = errno;
+     153           0 :         dlt_vlog(LOG_WARNING,
+     154             :                  "dlt_daemon_socket_open: listen() failed with error %d: %s\n",
+     155             :                  lastErrno,
+     156             :                  strerror(lastErrno));
+     157           0 :         return -1;
+     158             :     }
+     159             : 
+     160             :     return 0; /* OK */
+     161             : }
+     162             : 
+     163           0 : int dlt_daemon_socket_close(int sock)
+     164             : {
+     165           0 :     close(sock);
+     166             : 
+     167           0 :     return 0;
+     168             : }
+     169             : 
+     170          16 : int dlt_daemon_socket_send(int sock,
+     171             :                            void *data1,
+     172             :                            int size1,
+     173             :                            void *data2,
+     174             :                            int size2,
+     175             :                            char serialheader)
+     176             : {
+     177             :     int ret = DLT_RETURN_OK;
+     178             : 
+     179             :     /* Optional: Send serial header, if requested */
+     180          16 :     if (serialheader) {
+     181           0 :         ret = dlt_daemon_socket_sendreliable(sock,
+     182             :                                              (void *)dltSerialHeader,
+     183             :                                              sizeof(dltSerialHeader));
+     184             : 
+     185           0 :         if (ret != DLT_RETURN_OK) {
+     186             :             return ret;
+     187             :         }
+     188             :     }
+     189             : 
+     190             :     /* Send data */
+     191          16 :     if ((data1 != NULL) && (size1 > 0)) {
+     192          16 :         ret = dlt_daemon_socket_sendreliable(sock, data1, size1);
+     193             : 
+     194          16 :         if (ret != DLT_RETURN_OK) {
+     195             :             return ret;
+     196             :         }
+     197             :     }
+     198             : 
+     199          16 :     if ((data2 != NULL) && (size2 > 0)) {
+     200          16 :         ret = dlt_daemon_socket_sendreliable(sock, data2, size2);
+     201             :     }
+     202             : 
+     203             :     return ret;
+     204             : }
+     205             : 
+     206           9 : int dlt_daemon_socket_get_send_qeue_max_size(int sock)
+     207             : {
+     208           9 :     int n = 0;
+     209           9 :     socklen_t m = sizeof(n);
+     210           9 :     if (getsockopt(sock, SOL_SOCKET, SO_SNDBUF, (void *)&n, &m) < 0) {
+     211           0 :         dlt_vlog(LOG_ERR,
+     212             :                  "%s: socket get failed!\n", __func__);
+     213           0 :         return -errno;
+     214             :     }
+     215             : 
+     216           9 :     return n;
+     217             : }
+     218             : 
+     219         466 : int dlt_daemon_socket_sendreliable(int sock, void *data_buffer, int message_size)
+     220             : {
+     221             :     int data_sent = 0;
+     222             : 
+     223         932 :     while (data_sent < message_size) {
+     224         466 :         ssize_t ret = send(sock,
+     225             :                            (uint8_t *)data_buffer + data_sent,
+     226         466 :                            message_size - data_sent,
+     227             :                            0);
+     228             : 
+     229         466 :         if (ret < 0) {
+     230           0 :             dlt_vlog(LOG_WARNING,
+     231           0 :                      "%s: socket send failed [errno: %d]!\n", __func__, errno);
+     232             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+     233             :             /* notify systemd here that we are still alive
+     234             :              * otherwise we might miss notifying the watchdog when
+     235             :              * the watchdog interval is small and multiple timeouts occur back to back
+     236             :              */
+     237             :             if (sd_notify(0, "WATCHDOG=1") < 0)
+     238             :                 dlt_vlog(LOG_WARNING, "%s: Could not reset systemd watchdog\n", __func__);
+     239             : #endif
+     240           0 :             return DLT_DAEMON_ERROR_SEND_FAILED;
+     241             :         } else {
+     242         466 :             data_sent += ret;
+     243             :         }
+     244             :     }
+     245             : 
+     246             :     return DLT_DAEMON_ERROR_OK;
+     247             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_unix_socket.c.func-sort-c.html b/dlt_lcov_report/daemon/dlt_daemon_unix_socket.c.func-sort-c.html new file mode 100644 index 000000000..3a96f5956 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_unix_socket.c.func-sort-c.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_unix_socket.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_unix_socket.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:122744.4 %
Date:2024-12-05 09:07:13Functions:1250.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_unix_socket_close0
dlt_daemon_unix_socket_open9
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_unix_socket.c.func.html b/dlt_lcov_report/daemon/dlt_daemon_unix_socket.c.func.html new file mode 100644 index 000000000..66c0fabf2 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_unix_socket.c.func.html @@ -0,0 +1,80 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_unix_socket.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_unix_socket.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:122744.4 %
Date:2024-12-05 09:07:13Functions:1250.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_unix_socket_close0
dlt_daemon_unix_socket_open9
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_unix_socket.c.gcov.html b/dlt_lcov_report/daemon/dlt_daemon_unix_socket.c.gcov.html new file mode 100644 index 000000000..2e151ee78 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_unix_socket.c.gcov.html @@ -0,0 +1,264 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_unix_socket.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_unix_socket.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:122744.4 %
Date:2024-12-05 09:07:13Functions:1250.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2015, Advanced Driver Information Technology
+       5             :  * Copyright of Advanced Driver Information Technology, Bosch and Denso
+       6             :  *
+       7             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       8             :  *
+       9             :  * This Source Code Form is subject to the terms of the
+      10             :  * Mozilla Public License (MPL), v. 2.0.
+      11             :  * If a copy of the MPL was not distributed with this file,
+      12             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      13             :  *
+      14             :  * For further information see http://www.covesa.org/.
+      15             :  */
+      16             : 
+      17             : /*!
+      18             :  * \author
+      19             :  * Christoph Lipka <clipka@jp.adit-jv.com>
+      20             :  *
+      21             :  * \copyright Copyright © 2015 ADIT. \n
+      22             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      23             :  *
+      24             :  * \file dlt_daemon_unix_socket.c
+      25             :  */
+      26             : 
+      27             : #include <stdio.h>
+      28             : #include <stdlib.h>
+      29             : #include <string.h>
+      30             : #include <sys/un.h>
+      31             : #if defined(ANDROID)
+      32             : #   include <cutils/sockets.h> /* for android_get_control_socket() */
+      33             : #   include <libgen.h> /* for basename() */
+      34             : #else
+      35             : #   include <sys/socket.h> /* for socket(), connect(), (), and recv() */
+      36             : #endif
+      37             : #include <sys/types.h>
+      38             : #include <sys/stat.h>
+      39             : #include <syslog.h>
+      40             : #include <errno.h>
+      41             : #if DLT_SYSTEM_SOCKET_ACTIVATION_ENABLE
+      42             : #include <systemd/sd-daemon.h>
+      43             : #endif
+      44             : 
+      45             : #include "dlt-daemon.h"
+      46             : #include "dlt_common.h"
+      47             : #include "dlt-daemon_cfg.h"
+      48             : #include "dlt_daemon_socket.h"
+      49             : #include "dlt_daemon_unix_socket.h"
+      50             : 
+      51             : #ifdef ANDROID
+      52             : DltReturnValue dlt_daemon_unix_android_get_socket(int *sock, const char *sock_path)
+      53             : {
+      54             :     DltReturnValue ret = DLT_RETURN_OK;
+      55             : 
+      56             :     if ((sock == NULL) || (sock_path == NULL)) {
+      57             :         dlt_log(LOG_ERR, "dlt_daemon_unix_android_get_socket: arguments invalid");
+      58             :         ret = DLT_RETURN_WRONG_PARAMETER;
+      59             :     }
+      60             :     else {
+      61             :         const char* sock_name = basename(sock_path);
+      62             :         if (sock_name == NULL) {
+      63             :             dlt_log(LOG_WARNING,
+      64             :                     "dlt_daemon_unix_android_get_socket: can't get socket name from its path");
+      65             :             ret = DLT_RETURN_ERROR;
+      66             :         }
+      67             :         else {
+      68             :             *sock = android_get_control_socket(sock_name);
+      69             :             if (*sock < 0) {
+      70             :                 dlt_log(LOG_WARNING,
+      71             :                         "dlt_daemon_unix_android_get_socket: can get socket from init");
+      72             :                 ret = DLT_RETURN_ERROR;
+      73             :             }
+      74             :             else {
+      75             :                 if (listen(*sock, 1) == -1) {
+      76             :                     dlt_vlog(LOG_WARNING, "unix socket: listen error: %s", strerror(errno));
+      77             :                     ret = DLT_RETURN_ERROR;
+      78             :                 }
+      79             :             }
+      80             :         }
+      81             :     }
+      82             : 
+      83             :     return ret;
+      84             : }
+      85             : #endif
+      86             : 
+      87           9 : int dlt_daemon_unix_socket_open(int *sock, char *sock_path, int type, int mask)
+      88             : {
+      89             :     struct sockaddr_un addr;
+      90             :     int old_mask;
+      91             : 
+      92           9 :     if ((sock == NULL) || (sock_path == NULL)) {
+      93           0 :         dlt_log(LOG_ERR, "dlt_daemon_unix_socket_open: arguments invalid");
+      94           0 :         return -1;
+      95             :     }
+      96             : 
+      97             : #ifdef DLT_SYSTEM_SOCKET_ACTIVATION_ENABLE
+      98             : 
+      99             :     char **names = NULL;
+     100             :     const int num_fds = sd_listen_fds_with_names(0, &names);
+     101             :     bool sd_socket_open = false;
+     102             :     int i;
+     103             : 
+     104             :     if (num_fds <= 0) {
+     105             :         dlt_vlog(LOG_WARNING, "unix socket: no sockets configured via systemd, error: %s\n", strerror(errno));
+     106             :     } else {
+     107             :         for (i = 0; i < num_fds; ++i) {
+     108             :             if (strcmp(sock_path, names[i]) != 0) {
+     109             :                 continue;
+     110             :             }
+     111             : 
+     112             :             if (sd_is_socket_unix(i + SD_LISTEN_FDS_START, type, 1, names[i], strlen(names[i])) < 0) {
+     113             :                 dlt_vlog(LOG_WARNING,
+     114             :                         "unix socket: socket with matching name is not of correct type or not in listen mode, error: %s\n",
+     115             :                         strerror(errno));
+     116             :                 continue;
+     117             :             }
+     118             : 
+     119             :             *sock = i + SD_LISTEN_FDS_START;
+     120             :             sd_socket_open = true;
+     121             :             dlt_vlog(LOG_INFO, "unix socket: sock_path %s found systemd socket %s\n", sock_path, names[i]);
+     122             :             break;
+     123             :         }
+     124             : 
+     125             :         /*
+     126             :          * The caller [of sd_listen_fds_with_names] needs to free the array
+     127             :          * itself and each of its elements with libc's free() call after use.
+     128             :          * */
+     129             :         for (i = 0; i < num_fds; ++i) {
+     130             :             free(names[i]);
+     131             :         }
+     132             :         free(names);
+     133             :     }
+     134             : 
+     135             :     if (!sd_socket_open) {
+     136             :         dlt_vlog(LOG_INFO, "unix socket: sock_path %s no systemd socket found\n", sock_path);
+     137             : #endif
+     138             : 
+     139           9 :     if ((*sock = socket(AF_UNIX, type, 0)) == -1) {
+     140           0 :         dlt_log(LOG_WARNING, "unix socket: socket() error");
+     141           0 :         return -1;
+     142             :     }
+     143             : 
+     144             :     memset(&addr, 0, sizeof(addr));
+     145           9 :     addr.sun_family = AF_UNIX;
+     146             :     memcpy(addr.sun_path, sock_path, sizeof(addr.sun_path));
+     147             : 
+     148           9 :     if (unlink(sock_path) != 0) {
+     149           8 :         dlt_vlog(LOG_WARNING, "%s: unlink() failed: %s\n",
+     150           8 :                 __func__, strerror(errno));
+     151             :     }
+     152             : 
+     153             :     /* set appropriate access permissions */
+     154           9 :     old_mask = umask(mask);
+     155             : 
+     156           9 :     if (bind(*sock, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
+     157           0 :         dlt_vlog(LOG_WARNING, "%s: bind() error (%s)\n", __func__,
+     158           0 :                  strerror(errno));
+     159           0 :         return -1;
+     160             :     }
+     161             : 
+     162           9 :     if (listen(*sock, 1) == -1) {
+     163           0 :         dlt_vlog(LOG_WARNING, "%s: listen error (%s)\n", __func__,
+     164           0 :                  strerror(errno));
+     165           0 :         return -1;
+     166             :     }
+     167             : 
+     168             :     /* restore permissions */
+     169           9 :     umask(old_mask);
+     170             : 
+     171             : #ifdef DLT_SYSTEM_SOCKET_ACTIVATION_ENABLE
+     172             :     } // end of: if (!sd_socket_open) {
+     173             : #endif
+     174             : 
+     175             : 
+     176           9 :     return 0;
+     177             : }
+     178             : 
+     179           0 : int dlt_daemon_unix_socket_close(int sock)
+     180             : {
+     181           0 :     int ret = close(sock);
+     182             : 
+     183           0 :     if (ret != 0) {
+     184           0 :         dlt_vlog(LOG_WARNING, "unix socket close failed: %s", strerror(errno));
+     185             :     }
+     186             : 
+     187           0 :     return ret;
+     188             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/index-sort-f.html b/dlt_lcov_report/daemon/index-sort-f.html new file mode 100644 index 000000000..5056e6c8d --- /dev/null +++ b/dlt_lcov_report/daemon/index-sort-f.html @@ -0,0 +1,173 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemonHitTotalCoverage
Test:dlt_final_coverage.infoLines:1693343249.3 %
Date:2024-12-05 09:07:13Functions:11015770.1 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_daemon_serial.c +
0.0%
+
0.0 %0 / 80.0 %0 / 1
dlt_daemon_client.c +
27.0%27.0%
+
27.0 %261 / 96639.4 %13 / 33
dlt_daemon_unix_socket.c +
44.4%44.4%
+
44.4 %12 / 2750.0 %1 / 2
dlt_daemon_common.c +
56.3%56.3%
+
56.3 %351 / 62371.9 %23 / 32
dlt-daemon.c +
52.6%52.6%
+
52.6 %606 / 115273.8 %31 / 42
dlt_daemon_socket.c +
52.5%52.5%
+
52.5 %31 / 5980.0 %4 / 5
dlt_daemon_offline_logstorage.c +
61.7%61.7%
+
61.7 %205 / 33282.6 %19 / 23
dlt_daemon_connection.c +
88.7%88.7%
+
88.7 %102 / 115100.0 %8 / 8
dlt_daemon_event_handler.c +
83.3%83.3%
+
83.3 %125 / 150100.0 %11 / 11
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/index-sort-l.html b/dlt_lcov_report/daemon/index-sort-l.html new file mode 100644 index 000000000..861a957d6 --- /dev/null +++ b/dlt_lcov_report/daemon/index-sort-l.html @@ -0,0 +1,173 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemonHitTotalCoverage
Test:dlt_final_coverage.infoLines:1693343249.3 %
Date:2024-12-05 09:07:13Functions:11015770.1 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_daemon_serial.c +
0.0%
+
0.0 %0 / 80.0 %0 / 1
dlt_daemon_client.c +
27.0%27.0%
+
27.0 %261 / 96639.4 %13 / 33
dlt_daemon_unix_socket.c +
44.4%44.4%
+
44.4 %12 / 2750.0 %1 / 2
dlt_daemon_socket.c +
52.5%52.5%
+
52.5 %31 / 5980.0 %4 / 5
dlt-daemon.c +
52.6%52.6%
+
52.6 %606 / 115273.8 %31 / 42
dlt_daemon_common.c +
56.3%56.3%
+
56.3 %351 / 62371.9 %23 / 32
dlt_daemon_offline_logstorage.c +
61.7%61.7%
+
61.7 %205 / 33282.6 %19 / 23
dlt_daemon_event_handler.c +
83.3%83.3%
+
83.3 %125 / 150100.0 %11 / 11
dlt_daemon_connection.c +
88.7%88.7%
+
88.7 %102 / 115100.0 %8 / 8
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/index.html b/dlt_lcov_report/daemon/index.html new file mode 100644 index 000000000..aaa4981ac --- /dev/null +++ b/dlt_lcov_report/daemon/index.html @@ -0,0 +1,173 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemonHitTotalCoverage
Test:dlt_final_coverage.infoLines:1693343249.3 %
Date:2024-12-05 09:07:13Functions:11015770.1 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt-daemon.c +
52.6%52.6%
+
52.6 %606 / 115273.8 %31 / 42
dlt_daemon_client.c +
27.0%27.0%
+
27.0 %261 / 96639.4 %13 / 33
dlt_daemon_common.c +
56.3%56.3%
+
56.3 %351 / 62371.9 %23 / 32
dlt_daemon_connection.c +
88.7%88.7%
+
88.7 %102 / 115100.0 %8 / 8
dlt_daemon_event_handler.c +
83.3%83.3%
+
83.3 %125 / 150100.0 %11 / 11
dlt_daemon_offline_logstorage.c +
61.7%61.7%
+
61.7 %205 / 33282.6 %19 / 23
dlt_daemon_serial.c +
0.0%
+
0.0 %0 / 80.0 %0 / 1
dlt_daemon_socket.c +
52.5%52.5%
+
52.5 %31 / 5980.0 %4 / 5
dlt_daemon_unix_socket.c +
44.4%44.4%
+
44.4 %12 / 2750.0 %1 / 2
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/dlt_final_coverage.info b/dlt_lcov_report/dlt_final_coverage.info new file mode 100644 index 000000000..a938d03fd --- /dev/null +++ b/dlt_lcov_report/dlt_final_coverage.info @@ -0,0 +1,12708 @@ +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/console/dlt-control-common.c +FN:102,get_verbosity +FN:107,set_verbosity +FN:112,get_ecuid +FN:117,set_ecuid +FN:144,set_conf +FN:156,get_timeout +FN:161,set_timeout +FN:172,set_send_serial_header +FN:177,set_resync_serial_header +FN:182,dlt_parse_config_param +FN:263,prepare_extra_headers +FN:310,prepare_headers +FN:366,dlt_control_prepare_message +FN:433,dlt_control_init_connection +FN:475,dlt_control_listen_to_daemon +FN:499,dlt_control_callback +FN:549,dlt_control_send_message +FN:618,dlt_control_init +FN:655,dlt_control_deinit +FNDA:2,dlt_control_init +FNDA:2,prepare_headers +FNDA:2,set_send_serial_header +FNDA:2,set_timeout +FNDA:18,get_verbosity +FNDA:2,set_conf +FNDA:4,get_ecuid +FNDA:2,dlt_control_callback +FNDA:2,dlt_control_prepare_message +FNDA:2,set_ecuid +FNDA:2,dlt_control_send_message +FNDA:0,set_verbosity +FNDA:2,prepare_extra_headers +FNDA:2,dlt_control_init_connection +FNDA:2,dlt_control_listen_to_daemon +FNDA:2,dlt_control_deinit +FNDA:2,get_timeout +FNDA:2,set_resync_serial_header +FNDA:2,dlt_parse_config_param +FNF:19 +FNH:18 +DA:102,18 +DA:104,46 +DA:107,0 +DA:109,2 +DA:110,0 +DA:112,4 +DA:114,4 +DA:117,2 +DA:119,2 +DA:121,2 +DA:123,0 +DA:124,0 +DA:126,0 +DA:127,0 +DA:129,0 +DA:132,0 +DA:139,0 +DA:142,2 +DA:144,2 +DA:146,2 +DA:149,2 +DA:152,0 +DA:154,2 +DA:156,2 +DA:158,2 +DA:161,2 +DA:163,2 +DA:165,2 +DA:166,2 +DA:168,0 +DA:170,2 +DA:172,2 +DA:174,2 +DA:175,2 +DA:177,2 +DA:179,2 +DA:180,2 +DA:182,2 +DA:186,2 +DA:187,2 +DA:188,2 +DA:192,2 +DA:193,0 +DA:196,2 +DA:201,2 +DA:203,2 +DA:206,14 +DA:207,12 +DA:208,2 +DA:209,2 +DA:210,2 +DA:212,4 +DA:213,4 +DA:215,2 +DA:219,2 +DA:220,2 +DA:223,2 +DA:226,2 +DA:227,2 +DA:228,2 +DA:229,2 +DA:242,2 +DA:245,0 +DA:248,2 +DA:249,0 +DA:263,2 +DA:267,2 +DA:269,2 +DA:272,2 +DA:274,2 +DA:277,2 +DA:279,2 +DA:282,2 +DA:283,0 +DA:284,0 +DA:288,2 +DA:290,2 +DA:292,2 +DA:295,2 +DA:296,2 +DA:298,2 +DA:310,2 +DA:314,2 +DA:316,2 +DA:319,2 +DA:321,2 +DA:322,0 +DA:323,0 +DA:327,2 +DA:328,2 +DA:330,2 +DA:337,2 +DA:340,2 +DA:345,2 +DA:347,2 +DA:348,0 +DA:349,0 +DA:352,2 +DA:354,2 +DA:366,2 +DA:370,2 +DA:372,2 +DA:373,0 +DA:374,0 +DA:377,2 +DA:379,2 +DA:380,0 +DA:381,0 +DA:384,2 +DA:385,0 +DA:386,0 +DA:387,0 +DA:391,2 +DA:394,2 +DA:396,2 +DA:397,0 +DA:398,0 +DA:399,0 +DA:403,2 +DA:406,2 +DA:407,0 +DA:408,0 +DA:409,0 +DA:413,2 +DA:414,0 +DA:415,0 +DA:416,0 +DA:433,2 +DA:435,2 +DA:437,2 +DA:438,0 +DA:439,0 +DA:442,2 +DA:444,2 +DA:445,0 +DA:446,0 +DA:449,2 +DA:451,2 +DA:453,2 +DA:455,0 +DA:456,0 +DA:457,0 +DA:461,2 +DA:463,2 +DA:475,2 +DA:477,2 +DA:478,2 +DA:479,2 +DA:499,2 +DA:501,2 +DA:504,2 +DA:505,0 +DA:506,0 +DA:510,2 +DA:511,2 +DA:513,0 +DA:515,2 +DA:518,2 +DA:526,2 +DA:527,4 +DA:528,2 +DA:529,2 +DA:530,2 +DA:531,2 +DA:533,2 +DA:549,2 +DA:554,2 +DA:555,0 +DA:556,0 +DA:559,2 +DA:560,0 +DA:561,0 +DA:564,2 +DA:567,2 +DA:569,2 +DA:570,0 +DA:571,0 +DA:574,2 +DA:577,2 +DA:579,2 +DA:581,0 +DA:582,0 +DA:583,0 +DA:586,0 +DA:587,0 +DA:594,2 +DA:595,2 +DA:598,2 +DA:599,2 +DA:604,2 +DA:618,2 +DA:622,2 +DA:623,0 +DA:624,0 +DA:627,2 +DA:628,2 +DA:631,2 +DA:632,0 +DA:633,0 +DA:634,0 +DA:638,2 +DA:642,0 +DA:643,0 +DA:655,2 +DA:661,2 +DA:662,2 +DA:663,2 +DA:664,2 +DA:668,2 +DA:669,0 +DA:672,2 +DA:673,0 +DA:678,2 +LF:213 +LH:147 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/console/dlt-convert.c +FN:100,usage +FN:129,empty_dir +FN:182,main +FNDA:0,usage +FNDA:18,main +FNDA:0,empty_dir +FNF:3 +FNH:1 +DA:100,0 +DA:104,0 +DA:127,0 +DA:129,0 +DA:131,0 +DA:134,0 +DA:137,0 +DA:138,0 +DA:139,0 +DA:142,0 +DA:143,0 +DA:144,0 +DA:147,0 +DA:148,0 +DA:149,0 +DA:150,0 +DA:153,0 +DA:155,0 +DA:157,0 +DA:158,0 +DA:159,0 +DA:161,0 +DA:162,0 +DA:163,0 +DA:164,0 +DA:165,0 +DA:167,0 +DA:173,0 +DA:176,0 +DA:182,18 +DA:207,18 +DA:210,18 +DA:213,18 +DA:221,18 +DA:223,36 +DA:224,18 +DA:231,0 +DA:234,0 +DA:236,18 +DA:239,18 +DA:241,0 +DA:244,0 +DA:246,0 +DA:249,0 +DA:251,0 +DA:254,0 +DA:256,0 +DA:259,0 +DA:261,0 +DA:264,0 +DA:266,0 +DA:268,0 +DA:269,0 +DA:271,0 +DA:273,0 +DA:274,0 +DA:276,0 +DA:278,0 +DA:279,0 +DA:281,0 +DA:283,0 +DA:284,0 +DA:286,0 +DA:288,0 +DA:289,0 +DA:291,0 +DA:293,0 +DA:294,0 +DA:295,0 +DA:296,0 +DA:298,0 +DA:301,0 +DA:302,0 +DA:312,18 +DA:315,18 +DA:316,0 +DA:317,0 +DA:318,0 +DA:321,0 +DA:324,18 +DA:327,0 +DA:328,0 +DA:329,0 +DA:330,0 +DA:334,18 +DA:336,0 +DA:337,0 +DA:338,0 +DA:339,0 +DA:340,0 +DA:342,0 +DA:346,0 +DA:347,0 +DA:349,0 +DA:352,0 +DA:356,0 +DA:357,0 +DA:358,0 +DA:359,0 +DA:360,0 +DA:363,0 +DA:364,0 +DA:365,0 +DA:366,0 +DA:371,0 +DA:372,0 +DA:373,0 +DA:374,0 +DA:375,0 +DA:377,0 +DA:381,0 +DA:384,35 +DA:385,18 +DA:388,0 +DA:390,0 +DA:394,18 +DA:395,526 +DA:399,18 +DA:400,18 +DA:405,18 +DA:408,18 +DA:410,18 +DA:411,1 +DA:412,1 +DA:413,0 +DA:415,1 +DA:418,17 +DA:419,0 +DA:420,0 +DA:421,0 +DA:423,0 +DA:426,526 +DA:427,509 +DA:428,0 +DA:430,509 +DA:432,0 +DA:433,0 +DA:435,509 +DA:438,509 +DA:439,0 +DA:443,509 +DA:444,0 +DA:448,0 +DA:450,0 +DA:451,0 +DA:453,0 +DA:456,0 +DA:457,0 +DA:463,509 +DA:464,0 +DA:465,0 +DA:466,0 +DA:467,0 +DA:469,0 +DA:471,0 +DA:473,0 +DA:474,0 +DA:475,0 +DA:480,509 +DA:482,0 +DA:485,0 +DA:488,0 +DA:489,0 +DA:490,0 +DA:502,17 +DA:503,0 +DA:505,0 +DA:506,0 +DA:510,17 +DA:511,0 +DA:513,17 +DA:514,0 +DA:515,0 +DA:516,0 +DA:517,0 +DA:518,0 +DA:520,0 +DA:522,0 +DA:524,17 +DA:526,0 +DA:527,0 +DA:528,0 +DA:531,17 +DA:533,17 +LF:184 +LH:40 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/console/dlt-receive.c +FN:95,signal_handler +FN:148,usage +FN:184,convert_arg_to_byte_size +FN:238,dlt_receive_open_output_file +FN:312,dlt_receive_close_output_file +FN:324,main +FN:660,dlt_receive_message_callback +FNDA:0,convert_arg_to_byte_size +FNDA:1,signal_handler +FNDA:0,dlt_receive_open_output_file +FNDA:0,dlt_receive_close_output_file +FNDA:0,usage +FNDA:206,dlt_receive_message_callback +FNDA:1,main +FNF:7 +FNH:3 +DA:95,1 +DA:97,1 +DA:98,1 +DA:103,1 +DA:104,1 +DA:105,1 +DA:111,1 +DA:148,0 +DA:152,0 +DA:181,0 +DA:184,0 +DA:191,0 +DA:192,0 +DA:198,0 +DA:204,0 +DA:210,0 +DA:214,0 +DA:223,0 +DA:224,0 +DA:238,0 +DA:243,0 +DA:248,0 +DA:249,0 +DA:251,0 +DA:253,0 +DA:254,0 +DA:264,0 +DA:272,0 +DA:276,0 +DA:278,0 +DA:279,0 +DA:283,0 +DA:285,0 +DA:290,0 +DA:292,0 +DA:295,0 +DA:296,0 +DA:297,0 +DA:298,0 +DA:299,0 +DA:301,0 +DA:305,0 +DA:307,0 +DA:308,0 +DA:312,0 +DA:314,0 +DA:315,0 +DA:316,0 +DA:318,0 +DA:324,1 +DA:332,1 +DA:333,1 +DA:334,1 +DA:335,1 +DA:342,1 +DA:343,1 +DA:344,1 +DA:345,1 +DA:346,1 +DA:347,1 +DA:350,1 +DA:352,2 +DA:353,1 +DA:354,0 +DA:356,0 +DA:357,0 +DA:359,0 +DA:361,0 +DA:362,0 +DA:364,0 +DA:366,0 +DA:367,0 +DA:369,0 +DA:371,0 +DA:372,0 +DA:374,0 +DA:376,0 +DA:377,0 +DA:379,0 +DA:381,0 +DA:382,0 +DA:384,0 +DA:386,0 +DA:387,0 +DA:389,0 +DA:391,0 +DA:392,0 +DA:394,0 +DA:396,0 +DA:397,0 +DA:399,0 +DA:401,0 +DA:402,0 +DA:404,0 +DA:406,0 +DA:407,0 +DA:409,0 +DA:411,0 +DA:412,0 +DA:414,0 +DA:420,0 +DA:422,0 +DA:425,0 +DA:426,0 +DA:427,0 +DA:428,0 +DA:430,1 +DA:432,1 +DA:433,1 +DA:435,1 +DA:438,1 +DA:440,1 +DA:441,0 +DA:442,0 +DA:445,1 +DA:446,1 +DA:449,0 +DA:451,0 +DA:452,0 +DA:454,0 +DA:456,0 +DA:457,0 +DA:459,0 +DA:461,0 +DA:462,0 +DA:465,0 +DA:467,0 +DA:469,0 +DA:470,0 +DA:472,0 +DA:473,0 +DA:478,0 +DA:480,0 +DA:481,0 +DA:482,0 +DA:483,0 +DA:485,0 +DA:488,0 +DA:489,0 +DA:491,0 +DA:493,0 +DA:499,1 +DA:502,1 +DA:505,1 +DA:506,0 +DA:509,1 +DA:512,1 +DA:513,1 +DA:516,2 +DA:517,1 +DA:518,1 +DA:519,0 +DA:522,1 +DA:523,1 +DA:524,1 +DA:526,1 +DA:528,0 +DA:531,1 +DA:532,1 +DA:534,1 +DA:535,0 +DA:536,0 +DA:540,1 +DA:542,0 +DA:543,0 +DA:544,0 +DA:545,0 +DA:548,1 +DA:549,0 +DA:550,0 +DA:551,0 +DA:556,0 +DA:557,0 +DA:558,0 +DA:559,0 +DA:562,0 +DA:564,0 +DA:565,0 +DA:566,0 +DA:569,0 +DA:573,1 +DA:574,1 +DA:577,1 +DA:580,1 +DA:582,1 +DA:583,0 +DA:584,0 +DA:585,0 +DA:588,0 +DA:605,1 +DA:606,1 +DA:607,0 +DA:609,0 +DA:612,1 +DA:615,1 +DA:616,0 +DA:617,0 +DA:618,0 +DA:622,1 +DA:623,0 +DA:625,1 +DA:629,1 +DA:632,1 +DA:634,1 +DA:635,0 +DA:636,0 +DA:639,1 +DA:640,1 +DA:648,1 +DA:649,1 +DA:651,1 +DA:653,1 +DA:655,1 +DA:657,1 +DA:660,206 +DA:668,206 +DA:674,206 +DA:675,206 +DA:677,0 +DA:679,206 +DA:680,0 +DA:682,206 +DA:683,0 +DA:685,206 +DA:688,0 +DA:692,0 +DA:696,206 +DA:698,0 +DA:700,206 +DA:703,0 +DA:709,206 +DA:710,206 +DA:711,206 +DA:712,206 +DA:713,206 +DA:715,206 +DA:716,0 +DA:718,0 +DA:721,0 +DA:724,0 +DA:727,0 +DA:731,206 +DA:733,206 +DA:735,206 +DA:737,0 +LF:245 +LH:87 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/console/logstorage/dlt-logstorage-common.c +FN:87,get_handler_type +FN:92,set_handler_type +FN:100,get_default_event_type +FN:105,set_default_event_type +FN:110,get_default_path +FN:115,set_default_path +FN:126,get_logstorage_control +FN:131,dlt_logstorage_get_handler_cb +FN:136,dlt_logstorage_get_handler_fd +FN:145,dlt_logstorage_init_handler +FN:164,dlt_logstorage_deinit_handler +FN:188,dlt_logstorage_check_config_file +FN:233,dlt_logstorage_check_directory_permission +FN:254,prepare_message_body +FN:306,dlt_logstorage_send_event +FNDA:2,set_default_path +FNDA:6,get_default_event_type +FNDA:2,prepare_message_body +FNDA:4,get_handler_type +FNDA:2,dlt_logstorage_send_event +FNDA:0,dlt_logstorage_check_config_file +FNDA:0,dlt_logstorage_check_directory_permission +FNDA:0,dlt_logstorage_deinit_handler +FNDA:0,get_logstorage_control +FNDA:0,set_handler_type +FNDA:0,dlt_logstorage_get_handler_cb +FNDA:2,set_default_event_type +FNDA:0,dlt_logstorage_init_handler +FNDA:2,get_default_path +FNDA:0,dlt_logstorage_get_handler_fd +FNF:15 +FNH:7 +DA:87,4 +DA:89,4 +DA:92,0 +DA:94,0 +DA:98,0 +DA:100,6 +DA:102,6 +DA:105,2 +DA:107,2 +DA:108,2 +DA:110,2 +DA:112,2 +DA:115,2 +DA:119,2 +DA:121,2 +DA:126,0 +DA:128,0 +DA:131,0 +DA:133,0 +DA:136,0 +DA:138,0 +DA:145,0 +DA:147,0 +DA:150,0 +DA:155,0 +DA:164,0 +DA:166,0 +DA:169,0 +DA:174,0 +DA:188,0 +DA:195,0 +DA:196,0 +DA:197,0 +DA:200,0 +DA:202,0 +DA:204,0 +DA:205,0 +DA:206,0 +DA:210,0 +DA:212,0 +DA:214,0 +DA:218,0 +DA:220,0 +DA:221,0 +DA:223,0 +DA:224,0 +DA:233,0 +DA:235,0 +DA:236,0 +DA:237,0 +DA:240,0 +DA:241,0 +DA:254,2 +DA:260,2 +DA:261,0 +DA:262,0 +DA:265,2 +DA:267,2 +DA:269,2 +DA:270,0 +DA:271,0 +DA:274,2 +DA:276,2 +DA:277,0 +DA:278,0 +DA:279,0 +DA:280,0 +DA:283,2 +DA:287,2 +DA:288,2 +DA:292,2 +DA:294,2 +DA:296,2 +DA:306,2 +DA:309,2 +DA:312,2 +DA:313,0 +DA:314,0 +DA:317,2 +DA:319,2 +DA:320,2 +DA:322,2 +LF:82 +LH:32 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/console/logstorage/dlt-logstorage-ctrl.c +FN:90,dlt_logstorage_exit +FN:99,dlt_logstorage_must_exit +FN:110,catch_signal +FN:123,install_signal_handler +FN:153,analyze_response +FN:212,dlt_logstorage_ctrl_add_event +FN:236,dlt_logstorage_ctrl_execute_event_loop +FN:293,dlt_logstorage_ctrl_setup_event_loop +FN:349,dlt_logstorage_ctrl_single_request +FN:391,usage +FN:439,parse_args +FN:540,sd_notify +FN:558,main +FNDA:0,dlt_logstorage_ctrl_execute_event_loop +FNDA:0,sd_notify +FNDA:2,parse_args +FNDA:2,analyze_response +FNDA:0,install_signal_handler +FNDA:0,usage +FNDA:0,dlt_logstorage_must_exit +FNDA:0,dlt_logstorage_ctrl_setup_event_loop +FNDA:0,dlt_logstorage_ctrl_add_event +FNDA:2,main +FNDA:0,catch_signal +FNDA:0,dlt_logstorage_exit +FNDA:2,dlt_logstorage_ctrl_single_request +FNF:13 +FNH:4 +DA:90,0 +DA:92,0 +DA:93,0 +DA:99,0 +DA:101,0 +DA:110,0 +DA:112,0 +DA:113,0 +DA:116,0 +DA:123,0 +DA:125,0 +DA:129,0 +DA:132,0 +DA:134,0 +DA:136,0 +DA:137,0 +DA:140,0 +DA:153,2 +DA:156,2 +DA:157,2 +DA:158,2 +DA:160,2 +DA:182,2 +DA:185,2 +DA:186,0 +DA:190,2 +DA:191,0 +DA:195,2 +DA:196,2 +DA:212,0 +DA:216,0 +DA:217,0 +DA:218,0 +DA:221,0 +DA:223,0 +DA:224,0 +DA:226,0 +DA:236,0 +DA:239,0 +DA:241,0 +DA:243,0 +DA:244,0 +DA:247,0 +DA:248,0 +DA:250,0 +DA:253,0 +DA:256,0 +DA:257,0 +DA:261,0 +DA:262,0 +DA:263,0 +DA:265,0 +DA:268,0 +DA:269,0 +DA:271,0 +DA:274,0 +DA:276,0 +DA:277,0 +DA:279,0 +DA:293,0 +DA:296,0 +DA:303,0 +DA:305,0 +DA:308,0 +DA:310,0 +DA:311,0 +DA:312,0 +DA:315,0 +DA:316,0 +DA:317,0 +DA:320,0 +DA:322,0 +DA:323,0 +DA:324,0 +DA:325,0 +DA:328,0 +DA:331,0 +DA:335,0 +DA:336,0 +DA:339,0 +DA:340,0 +DA:342,0 +DA:349,2 +DA:354,2 +DA:356,0 +DA:357,0 +DA:360,0 +DA:363,0 +DA:364,0 +DA:365,0 +DA:370,2 +DA:372,0 +DA:373,0 +DA:374,0 +DA:377,2 +DA:381,2 +DA:384,2 +DA:386,2 +DA:391,0 +DA:411,0 +DA:414,0 +DA:439,2 +DA:442,2 +DA:444,6 +DA:448,6 +DA:449,4 +DA:450,2 +DA:451,2 +DA:453,2 +DA:454,0 +DA:455,0 +DA:458,2 +DA:459,2 +DA:460,0 +DA:461,0 +DA:462,0 +DA:464,0 +DA:466,0 +DA:467,0 +DA:469,0 +DA:471,0 +DA:472,0 +DA:474,0 +DA:475,0 +DA:476,0 +DA:477,0 +DA:478,0 +DA:479,0 +DA:480,0 +DA:481,0 +DA:482,0 +DA:483,0 +DA:485,0 +DA:487,0 +DA:488,0 +DA:489,0 +DA:492,0 +DA:493,0 +DA:494,0 +DA:495,0 +DA:496,0 +DA:498,0 +DA:499,0 +DA:500,0 +DA:502,2 +DA:503,2 +DA:504,2 +DA:506,0 +DA:507,0 +DA:508,0 +DA:509,0 +DA:510,0 +DA:512,0 +DA:513,0 +DA:515,0 +DA:517,0 +DA:518,0 +DA:519,0 +DA:520,0 +DA:521,0 +DA:526,4 +DA:527,2 +DA:528,0 +DA:529,0 +DA:533,2 +DA:534,0 +DA:540,0 +DA:545,0 +DA:558,2 +DA:562,2 +DA:563,2 +DA:564,2 +DA:567,2 +DA:572,2 +DA:573,2 +DA:575,2 +DA:577,2 +DA:578,0 +DA:581,0 +DA:585,0 +DA:590,0 +DA:591,0 +DA:592,0 +DA:596,0 +DA:597,0 +DA:600,2 +LF:186 +LH:43 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/console/logstorage/dlt-logstorage-list.c +FN:79,print_list +FN:103,logstorage_find_dev_info +FN:135,logstorage_store_dev_info +FN:200,logstorage_delete_dev_info +FNDA:0,logstorage_delete_dev_info +FNDA:0,logstorage_find_dev_info +FNDA:0,print_list +FNDA:0,logstorage_store_dev_info +FNF:4 +FNH:0 +DA:79,0 +DA:81,0 +DA:82,0 +DA:84,0 +DA:85,0 +DA:86,0 +DA:89,0 +DA:91,0 +DA:103,0 +DA:105,0 +DA:107,0 +DA:110,0 +DA:112,0 +DA:113,0 +DA:114,0 +DA:118,0 +DA:135,0 +DA:140,0 +DA:141,0 +DA:142,0 +DA:145,0 +DA:146,0 +DA:147,0 +DA:148,0 +DA:151,0 +DA:153,0 +DA:154,0 +DA:155,0 +DA:158,0 +DA:159,0 +DA:164,0 +DA:166,0 +DA:167,0 +DA:168,0 +DA:170,0 +DA:173,0 +DA:174,0 +DA:177,0 +DA:179,0 +DA:180,0 +DA:182,0 +DA:184,0 +DA:185,0 +DA:187,0 +DA:200,0 +DA:205,0 +DA:207,0 +DA:208,0 +DA:209,0 +DA:210,0 +DA:214,0 +DA:216,0 +DA:217,0 +DA:219,0 +DA:220,0 +DA:222,0 +DA:223,0 +DA:225,0 +DA:226,0 +DA:228,0 +DA:229,0 +DA:231,0 +LF:62 +LH:0 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/daemon/dlt-daemon.c +FN:194,usage +FN:239,option_handling +FN:382,option_file_parser +FN:1311,dlt_mkdir_recursive +FN:1360,dlt_daemon_create_pipes_dir +FN:1405,main +FN:1649,dlt_daemon_local_init_p1 +FN:1710,dlt_daemon_local_init_p2 +FN:1812,dlt_daemon_init_serial +FN:1870,dlt_daemon_init_fifo +FN:2044,dlt_daemon_initialize_control_socket +FN:2091,dlt_daemon_local_connection_init +FN:2207,file_read_everything +FN:2261,file_read_field +FN:2316,dlt_daemon_local_ecu_version_init +FN:2345,dlt_daemon_local_cleanup +FN:2405,dlt_daemon_exit_trigger +FN:2429,dlt_daemon_signal_handler +FN:2478,dlt_daemon_daemonize +FN:2548,dlt_daemon_log_internal +FN:2627,dlt_daemon_check_numeric_setting +FN:2643,dlt_daemon_process_client_connect +FN:2759,dlt_daemon_process_client_messages +FN:2836,dlt_daemon_process_client_messages_serial +FN:2905,dlt_daemon_process_control_connect +FN:3001,dlt_daemon_process_control_messages +FN:3069,dlt_daemon_process_user_message_not_sup +FN:3110,dlt_daemon_process_user_messages +FN:3203,dlt_daemon_process_user_message_overflow +FN:3241,dlt_daemon_send_message_overflow +FN:3261,dlt_daemon_process_user_message_register_application +FN:3384,dlt_daemon_process_user_message_register_context +FN:3594,dlt_daemon_process_user_message_unregister_application +FN:3691,dlt_daemon_process_user_message_unregister_context +FN:3768,dlt_daemon_process_user_message_log +FN:3925,enforce_context_ll_and_ts_keep_message +FN:4003,dlt_daemon_process_user_message_set_app_ll_ts +FN:4079,dlt_daemon_process_user_message_log_mode +FN:4112,dlt_daemon_process_user_message_marker +FN:4142,dlt_daemon_send_ringbuffer_to_client +FN:4231,create_timer_fd +FN:4323,dlt_daemon_close_socket +FNDA:9,dlt_daemon_local_cleanup +FNDA:9,dlt_daemon_exit_trigger +FNDA:0,file_read_field +FNDA:38,dlt_daemon_process_user_message_register_context +FNDA:0,usage +FNDA:0,dlt_daemon_process_user_message_marker +FNDA:9,dlt_daemon_local_init_p2 +FNDA:6,dlt_daemon_process_user_message_unregister_application +FNDA:4,dlt_daemon_process_client_connect +FNDA:9,dlt_mkdir_recursive +FNDA:0,dlt_daemon_process_user_message_log_mode +FNDA:0,dlt_daemon_process_user_message_not_sup +FNDA:11,dlt_daemon_process_client_messages +FNDA:0,dlt_daemon_send_message_overflow +FNDA:10,create_timer_fd +FNDA:9,dlt_daemon_initialize_control_socket +FNDA:5,dlt_daemon_close_socket +FNDA:4,dlt_daemon_process_control_messages +FNDA:9,dlt_daemon_init_serial +FNDA:0,file_read_everything +FNDA:5809,dlt_daemon_process_user_message_log +FNDA:0,dlt_daemon_process_client_messages_serial +FNDA:0,dlt_daemon_process_user_message_overflow +FNDA:9,option_file_parser +FNDA:40,dlt_daemon_log_internal +FNDA:9,dlt_daemon_local_init_p1 +FNDA:9,dlt_daemon_create_pipes_dir +FNDA:37,dlt_daemon_process_user_message_unregister_context +FNDA:0,enforce_context_ll_and_ts_keep_message +FNDA:3,dlt_daemon_check_numeric_setting +FNDA:1523,dlt_daemon_process_user_messages +FNDA:2,dlt_daemon_process_control_connect +FNDA:9,dlt_daemon_local_ecu_version_init +FNDA:9,dlt_daemon_init_fifo +FNDA:9,option_handling +FNDA:2,dlt_daemon_daemonize +FNDA:2,dlt_daemon_send_ringbuffer_to_client +FNDA:9,dlt_daemon_local_connection_init +FNDA:0,dlt_daemon_process_user_message_set_app_ll_ts +FNDA:9,main +FNDA:7,dlt_daemon_process_user_message_register_application +FNDA:9,dlt_daemon_signal_handler +FNF:42 +FNH:31 +DA:194,0 +DA:197,0 +DA:234,0 +DA:239,9 +DA:247,9 +DA:248,0 +DA:249,0 +DA:256,9 +DA:259,9 +DA:266,9 +DA:277,20 +DA:278,11 +DA:279,2 +DA:281,2 +DA:282,2 +DA:284,8 +DA:286,8 +DA:304,0 +DA:306,0 +DA:307,0 +DA:318,1 +DA:320,1 +DA:322,1 +DA:323,0 +DA:324,0 +DA:329,0 +DA:331,0 +DA:332,0 +DA:335,0 +DA:337,0 +DA:345,0 +DA:346,0 +DA:347,0 +DA:349,0 +DA:352,0 +DA:353,0 +DA:355,0 +DA:357,0 +DA:358,0 +DA:365,9 +DA:367,9 +DA:375,9 +DA:382,9 +DA:383,9 +DA:385,9 +DA:386,9 +DA:387,9 +DA:393,9 +DA:394,9 +DA:395,9 +DA:396,9 +DA:397,9 +DA:398,9 +DA:399,9 +DA:400,9 +DA:407,9 +DA:412,9 +DA:413,0 +DA:416,9 +DA:417,9 +DA:418,9 +DA:420,9 +DA:421,9 +DA:422,9 +DA:423,9 +DA:424,9 +DA:425,9 +DA:426,9 +DA:427,9 +DA:428,9 +DA:429,9 +DA:430,9 +DA:431,9 +DA:432,9 +DA:433,9 +DA:434,9 +DA:435,9 +DA:436,9 +DA:437,9 +DA:439,9 +DA:450,9 +DA:452,9 +DA:453,9 +DA:456,9 +DA:457,9 +DA:458,9 +DA:459,9 +DA:465,9 +DA:466,9 +DA:469,9 +DA:470,8 +DA:475,9 +DA:477,9 +DA:480,112 +DA:481,49 +DA:482,49 +DA:483,49 +DA:485,92 +DA:486,86 +DA:489,86 +DA:490,43 +DA:491,43 +DA:494,43 +DA:495,43 +DA:496,43 +DA:499,43 +DA:502,49 +DA:504,43 +DA:505,0 +DA:508,43 +DA:510,0 +DA:513,43 +DA:515,0 +DA:518,43 +DA:520,0 +DA:523,43 +DA:525,0 +DA:528,43 +DA:530,1 +DA:533,42 +DA:535,0 +DA:538,42 +DA:540,0 +DA:543,42 +DA:545,0 +DA:548,42 +DA:550,0 +DA:553,42 +DA:555,0 +DA:556,0 +DA:559,42 +DA:561,0 +DA:562,0 +DA:565,42 +DA:567,1 +DA:568,1 +DA:571,41 +DA:573,0 +DA:574,0 +DA:577,41 +DA:579,1 +DA:582,40 +DA:584,1 +DA:587,39 +DA:592,1 +DA:595,38 +DA:597,0 +DA:599,38 +DA:601,0 +DA:603,38 +DA:605,0 +DA:607,38 +DA:609,1 +DA:612,37 +DA:614,1 +DA:616,0 +DA:617,0 +DA:620,36 +DA:622,1 +DA:624,0 +DA:625,0 +DA:628,35 +DA:630,1 +DA:632,0 +DA:633,0 +DA:636,34 +DA:638,1 +DA:641,33 +DA:643,0 +DA:646,0 +DA:649,33 +DA:651,0 +DA:654,33 +DA:656,0 +DA:659,33 +DA:661,0 +DA:664,33 +DA:666,0 +DA:669,33 +DA:674,0 +DA:677,33 +DA:681,0 +DA:684,33 +DA:686,0 +DA:689,33 +DA:691,6 +DA:693,27 +DA:695,6 +DA:699,21 +DA:702,6 +DA:703,6 +DA:705,15 +DA:708,0 +DA:709,0 +DA:711,15 +DA:713,0 +DA:714,0 +DA:715,15 +DA:716,6 +DA:718,9 +DA:720,0 +DA:721,0 +DA:722,0 +DA:725,9 +DA:736,2 +DA:738,1 +DA:741,1 +DA:752,0 +DA:756,0 +DA:757,0 +DA:761,0 +DA:768,0 +DA:772,0 +DA:773,0 +DA:777,0 +DA:784,0 +DA:788,0 +DA:789,0 +DA:793,0 +DA:800,0 +DA:802,0 +DA:804,0 +DA:805,0 +DA:811,0 +DA:814,0 +DA:844,0 +DA:849,0 +DA:851,0 +DA:852,0 +DA:854,0 +DA:855,0 +DA:856,0 +DA:857,0 +DA:860,0 +DA:863,0 +DA:866,0 +DA:868,0 +DA:869,0 +DA:871,0 +DA:872,0 +DA:873,0 +DA:874,0 +DA:877,0 +DA:880,0 +DA:882,0 +DA:887,0 +DA:890,0 +DA:891,0 +DA:894,0 +DA:903,7 +DA:906,2 +DA:1311,9 +DA:1320,9 +DA:1322,9 +DA:1323,0 +DA:1325,9 +DA:1327,36 +DA:1328,27 +DA:1329,0 +DA:1331,0 +DA:1332,0 +DA:1340,0 +DA:1345,9 +DA:1346,9 +DA:1353,9 +DA:1356,9 +DA:1360,9 +DA:1364,9 +DA:1365,0 +DA:1366,0 +DA:1370,9 +DA:1373,9 +DA:1374,0 +DA:1379,0 +DA:1383,9 +DA:1387,9 +DA:1388,0 +DA:1391,0 +DA:1393,0 +DA:1405,9 +DA:1417,9 +DA:1418,0 +DA:1419,0 +DA:1421,0 +DA:1425,9 +DA:1426,0 +DA:1427,0 +DA:1429,0 +DA:1433,9 +DA:1434,9 +DA:1436,9 +DA:1437,9 +DA:1441,9 +DA:1442,0 +DA:1459,9 +DA:1461,9 +DA:1463,9 +DA:1468,9 +DA:1469,0 +DA:1470,0 +DA:1482,9 +DA:1483,0 +DA:1484,0 +DA:1489,9 +DA:1491,0 +DA:1492,0 +DA:1496,9 +DA:1497,0 +DA:1498,0 +DA:1503,9 +DA:1504,0 +DA:1505,0 +DA:1512,9 +DA:1515,9 +DA:1516,0 +DA:1517,0 +DA:1539,9 +DA:1540,6 +DA:1545,0 +DA:1568,9 +DA:1571,9 +DA:1572,9 +DA:1573,0 +DA:1576,9 +DA:1577,1 +DA:1578,0 +DA:1579,0 +DA:1583,1 +DA:1592,9 +DA:1593,0 +DA:1595,9 +DA:1597,9 +DA:1606,9 +DA:1607,0 +DA:1608,0 +DA:1610,0 +DA:1612,9 +DA:1618,1577 +DA:1619,1568 +DA:1623,9 +DA:1625,9 +DA:1628,9 +DA:1630,9 +DA:1636,9 +DA:1638,9 +DA:1640,9 +DA:1642,9 +DA:1644,9 +DA:1649,9 +DA:1651,9 +DA:1654,9 +DA:1655,0 +DA:1656,0 +DA:1678,9 +DA:1684,9 +DA:1685,2 +DA:1688,9 +DA:1690,9 +DA:1691,0 +DA:1693,0 +DA:1694,0 +DA:1697,9 +DA:1699,9 +DA:1700,9 +DA:1701,9 +DA:1702,9 +DA:1707,9 +DA:1710,9 +DA:1712,9 +DA:1714,9 +DA:1715,0 +DA:1716,0 +DA:1720,9 +DA:1721,9 +DA:1725,0 +DA:1726,0 +DA:1730,9 +DA:1731,0 +DA:1732,0 +DA:1733,0 +DA:1736,0 +DA:1740,0 +DA:1741,0 +DA:1746,9 +DA:1747,6 +DA:1749,6 +DA:1750,0 +DA:1751,0 +DA:1758,9 +DA:1759,1 +DA:1761,8 +DA:1764,9 +DA:1785,9 +DA:1786,0 +DA:1787,0 +DA:1791,9 +DA:1792,0 +DA:1795,9 +DA:1796,9 +DA:1798,9 +DA:1799,0 +DA:1800,0 +DA:1803,9 +DA:1807,9 +DA:1809,9 +DA:1812,9 +DA:1818,9 +DA:1821,0 +DA:1823,0 +DA:1824,0 +DA:1827,0 +DA:1828,0 +DA:1831,0 +DA:1834,0 +DA:1835,0 +DA:1837,0 +DA:1839,0 +DA:1840,0 +DA:1841,0 +DA:1843,0 +DA:1844,0 +DA:1846,0 +DA:1849,0 +DA:1850,0 +DA:1853,0 +DA:1854,0 +DA:1857,0 +DA:1858,0 +DA:1859,0 +DA:1862,0 +DA:1870,9 +DA:1877,9 +DA:1880,9 +DA:1881,9 +DA:1883,9 +DA:1885,9 +DA:1886,0 +DA:1887,0 +DA:1888,0 +DA:1892,9 +DA:1893,0 +DA:1894,0 +DA:1896,0 +DA:1897,0 +DA:1899,0 +DA:1900,0 +DA:1904,0 +DA:1906,0 +DA:1911,0 +DA:1919,9 +DA:1920,0 +DA:1921,0 +DA:1922,0 +DA:1929,9 +DA:1931,0 +DA:1932,0 +DA:1936,9 +DA:1937,0 +DA:1939,9 +DA:1946,9 +DA:2044,9 +DA:2049,9 +DA:2051,9 +DA:2052,0 +DA:2053,0 +DA:2072,9 +DA:2073,9 +DA:2077,9 +DA:2078,9 +DA:2083,0 +DA:2091,9 +DA:2095,9 +DA:2097,9 +DA:2099,9 +DA:2100,0 +DA:2101,0 +DA:2104,9 +DA:2115,9 +DA:2116,0 +DA:2117,0 +DA:2130,9 +DA:2132,9 +DA:2134,9 +DA:2135,9 +DA:2140,0 +DA:2141,0 +DA:2145,0 +DA:2146,0 +DA:2151,0 +DA:2153,0 +DA:2154,0 +DA:2159,0 +DA:2165,0 +DA:2168,0 +DA:2171,0 +DA:2172,0 +DA:2173,0 +DA:2193,9 +DA:2194,0 +DA:2195,0 +DA:2199,9 +DA:2200,0 +DA:2201,0 +DA:2207,0 +DA:2209,0 +DA:2214,0 +DA:2215,0 +DA:2216,0 +DA:2217,0 +DA:2218,0 +DA:2219,0 +DA:2223,0 +DA:2224,0 +DA:2225,0 +DA:2226,0 +DA:2227,0 +DA:2230,0 +DA:2231,0 +DA:2232,0 +DA:2233,0 +DA:2234,0 +DA:2238,0 +DA:2239,0 +DA:2241,0 +DA:2242,0 +DA:2243,0 +DA:2244,0 +DA:2245,0 +DA:2248,0 +DA:2249,0 +DA:2250,0 +DA:2251,0 +DA:2252,0 +DA:2256,0 +DA:2258,0 +DA:2261,0 +DA:2263,0 +DA:2268,0 +DA:2272,0 +DA:2273,0 +DA:2277,0 +DA:2285,0 +DA:2286,0 +DA:2287,0 +DA:2291,0 +DA:2292,0 +DA:2293,0 +DA:2298,0 +DA:2301,0 +DA:2302,0 +DA:2306,0 +DA:2307,0 +DA:2311,0 +DA:2313,0 +DA:2316,9 +DA:2320,9 +DA:2323,9 +DA:2326,9 +DA:2328,9 +DA:2330,9 +DA:2331,9 +DA:2334,0 +DA:2335,0 +DA:2337,0 +DA:2340,0 +DA:2342,0 +DA:2345,9 +DA:2347,9 +DA:2349,9 +DA:2350,0 +DA:2351,0 +DA:2355,9 +DA:2357,9 +DA:2360,9 +DA:2361,0 +DA:2364,9 +DA:2368,9 +DA:2384,9 +DA:2386,6 +DA:2390,6 +DA:2393,9 +DA:2394,9 +DA:2396,9 +DA:2397,1 +DA:2398,1 +DA:2402,9 +DA:2405,9 +DA:2408,9 +DA:2411,9 +DA:2414,9 +DA:2415,9 +DA:2416,0 +DA:2420,9 +DA:2427,9 +DA:2429,9 +DA:2431,9 +DA:2433,9 +DA:2434,9 +DA:2440,9 +DA:2442,9 +DA:2443,9 +DA:2452,9 +DA:2478,2 +DA:2483,2 +DA:2485,2 +DA:2488,2 +DA:2490,4 +DA:2491,0 +DA:2492,0 +DA:2495,4 +DA:2496,2 +DA:2503,2 +DA:2504,0 +DA:2505,0 +DA:2511,2 +DA:2513,2 +DA:2514,0 +DA:2517,2 +DA:2518,0 +DA:2520,2 +DA:2523,0 +DA:2524,0 +DA:2528,2 +DA:2531,2 +DA:2532,0 +DA:2535,2 +DA:2536,2 +DA:2537,2 +DA:2538,2 +DA:2540,2 +DA:2548,40 +DA:2552,40 +DA:2559,40 +DA:2562,40 +DA:2563,40 +DA:2566,40 +DA:2567,40 +DA:2569,40 +DA:2573,40 +DA:2578,40 +DA:2579,40 +DA:2580,40 +DA:2583,40 +DA:2584,40 +DA:2585,40 +DA:2586,40 +DA:2587,40 +DA:2588,40 +DA:2589,40 +DA:2590,40 +DA:2593,40 +DA:2594,40 +DA:2595,40 +DA:2597,40 +DA:2598,40 +DA:2600,40 +DA:2601,0 +DA:2602,0 +DA:2607,40 +DA:2608,40 +DA:2609,40 +DA:2610,40 +DA:2611,40 +DA:2614,40 +DA:2616,40 +DA:2619,40 +DA:2620,40 +DA:2622,40 +DA:2624,40 +DA:2627,3 +DA:2630,3 +DA:2631,3 +DA:2632,3 +DA:2633,3 +DA:2634,3 +DA:2635,0 +DA:2638,0 +DA:2643,4 +DA:2652,4 +DA:2654,4 +DA:2656,4 +DA:2657,0 +DA:2660,0 +DA:2664,4 +DA:2666,4 +DA:2667,0 +DA:2669,0 +DA:2670,0 +DA:2676,4 +DA:2677,4 +DA:2681,4 +DA:2682,4 +DA:2684,4 +DA:2689,0 +DA:2691,4 +DA:2696,0 +DA:2697,0 +DA:2698,0 +DA:2702,4 +DA:2710,4 +DA:2712,0 +DA:2717,0 +DA:2718,0 +DA:2724,4 +DA:2728,4 +DA:2731,4 +DA:2733,4 +DA:2734,2 +DA:2735,0 +DA:2737,2 +DA:2739,2 +DA:2740,0 +DA:2741,0 +DA:2743,0 +DA:2747,2 +DA:2748,2 +DA:2759,11 +DA:2767,11 +DA:2769,11 +DA:2770,0 +DA:2773,0 +DA:2776,11 +DA:2778,11 +DA:2779,0 +DA:2783,0 +DA:2787,21 +DA:2788,21 +DA:2789,21 +DA:2791,21 +DA:2793,10 +DA:2794,10 +DA:2795,10 +DA:2801,10 +DA:2802,10 +DA:2805,10 +DA:2808,10 +DA:2809,0 +DA:2811,10 +DA:2812,0 +DA:2814,0 +DA:2818,11 +DA:2819,0 +DA:2821,0 +DA:2824,11 +DA:2828,1 +DA:2836,0 +DA:2843,0 +DA:2845,0 +DA:2846,0 +DA:2849,0 +DA:2852,0 +DA:2853,0 +DA:2856,0 +DA:2860,0 +DA:2861,0 +DA:2862,0 +DA:2864,0 +DA:2866,0 +DA:2867,0 +DA:2873,0 +DA:2874,0 +DA:2878,0 +DA:2879,0 +DA:2882,0 +DA:2885,0 +DA:2886,0 +DA:2888,0 +DA:2889,0 +DA:2891,0 +DA:2895,0 +DA:2896,0 +DA:2899,0 +DA:2905,2 +DA:2915,2 +DA:2917,2 +DA:2918,0 +DA:2921,0 +DA:2925,2 +DA:2927,2 +DA:2928,0 +DA:2929,0 +DA:2935,2 +DA:2936,2 +DA:2938,2 +DA:2943,0 +DA:2945,0 +DA:2948,2 +DA:2949,0 +DA:3001,4 +DA:3009,4 +DA:3011,4 +DA:3012,0 +DA:3015,0 +DA:3018,4 +DA:3019,2 +DA:3026,2 +DA:3030,4 +DA:3032,4 +DA:3033,4 +DA:3035,4 +DA:3037,2 +DA:3038,2 +DA:3039,2 +DA:3044,2 +DA:3045,2 +DA:3048,2 +DA:3051,2 +DA:3052,0 +DA:3054,2 +DA:3055,0 +DA:3057,0 +DA:3061,2 +DA:3062,0 +DA:3063,0 +DA:3069,0 +DA:3074,0 +DA:3078,0 +DA:3080,0 +DA:3084,0 +DA:3085,0 +DA:3088,0 +DA:3110,1523 +DA:3121,1523 +DA:3123,1523 +DA:3124,0 +DA:3127,0 +DA:3130,1523 +DA:3132,1523 +DA:3133,0 +DA:3137,0 +DA:3139,1523 +DA:3140,0 +DA:3142,0 +DA:3154,7420 +DA:3158,5897 +DA:3160,5897 +DA:3161,0 +DA:3163,0 +DA:3164,0 +DA:3168,5897 +DA:3172,5897 +DA:3173,0 +DA:3174,0 +DA:3176,0 +DA:3180,5897 +DA:3183,5897 +DA:3185,5897 +DA:3193,1523 +DA:3194,0 +DA:3197,0 +DA:3203,0 +DA:3211,0 +DA:3213,0 +DA:3214,0 +DA:3216,0 +DA:3219,0 +DA:3228,0 +DA:3236,0 +DA:3241,0 +DA:3244,0 +DA:3246,0 +DA:3247,0 +DA:3248,0 +DA:3252,0 +DA:3253,0 +DA:3256,0 +DA:3261,7 +DA:3271,7 +DA:3276,7 +DA:3278,7 +DA:3279,0 +DA:3281,0 +DA:3285,7 +DA:3291,7 +DA:3296,7 +DA:3300,7 +DA:3303,7 +DA:3305,7 +DA:3307,0 +DA:3311,7 +DA:3313,7 +DA:3314,0 +DA:3325,7 +DA:3327,7 +DA:3330,7 +DA:3331,0 +DA:3332,0 +DA:3335,7 +DA:3337,7 +DA:3338,0 +DA:3340,7 +DA:3341,0 +DA:3343,7 +DA:3352,7 +DA:3354,7 +DA:3355,0 +DA:3357,0 +DA:3359,7 +DA:3361,7 +DA:3363,7 +DA:3366,7 +DA:3369,7 +DA:3372,7 +DA:3384,38 +DA:3392,38 +DA:3400,38 +DA:3402,38 +DA:3403,0 +DA:3405,0 +DA:3409,38 +DA:3414,38 +DA:3419,38 +DA:3423,38 +DA:3426,38 +DA:3428,38 +DA:3429,0 +DA:3434,38 +DA:3436,38 +DA:3437,0 +DA:3448,38 +DA:3450,38 +DA:3453,38 +DA:3454,0 +DA:3455,0 +DA:3458,38 +DA:3460,38 +DA:3463,38 +DA:3464,0 +DA:3470,0 +DA:3474,38 +DA:3475,38 +DA:3478,0 +DA:3485,38 +DA:3486,38 +DA:3489,0 +DA:3495,38 +DA:3498,38 +DA:3499,38 +DA:3506,38 +DA:3507,0 +DA:3510,0 +DA:3513,38 +DA:3515,38 +DA:3518,38 +DA:3519,38 +DA:3522,38 +DA:3523,0 +DA:3527,38 +DA:3530,38 +DA:3532,33 +DA:3533,33 +DA:3534,33 +DA:3538,5 +DA:3541,38 +DA:3543,0 +DA:3544,0 +DA:3545,0 +DA:3548,0 +DA:3550,0 +DA:3551,0 +DA:3552,0 +DA:3555,0 +DA:3556,0 +DA:3557,0 +DA:3560,0 +DA:3561,0 +DA:3562,0 +DA:3567,0 +DA:3568,0 +DA:3569,0 +DA:3570,0 +DA:3571,0 +DA:3573,0 +DA:3575,0 +DA:3578,38 +DA:3579,38 +DA:3581,38 +DA:3582,0 +DA:3586,0 +DA:3594,6 +DA:3606,6 +DA:3608,6 +DA:3609,0 +DA:3612,0 +DA:3615,6 +DA:3622,6 +DA:3624,6 +DA:3627,6 +DA:3631,6 +DA:3636,6 +DA:3640,6 +DA:3641,0 +DA:3643,6 +DA:3644,0 +DA:3646,0 +DA:3648,0 +DA:3652,0 +DA:3654,0 +DA:3655,0 +DA:3657,0 +DA:3663,6 +DA:3667,0 +DA:3669,0 +DA:3671,0 +DA:3674,6 +DA:3680,6 +DA:3683,6 +DA:3691,37 +DA:3700,37 +DA:3702,37 +DA:3703,0 +DA:3707,0 +DA:3710,37 +DA:3717,37 +DA:3720,37 +DA:3727,37 +DA:3729,37 +DA:3730,0 +DA:3735,0 +DA:3738,37 +DA:3746,37 +DA:3747,0 +DA:3751,37 +DA:3756,37 +DA:3757,0 +DA:3768,5809 +DA:3776,5809 +DA:3778,5809 +DA:3779,0 +DA:3780,0 +DA:3854,5809 +DA:3855,5809 +DA:3856,5809 +DA:3860,5809 +DA:3861,0 +DA:3869,0 +DA:3871,0 +DA:3879,0 +DA:3882,0 +DA:3891,0 +DA:3904,0 +DA:3905,5809 +DA:3908,5809 +DA:3909,5809 +DA:3912,5809 +DA:3915,5809 +DA:3916,0 +DA:3917,0 +DA:3925,0 +DA:3931,5809 +DA:3932,0 +DA:3942,0 +DA:3953,0 +DA:4003,0 +DA:4016,0 +DA:4018,0 +DA:4019,0 +DA:4022,0 +DA:4025,0 +DA:4027,0 +DA:4032,0 +DA:4039,0 +DA:4041,0 +DA:4046,0 +DA:4050,0 +DA:4051,0 +DA:4053,0 +DA:4054,0 +DA:4056,0 +DA:4057,0 +DA:4058,0 +DA:4060,0 +DA:4061,0 +DA:4064,0 +DA:4065,0 +DA:4068,0 +DA:4069,0 +DA:4079,0 +DA:4087,0 +DA:4089,0 +DA:4090,0 +DA:4091,0 +DA:4096,0 +DA:4104,0 +DA:4107,0 +DA:4109,0 +DA:4112,0 +DA:4119,0 +DA:4121,0 +DA:4122,0 +DA:4124,0 +DA:4129,0 +DA:4137,0 +DA:4139,0 +DA:4142,2 +DA:4151,2 +DA:4153,2 +DA:4154,0 +DA:4155,0 +DA:4158,2 +DA:4159,0 +DA:4160,0 +DA:4163,4 +DA:4168,4 +DA:4169,4 +DA:4171,0 +DA:4173,4 +DA:4175,4 +DA:4176,0 +DA:4178,4 +DA:4179,2 +DA:4180,2 +DA:4231,10 +DA:4239,10 +DA:4240,0 +DA:4241,0 +DA:4244,10 +DA:4246,10 +DA:4247,0 +DA:4248,0 +DA:4251,10 +DA:4253,0 +DA:4259,10 +DA:4261,10 +DA:4262,0 +DA:4263,0 +DA:4265,10 +DA:4266,10 +DA:4267,10 +DA:4268,10 +DA:4270,10 +DA:4271,0 +DA:4272,0 +DA:4315,10 +DA:4319,10 +DA:4323,5 +DA:4325,5 +DA:4327,5 +DA:4329,5 +DA:4330,0 +DA:4331,0 +DA:4335,5 +DA:4339,5 +DA:4341,3 +DA:4342,3 +DA:4347,3 +DA:4348,3 +DA:4351,5 +DA:4358,5 +DA:4362,5 +DA:4365,5 +DA:4367,5 +LF:1152 +LH:606 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/daemon/dlt_daemon_client.c +FN:104,dlt_daemon_client_send_all_multiple +FN:172,dlt_daemon_client_send +FN:324,dlt_daemon_client_send_message_to_all_client +FN:398,dlt_daemon_client_send_control_message +FN:482,dlt_daemon_client_process_control +FN:744,dlt_daemon_control_get_software_version +FN:805,dlt_daemon_control_get_default_log_level +FN:860,dlt_daemon_control_get_log_info +FN:1228,dlt_daemon_control_message_buffer_overflow +FN:1289,dlt_daemon_control_service_response +FN:1335,dlt_daemon_control_message_unregister_context +FN:1390,dlt_daemon_control_message_connection_info +FN:1443,dlt_daemon_control_message_timezone +FN:1498,dlt_daemon_control_message_marker +FN:1544,dlt_daemon_control_callsw_cinjection +FN:1669,dlt_daemon_send_log_level +FN:1695,dlt_daemon_find_multiple_context_and_send_log_level +FN:1743,dlt_daemon_control_set_log_level +FN:1842,dlt_daemon_send_trace_status +FN:1868,dlt_daemon_find_multiple_context_and_send_trace_status +FN:1916,dlt_daemon_control_set_trace_status +FN:2014,dlt_daemon_control_set_default_log_level +FN:2051,dlt_daemon_control_set_all_log_level +FN:2092,dlt_daemon_control_set_default_trace_status +FN:2130,dlt_daemon_control_set_all_trace_status +FN:2170,dlt_daemon_control_set_timing_packets +FN:2199,dlt_daemon_control_message_time +FN:2273,dlt_daemon_process_one_s_timer +FN:2318,dlt_daemon_process_sixty_s_timer +FN:2409,dlt_daemon_process_systemd_timer +FN:2425,dlt_daemon_control_service_logstorage +FN:2662,dlt_daemon_control_passive_node_connect +FN:2719,dlt_daemon_control_passive_node_connect_status +FNDA:0,dlt_daemon_control_set_default_trace_status +FNDA:0,dlt_daemon_control_callsw_cinjection +FNDA:0,dlt_daemon_control_set_default_log_level +FNDA:1,dlt_daemon_control_set_log_level +FNDA:0,dlt_daemon_process_sixty_s_timer +FNDA:0,dlt_daemon_control_set_timing_packets +FNDA:0,dlt_daemon_control_set_trace_status +FNDA:0,dlt_daemon_control_message_buffer_overflow +FNDA:0,dlt_daemon_control_set_all_log_level +FNDA:3,dlt_daemon_control_service_response +FNDA:11,dlt_daemon_process_one_s_timer +FNDA:0,dlt_daemon_find_multiple_context_and_send_trace_status +FNDA:0,dlt_daemon_control_message_marker +FNDA:9,dlt_daemon_control_message_connection_info +FNDA:0,dlt_daemon_control_passive_node_connect_status +FNDA:0,dlt_daemon_find_multiple_context_and_send_log_level +FNDA:0,dlt_daemon_control_set_all_trace_status +FNDA:2,dlt_daemon_control_service_logstorage +FNDA:0,dlt_daemon_control_message_time +FNDA:0,dlt_daemon_process_systemd_timer +FNDA:0,dlt_daemon_send_log_level +FNDA:5809,dlt_daemon_client_send_message_to_all_client +FNDA:0,dlt_daemon_control_passive_node_connect +FNDA:4,dlt_daemon_control_get_log_info +FNDA:0,dlt_daemon_control_message_timezone +FNDA:5885,dlt_daemon_client_send +FNDA:4,dlt_daemon_control_get_software_version +FNDA:1,dlt_daemon_control_get_default_log_level +FNDA:12,dlt_daemon_client_process_control +FNDA:0,dlt_daemon_send_trace_status +FNDA:214,dlt_daemon_client_send_all_multiple +FNDA:21,dlt_daemon_client_send_control_message +FNDA:0,dlt_daemon_control_message_unregister_context +FNF:33 +FNH:13 +DA:81,0 +DA:104,214 +DA:119,214 +DA:121,214 +DA:122,0 +DA:123,0 +DA:126,1286 +DA:128,1072 +DA:129,1072 +DA:131,1072 +DA:132,1072 +DA:133,856 +DA:134,856 +DA:137,216 +DA:144,216 +DA:145,0 +DA:146,0 +DA:152,216 +DA:153,0 +DA:172,5885 +DA:187,5885 +DA:188,0 +DA:189,0 +DA:192,5885 +DA:194,16 +DA:195,0 +DA:196,0 +DA:197,0 +DA:198,0 +DA:199,0 +DA:202,16 +DA:203,16 +DA:204,16 +DA:205,0 +DA:206,0 +DA:210,16 +DA:217,5869 +DA:218,5865 +DA:219,0 +DA:220,0 +DA:224,0 +DA:225,0 +DA:226,0 +DA:236,5865 +DA:237,5839 +DA:248,5869 +DA:263,5869 +DA:265,415 +DA:266,214 +DA:274,214 +DA:282,5869 +DA:283,5865 +DA:285,5454 +DA:287,5454 +DA:288,5454 +DA:289,0 +DA:292,5454 +DA:293,0 +DA:294,0 +DA:295,0 +DA:297,0 +DA:300,415 +DA:301,0 +DA:302,0 +DA:303,0 +DA:304,0 +DA:307,0 +DA:309,0 +DA:313,0 +DA:314,0 +DA:324,5809 +DA:331,5809 +DA:333,5809 +DA:334,0 +DA:335,0 +DA:339,5809 +DA:340,0 +DA:343,0 +DA:346,0 +DA:347,0 +DA:349,0 +DA:353,0 +DA:354,0 +DA:358,5809 +DA:359,5809 +DA:361,0 +DA:364,5809 +DA:365,0 +DA:367,0 +DA:368,0 +DA:372,5809 +DA:373,0 +DA:374,0 +DA:376,0 +DA:377,5809 +DA:378,0 +DA:379,0 +DA:381,0 +DA:382,5809 +DA:383,0 +DA:384,0 +DA:386,0 +DA:390,5809 +DA:391,5809 +DA:393,5809 +DA:394,5809 +DA:398,21 +DA:409,21 +DA:411,21 +DA:415,21 +DA:417,21 +DA:421,21 +DA:422,21 +DA:428,21 +DA:431,21 +DA:435,21 +DA:437,21 +DA:440,21 +DA:441,21 +DA:442,21 +DA:443,21 +DA:445,21 +DA:447,21 +DA:448,21 +DA:450,0 +DA:452,21 +DA:453,21 +DA:455,0 +DA:458,21 +DA:459,21 +DA:461,21 +DA:463,21 +DA:464,0 +DA:465,0 +DA:468,21 +DA:470,21 +DA:471,21 +DA:473,21 +DA:474,21 +DA:475,0 +DA:476,0 +DA:482,12 +DA:491,12 +DA:493,12 +DA:496,12 +DA:499,12 +DA:502,12 +DA:503,0 +DA:504,0 +DA:511,12 +DA:512,12 +DA:514,12 +DA:516,12 +DA:517,1 +DA:519,1 +DA:520,1 +DA:522,0 +DA:524,0 +DA:525,0 +DA:527,4 +DA:529,4 +DA:530,4 +DA:532,1 +DA:534,1 +DA:535,1 +DA:537,0 +DA:539,0 +DA:540,0 +DA:541,0 +DA:546,0 +DA:553,0 +DA:562,0 +DA:568,0 +DA:570,0 +DA:571,0 +DA:572,0 +DA:577,0 +DA:578,0 +DA:580,0 +DA:582,0 +DA:588,0 +DA:590,0 +DA:592,0 +DA:598,0 +DA:600,0 +DA:602,0 +DA:608,0 +DA:610,0 +DA:612,0 +DA:618,0 +DA:620,0 +DA:622,0 +DA:623,0 +DA:625,0 +DA:628,0 +DA:629,0 +DA:631,0 +DA:633,0 +DA:639,0 +DA:641,0 +DA:643,0 +DA:649,0 +DA:651,0 +DA:653,0 +DA:659,0 +DA:661,0 +DA:663,0 +DA:669,0 +DA:671,0 +DA:673,0 +DA:674,0 +DA:676,0 +DA:678,0 +DA:679,0 +DA:681,4 +DA:683,4 +DA:684,4 +DA:686,0 +DA:688,0 +DA:690,0 +DA:692,2 +DA:694,2 +DA:695,2 +DA:697,0 +DA:699,0 +DA:704,0 +DA:706,0 +DA:708,0 +DA:712,0 +DA:714,0 +DA:716,0 +DA:717,0 +DA:719,0 +DA:721,0 +DA:722,0 +DA:724,0 +DA:726,0 +DA:732,0 +DA:738,0 +DA:744,4 +DA:750,4 +DA:752,4 +DA:753,0 +DA:756,4 +DA:757,0 +DA:763,0 +DA:767,4 +DA:770,4 +DA:772,4 +DA:773,0 +DA:774,0 +DA:777,4 +DA:778,4 +DA:779,4 +DA:782,4 +DA:783,0 +DA:789,0 +DA:793,4 +DA:794,4 +DA:795,4 +DA:796,4 +DA:799,4 +DA:802,4 +DA:805,1 +DA:810,1 +DA:812,1 +DA:813,0 +DA:816,1 +DA:817,0 +DA:823,0 +DA:826,1 +DA:828,1 +DA:829,0 +DA:830,0 +DA:833,1 +DA:834,1 +DA:835,1 +DA:838,1 +DA:839,0 +DA:845,0 +DA:849,1 +DA:850,1 +DA:851,1 +DA:854,1 +DA:857,1 +DA:860,4 +DA:872,4 +DA:891,4 +DA:893,4 +DA:894,0 +DA:896,4 +DA:899,4 +DA:901,4 +DA:905,4 +DA:908,4 +DA:909,0 +DA:915,0 +DA:919,4 +DA:920,0 +DA:926,0 +DA:929,4 +DA:930,0 +DA:931,0 +DA:935,0 +DA:938,0 +DA:939,0 +DA:941,0 +DA:945,0 +DA:948,0 +DA:958,4 +DA:959,4 +DA:970,4 +DA:974,4 +DA:975,4 +DA:977,4 +DA:978,4 +DA:980,4 +DA:983,4 +DA:984,4 +DA:985,0 +DA:988,0 +DA:989,0 +DA:991,0 +DA:992,0 +DA:997,0 +DA:1001,0 +DA:1002,0 +DA:1005,0 +DA:1007,0 +DA:1009,0 +DA:1010,0 +DA:1012,0 +DA:1013,0 +DA:1019,0 +DA:1020,0 +DA:1022,0 +DA:1023,0 +DA:1028,4 +DA:1029,0 +DA:1031,0 +DA:1032,0 +DA:1033,0 +DA:1036,4 +DA:1037,0 +DA:1039,0 +DA:1040,0 +DA:1045,4 +DA:1046,0 +DA:1051,4 +DA:1052,4 +DA:1054,4 +DA:1055,0 +DA:1061,0 +DA:1068,4 +DA:1072,4 +DA:1074,4 +DA:1077,4 +DA:1079,4 +DA:1080,0 +DA:1087,0 +DA:1088,0 +DA:1089,0 +DA:1092,0 +DA:1093,0 +DA:1099,0 +DA:1104,0 +DA:1108,0 +DA:1109,0 +DA:1111,0 +DA:1112,0 +DA:1119,0 +DA:1120,0 +DA:1122,0 +DA:1124,0 +DA:1125,0 +DA:1131,0 +DA:1136,0 +DA:1137,0 +DA:1138,0 +DA:1143,0 +DA:1144,0 +DA:1145,0 +DA:1147,0 +DA:1148,0 +DA:1156,0 +DA:1157,0 +DA:1158,0 +DA:1159,0 +DA:1163,0 +DA:1164,0 +DA:1165,0 +DA:1166,0 +DA:1170,0 +DA:1171,0 +DA:1172,0 +DA:1173,0 +DA:1174,0 +DA:1175,0 +DA:1176,0 +DA:1177,0 +DA:1180,0 +DA:1181,0 +DA:1182,0 +DA:1198,0 +DA:1199,0 +DA:1200,0 +DA:1201,0 +DA:1202,0 +DA:1203,0 +DA:1204,0 +DA:1205,0 +DA:1208,0 +DA:1209,0 +DA:1210,0 +DA:1219,4 +DA:1222,4 +DA:1225,4 +DA:1228,0 +DA:1239,0 +DA:1241,0 +DA:1245,0 +DA:1246,0 +DA:1252,0 +DA:1256,0 +DA:1258,0 +DA:1259,0 +DA:1260,0 +DA:1263,0 +DA:1264,0 +DA:1265,0 +DA:1268,0 +DA:1272,0 +DA:1273,0 +DA:1274,0 +DA:1275,0 +DA:1278,0 +DA:1279,0 +DA:1280,0 +DA:1284,0 +DA:1286,0 +DA:1289,3 +DA:1299,3 +DA:1301,3 +DA:1302,0 +DA:1305,3 +DA:1309,3 +DA:1311,3 +DA:1312,0 +DA:1313,0 +DA:1316,3 +DA:1317,3 +DA:1318,3 +DA:1321,3 +DA:1325,3 +DA:1326,3 +DA:1329,3 +DA:1332,3 +DA:1335,0 +DA:1346,0 +DA:1348,0 +DA:1352,0 +DA:1356,0 +DA:1358,0 +DA:1359,0 +DA:1360,0 +DA:1363,0 +DA:1364,0 +DA:1365,0 +DA:1368,0 +DA:1372,0 +DA:1373,0 +DA:1374,0 +DA:1375,0 +DA:1376,0 +DA:1379,0 +DA:1380,0 +DA:1381,0 +DA:1385,0 +DA:1387,0 +DA:1390,9 +DA:1400,9 +DA:1402,9 +DA:1406,9 +DA:1410,9 +DA:1412,9 +DA:1413,0 +DA:1414,0 +DA:1417,9 +DA:1418,9 +DA:1419,9 +DA:1422,9 +DA:1426,9 +DA:1427,9 +DA:1428,9 +DA:1429,9 +DA:1432,9 +DA:1433,0 +DA:1434,0 +DA:1438,9 +DA:1440,9 +DA:1443,0 +DA:1448,0 +DA:1450,0 +DA:1454,0 +DA:1458,0 +DA:1460,0 +DA:1461,0 +DA:1462,0 +DA:1465,0 +DA:1466,0 +DA:1467,0 +DA:1470,0 +DA:1474,0 +DA:1475,0 +DA:1477,0 +DA:1479,0 +DA:1480,0 +DA:1482,0 +DA:1484,0 +DA:1487,0 +DA:1488,0 +DA:1489,0 +DA:1493,0 +DA:1495,0 +DA:1498,0 +DA:1503,0 +DA:1505,0 +DA:1509,0 +DA:1513,0 +DA:1515,0 +DA:1516,0 +DA:1517,0 +DA:1520,0 +DA:1521,0 +DA:1522,0 +DA:1525,0 +DA:1529,0 +DA:1530,0 +DA:1533,0 +DA:1534,0 +DA:1535,0 +DA:1539,0 +DA:1541,0 +DA:1544,0 +DA:1563,0 +DA:1565,0 +DA:1566,0 +DA:1568,0 +DA:1571,0 +DA:1572,0 +DA:1575,0 +DA:1576,0 +DA:1577,0 +DA:1581,0 +DA:1586,0 +DA:1587,0 +DA:1591,0 +DA:1592,0 +DA:1593,0 +DA:1597,0 +DA:1598,0 +DA:1602,0 +DA:1605,0 +DA:1608,0 +DA:1610,0 +DA:1611,0 +DA:1615,0 +DA:1616,0 +DA:1617,0 +DA:1620,0 +DA:1622,0 +DA:1623,0 +DA:1624,0 +DA:1627,0 +DA:1629,0 +DA:1630,0 +DA:1631,0 +DA:1634,0 +DA:1635,0 +DA:1641,0 +DA:1645,0 +DA:1646,0 +DA:1648,0 +DA:1649,0 +DA:1652,0 +DA:1655,0 +DA:1658,0 +DA:1664,0 +DA:1669,0 +DA:1676,0 +DA:1681,0 +DA:1682,0 +DA:1684,0 +DA:1685,0 +DA:1686,0 +DA:1689,0 +DA:1690,0 +DA:1691,0 +DA:1693,0 +DA:1695,0 +DA:1704,0 +DA:1708,0 +DA:1712,0 +DA:1713,0 +DA:1714,0 +DA:1717,0 +DA:1719,0 +DA:1722,0 +DA:1723,0 +DA:1725,0 +DA:1726,0 +DA:1727,0 +DA:1729,0 +DA:1731,0 +DA:1733,0 +DA:1734,0 +DA:1735,0 +DA:1738,0 +DA:1743,1 +DA:1749,1 +DA:1751,1 +DA:1752,1 +DA:1758,1 +DA:1759,0 +DA:1761,1 +DA:1764,1 +DA:1766,1 +DA:1767,0 +DA:1769,1 +DA:1770,1 +DA:1771,1 +DA:1772,1 +DA:1774,1 +DA:1775,0 +DA:1780,0 +DA:1781,0 +DA:1784,1 +DA:1786,0 +DA:1791,0 +DA:1792,0 +DA:1795,1 +DA:1797,0 +DA:1803,0 +DA:1806,1 +DA:1808,0 +DA:1814,0 +DA:1818,1 +DA:1821,1 +DA:1825,1 +DA:1826,0 +DA:1829,1 +DA:1831,1 +DA:1842,0 +DA:1849,0 +DA:1854,0 +DA:1855,0 +DA:1857,0 +DA:1858,0 +DA:1859,0 +DA:1862,0 +DA:1863,0 +DA:1864,0 +DA:1866,0 +DA:1868,0 +DA:1877,0 +DA:1881,0 +DA:1885,0 +DA:1886,0 +DA:1887,0 +DA:1890,0 +DA:1892,0 +DA:1895,0 +DA:1896,0 +DA:1898,0 +DA:1899,0 +DA:1900,0 +DA:1902,0 +DA:1904,0 +DA:1906,0 +DA:1907,0 +DA:1908,0 +DA:1911,0 +DA:1916,0 +DA:1922,0 +DA:1924,0 +DA:1925,0 +DA:1931,0 +DA:1932,0 +DA:1934,0 +DA:1937,0 +DA:1939,0 +DA:1940,0 +DA:1942,0 +DA:1943,0 +DA:1944,0 +DA:1945,0 +DA:1947,0 +DA:1948,0 +DA:1953,0 +DA:1954,0 +DA:1957,0 +DA:1960,0 +DA:1965,0 +DA:1966,0 +DA:1969,0 +DA:1971,0 +DA:1977,0 +DA:1980,0 +DA:1982,0 +DA:1988,0 +DA:1992,0 +DA:1995,0 +DA:1996,0 +DA:1999,0 +DA:2001,0 +DA:2004,0 +DA:2014,0 +DA:2020,0 +DA:2025,0 +DA:2028,0 +DA:2031,0 +DA:2034,0 +DA:2035,0 +DA:2036,0 +DA:2037,0 +DA:2039,0 +DA:2042,0 +DA:2044,0 +DA:2047,0 +DA:2051,0 +DA:2057,0 +DA:2063,0 +DA:2064,0 +DA:2065,0 +DA:2068,0 +DA:2071,0 +DA:2074,0 +DA:2075,0 +DA:2078,0 +DA:2081,0 +DA:2085,0 +DA:2088,0 +DA:2092,0 +DA:2098,0 +DA:2104,0 +DA:2107,0 +DA:2110,0 +DA:2113,0 +DA:2115,0 +DA:2116,0 +DA:2118,0 +DA:2121,0 +DA:2123,0 +DA:2126,0 +DA:2130,0 +DA:2136,0 +DA:2142,0 +DA:2143,0 +DA:2144,0 +DA:2147,0 +DA:2150,0 +DA:2153,0 +DA:2154,0 +DA:2155,0 +DA:2156,0 +DA:2158,0 +DA:2161,0 +DA:2163,0 +DA:2166,0 +DA:2170,0 +DA:2176,0 +DA:2181,0 +DA:2184,0 +DA:2187,0 +DA:2189,0 +DA:2190,0 +DA:2192,0 +DA:2195,0 +DA:2199,0 +DA:2204,0 +DA:2206,0 +DA:2207,0 +DA:2210,0 +DA:2216,0 +DA:2217,0 +DA:2220,0 +DA:2221,0 +DA:2227,0 +DA:2230,0 +DA:2231,0 +DA:2233,0 +DA:2236,0 +DA:2237,0 +DA:2238,0 +DA:2239,0 +DA:2241,0 +DA:2242,0 +DA:2243,0 +DA:2246,0 +DA:2247,0 +DA:2249,0 +DA:2251,0 +DA:2252,0 +DA:2255,0 +DA:2257,0 +DA:2260,0 +DA:2263,0 +DA:2267,0 +DA:2270,0 +DA:2273,11 +DA:2278,11 +DA:2281,11 +DA:2283,11 +DA:2284,0 +DA:2285,0 +DA:2288,11 +DA:2290,11 +DA:2291,0 +DA:2292,0 +DA:2297,11 +DA:2299,0 +DA:2302,0 +DA:2306,11 +DA:2307,0 +DA:2308,0 +DA:2313,11 +DA:2315,11 +DA:2318,0 +DA:2323,0 +DA:2326,0 +DA:2328,0 +DA:2329,0 +DA:2330,0 +DA:2333,0 +DA:2335,0 +DA:2336,0 +DA:2337,0 +DA:2342,0 +DA:2343,0 +DA:2348,0 +DA:2350,0 +DA:2355,0 +DA:2356,0 +DA:2358,0 +DA:2364,0 +DA:2366,0 +DA:2409,0 +DA:2419,0 +DA:2421,0 +DA:2425,2 +DA:2440,2 +DA:2443,2 +DA:2446,2 +DA:2448,2 +DA:2449,0 +DA:2452,0 +DA:2455,2 +DA:2456,0 +DA:2463,0 +DA:2465,0 +DA:2468,2 +DA:2471,2 +DA:2473,2 +DA:2474,0 +DA:2475,0 +DA:2476,0 +DA:2477,0 +DA:2484,0 +DA:2487,0 +DA:2491,4 +DA:2492,2 +DA:2495,2 +DA:2496,0 +DA:2498,0 +DA:2500,0 +DA:2501,0 +DA:2507,0 +DA:2509,0 +DA:2511,0 +DA:2515,0 +DA:2516,0 +DA:2517,0 +DA:2518,0 +DA:2523,2 +DA:2524,2 +DA:2525,0 +DA:2529,2 +DA:2530,2 +DA:2534,0 +DA:2535,0 +DA:2541,0 +DA:2542,0 +DA:2546,2 +DA:2548,2 +DA:2549,0 +DA:2551,0 +DA:2552,0 +DA:2558,0 +DA:2560,0 +DA:2562,0 +DA:2568,0 +DA:2571,0 +DA:2579,0 +DA:2581,0 +DA:2585,0 +DA:2592,2 +DA:2595,0 +DA:2602,0 +DA:2605,0 +DA:2614,2 +DA:2618,2 +DA:2620,4 +DA:2621,2 +DA:2623,2 +DA:2626,2 +DA:2631,0 +DA:2633,0 +DA:2637,2 +DA:2638,2 +DA:2645,0 +DA:2653,0 +DA:2662,0 +DA:2668,0 +DA:2673,0 +DA:2674,0 +DA:2678,0 +DA:2679,0 +DA:2683,0 +DA:2691,0 +DA:2694,0 +DA:2697,0 +DA:2699,0 +DA:2701,0 +DA:2702,0 +DA:2704,0 +DA:2711,0 +DA:2719,0 +DA:2729,0 +DA:2731,0 +DA:2732,0 +DA:2734,0 +DA:2738,0 +DA:2739,0 +DA:2743,0 +DA:2751,0 +DA:2755,0 +DA:2757,0 +DA:2758,0 +DA:2760,0 +DA:2761,0 +DA:2763,0 +DA:2764,0 +DA:2765,0 +DA:2768,0 +DA:2771,0 +DA:2773,0 +DA:2775,0 +DA:2777,0 +DA:2778,0 +DA:2779,0 +DA:2781,0 +DA:2784,0 +DA:2786,0 +DA:2787,0 +DA:2790,0 +DA:2798,0 +LF:966 +LH:261 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/daemon/dlt_daemon_common.c +FN:96,dlt_daemon_cmp_apid +FN:107,dlt_daemon_cmp_apid_ctid +FN:128,dlt_daemon_find_users_list +FN:302,dlt_daemon_init_runtime_configuration +FN:359,dlt_daemon_init +FN:417,dlt_daemon_free +FN:462,dlt_daemon_init_user_information +FN:508,dlt_daemon_applications_invalidate_fd +FN:534,dlt_daemon_applications_clear +FN:576,dlt_daemon_application_reset_user_handle +FN:603,dlt_daemon_application_add +FN:829,dlt_daemon_application_del +FN:881,dlt_daemon_application_find +FN:915,dlt_daemon_applications_load +FN:1007,dlt_daemon_applications_save +FN:1056,dlt_daemon_context_add +FN:1275,dlt_daemon_context_del +FN:1328,dlt_daemon_context_find +FN:1365,dlt_daemon_contexts_invalidate_fd +FN:1391,dlt_daemon_contexts_clear +FN:1425,dlt_daemon_contexts_load +FN:1535,dlt_daemon_contexts_save +FN:1589,dlt_daemon_configuration_save +FN:1610,dlt_daemon_configuration_load +FN:1677,dlt_daemon_user_send_log_level +FN:1738,dlt_daemon_user_send_log_state +FN:1767,dlt_daemon_control_reset_to_factory_default +FN:1823,dlt_daemon_user_send_default_update +FN:1857,dlt_daemon_user_send_all_log_level_update +FN:1913,dlt_daemon_user_send_all_trace_status_update +FN:1949,dlt_daemon_user_send_all_log_state +FN:1978,dlt_daemon_change_state +FNDA:149,dlt_daemon_application_find +FNDA:0,dlt_daemon_user_send_all_trace_status_update +FNDA:0,dlt_daemon_user_send_default_update +FNDA:9,dlt_daemon_user_send_log_state +FNDA:5,dlt_daemon_user_send_all_log_state +FNDA:41,dlt_daemon_context_add +FNDA:6,dlt_daemon_application_del +FNDA:0,dlt_daemon_contexts_save +FNDA:17,dlt_daemon_init +FNDA:10,dlt_daemon_application_add +FNDA:9,dlt_daemon_applications_load +FNDA:10,dlt_daemon_contexts_clear +FNDA:157,dlt_daemon_context_find +FNDA:0,dlt_daemon_cmp_apid +FNDA:9,dlt_daemon_init_runtime_configuration +FNDA:10,dlt_daemon_applications_clear +FNDA:9,dlt_daemon_configuration_load +FNDA:9,dlt_daemon_free +FNDA:0,dlt_daemon_control_reset_to_factory_default +FNDA:0,dlt_daemon_configuration_save +FNDA:471,dlt_daemon_cmp_apid_ctid +FNDA:18,dlt_daemon_init_user_information +FNDA:41,dlt_daemon_user_send_log_level +FNDA:16,dlt_daemon_change_state +FNDA:0,dlt_daemon_user_send_all_log_level_update +FNDA:15,dlt_daemon_application_reset_user_handle +FNDA:474,dlt_daemon_find_users_list +FNDA:0,dlt_daemon_applications_save +FNDA:0,dlt_daemon_contexts_load +FNDA:37,dlt_daemon_context_del +FNDA:15,dlt_daemon_applications_invalidate_fd +FNDA:15,dlt_daemon_contexts_invalidate_fd +FNF:32 +FNH:23 +DA:96,0 +DA:98,132 +DA:104,132 +DA:107,471 +DA:109,471 +DA:116,471 +DA:118,471 +DA:120,471 +DA:121,471 +DA:128,474 +DA:132,474 +DA:136,474 +DA:137,0 +DA:138,0 +DA:141,476 +DA:142,444 +DA:143,442 +DA:145,32 +DA:146,32 +DA:302,9 +DA:304,9 +DA:307,9 +DA:311,9 +DA:313,9 +DA:319,9 +DA:320,0 +DA:321,0 +DA:324,9 +DA:325,9 +DA:328,9 +DA:332,9 +DA:333,0 +DA:334,0 +DA:337,9 +DA:338,9 +DA:341,9 +DA:345,9 +DA:346,0 +DA:347,0 +DA:350,9 +DA:351,9 +DA:354,9 +DA:356,9 +DA:359,17 +DA:369,17 +DA:371,17 +DA:374,17 +DA:375,17 +DA:377,17 +DA:378,17 +DA:379,17 +DA:381,17 +DA:383,17 +DA:385,17 +DA:387,17 +DA:395,17 +DA:396,17 +DA:398,17 +DA:401,17 +DA:404,17 +DA:410,17 +DA:414,17 +DA:417,9 +DA:422,9 +DA:424,9 +DA:428,19 +DA:429,10 +DA:431,10 +DA:433,10 +DA:434,10 +DA:438,9 +DA:453,9 +DA:454,9 +DA:457,9 +DA:459,9 +DA:462,18 +DA:470,18 +DA:472,18 +DA:475,18 +DA:477,17 +DA:479,17 +DA:480,0 +DA:481,0 +DA:484,17 +DA:485,17 +DA:488,1 +DA:491,1 +DA:493,1 +DA:494,0 +DA:495,0 +DA:498,1 +DA:499,1 +DA:501,2 +DA:502,1 +DA:508,15 +DA:516,15 +DA:518,15 +DA:521,15 +DA:523,15 +DA:524,26 +DA:525,11 +DA:526,0 +DA:534,10 +DA:539,10 +DA:541,10 +DA:544,10 +DA:546,10 +DA:549,11 +DA:550,1 +DA:563,1 +DA:564,1 +DA:567,10 +DA:568,7 +DA:570,10 +DA:571,10 +DA:573,10 +DA:576,15 +DA:584,15 +DA:587,6 +DA:588,6 +DA:589,6 +DA:590,0 +DA:591,0 +DA:592,0 +DA:596,6 +DA:597,6 +DA:599,6 +DA:600,6 +DA:603,10 +DA:622,10 +DA:625,10 +DA:627,10 +DA:630,10 +DA:631,10 +DA:632,10 +DA:634,10 +DA:641,10 +DA:643,10 +DA:644,10 +DA:646,10 +DA:647,10 +DA:649,0 +DA:650,0 +DA:651,0 +DA:652,0 +DA:655,0 +DA:656,0 +DA:657,0 +DA:658,0 +DA:661,0 +DA:663,0 +DA:664,0 +DA:668,10 +DA:670,10 +DA:671,10 +DA:672,10 +DA:673,10 +DA:674,10 +DA:675,10 +DA:684,0 +DA:687,0 +DA:695,10 +DA:696,0 +DA:697,0 +DA:700,10 +DA:701,10 +DA:703,10 +DA:704,10 +DA:706,0 +DA:707,0 +DA:708,0 +DA:712,10 +DA:713,9 +DA:714,9 +DA:718,10 +DA:738,9 +DA:739,0 +DA:740,0 +DA:748,9 +DA:749,9 +DA:751,9 +DA:752,9 +DA:753,9 +DA:757,10 +DA:758,10 +DA:759,10 +DA:764,10 +DA:829,6 +DA:837,6 +DA:839,6 +DA:842,6 +DA:844,6 +DA:847,6 +DA:848,6 +DA:851,6 +DA:852,6 +DA:853,6 +DA:863,6 +DA:866,6 +DA:867,6 +DA:868,6 +DA:871,6 +DA:875,6 +DA:881,149 +DA:889,149 +DA:891,149 +DA:892,149 +DA:895,149 +DA:897,149 +DA:901,132 +DA:902,132 +DA:903,132 +DA:907,132 +DA:908,132 +DA:909,132 +DA:910,132 +DA:915,9 +DA:923,9 +DA:925,9 +DA:928,9 +DA:930,9 +DA:931,9 +DA:935,9 +DA:937,9 +DA:940,0 +DA:947,0 +DA:950,0 +DA:951,0 +DA:954,0 +DA:955,0 +DA:956,0 +DA:958,0 +DA:960,0 +DA:961,0 +DA:964,0 +DA:967,0 +DA:968,0 +DA:972,0 +DA:974,0 +DA:976,0 +DA:977,0 +DA:978,0 +DA:980,0 +DA:983,0 +DA:988,0 +DA:990,0 +DA:994,0 +DA:995,0 +DA:1002,0 +DA:1004,0 +DA:1007,0 +DA:1015,0 +DA:1017,0 +DA:1022,0 +DA:1024,0 +DA:1027,0 +DA:1028,0 +DA:1030,0 +DA:1031,0 +DA:1032,0 +DA:1034,0 +DA:1035,0 +DA:1044,0 +DA:1047,0 +DA:1056,41 +DA:1073,41 +DA:1075,41 +DA:1076,41 +DA:1079,41 +DA:1082,41 +DA:1085,41 +DA:1087,41 +DA:1090,41 +DA:1091,10 +DA:1093,10 +DA:1098,41 +DA:1100,41 +DA:1104,41 +DA:1106,41 +DA:1107,41 +DA:1109,41 +DA:1110,41 +DA:1112,0 +DA:1113,0 +DA:1114,0 +DA:1115,0 +DA:1118,0 +DA:1119,0 +DA:1120,0 +DA:1121,0 +DA:1124,0 +DA:1126,0 +DA:1127,0 +DA:1131,41 +DA:1134,41 +DA:1135,41 +DA:1137,41 +DA:1142,41 +DA:1143,0 +DA:1144,0 +DA:1147,41 +DA:1148,41 +DA:1150,41 +DA:1151,41 +DA:1185,41 +DA:1189,0 +DA:1193,0 +DA:1196,0 +DA:1207,41 +DA:1208,0 +DA:1209,41 +DA:1210,41 +DA:1213,41 +DA:1214,41 +DA:1219,41 +DA:1220,0 +DA:1222,41 +DA:1225,41 +DA:1226,41 +DA:1227,41 +DA:1232,41 +DA:1275,37 +DA:1284,37 +DA:1286,37 +DA:1289,37 +DA:1291,37 +DA:1294,37 +DA:1295,37 +DA:1301,37 +DA:1302,37 +DA:1303,37 +DA:1306,37 +DA:1309,37 +DA:1310,37 +DA:1311,37 +DA:1314,37 +DA:1318,37 +DA:1321,37 +DA:1322,37 +DA:1328,157 +DA:1337,157 +DA:1339,157 +DA:1340,157 +DA:1343,157 +DA:1345,157 +DA:1349,112 +DA:1350,112 +DA:1351,112 +DA:1355,112 +DA:1356,112 +DA:1358,112 +DA:1359,112 +DA:1360,112 +DA:1365,15 +DA:1373,15 +DA:1375,15 +DA:1378,15 +DA:1380,15 +DA:1381,39 +DA:1382,24 +DA:1383,0 +DA:1391,10 +DA:1396,10 +DA:1398,10 +DA:1401,10 +DA:1403,10 +DA:1406,11 +DA:1407,1 +DA:1408,1 +DA:1409,1 +DA:1412,10 +DA:1413,7 +DA:1414,7 +DA:1417,11 +DA:1418,1 +DA:1420,10 +DA:1422,10 +DA:1425,0 +DA:1434,0 +DA:1436,0 +DA:1439,0 +DA:1441,0 +DA:1442,0 +DA:1445,0 +DA:1447,0 +DA:1450,0 +DA:1457,0 +DA:1460,0 +DA:1461,0 +DA:1464,0 +DA:1465,0 +DA:1466,0 +DA:1468,0 +DA:1470,0 +DA:1471,0 +DA:1474,0 +DA:1477,0 +DA:1478,0 +DA:1482,0 +DA:1484,0 +DA:1486,0 +DA:1487,0 +DA:1488,0 +DA:1490,0 +DA:1491,0 +DA:1492,0 +DA:1494,0 +DA:1495,0 +DA:1496,0 +DA:1498,0 +DA:1499,0 +DA:1500,0 +DA:1502,0 +DA:1506,0 +DA:1509,0 +DA:1510,0 +DA:1514,0 +DA:1516,0 +DA:1519,0 +DA:1520,0 +DA:1530,0 +DA:1532,0 +DA:1535,0 +DA:1543,0 +DA:1545,0 +DA:1548,0 +DA:1550,0 +DA:1556,0 +DA:1557,0 +DA:1559,0 +DA:1560,0 +DA:1561,0 +DA:1562,0 +DA:1564,0 +DA:1565,0 +DA:1566,0 +DA:1567,0 +DA:1568,0 +DA:1571,0 +DA:1572,0 +DA:1573,0 +DA:1576,0 +DA:1579,0 +DA:1589,0 +DA:1593,0 +DA:1595,0 +DA:1598,0 +DA:1600,0 +DA:1602,0 +DA:1604,0 +DA:1610,9 +DA:1612,9 +DA:1621,9 +DA:1623,9 +DA:1625,9 +DA:1628,18 +DA:1629,9 +DA:1630,9 +DA:1631,9 +DA:1633,18 +DA:1634,9 +DA:1637,9 +DA:1639,9 +DA:1643,0 +DA:1644,0 +DA:1647,9 +DA:1650,9 +DA:1652,0 +DA:1653,0 +DA:1654,0 +DA:1658,0 +DA:1668,9 +DA:1671,0 +DA:1677,41 +DA:1684,41 +DA:1686,41 +DA:1687,0 +DA:1688,0 +DA:1691,41 +DA:1692,0 +DA:1693,0 +DA:1696,41 +DA:1697,34 +DA:1698,32 +DA:1701,9 +DA:1702,9 +DA:1704,41 +DA:1705,41 +DA:1707,41 +DA:1709,41 +DA:1710,41 +DA:1711,41 +DA:1712,41 +DA:1713,41 +DA:1718,41 +DA:1719,41 +DA:1723,41 +DA:1724,0 +DA:1726,0 +DA:1728,0 +DA:1729,0 +DA:1730,0 +DA:1731,0 +DA:1735,41 +DA:1738,9 +DA:1744,9 +DA:1746,9 +DA:1749,9 +DA:1752,9 +DA:1755,9 +DA:1759,9 +DA:1760,0 +DA:1761,0 +DA:1764,9 +DA:1767,0 +DA:1777,0 +DA:1779,0 +DA:1780,0 +DA:1781,0 +DA:1784,0 +DA:1785,0 +DA:1786,0 +DA:1790,0 +DA:1792,0 +DA:1794,0 +DA:1795,0 +DA:1796,0 +DA:1797,0 +DA:1801,0 +DA:1803,0 +DA:1805,0 +DA:1806,0 +DA:1807,0 +DA:1808,0 +DA:1812,0 +DA:1813,0 +DA:1814,0 +DA:1820,0 +DA:1823,0 +DA:1829,0 +DA:1831,0 +DA:1832,0 +DA:1833,0 +DA:1836,0 +DA:1838,0 +DA:1841,0 +DA:1842,0 +DA:1844,0 +DA:1845,0 +DA:1846,0 +DA:1847,0 +DA:1848,0 +DA:1851,0 +DA:1857,0 +DA:1867,0 +DA:1869,0 +DA:1872,0 +DA:1874,0 +DA:1877,0 +DA:1878,0 +DA:1880,0 +DA:1881,0 +DA:1882,0 +DA:1884,0 +DA:1895,0 +DA:1896,0 +DA:1900,0 +DA:1903,0 +DA:1905,0 +DA:1906,0 +DA:1907,0 +DA:1913,0 +DA:1919,0 +DA:1921,0 +DA:1924,0 +DA:1926,0 +DA:1929,0 +DA:1931,0 +DA:1932,0 +DA:1934,0 +DA:1935,0 +DA:1936,0 +DA:1938,0 +DA:1939,0 +DA:1941,0 +DA:1942,0 +DA:1943,0 +DA:1949,5 +DA:1955,5 +DA:1957,5 +DA:1958,0 +DA:1959,0 +DA:1962,5 +DA:1964,5 +DA:1967,7 +DA:1968,2 +DA:1970,2 +DA:1971,2 +DA:1972,2 +DA:1973,0 +DA:1978,16 +DA:1980,16 +DA:1981,0 +DA:1982,0 +DA:1983,0 +DA:1984,0 +DA:1985,12 +DA:1986,12 +DA:1987,12 +DA:1988,12 +DA:1989,0 +DA:1990,0 +DA:1991,0 +DA:1992,0 +DA:1993,2 +DA:1994,2 +DA:1995,2 +DA:1996,2 +DA:1997,2 +DA:1998,2 +DA:1999,2 +DA:2000,2 +DA:2002,16 +LF:623 +LH:351 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/daemon/dlt_daemon_connection.c +FN:69,dlt_connection_send +FN:111,dlt_connection_send_multiple +FN:149,dlt_connection_get_next +FN:157,dlt_connection_destroy_receiver +FN:193,dlt_connection_get_receiver +FN:280,dlt_connection_get_callback +FN:345,dlt_connection_destroy +FN:368,dlt_connection_create +FNDA:48,dlt_connection_destroy +FNDA:1557,dlt_connection_get_callback +FNDA:49,dlt_connection_destroy_receiver +FNDA:219,dlt_connection_send_multiple +FNDA:2,dlt_connection_get_next +FNDA:48,dlt_connection_get_receiver +FNDA:436,dlt_connection_send +FNDA:47,dlt_connection_create +FNF:8 +FNH:8 +DA:69,436 +DA:76,436 +DA:77,436 +DA:79,436 +DA:80,1 +DA:82,1 +DA:83,1 +DA:87,434 +DA:88,434 +DA:91,434 +DA:111,219 +DA:120,219 +DA:123,218 +DA:124,1 +DA:128,218 +DA:129,218 +DA:131,218 +DA:132,214 +DA:149,2 +DA:151,3 +DA:152,1 +DA:154,2 +DA:157,49 +DA:159,49 +DA:162,49 +DA:166,9 +DA:167,9 +DA:168,9 +DA:169,9 +DA:170,9 +DA:171,36 +DA:172,36 +DA:173,36 +DA:174,36 +DA:175,36 +DA:193,48 +DA:201,48 +DA:202,25 +DA:209,25 +DA:211,25 +DA:212,25 +DA:215,1 +DA:216,1 +DA:218,1 +DA:219,1 +DA:222,9 +DA:223,9 +DA:227,9 +DA:228,9 +DA:231,0 +DA:235,9 +DA:236,9 +DA:243,10 +DA:252,10 +DA:254,10 +DA:255,10 +DA:258,3 +DA:260,3 +DA:261,3 +DA:266,48 +DA:280,1557 +DA:285,1557 +DA:286,1557 +DA:288,1557 +DA:292,11 +DA:294,11 +DA:295,0 +DA:297,0 +DA:303,1523 +DA:305,1523 +DA:306,11 +DA:308,11 +DA:309,0 +DA:311,0 +DA:317,2 +DA:319,2 +DA:320,4 +DA:322,4 +DA:323,2 +DA:325,2 +DA:326,0 +DA:328,0 +DA:329,0 +DA:333,1557 +DA:345,48 +DA:347,48 +DA:348,48 +DA:349,48 +DA:350,48 +DA:351,48 +DA:368,47 +DA:376,47 +DA:380,47 +DA:388,47 +DA:390,47 +DA:391,0 +DA:392,0 +DA:397,47 +DA:399,47 +DA:400,0 +DA:402,0 +DA:403,0 +DA:407,47 +DA:408,47 +DA:417,47 +DA:418,20 +DA:421,20 +DA:422,1 +DA:423,1 +DA:428,46 +DA:430,46 +DA:432,10 +DA:434,46 +DA:435,46 +DA:440,46 +LF:115 +LH:102 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/daemon/dlt_daemon_event_handler.c +FN:79,dlt_daemon_prepare_event_handling +FN:111,dlt_event_handler_enable_fd +FN:144,dlt_event_handler_disable_fd +FN:184,dlt_daemon_handle_event +FN:289,dlt_event_handler_find_connection +FN:312,dlt_daemon_remove_connection +FN:352,dlt_event_handler_cleanup_connections +FN:377,dlt_daemon_add_connection +FN:402,dlt_connection_check_activate +FN:463,dlt_event_handler_register_connection +FN:504,dlt_event_handler_unregister_connection +FNDA:10,dlt_event_handler_cleanup_connections +FNDA:1122,dlt_event_handler_find_connection +FNDA:1570,dlt_daemon_handle_event +FNDA:47,dlt_daemon_remove_connection +FNDA:7,dlt_event_handler_disable_fd +FNDA:7,dlt_event_handler_unregister_connection +FNDA:16,dlt_daemon_prepare_event_handling +FNDA:49,dlt_event_handler_enable_fd +FNDA:6,dlt_daemon_add_connection +FNDA:57,dlt_connection_check_activate +FNDA:49,dlt_event_handler_register_connection +FNF:11 +FNH:11 +DA:66,293 +DA:67,293 +DA:68,293 +DA:69,7 +DA:79,16 +DA:83,16 +DA:86,15 +DA:88,15 +DA:89,0 +DA:90,0 +DA:93,255 +DA:94,240 +DA:96,15 +DA:97,15 +DA:99,15 +DA:111,49 +DA:113,49 +DA:114,2 +DA:115,2 +DA:116,2 +DA:118,2 +DA:119,0 +DA:121,0 +DA:124,2 +DA:125,2 +DA:127,2 +DA:128,0 +DA:131,49 +DA:132,49 +DA:133,49 +DA:144,7 +DA:148,7 +DA:150,36 +DA:151,29 +DA:153,7 +DA:154,7 +DA:157,29 +DA:158,22 +DA:161,7 +DA:162,0 +DA:163,0 +DA:164,0 +DA:170,7 +DA:184,1570 +DA:192,1570 +DA:195,1569 +DA:197,1569 +DA:201,10 +DA:204,1 +DA:205,0 +DA:207,10 +DA:214,8044 +DA:219,6485 +DA:220,4926 +DA:222,1559 +DA:224,1559 +DA:225,1559 +DA:226,1559 +DA:229,0 +DA:230,0 +DA:234,1559 +DA:237,2 +DA:242,2 +DA:244,0 +DA:248,2 +DA:252,1557 +DA:254,1557 +DA:255,0 +DA:258,0 +DA:262,1557 +DA:266,0 +DA:268,0 +DA:289,1122 +DA:291,2686 +DA:293,5077 +DA:294,5029 +DA:295,1074 +DA:296,2391 +DA:312,47 +DA:315,47 +DA:318,47 +DA:322,70 +DA:324,23 +DA:327,47 +DA:329,0 +DA:330,0 +DA:332,47 +DA:334,41 +DA:337,6 +DA:341,47 +DA:343,47 +DA:352,10 +DA:356,10 +DA:360,50 +DA:362,40 +DA:364,49 +DA:365,39 +DA:367,10 +DA:377,6 +DA:381,50 +DA:383,143 +DA:384,93 +DA:386,50 +DA:387,6 +DA:402,57 +DA:406,57 +DA:407,1 +DA:408,1 +DA:411,56 +DA:412,7 +DA:414,7 +DA:415,7 +DA:417,7 +DA:419,7 +DA:420,0 +DA:422,7 +DA:426,49 +DA:428,49 +DA:429,49 +DA:431,49 +DA:432,49 +DA:435,49 +DA:439,0 +DA:440,0 +DA:441,0 +DA:463,49 +DA:468,49 +DA:469,1 +DA:470,1 +DA:473,4 +DA:475,48 +DA:477,4 +DA:480,48 +DA:482,48 +DA:483,48 +DA:485,48 +DA:504,7 +DA:508,7 +DA:514,2 +DA:516,7 +DA:517,1 +DA:518,1 +DA:521,6 +DA:523,3 +DA:525,3 +DA:526,0 +DA:527,0 +DA:531,6 +DA:534,0 +DA:537,6 +LF:150 +LH:125 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/daemon/dlt_daemon_offline_logstorage.c +FN:43,dlt_logstorage_split_ecuid +FN:71,dlt_logstorage_split_ctid +FN:96,dlt_logstorage_split_apid +FN:121,dlt_logstorage_split_apid_ctid +FN:161,dlt_logstorage_split_ecuid_apid +FN:205,dlt_logstorage_split_multi +FN:263,dlt_logstorage_split_key +FN:309,dlt_daemon_logstorage_update_passive_node_context +FN:371,dlt_daemon_logstorage_send_log_level +FN:433,dlt_daemon_logstorage_reset_log_level +FN:485,dlt_daemon_logstorage_force_reset_level +FN:547,dlt_logstorage_update_all_contexts +FN:618,dlt_logstorage_update_context +FN:691,dlt_logstorage_update_context_loglevel +FN:786,dlt_daemon_logstorage_reset_application_loglevel +FN:873,dlt_daemon_logstorage_update_application_loglevel +FN:946,dlt_daemon_logstorage_get_loglevel +FN:1014,dlt_daemon_logstorage_write +FN:1093,dlt_daemon_logstorage_setup_internal_storage +FN:1133,dlt_daemon_logstorage_set_logstorage_cache_size +FN:1139,dlt_daemon_logstorage_cleanup +FN:1174,dlt_daemon_logstorage_sync_cache +FN:1236,dlt_daemon_logstorage_get_device +FNDA:0,dlt_logstorage_split_ecuid +FNDA:10,dlt_daemon_logstorage_set_logstorage_cache_size +FNDA:0,dlt_daemon_logstorage_force_reset_level +FNDA:2,dlt_daemon_logstorage_reset_application_loglevel +FNDA:2,dlt_daemon_logstorage_send_log_level +FNDA:5,dlt_daemon_logstorage_get_device +FNDA:1,dlt_logstorage_split_apid +FNDA:37,dlt_logstorage_update_context_loglevel +FNDA:8,dlt_daemon_logstorage_setup_internal_storage +FNDA:42,dlt_logstorage_split_key +FNDA:8,dlt_daemon_logstorage_cleanup +FNDA:38,dlt_logstorage_update_context +FNDA:0,dlt_logstorage_split_ctid +FNDA:34,dlt_logstorage_split_multi +FNDA:1,dlt_logstorage_split_apid_ctid +FNDA:0,dlt_daemon_logstorage_update_passive_node_context +FNDA:4,dlt_daemon_logstorage_sync_cache +FNDA:1,dlt_logstorage_split_ecuid_apid +FNDA:1,dlt_daemon_logstorage_reset_log_level +FNDA:5841,dlt_daemon_logstorage_write +FNDA:10,dlt_daemon_logstorage_update_application_loglevel +FNDA:4,dlt_logstorage_update_all_contexts +FNDA:35,dlt_daemon_logstorage_get_loglevel +FNF:23 +FNH:19 +DA:43,0 +DA:49,0 +DA:52,0 +DA:56,0 +DA:71,0 +DA:76,0 +DA:79,0 +DA:82,0 +DA:96,1 +DA:101,1 +DA:104,1 +DA:107,1 +DA:121,1 +DA:128,1 +DA:132,1 +DA:134,1 +DA:139,1 +DA:141,1 +DA:146,1 +DA:161,1 +DA:169,1 +DA:173,1 +DA:175,1 +DA:180,1 +DA:182,1 +DA:189,1 +DA:205,34 +DA:213,34 +DA:216,34 +DA:218,34 +DA:221,34 +DA:223,34 +DA:226,0 +DA:228,0 +DA:235,34 +DA:237,34 +DA:240,34 +DA:242,34 +DA:263,42 +DA:269,42 +DA:272,37 +DA:274,37 +DA:276,37 +DA:280,37 +DA:281,0 +DA:283,37 +DA:284,0 +DA:286,37 +DA:287,1 +DA:289,36 +DA:290,1 +DA:292,35 +DA:293,1 +DA:296,34 +DA:309,0 +DA:317,0 +DA:318,0 +DA:321,0 +DA:323,0 +DA:324,0 +DA:325,0 +DA:326,0 +DA:329,0 +DA:331,0 +DA:332,0 +DA:335,0 +DA:338,0 +DA:339,0 +DA:341,0 +DA:342,0 +DA:344,0 +DA:346,0 +DA:347,0 +DA:351,0 +DA:371,2 +DA:381,2 +DA:382,2 +DA:383,0 +DA:384,0 +DA:387,2 +DA:388,2 +DA:390,2 +DA:393,2 +DA:394,2 +DA:395,0 +DA:396,0 +DA:402,0 +DA:404,0 +DA:406,0 +DA:407,0 +DA:408,0 +DA:409,0 +DA:433,1 +DA:440,1 +DA:441,1 +DA:442,0 +DA:443,0 +DA:447,1 +DA:449,1 +DA:450,1 +DA:451,1 +DA:454,0 +DA:455,0 +DA:459,0 +DA:460,0 +DA:461,0 +DA:485,0 +DA:496,0 +DA:498,0 +DA:499,0 +DA:500,0 +DA:501,0 +DA:504,0 +DA:505,0 +DA:507,0 +DA:511,0 +DA:512,0 +DA:515,0 +DA:518,0 +DA:519,0 +DA:521,0 +DA:523,0 +DA:547,4 +DA:557,4 +DA:559,4 +DA:560,3 +DA:562,1 +DA:563,1 +DA:566,3 +DA:568,3 +DA:571,3 +DA:572,0 +DA:573,0 +DA:574,0 +DA:575,0 +DA:578,0 +DA:580,0 +DA:581,0 +DA:582,0 +DA:584,0 +DA:589,0 +DA:591,0 +DA:618,38 +DA:628,38 +DA:629,37 +DA:630,1 +DA:631,1 +DA:634,37 +DA:636,37 +DA:637,3 +DA:638,2 +DA:645,1 +DA:653,34 +DA:656,0 +DA:665,34 +DA:671,34 +DA:691,37 +DA:698,37 +DA:699,37 +DA:700,37 +DA:702,37 +DA:704,37 +DA:707,36 +DA:708,0 +DA:710,0 +DA:713,36 +DA:714,2 +DA:717,36 +DA:720,0 +DA:727,0 +DA:729,36 +DA:732,1 +DA:739,0 +DA:742,35 +DA:746,0 +DA:753,0 +DA:757,35 +DA:765,34 +DA:786,2 +DA:795,2 +DA:799,2 +DA:801,2 +DA:802,1 +DA:803,2 +DA:806,2 +DA:809,0 +DA:811,0 +DA:812,0 +DA:817,0 +DA:818,0 +DA:820,0 +DA:824,0 +DA:825,0 +DA:833,0 +DA:840,0 +DA:844,0 +DA:845,0 +DA:847,0 +DA:848,0 +DA:850,0 +DA:851,0 +DA:873,10 +DA:880,10 +DA:884,10 +DA:886,10 +DA:888,1 +DA:891,1 +DA:894,9 +DA:896,9 +DA:897,9 +DA:902,9 +DA:903,44 +DA:905,70 +DA:909,35 +DA:910,35 +DA:914,35 +DA:915,35 +DA:917,0 +DA:918,0 +DA:922,35 +DA:928,35 +DA:946,35 +DA:951,35 +DA:958,35 +DA:961,68 +DA:962,34 +DA:964,34 +DA:968,34 +DA:970,34 +DA:971,1 +DA:972,1 +DA:975,66 +DA:977,33 +DA:978,0 +DA:982,33 +DA:983,0 +DA:984,0 +DA:987,33 +DA:988,33 +DA:994,34 +DA:1014,5841 +DA:1027,5841 +DA:1028,5840 +DA:1029,5840 +DA:1030,1 +DA:1033,1 +DA:1038,5840 +DA:1039,5840 +DA:1040,5840 +DA:1041,5840 +DA:1042,5840 +DA:1043,5840 +DA:1045,11680 +DA:1046,5840 +DA:1048,5840 +DA:1049,5840 +DA:1058,0 +DA:1063,0 +DA:1064,0 +DA:1067,5840 +DA:1068,5840 +DA:1072,0 +DA:1093,8 +DA:1100,8 +DA:1102,8 +DA:1107,7 +DA:1109,7 +DA:1110,0 +DA:1111,0 +DA:1115,7 +DA:1120,7 +DA:1122,0 +DA:1125,0 +DA:1133,10 +DA:1136,10 +DA:1137,10 +DA:1139,8 +DA:1145,8 +DA:1147,8 +DA:1150,14 +DA:1152,7 +DA:1155,6 +DA:1156,6 +DA:1157,6 +DA:1158,6 +DA:1159,6 +DA:1160,6 +DA:1161,6 +DA:1162,6 +DA:1163,6 +DA:1164,6 +DA:1166,6 +DA:1174,4 +DA:1182,4 +DA:1184,4 +DA:1187,3 +DA:1188,3 +DA:1193,3 +DA:1197,3 +DA:1198,3 +DA:1199,3 +DA:1200,3 +DA:1201,3 +DA:1202,3 +DA:1203,3 +DA:1204,3 +DA:1205,3 +DA:1206,3 +DA:1208,3 +DA:1209,0 +DA:1214,0 +DA:1215,0 +DA:1217,0 +DA:1218,0 +DA:1219,0 +DA:1220,0 +DA:1221,0 +DA:1222,0 +DA:1223,0 +DA:1224,0 +DA:1225,0 +DA:1226,0 +DA:1228,0 +DA:1236,5 +DA:1246,5 +DA:1248,5 +DA:1251,4 +DA:1253,4 +DA:1254,4 +DA:1259,4 +DA:1261,4 +DA:1262,4 +LF:332 +LH:205 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/daemon/dlt_daemon_serial.c +FN:69,dlt_daemon_serial_send +FNDA:0,dlt_daemon_serial_send +FNF:1 +FNH:0 +DA:69,0 +DA:77,0 +DA:78,0 +DA:85,0 +DA:86,0 +DA:91,0 +DA:92,0 +DA:93,0 +LF:8 +LH:0 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/daemon/dlt_daemon_socket.c +FN:63,dlt_daemon_socket_open +FN:163,dlt_daemon_socket_close +FN:170,dlt_daemon_socket_send +FN:206,dlt_daemon_socket_get_send_qeue_max_size +FN:219,dlt_daemon_socket_sendreliable +FNDA:466,dlt_daemon_socket_sendreliable +FNDA:0,dlt_daemon_socket_close +FNDA:16,dlt_daemon_socket_send +FNDA:9,dlt_daemon_socket_open +FNDA:9,dlt_daemon_socket_get_send_qeue_max_size +FNF:5 +FNH:4 +DA:63,9 +DA:65,9 +DA:72,9 +DA:73,0 +DA:74,0 +DA:76,0 +DA:90,9 +DA:93,9 +DA:94,0 +DA:95,0 +DA:100,0 +DA:107,9 +DA:108,9 +DA:110,9 +DA:111,9 +DA:113,0 +DA:125,0 +DA:126,0 +DA:127,0 +DA:133,0 +DA:136,9 +DA:137,0 +DA:138,0 +DA:139,0 +DA:141,0 +DA:145,9 +DA:148,9 +DA:151,9 +DA:152,0 +DA:153,0 +DA:157,0 +DA:163,0 +DA:165,0 +DA:167,0 +DA:170,16 +DA:180,16 +DA:181,0 +DA:185,0 +DA:191,16 +DA:192,16 +DA:194,16 +DA:199,16 +DA:200,16 +DA:206,9 +DA:208,9 +DA:209,9 +DA:210,9 +DA:211,0 +DA:213,0 +DA:216,9 +DA:219,466 +DA:223,932 +DA:224,466 +DA:226,466 +DA:229,466 +DA:230,0 +DA:231,0 +DA:240,0 +DA:242,466 +LF:59 +LH:31 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/daemon/dlt_daemon_unix_socket.c +FN:87,dlt_daemon_unix_socket_open +FN:179,dlt_daemon_unix_socket_close +FNDA:9,dlt_daemon_unix_socket_open +FNDA:0,dlt_daemon_unix_socket_close +FNF:2 +FNH:1 +DA:87,9 +DA:92,9 +DA:93,0 +DA:94,0 +DA:139,9 +DA:140,0 +DA:141,0 +DA:145,9 +DA:148,9 +DA:149,8 +DA:150,8 +DA:154,9 +DA:156,9 +DA:157,0 +DA:158,0 +DA:159,0 +DA:162,9 +DA:163,0 +DA:164,0 +DA:165,0 +DA:169,9 +DA:176,9 +DA:179,0 +DA:181,0 +DA:183,0 +DA:184,0 +DA:187,0 +LF:27 +LH:12 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/gateway/dlt_gateway.c +FN:58,dlt_gateway_check_ip +FN:99,dlt_gateway_check_port +FN:137,dlt_gateway_check_ecu +FN:160,dlt_gateway_check_connect_trigger +FN:191,dlt_gateway_check_timeout +FN:215,dlt_gateway_check_interval +FN:238,dlt_gateway_check_send_serial +FN:257,dlt_gateway_allocate_control_messages +FN:295,dlt_gateway_check_control_messages +FN:362,dlt_gateway_check_periodic_control_messages +FN:542,dlt_gateway_check_general_param +FN:566,dlt_gateway_check_param +FN:590,dlt_gateway_store_connection +FN:658,dlt_gateway_configure +FN:832,dlt_gateway_init +FN:866,dlt_gateway_deinit +FN:905,dlt_gateway_add_to_event_loop +FN:962,dlt_gateway_establish_connections +FN:1052,dlt_gateway_get_connection_receiver +FN:1081,dlt_gateway_parse_get_log_info +FN:1207,dlt_gateway_parse_get_default_log_level +FN:1256,dlt_gateway_control_service_logstorage +FN:1283,dlt_gateway_process_passive_node_messages +FN:1496,dlt_gateway_process_gateway_timer +FN:1533,dlt_gateway_forward_control_message +FN:1611,dlt_gateway_process_on_demand_request +FN:1679,dlt_gateway_send_control_message +FN:1758,dlt_gateway_get_connection +FNDA:7,dlt_gateway_check_ip +FNDA:1,dlt_gateway_control_service_logstorage +FNDA:17,dlt_gateway_allocate_control_messages +FNDA:2,dlt_gateway_process_gateway_timer +FNDA:32,dlt_gateway_check_param +FNDA:0,dlt_gateway_forward_control_message +FNDA:6,dlt_gateway_check_ecu +FNDA:5,dlt_gateway_configure +FNDA:12,dlt_gateway_send_control_message +FNDA:9,dlt_gateway_check_port +FNDA:7,dlt_gateway_check_connect_trigger +FNDA:6,dlt_gateway_establish_connections +FNDA:3,dlt_gateway_parse_get_log_info +FNDA:2,dlt_gateway_check_periodic_control_messages +FNDA:6,dlt_gateway_check_send_serial +FNDA:10,dlt_gateway_deinit +FNDA:7,dlt_gateway_store_connection +FNDA:4,dlt_gateway_process_passive_node_messages +FNDA:4,dlt_gateway_init +FNDA:0,dlt_gateway_parse_get_default_log_level +FNDA:6,dlt_gateway_get_connection_receiver +FNDA:0,dlt_gateway_get_connection +FNDA:6,dlt_gateway_check_control_messages +FNDA:3,dlt_gateway_add_to_event_loop +FNDA:0,dlt_gateway_check_interval +FNDA:0,dlt_gateway_check_general_param +FNDA:7,dlt_gateway_check_timeout +FNDA:3,dlt_gateway_process_on_demand_request +FNF:28 +FNH:23 +DA:58,7 +DA:60,7 +DA:61,1 +DA:62,1 +DA:68,6 +DA:75,6 +DA:76,6 +DA:78,6 +DA:79,0 +DA:80,0 +DA:86,0 +DA:89,0 +DA:99,9 +DA:104,9 +DA:105,1 +DA:106,1 +DA:109,8 +DA:110,8 +DA:111,8 +DA:112,8 +DA:113,0 +DA:114,0 +DA:118,8 +DA:120,6 +DA:121,6 +DA:124,2 +DA:127,2 +DA:137,6 +DA:140,6 +DA:141,1 +DA:142,1 +DA:145,5 +DA:147,5 +DA:148,0 +DA:160,7 +DA:163,7 +DA:164,1 +DA:165,1 +DA:168,6 +DA:169,5 +DA:171,1 +DA:173,0 +DA:176,1 +DA:177,1 +DA:178,1 +DA:191,7 +DA:194,7 +DA:195,1 +DA:196,1 +DA:199,6 +DA:202,6 +DA:203,5 +DA:215,0 +DA:218,0 +DA:219,0 +DA:220,0 +DA:223,0 +DA:225,0 +DA:226,0 +DA:238,6 +DA:241,6 +DA:242,1 +DA:243,1 +DA:246,5 +DA:248,5 +DA:257,17 +DA:259,17 +DA:260,1 +DA:261,1 +DA:264,16 +DA:265,7 +DA:267,7 +DA:268,0 +DA:270,0 +DA:274,9 +DA:276,9 +DA:277,0 +DA:279,0 +DA:282,9 +DA:295,6 +DA:300,6 +DA:303,6 +DA:304,1 +DA:305,1 +DA:308,5 +DA:312,5 +DA:314,18 +DA:315,13 +DA:316,0 +DA:318,0 +DA:321,13 +DA:322,13 +DA:323,13 +DA:324,13 +DA:325,13 +DA:327,13 +DA:330,13 +DA:331,0 +DA:334,0 +DA:336,13 +DA:339,0 +DA:342,0 +DA:345,13 +DA:349,5 +DA:350,5 +DA:352,5 +DA:362,2 +DA:367,2 +DA:370,2 +DA:371,1 +DA:372,1 +DA:375,1 +DA:379,1 +DA:382,1 +DA:384,3 +DA:386,2 +DA:389,2 +DA:391,2 +DA:392,2 +DA:395,2 +DA:398,3 +DA:399,1 +DA:400,0 +DA:401,0 +DA:403,0 +DA:404,0 +DA:412,1 +DA:416,2 +DA:418,2 +DA:421,2 +DA:422,1 +DA:425,0 +DA:428,2 +DA:429,0 +DA:431,0 +DA:434,2 +DA:435,2 +DA:436,2 +DA:437,2 +DA:438,2 +DA:440,2 +DA:441,0 +DA:446,2 +DA:447,1 +DA:451,2 +DA:452,0 +DA:455,0 +DA:457,2 +DA:460,0 +DA:463,0 +DA:466,2 +DA:470,1 +DA:471,1 +DA:473,1 +DA:542,0 +DA:546,0 +DA:547,0 +DA:548,0 +DA:551,0 +DA:552,0 +DA:566,32 +DA:571,32 +DA:572,1 +DA:573,1 +DA:576,31 +DA:577,31 +DA:590,7 +DA:596,7 +DA:598,7 +DA:599,2 +DA:600,2 +DA:604,5 +DA:605,5 +DA:608,0 +DA:612,5 +DA:613,5 +DA:614,5 +DA:615,5 +DA:616,5 +DA:617,5 +DA:618,5 +DA:619,5 +DA:620,5 +DA:621,5 +DA:622,5 +DA:623,5 +DA:624,5 +DA:626,5 +DA:629,0 +DA:630,0 +DA:631,0 +DA:632,0 +DA:633,0 +DA:634,0 +DA:635,0 +DA:636,0 +DA:640,5 +DA:641,5 +DA:642,0 +DA:644,0 +DA:658,5 +DA:663,5 +DA:665,5 +DA:667,5 +DA:668,1 +DA:669,1 +DA:673,4 +DA:674,4 +DA:679,4 +DA:680,4 +DA:681,0 +DA:682,0 +DA:683,0 +DA:686,4 +DA:687,4 +DA:692,4 +DA:693,4 +DA:702,0 +DA:705,4 +DA:708,4 +DA:709,0 +DA:710,0 +DA:711,0 +DA:714,8 +DA:719,4 +DA:720,4 +DA:725,4 +DA:726,4 +DA:728,4 +DA:729,4 +DA:730,0 +DA:731,0 +DA:734,4 +DA:736,0 +DA:737,0 +DA:739,0 +DA:742,0 +DA:744,0 +DA:747,0 +DA:749,0 +DA:751,0 +DA:754,0 +DA:758,0 +DA:760,0 +DA:761,0 +DA:767,36 +DA:768,32 +DA:770,32 +DA:773,32 +DA:775,4 +DA:778,4 +DA:780,28 +DA:782,0 +DA:786,0 +DA:790,28 +DA:792,28 +DA:793,0 +DA:799,4 +DA:803,4 +DA:804,0 +DA:810,4 +DA:812,4 +DA:813,0 +DA:818,4 +DA:819,4 +DA:820,4 +DA:822,4 +DA:823,4 +DA:828,4 +DA:829,4 +DA:832,4 +DA:834,4 +DA:836,4 +DA:837,1 +DA:838,1 +DA:841,3 +DA:845,3 +DA:846,3 +DA:848,3 +DA:849,3 +DA:851,0 +DA:852,0 +DA:861,3 +DA:863,3 +DA:866,10 +DA:871,10 +DA:872,0 +DA:873,0 +DA:876,10 +DA:878,12 +DA:879,2 +DA:880,2 +DA:881,2 +DA:882,2 +DA:883,2 +DA:884,2 +DA:886,6 +DA:887,4 +DA:888,4 +DA:889,4 +DA:893,10 +DA:894,10 +DA:905,3 +DA:912,3 +DA:913,0 +DA:914,0 +DA:918,3 +DA:919,3 +DA:920,3 +DA:921,3 +DA:924,3 +DA:929,0 +DA:930,0 +DA:934,3 +DA:936,9 +DA:937,6 +DA:939,6 +DA:943,6 +DA:947,6 +DA:948,0 +DA:949,0 +DA:950,0 +DA:952,6 +DA:956,3 +DA:957,3 +DA:959,3 +DA:962,6 +DA:969,6 +DA:971,6 +DA:972,1 +DA:973,1 +DA:976,10 +DA:977,5 +DA:980,5 +DA:981,5 +DA:983,5 +DA:985,5 +DA:987,3 +DA:988,0 +DA:989,0 +DA:993,2 +DA:996,2 +DA:998,2 +DA:999,0 +DA:1000,0 +DA:1001,0 +DA:1006,2 +DA:1007,2 +DA:1011,0 +DA:1012,0 +DA:1015,0 +DA:1020,0 +DA:1021,0 +DA:1025,0 +DA:1027,0 +DA:1028,0 +DA:1030,0 +DA:1034,0 +DA:1037,0 +DA:1041,0 +DA:1042,0 +DA:1044,0 +DA:1045,0 +DA:1052,6 +DA:1056,6 +DA:1057,1 +DA:1058,1 +DA:1061,6 +DA:1062,5 +DA:1064,5 +DA:1065,4 +DA:1081,3 +DA:1087,3 +DA:1094,3 +DA:1096,3 +DA:1097,1 +DA:1098,1 +DA:1101,2 +DA:1105,1 +DA:1107,0 +DA:1108,0 +DA:1109,0 +DA:1113,0 +DA:1114,0 +DA:1115,0 +DA:1120,1 +DA:1124,0 +DA:1125,0 +DA:1129,1 +DA:1131,1 +DA:1132,0 +DA:1134,0 +DA:1137,1 +DA:1138,0 +DA:1139,0 +DA:1140,0 +DA:1143,1 +DA:1144,0 +DA:1145,0 +DA:1146,0 +DA:1149,2 +DA:1150,1 +DA:1153,1 +DA:1160,0 +DA:1163,0 +DA:1164,0 +DA:1167,2 +DA:1168,1 +DA:1171,1 +DA:1174,1 +DA:1175,1 +DA:1181,0 +DA:1185,0 +DA:1186,0 +DA:1192,1 +DA:1194,1 +DA:1207,0 +DA:1216,0 +DA:1218,0 +DA:1219,0 +DA:1220,0 +DA:1223,0 +DA:1225,0 +DA:1226,0 +DA:1230,0 +DA:1232,0 +DA:1236,0 +DA:1237,0 +DA:1240,0 +DA:1243,0 +DA:1245,0 +DA:1256,1 +DA:1263,1 +DA:1264,1 +DA:1266,1 +DA:1269,0 +DA:1270,0 +DA:1272,0 +DA:1274,0 +DA:1283,4 +DA:1291,4 +DA:1294,4 +DA:1295,1 +DA:1296,1 +DA:1299,3 +DA:1308,3 +DA:1309,3 +DA:1314,3 +DA:1315,0 +DA:1316,0 +DA:1320,3 +DA:1321,0 +DA:1323,0 +DA:1327,3 +DA:1329,1 +DA:1330,0 +DA:1331,0 +DA:1334,1 +DA:1336,1 +DA:1337,1 +DA:1338,1 +DA:1339,1 +DA:1342,0 +DA:1344,0 +DA:1347,0 +DA:1350,1 +DA:1353,13 +DA:1354,13 +DA:1355,13 +DA:1357,13 +DA:1364,11 +DA:1367,11 +DA:1369,11 +DA:1377,11 +DA:1378,11 +DA:1381,11 +DA:1382,1 +DA:1383,1 +DA:1384,1 +DA:1387,1 +DA:1389,1 +DA:1392,1 +DA:1397,1 +DA:1398,1 +DA:1401,0 +DA:1404,10 +DA:1406,0 +DA:1412,0 +DA:1417,11 +DA:1419,0 +DA:1420,0 +DA:1423,11 +DA:1429,11 +DA:1430,11 +DA:1434,0 +DA:1442,0 +DA:1443,0 +DA:1445,0 +DA:1449,0 +DA:1451,0 +DA:1460,11 +DA:1461,0 +DA:1462,0 +DA:1463,0 +DA:1464,0 +DA:1467,0 +DA:1468,0 +DA:1471,11 +DA:1472,11 +DA:1473,11 +DA:1476,0 +DA:1477,0 +DA:1481,2 +DA:1482,0 +DA:1484,2 +DA:1486,0 +DA:1487,0 +DA:1490,2 +DA:1491,0 +DA:1496,2 +DA:1501,2 +DA:1504,2 +DA:1506,2 +DA:1507,1 +DA:1510,1 +DA:1513,1 +DA:1515,1 +DA:1516,1 +DA:1519,1 +DA:1524,1 +DA:1528,1 +DA:1530,1 +DA:1533,0 +DA:1545,0 +DA:1547,0 +DA:1548,0 +DA:1549,0 +DA:1552,0 +DA:1553,0 +DA:1562,0 +DA:1563,0 +DA:1564,0 +DA:1567,0 +DA:1568,0 +DA:1569,0 +DA:1572,0 +DA:1573,0 +DA:1578,0 +DA:1579,0 +DA:1580,0 +DA:1584,0 +DA:1586,0 +DA:1589,0 +DA:1590,0 +DA:1591,0 +DA:1594,0 +DA:1596,0 +DA:1597,0 +DA:1598,0 +DA:1602,0 +DA:1603,0 +DA:1605,0 +DA:1608,0 +DA:1611,3 +DA:1620,3 +DA:1622,3 +DA:1623,1 +DA:1624,1 +DA:1628,2 +DA:1629,2 +DA:1635,2 +DA:1636,0 +DA:1637,0 +DA:1640,2 +DA:1642,2 +DA:1643,1 +DA:1645,0 +DA:1646,0 +DA:1647,0 +DA:1651,1 +DA:1652,1 +DA:1656,1 +DA:1659,0 +DA:1662,0 +DA:1663,0 +DA:1665,0 +DA:1668,0 +DA:1672,0 +DA:1673,0 +DA:1679,12 +DA:1686,12 +DA:1688,12 +DA:1689,1 +DA:1692,1 +DA:1696,11 +DA:1701,11 +DA:1702,0 +DA:1705,0 +DA:1707,0 +DA:1712,11 +DA:1713,0 +DA:1718,0 +DA:1719,0 +DA:1720,0 +DA:1724,11 +DA:1725,4 +DA:1726,4 +DA:1728,1 +DA:1729,1 +DA:1731,4 +DA:1732,4 +DA:1734,2 +DA:1736,2 +DA:1737,1 +DA:1740,1 +DA:1744,1 +DA:1745,1 +DA:1746,1 +DA:1747,1 +DA:1749,0 +DA:1750,0 +DA:1755,0 +DA:1758,0 +DA:1765,0 +DA:1767,0 +DA:1768,0 +DA:1769,0 +DA:1772,0 +DA:1773,0 +DA:1775,0 +DA:1776,0 +DA:1779,0 +DA:1781,0 +LF:633 +LH:385 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/lib/dlt_client.c +FN:104,dlt_client_register_message_callback +FN:109,dlt_client_register_fetch_next_message_callback +FN:114,dlt_client_init_port +FN:140,dlt_client_init +FN:173,dlt_client_connect +FN:478,dlt_client_cleanup +FN:518,dlt_client_main_loop +FN:585,dlt_client_send_message_to_socket +FN:627,dlt_client_send_ctrl_msg +FN:781,dlt_client_send_inject_msg +FN:816,dlt_client_send_log_level +FN:848,dlt_client_get_log_info +FN:879,dlt_client_get_default_log_level +FN:907,dlt_client_get_software_version +FN:931,dlt_client_send_trace_status +FN:958,dlt_client_send_default_log_level +FN:983,dlt_client_send_all_log_level +FN:1008,dlt_client_send_default_trace_status +FN:1033,dlt_client_send_all_trace_status +FN:1065,dlt_client_send_timing_pakets +FN:1089,dlt_client_send_store_config +FN:1102,dlt_client_send_reset_to_factory_default +FN:1115,dlt_client_setbaudrate +FN:1125,dlt_client_set_mode +FN:1135,dlt_client_set_server_ip +FN:1147,dlt_client_set_host_if_address +FN:1159,dlt_client_set_serial_device +FN:1171,dlt_client_set_socket_path +FN:1188,dlt_client_free_calloc_failed_get_log_info +FN:1220,dlt_client_parse_get_log_info_resp_text +FN:1374,dlt_client_cleanup_get_log_info +FNDA:0,dlt_client_send_all_log_level +FNDA:3,dlt_client_main_loop +FNDA:6,dlt_client_set_server_ip +FNDA:0,dlt_client_free_calloc_failed_get_log_info +FNDA:4,dlt_client_get_software_version +FNDA:0,dlt_client_send_timing_pakets +FNDA:1,dlt_client_send_log_level +FNDA:9,dlt_client_connect +FNDA:0,dlt_client_send_default_log_level +FNDA:0,dlt_client_send_trace_status +FNDA:0,dlt_client_setbaudrate +FNDA:0,dlt_client_set_serial_device +FNDA:0,dlt_client_set_mode +FNDA:8,dlt_client_init_port +FNDA:1,dlt_client_get_default_log_level +FNDA:0,dlt_client_send_all_trace_status +FNDA:2,dlt_client_cleanup_get_log_info +FNDA:0,dlt_client_send_default_trace_status +FNDA:5,dlt_client_cleanup +FNDA:0,dlt_client_set_socket_path +FNDA:0,dlt_client_register_fetch_next_message_callback +FNDA:10,dlt_client_send_ctrl_msg +FNDA:0,dlt_client_send_store_config +FNDA:4,dlt_client_get_log_info +FNDA:0,dlt_client_send_inject_msg +FNDA:3,dlt_client_init +FNDA:0,dlt_client_set_host_if_address +FNDA:0,dlt_client_send_reset_to_factory_default +FNDA:2,dlt_client_send_message_to_socket +FNDA:2,dlt_client_parse_get_log_info_resp_text +FNDA:3,dlt_client_register_message_callback +FNF:31 +FNH:15 +DA:104,3 +DA:106,3 +DA:107,3 +DA:109,0 +DA:111,0 +DA:112,0 +DA:114,8 +DA:116,8 +DA:117,0 +DA:122,8 +DA:125,8 +DA:126,8 +DA:127,8 +DA:128,8 +DA:129,8 +DA:130,8 +DA:131,8 +DA:132,8 +DA:133,8 +DA:134,8 +DA:135,8 +DA:137,8 +DA:140,3 +DA:148,3 +DA:150,3 +DA:153,0 +DA:154,0 +DA:158,0 +DA:161,0 +DA:165,3 +DA:166,0 +DA:170,3 +DA:173,9 +DA:175,9 +DA:176,9 +DA:186,9 +DA:190,9 +DA:192,9 +DA:195,9 +DA:196,7 +DA:197,7 +DA:199,7 +DA:200,0 +DA:204,3 +DA:207,11 +DA:208,8 +DA:209,0 +DA:212,0 +DA:213,0 +DA:217,8 +DA:219,0 +DA:221,0 +DA:222,0 +DA:223,0 +DA:226,8 +DA:227,8 +DA:228,8 +DA:229,8 +DA:231,8 +DA:232,0 +DA:234,0 +DA:235,0 +DA:237,16 +DA:238,8 +DA:240,8 +DA:241,4 +DA:242,4 +DA:243,4 +DA:244,0 +DA:247,0 +DA:248,0 +DA:253,4 +DA:254,4 +DA:258,0 +DA:259,0 +DA:260,0 +DA:265,0 +DA:266,0 +DA:273,7 +DA:275,7 +DA:276,3 +DA:280,3 +DA:283,4 +DA:284,1 +DA:292,6 +DA:293,0 +DA:295,0 +DA:297,0 +DA:298,0 +DA:302,0 +DA:305,0 +DA:308,0 +DA:309,0 +DA:313,0 +DA:314,0 +DA:322,0 +DA:323,0 +DA:327,0 +DA:329,0 +DA:332,0 +DA:333,0 +DA:341,2 +DA:343,2 +DA:344,0 +DA:347,0 +DA:349,0 +DA:353,2 +DA:354,2 +DA:356,2 +DA:359,0 +DA:362,0 +DA:364,0 +DA:367,2 +DA:368,0 +DA:373,0 +DA:379,0 +DA:381,0 +DA:383,0 +DA:386,0 +DA:388,0 +DA:392,0 +DA:394,0 +DA:397,0 +DA:399,0 +DA:402,0 +DA:403,0 +DA:405,0 +DA:408,0 +DA:410,0 +DA:413,0 +DA:415,0 +DA:418,0 +DA:419,0 +DA:421,0 +DA:423,0 +DA:425,0 +DA:429,0 +DA:432,0 +DA:433,0 +DA:435,0 +DA:436,0 +DA:437,0 +DA:439,0 +DA:444,0 +DA:447,0 +DA:449,0 +DA:452,0 +DA:454,0 +DA:456,0 +DA:461,0 +DA:462,0 +DA:467,0 +DA:470,6 +DA:471,0 +DA:472,0 +DA:478,5 +DA:482,5 +DA:483,0 +DA:485,5 +DA:488,5 +DA:489,5 +DA:491,5 +DA:492,0 +DA:496,5 +DA:497,0 +DA:498,0 +DA:501,5 +DA:502,3 +DA:503,3 +DA:506,5 +DA:507,2 +DA:508,2 +DA:511,5 +DA:512,0 +DA:513,0 +DA:518,3 +DA:523,3 +DA:526,3 +DA:530,414 +DA:532,414 +DA:534,414 +DA:536,3 +DA:539,3 +DA:542,619 +DA:543,619 +DA:545,619 +DA:548,208 +DA:549,208 +DA:551,208 +DA:552,0 +DA:553,0 +DA:557,0 +DA:558,0 +DA:561,208 +DA:562,208 +DA:565,0 +DA:566,0 +DA:570,411 +DA:572,0 +DA:573,0 +DA:575,411 +DA:576,0 +DA:579,0 +DA:580,0 +DA:585,2 +DA:589,2 +DA:590,2 +DA:592,0 +DA:593,0 +DA:596,2 +DA:598,0 +DA:600,0 +DA:602,0 +DA:603,0 +DA:604,0 +DA:608,4 +DA:610,2 +DA:611,2 +DA:613,0 +DA:614,0 +DA:617,2 +DA:618,2 +DA:620,0 +DA:621,0 +DA:627,10 +DA:636,10 +DA:640,10 +DA:644,10 +DA:646,10 +DA:647,0 +DA:648,0 +DA:651,10 +DA:652,10 +DA:653,10 +DA:656,10 +DA:657,0 +DA:658,0 +DA:662,10 +DA:665,10 +DA:667,10 +DA:668,0 +DA:669,0 +DA:673,10 +DA:674,10 +DA:680,10 +DA:683,10 +DA:685,10 +DA:688,10 +DA:689,0 +DA:690,0 +DA:694,10 +DA:696,10 +DA:697,10 +DA:699,10 +DA:701,10 +DA:703,19 +DA:704,19 +DA:707,10 +DA:710,10 +DA:712,10 +DA:714,10 +DA:715,0 +DA:719,0 +DA:721,0 +DA:724,10 +DA:727,10 +DA:729,10 +DA:731,0 +DA:732,0 +DA:734,0 +DA:735,0 +DA:736,0 +DA:739,10 +DA:740,10 +DA:742,10 +DA:743,0 +DA:744,0 +DA:745,0 +DA:748,10 +DA:750,10 +DA:751,0 +DA:752,0 +DA:753,0 +DA:756,10 +DA:757,10 +DA:759,10 +DA:766,0 +DA:768,0 +DA:769,0 +DA:770,0 +DA:775,10 +DA:776,0 +DA:781,0 +DA:791,0 +DA:793,0 +DA:799,0 +DA:801,0 +DA:804,0 +DA:806,0 +DA:807,0 +DA:810,0 +DA:812,0 +DA:816,1 +DA:821,1 +DA:824,1 +DA:826,1 +DA:829,1 +DA:830,1 +DA:831,1 +DA:832,1 +DA:833,1 +DA:836,1 +DA:843,1 +DA:845,1 +DA:848,4 +DA:853,4 +DA:856,4 +DA:858,4 +DA:861,4 +DA:862,4 +DA:863,4 +DA:864,4 +DA:865,4 +DA:868,4 +DA:874,4 +DA:876,4 +DA:879,1 +DA:884,1 +DA:888,1 +DA:890,1 +DA:893,1 +DA:896,1 +DA:902,1 +DA:904,1 +DA:907,4 +DA:912,4 +DA:915,4 +DA:917,4 +DA:920,4 +DA:926,4 +DA:928,4 +DA:931,0 +DA:935,0 +DA:937,0 +DA:940,0 +DA:941,0 +DA:942,0 +DA:943,0 +DA:944,0 +DA:947,0 +DA:949,0 +DA:950,0 +DA:953,0 +DA:955,0 +DA:958,0 +DA:962,0 +DA:964,0 +DA:967,0 +DA:968,0 +DA:969,0 +DA:972,0 +DA:974,0 +DA:975,0 +DA:978,0 +DA:980,0 +DA:983,0 +DA:987,0 +DA:989,0 +DA:992,0 +DA:993,0 +DA:994,0 +DA:997,0 +DA:999,0 +DA:1000,0 +DA:1003,0 +DA:1005,0 +DA:1008,0 +DA:1012,0 +DA:1014,0 +DA:1017,0 +DA:1018,0 +DA:1019,0 +DA:1022,0 +DA:1024,0 +DA:1025,0 +DA:1028,0 +DA:1030,0 +DA:1033,0 +DA:1037,0 +DA:1038,0 +DA:1039,0 +DA:1042,0 +DA:1044,0 +DA:1045,0 +DA:1046,0 +DA:1049,0 +DA:1050,0 +DA:1051,0 +DA:1054,0 +DA:1056,0 +DA:1057,0 +DA:1060,0 +DA:1062,0 +DA:1065,0 +DA:1069,0 +DA:1071,0 +DA:1074,0 +DA:1075,0 +DA:1078,0 +DA:1080,0 +DA:1081,0 +DA:1084,0 +DA:1086,0 +DA:1089,0 +DA:1093,0 +DA:1096,0 +DA:1097,0 +DA:1102,0 +DA:1106,0 +DA:1109,0 +DA:1110,0 +DA:1115,0 +DA:1117,0 +DA:1120,0 +DA:1122,0 +DA:1125,0 +DA:1127,0 +DA:1130,0 +DA:1131,0 +DA:1135,6 +DA:1137,6 +DA:1139,6 +DA:1140,0 +DA:1141,0 +DA:1147,0 +DA:1149,0 +DA:1151,0 +DA:1152,0 +DA:1153,0 +DA:1159,0 +DA:1161,0 +DA:1163,0 +DA:1164,0 +DA:1165,0 +DA:1171,0 +DA:1173,0 +DA:1175,0 +DA:1176,0 +DA:1177,0 +DA:1188,0 +DA:1196,0 +DA:1197,0 +DA:1199,0 +DA:1200,0 +DA:1202,0 +DA:1203,0 +DA:1206,0 +DA:1207,0 +DA:1209,0 +DA:1210,0 +DA:1213,0 +DA:1214,0 +DA:1215,0 +DA:1217,0 +DA:1220,2 +DA:1228,2 +DA:1230,2 +DA:1254,2 +DA:1258,2 +DA:1260,0 +DA:1261,0 +DA:1265,0 +DA:1266,0 +DA:1271,0 +DA:1276,0 +DA:1280,2 +DA:1281,2 +DA:1282,2 +DA:1284,2 +DA:1285,2 +DA:1287,2 +DA:1288,0 +DA:1289,0 +DA:1290,0 +DA:1293,5 +DA:1294,3 +DA:1296,3 +DA:1299,3 +DA:1300,3 +DA:1301,3 +DA:1303,3 +DA:1304,3 +DA:1306,3 +DA:1307,0 +DA:1309,0 +DA:1310,0 +DA:1313,9 +DA:1314,6 +DA:1316,6 +DA:1318,6 +DA:1322,6 +DA:1323,6 +DA:1327,6 +DA:1328,6 +DA:1332,6 +DA:1333,6 +DA:1335,6 +DA:1336,6 +DA:1338,6 +DA:1339,0 +DA:1340,0 +DA:1341,0 +DA:1344,6 +DA:1352,3 +DA:1353,3 +DA:1355,3 +DA:1356,3 +DA:1358,3 +DA:1359,0 +DA:1360,0 +DA:1361,0 +DA:1364,3 +DA:1374,2 +DA:1380,2 +DA:1383,5 +DA:1384,3 +DA:1386,9 +DA:1387,6 +DA:1388,6 +DA:1391,3 +DA:1393,3 +DA:1397,2 +DA:1400,2 +DA:1403,2 +LF:534 +LH:240 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/lib/dlt_env_ll.c +FN:58,dlt_env_extract_id +FN:90,dlt_env_helper_to_lower +FN:126,dlt_env_extract_symbolic_ll +FN:198,dlt_env_extract_ll +FN:239,dlt_env_extract_ll_item +FN:284,dlt_env_init_ll_set +FN:307,dlt_env_free_ll_set +FN:329,dlt_env_increase_ll_set +FN:364,dlt_env_extract_ll_set +FN:403,dlt_env_ids_match +FN:436,dlt_env_ll_item_get_matching_prio +FN:471,dlt_env_adjust_ll_from_env +FNDA:0,dlt_env_extract_ll_set +FNDA:0,dlt_env_init_ll_set +FNDA:0,dlt_env_ids_match +FNDA:0,dlt_env_extract_ll +FNDA:16786,dlt_env_free_ll_set +FNDA:0,dlt_env_extract_symbolic_ll +FNDA:0,dlt_env_increase_ll_set +FNDA:0,dlt_env_extract_ll_item +FNDA:0,dlt_env_ll_item_get_matching_prio +FNDA:0,dlt_env_extract_id +FNDA:205,dlt_env_adjust_ll_from_env +FNDA:0,dlt_env_helper_to_lower +FNF:12 +FNH:2 +DA:58,0 +DA:62,0 +DA:66,0 +DA:72,0 +DA:73,0 +DA:77,0 +DA:78,0 +DA:90,0 +DA:95,0 +DA:99,0 +DA:103,0 +DA:105,0 +DA:106,0 +DA:107,0 +DA:109,0 +DA:112,0 +DA:113,0 +DA:116,0 +DA:118,0 +DA:121,0 +DA:126,0 +DA:127,0 +DA:130,0 +DA:134,0 +DA:138,0 +DA:139,0 +DA:140,0 +DA:141,0 +DA:142,0 +DA:143,0 +DA:144,0 +DA:145,0 +DA:146,0 +DA:147,0 +DA:148,0 +DA:149,0 +DA:150,0 +DA:151,0 +DA:152,0 +DA:153,0 +DA:154,0 +DA:159,0 +DA:160,0 +DA:163,0 +DA:198,0 +DA:200,0 +DA:204,0 +DA:209,0 +DA:210,0 +DA:212,0 +DA:213,0 +DA:214,0 +DA:217,0 +DA:218,0 +DA:219,0 +DA:220,0 +DA:226,0 +DA:227,0 +DA:239,0 +DA:243,0 +DA:247,0 +DA:252,0 +DA:254,0 +DA:258,0 +DA:259,0 +DA:261,0 +DA:265,0 +DA:266,0 +DA:268,0 +DA:269,0 +DA:284,0 +DA:286,0 +DA:290,0 +DA:291,0 +DA:293,0 +DA:295,0 +DA:296,0 +DA:299,0 +DA:300,0 +DA:307,16786 +DA:309,16786 +DA:313,16786 +DA:314,0 +DA:315,0 +DA:318,16786 +DA:319,16786 +DA:329,0 +DA:334,0 +DA:338,0 +DA:339,0 +DA:341,0 +DA:342,0 +DA:344,0 +DA:346,0 +DA:347,0 +DA:349,0 +DA:350,0 +DA:351,0 +DA:364,0 +DA:366,0 +DA:370,0 +DA:374,0 +DA:379,0 +DA:380,0 +DA:385,0 +DA:389,0 +DA:390,0 +DA:392,0 +DA:403,0 +DA:405,0 +DA:409,0 +DA:413,0 +DA:417,0 +DA:418,0 +DA:436,0 +DA:440,0 +DA:444,0 +DA:445,0 +DA:447,0 +DA:448,0 +DA:450,0 +DA:451,0 +DA:453,0 +DA:454,0 +DA:471,205 +DA:476,205 +DA:484,205 +DA:485,0 +DA:487,0 +DA:489,0 +DA:491,0 +DA:492,0 +LF:132 +LH:8 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/lib/dlt_filetransfer.c +FN:84,getFilesize +FN:103,stringHash +FN:129,getFileSerialNumber +FN:155,getFileCreationDate +FN:175,getFileCreationDate2 +FN:196,isFile +FN:206,doTimeout +FN:218,checkUserBufferForFreeSpace +FN:236,doRemoveFile +FN:241,dlt_user_log_file_errorMessage +FN:306,dlt_user_log_file_infoAbout +FN:369,dlt_user_log_file_complete +FN:404,dlt_user_log_file_packagesCount +FN:454,dlt_user_log_file_header_alias +FN:516,dlt_user_log_file_header +FN:576,dlt_user_log_file_data +FN:594,dlt_user_log_file_data_cancelable +FN:745,dlt_user_log_file_end +FNDA:0,dlt_user_log_file_header +FNDA:0,dlt_user_log_file_packagesCount +FNDA:0,stringHash +FNDA:0,dlt_user_log_file_data +FNDA:0,doTimeout +FNDA:0,getFilesize +FNDA:0,dlt_user_log_file_infoAbout +FNDA:0,checkUserBufferForFreeSpace +FNDA:0,doRemoveFile +FNDA:0,dlt_user_log_file_data_cancelable +FNDA:0,getFileCreationDate +FNDA:0,dlt_user_log_file_end +FNDA:0,getFileCreationDate2 +FNDA:0,isFile +FNDA:0,dlt_user_log_file_complete +FNDA:0,dlt_user_log_file_errorMessage +FNDA:0,dlt_user_log_file_header_alias +FNDA:0,getFileSerialNumber +FNF:18 +FNH:0 +DA:84,0 +DA:88,0 +DA:90,0 +DA:91,0 +DA:94,0 +DA:95,0 +DA:103,0 +DA:105,0 +DA:109,0 +DA:113,0 +DA:117,0 +DA:118,0 +DA:129,0 +DA:134,0 +DA:135,0 +DA:136,0 +DA:138,0 +DA:139,0 +DA:140,0 +DA:141,0 +DA:142,0 +DA:143,0 +DA:146,0 +DA:155,0 +DA:159,0 +DA:160,0 +DA:161,0 +DA:164,0 +DA:165,0 +DA:175,0 +DA:180,0 +DA:181,0 +DA:183,0 +DA:186,0 +DA:187,0 +DA:188,0 +DA:189,0 +DA:196,0 +DA:199,0 +DA:206,0 +DA:209,0 +DA:210,0 +DA:211,0 +DA:212,0 +DA:218,0 +DA:222,0 +DA:224,0 +DA:225,0 +DA:236,0 +DA:238,0 +DA:241,0 +DA:244,0 +DA:245,0 +DA:246,0 +DA:248,0 +DA:249,0 +DA:254,0 +DA:256,0 +DA:257,0 +DA:263,0 +DA:264,0 +DA:266,0 +DA:267,0 +DA:273,0 +DA:275,0 +DA:288,0 +DA:296,0 +DA:306,0 +DA:309,0 +DA:312,0 +DA:314,0 +DA:315,0 +DA:321,0 +DA:323,0 +DA:324,0 +DA:330,0 +DA:331,0 +DA:333,0 +DA:334,0 +DA:340,0 +DA:352,0 +DA:353,0 +DA:369,0 +DA:374,0 +DA:375,0 +DA:376,0 +DA:379,0 +DA:383,0 +DA:388,0 +DA:389,0 +DA:404,0 +DA:409,0 +DA:412,0 +DA:414,0 +DA:415,0 +DA:420,0 +DA:423,0 +DA:426,0 +DA:428,0 +DA:431,0 +DA:435,0 +DA:440,0 +DA:454,0 +DA:457,0 +DA:460,0 +DA:462,0 +DA:463,0 +DA:467,0 +DA:470,0 +DA:472,0 +DA:473,0 +DA:479,0 +DA:480,0 +DA:482,0 +DA:483,0 +DA:489,0 +DA:500,0 +DA:502,0 +DA:503,0 +DA:516,0 +DA:519,0 +DA:522,0 +DA:524,0 +DA:525,0 +DA:531,0 +DA:533,0 +DA:534,0 +DA:540,0 +DA:541,0 +DA:543,0 +DA:544,0 +DA:550,0 +DA:563,0 +DA:564,0 +DA:576,0 +DA:581,0 +DA:582,0 +DA:594,0 +DA:604,0 +DA:606,0 +DA:608,0 +DA:609,0 +DA:610,0 +DA:613,0 +DA:615,0 +DA:616,0 +DA:617,0 +DA:626,0 +DA:627,0 +DA:632,0 +DA:637,0 +DA:638,0 +DA:645,0 +DA:646,0 +DA:652,0 +DA:654,0 +DA:655,0 +DA:658,0 +DA:659,0 +DA:662,0 +DA:670,0 +DA:671,0 +DA:675,0 +DA:677,0 +DA:681,0 +DA:684,0 +DA:685,0 +DA:686,0 +DA:688,0 +DA:696,0 +DA:698,0 +DA:699,0 +DA:702,0 +DA:703,0 +DA:706,0 +DA:713,0 +DA:714,0 +DA:718,0 +DA:721,0 +DA:722,0 +DA:724,0 +DA:728,0 +DA:730,0 +DA:732,0 +DA:733,0 +DA:745,0 +DA:748,0 +DA:751,0 +DA:753,0 +DA:754,0 +DA:757,0 +DA:760,0 +DA:766,0 +DA:767,0 +DA:768,0 +DA:771,0 +DA:775,0 +DA:777,0 +DA:778,0 +LF:199 +LH:0 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/lib/dlt_user.c +FN:164,dlt_lock_mutex +FN:174,dlt_unlock_mutex +FN:238,dlt_user_check_library_version +FN:399,dlt_initialize_fifo_connection +FN:467,dlt_init +FN:599,dlt_get_appid +FN:610,dlt_init_file +FN:649,dlt_set_filesize_max +FN:671,dlt_init_message_queue +FN:743,dlt_init_common +FN:954,dlt_user_atexit_handler +FN:986,dlt_user_atexit_blow_out_user_buffer +FN:1049,dlt_free +FN:1252,dlt_check_library_version +FN:1257,dlt_register_app +FN:1338,dlt_register_context +FN:1365,dlt_register_context_ll_ts_llccb +FN:1568,dlt_register_context_ll_ts +FN:1583,dlt_register_context_llccb +FN:1614,dlt_unregister_app_util +FN:1652,dlt_unregister_app +FN:1657,dlt_unregister_app_flush_buffered_logs +FN:1679,dlt_unregister_context +FN:1741,dlt_set_application_ll_ts_limit +FN:1791,dlt_get_log_state +FN:1796,dlt_set_log_mode +FN:1819,dlt_set_resend_timeout_atexit +FN:1835,dlt_user_log_write_start_init +FN:1861,dlt_user_log_write_start +FN:1866,dlt_user_log_write_start_id +FN:1874,dlt_user_log_write_start_internal +FN:1937,dlt_user_log_write_start_w_given_buffer +FN:1972,dlt_user_log_write_finish +FN:1986,dlt_user_log_write_finish_w_given_buffer +FN:1998,dlt_user_log_write_raw_internal +FN:2079,dlt_user_log_write_raw +FN:2084,dlt_user_log_write_raw_formatted +FN:2089,dlt_user_log_write_raw_attr +FN:2094,dlt_user_log_write_raw_formatted_attr +FN:2100,dlt_user_log_write_generic_attr +FN:2173,dlt_user_log_write_generic_formatted +FN:2217,dlt_user_log_write_float32 +FN:2226,dlt_user_log_write_float64 +FN:2235,dlt_user_log_write_float32_attr +FN:2245,dlt_user_log_write_float64_attr +FN:2255,dlt_user_log_write_uint +FN:2296,dlt_user_log_write_uint8 +FN:2302,dlt_user_log_write_uint16 +FN:2308,dlt_user_log_write_uint32 +FN:2314,dlt_user_log_write_uint64 +FN:2320,dlt_user_log_write_uint_attr +FN:2361,dlt_user_log_write_uint8_attr +FN:2368,dlt_user_log_write_uint16_attr +FN:2375,dlt_user_log_write_uint32_attr +FN:2382,dlt_user_log_write_uint64_attr +FN:2389,dlt_user_log_write_uint8_formatted +FN:2395,dlt_user_log_write_uint16_formatted +FN:2401,dlt_user_log_write_uint32_formatted +FN:2407,dlt_user_log_write_uint64_formatted +FN:2413,dlt_user_log_write_ptr +FN:2441,dlt_user_log_write_int +FN:2482,dlt_user_log_write_int8 +FN:2488,dlt_user_log_write_int16 +FN:2494,dlt_user_log_write_int32 +FN:2500,dlt_user_log_write_int64 +FN:2506,dlt_user_log_write_int_attr +FN:2547,dlt_user_log_write_int8_attr +FN:2554,dlt_user_log_write_int16_attr +FN:2561,dlt_user_log_write_int32_attr +FN:2568,dlt_user_log_write_int64_attr +FN:2575,dlt_user_log_write_bool +FN:2581,dlt_user_log_write_bool_attr +FN:2588,dlt_user_log_write_string +FN:2593,dlt_user_log_write_string_attr +FN:2598,dlt_user_log_write_sized_string +FN:2603,dlt_user_log_write_sized_string_attr +FN:2608,dlt_user_log_write_constant_string +FN:2614,dlt_user_log_write_constant_string_attr +FN:2620,dlt_user_log_write_sized_constant_string +FN:2626,dlt_user_log_write_sized_constant_string_attr +FN:2632,dlt_user_log_write_utf8_string +FN:2637,dlt_user_log_write_utf8_string_attr +FN:2642,dlt_user_log_write_sized_utf8_string +FN:2647,dlt_user_log_write_sized_utf8_string_attr +FN:2652,dlt_user_log_write_constant_utf8_string +FN:2658,dlt_user_log_write_constant_utf8_string_attr +FN:2664,dlt_user_log_write_sized_constant_utf8_string +FN:2670,dlt_user_log_write_sized_constant_utf8_string_attr +FN:2676,dlt_user_log_write_sized_string_utils_attr +FN:2831,dlt_user_log_write_string_utils_attr +FN:2840,dlt_register_injection_callback_with_id +FN:2931,dlt_register_injection_callback +FN:2942,dlt_register_log_level_changed_callback +FN:2982,check_buffer +FN:2994,dlt_user_trace_network_segmented_start +FN:3091,dlt_user_trace_network_segmented_segment +FN:3174,dlt_user_trace_network_segmented_end +FN:3230,dlt_user_trace_network_segmented_thread +FN:3297,dlt_user_trace_network_segmented_thread_segmenter +FN:3334,dlt_user_trace_network_segmented +FN:3422,dlt_user_trace_network +FN:3432,dlt_user_trace_network_truncated +FN:3584,dlt_log_string +FN:3605,dlt_log_string_int +FN:3627,dlt_log_string_uint +FN:3649,dlt_log_int +FN:3669,dlt_log_uint +FN:3689,dlt_log_raw +FN:3713,dlt_log_marker +FN:3725,dlt_verbose_mode +FN:3740,dlt_nonverbose_mode +FN:3755,dlt_use_extended_header_for_non_verbose +FN:3770,dlt_with_session_id +FN:3785,dlt_with_timestamp +FN:3800,dlt_with_ecu_id +FN:3815,dlt_enable_local_print +FN:3829,dlt_disable_local_print +FN:3844,dlt_user_cleanup_handler +FN:3857,dlt_user_housekeeperthread_function +FN:3939,dlt_user_log_init +FN:3962,dlt_user_log_send_log +FN:4289,dlt_user_log_send_register_application +FN:4332,dlt_user_log_send_unregister_application +FN:4368,dlt_user_log_send_register_context +FN:4427,dlt_user_log_send_unregister_context +FN:4472,dlt_send_app_ll_ts_limit +FN:4519,dlt_user_log_send_log_mode +FN:4556,dlt_user_log_send_marker +FN:4584,dlt_user_print_msg +FN:4621,dlt_user_log_check_user_message +FN:4982,dlt_user_log_resend_buffer +FN:5076,dlt_user_log_reattach_to_daemon +FN:5161,dlt_user_log_send_overflow +FN:5182,dlt_user_check_buffer +FN:5214,dlt_start_threads +FN:5303,dlt_stop_threads +FN:5375,dlt_fork_child_fork_handler +FN:5455,dlt_user_log_out_error_handling +FNDA:5,dlt_user_log_write_constant_utf8_string +FNDA:6,dlt_user_log_write_int64 +FNDA:11721,dlt_user_log_write_string_utils_attr +FNDA:59636257,dlt_init +FNDA:7,dlt_user_log_write_int_attr +FNDA:11686,dlt_user_log_write_string +FNDA:6411,dlt_user_log_init +FNDA:0,dlt_user_trace_network_segmented_end +FNDA:7,dlt_user_check_library_version +FNDA:8,dlt_user_log_write_sized_utf8_string +FNDA:216,dlt_register_context_ll_ts_llccb +FNDA:204,dlt_user_log_send_unregister_context +FNDA:5,dlt_user_log_write_sized_constant_utf8_string +FNDA:72878,dlt_free +FNDA:1,dlt_user_log_write_sized_constant_string +FNDA:7,dlt_check_library_version +FNDA:1,dlt_user_log_send_marker +FNDA:37,dlt_user_log_write_int +FNDA:4,dlt_set_log_mode +FNDA:18,dlt_log_string +FNDA:11580,dlt_user_log_write_uint32 +FNDA:4,dlt_user_log_write_uint8 +FNDA:10,dlt_verbose_mode +FNDA:203,dlt_register_context +FNDA:4,dlt_user_log_send_log_mode +FNDA:0,dlt_user_log_write_finish_w_given_buffer +FNDA:28,dlt_user_log_write_uint8_formatted +FNDA:7,dlt_user_log_write_float64 +FNDA:3,dlt_user_log_write_raw_formatted_attr +FNDA:10,dlt_nonverbose_mode +FNDA:0,dlt_send_app_ll_ts_limit +FNDA:0,dlt_user_trace_network_segmented_start +FNDA:0,dlt_get_appid +FNDA:38,dlt_user_log_write_raw_internal +FNDA:28,dlt_user_log_write_uint16_formatted +FNDA:0,dlt_user_print_msg +FNDA:7,dlt_user_log_write_int16_attr +FNDA:7,dlt_user_log_write_uint64_attr +FNDA:16786,dlt_initialize_fifo_connection +FNDA:16787,dlt_init_common +FNDA:22,dlt_log_uint +FNDA:4,dlt_user_log_write_sized_constant_utf8_string_attr +FNDA:204,dlt_unregister_context +FNDA:7,dlt_user_log_write_int64_attr +FNDA:0,dlt_register_context_llccb +FNDA:6008,dlt_user_log_write_finish +FNDA:2,dlt_user_log_write_sized_string +FNDA:205,dlt_user_log_send_register_context +FNDA:176,dlt_register_app +FNDA:11760,dlt_user_log_write_generic_attr +FNDA:181,dlt_user_log_send_unregister_application +FNDA:2,dlt_use_extended_header_for_non_verbose +FNDA:0,dlt_set_application_ll_ts_limit +FNDA:25,dlt_log_string_int +FNDA:0,dlt_user_log_write_ptr +FNDA:0,dlt_register_injection_callback_with_id +FNDA:8,dlt_user_atexit_handler +FNDA:171,dlt_user_log_send_register_application +FNDA:4,dlt_user_log_write_constant_utf8_string_attr +FNDA:7,dlt_user_log_write_uint_attr +FNDA:33572,dlt_lock_mutex +FNDA:1,dlt_log_marker +FNDA:16786,dlt_stop_threads +FNDA:5,dlt_user_log_write_constant_string_attr +FNDA:16802,dlt_user_log_check_user_message +FNDA:11729,dlt_user_log_write_sized_string_utils_attr +FNDA:0,dlt_user_trace_network_segmented_thread_segmenter +FNDA:7,dlt_user_atexit_blow_out_user_buffer +FNDA:0,dlt_with_ecu_id +FNDA:1,dlt_get_log_state +FNDA:6008,dlt_user_log_send_log +FNDA:0,dlt_user_log_write_start_w_given_buffer +FNDA:0,dlt_register_injection_callback +FNDA:7,dlt_user_log_write_uint8_attr +FNDA:4,dlt_user_log_write_uint64 +FNDA:42,dlt_user_log_write_int32 +FNDA:7,dlt_user_log_write_sized_utf8_string_attr +FNDA:5926,dlt_user_log_write_start +FNDA:19,dlt_user_log_write_raw_formatted +FNDA:21,dlt_user_log_write_utf8_string +FNDA:3,dlt_user_log_write_sized_constant_string_attr +FNDA:35,dlt_user_log_write_uint +FNDA:216,dlt_register_context_ll_ts +FNDA:7,dlt_user_log_write_float32 +FNDA:14,dlt_user_trace_network +FNDA:3,dlt_user_log_write_bool +FNDA:18,dlt_user_log_write_uint32_attr +FNDA:0,dlt_enable_local_print +FNDA:3,dlt_user_log_write_raw_attr +FNDA:5834,dlt_user_log_resend_buffer +FNDA:13,dlt_user_log_write_raw +FNDA:0,dlt_user_trace_network_segmented_segment +FNDA:0,dlt_user_log_send_overflow +FNDA:7,dlt_user_log_write_int8_attr +FNDA:33572,dlt_user_housekeeperthread_function +FNDA:7,dlt_user_log_write_float64_attr +FNDA:16786,dlt_start_threads +FNDA:22,dlt_log_int +FNDA:6001,dlt_user_log_write_start_init +FNDA:859,dlt_user_log_out_error_handling +FNDA:0,dlt_disable_local_print +FNDA:0,dlt_set_resend_timeout_atexit +FNDA:0,dlt_init_message_queue +FNDA:3,dlt_user_log_write_bool_attr +FNDA:7,dlt_user_log_write_uint16_attr +FNDA:0,check_buffer +FNDA:6,dlt_user_log_write_int8 +FNDA:0,dlt_init_file +FNDA:7,dlt_user_log_write_float32_attr +FNDA:6059,dlt_user_log_write_start_internal +FNDA:121,dlt_user_log_reattach_to_daemon +FNDA:14,dlt_user_log_write_int32_attr +FNDA:25,dlt_log_string_uint +FNDA:21,dlt_user_trace_network_truncated +FNDA:7,dlt_user_log_write_utf8_string_attr +FNDA:0,dlt_fork_child_fork_handler +FNDA:6,dlt_user_log_write_sized_string_attr +FNDA:11,dlt_log_raw +FNDA:4,dlt_user_log_write_uint16 +FNDA:50356,dlt_unlock_mutex +FNDA:7,dlt_unregister_app_flush_buffered_logs +FNDA:181,dlt_unregister_app_util +FNDA:28,dlt_user_log_write_uint64_formatted +FNDA:0,dlt_user_check_buffer +FNDA:1,dlt_register_log_level_changed_callback +FNDA:167,dlt_unregister_app +FNDA:7,dlt_user_trace_network_segmented +FNDA:7,dlt_user_log_write_constant_string +FNDA:28,dlt_user_log_write_uint32_formatted +FNDA:6,dlt_user_log_write_int16 +FNDA:23,dlt_user_log_write_start_id +FNDA:0,dlt_with_timestamp +FNDA:112,dlt_user_log_write_generic_formatted +FNDA:33572,dlt_user_trace_network_segmented_thread +FNDA:0,dlt_set_filesize_max +FNDA:33569,dlt_user_cleanup_handler +FNDA:7,dlt_user_log_write_string_attr +FNDA:0,dlt_with_session_id +FNF:138 +FNH:111 +DA:164,33572 +DA:166,33572 +DA:168,33572 +DA:169,0 +DA:172,33572 +DA:174,50356 +DA:176,50356 +DA:177,50356 +DA:238,7 +DA:243,7 +DA:244,7 +DA:246,7 +DA:247,0 +DA:255,0 +DA:399,16786 +DA:406,16786 +DA:408,16786 +DA:409,0 +DA:410,0 +DA:414,16786 +DA:416,1 +DA:420,1 +DA:421,0 +DA:422,0 +DA:427,16786 +DA:430,16786 +DA:432,16786 +DA:434,16786 +DA:435,0 +DA:438,16786 +DA:440,16786 +DA:441,0 +DA:442,0 +DA:445,16786 +DA:447,16786 +DA:448,0 +DA:449,0 +DA:450,0 +DA:454,16786 +DA:456,16786 +DA:460,16779 +DA:467,59636257 +DA:470,59636257 +DA:487,8704037 +DA:492,16786 +DA:495,16786 +DA:496,0 +DA:500,16786 +DA:501,0 +DA:502,0 +DA:503,0 +DA:506,16786 +DA:507,16786 +DA:508,16786 +DA:510,16786 +DA:511,16786 +DA:560,16786 +DA:561,0 +DA:562,0 +DA:563,0 +DA:566,16786 +DA:570,0 +DA:571,0 +DA:572,0 +DA:579,16786 +DA:580,16786 +DA:582,16786 +DA:585,16786 +DA:586,0 +DA:587,0 +DA:588,0 +DA:592,16786 +DA:594,16786 +DA:596,16786 +DA:599,0 +DA:601,0 +DA:603,0 +DA:605,0 +DA:606,0 +DA:610,0 +DA:613,0 +DA:625,0 +DA:629,0 +DA:634,0 +DA:637,0 +DA:640,0 +DA:641,0 +DA:642,0 +DA:643,0 +DA:649,0 +DA:651,0 +DA:653,0 +DA:655,0 +DA:658,0 +DA:659,0 +DA:662,0 +DA:664,0 +DA:667,0 +DA:671,0 +DA:673,0 +DA:675,0 +DA:676,0 +DA:678,0 +DA:679,0 +DA:684,0 +DA:688,0 +DA:689,0 +DA:690,0 +DA:691,0 +DA:697,0 +DA:701,0 +DA:702,0 +DA:703,0 +DA:705,0 +DA:706,0 +DA:709,0 +DA:715,0 +DA:716,0 +DA:717,0 +DA:718,0 +DA:722,0 +DA:724,0 +DA:726,0 +DA:727,0 +DA:728,0 +DA:731,0 +DA:732,0 +DA:733,0 +DA:740,11776 +DA:743,16787 +DA:759,16787 +DA:764,33572 +DA:765,33572 +DA:766,16786 +DA:767,0 +DA:768,0 +DA:772,16786 +DA:774,16786 +DA:775,16786 +DA:777,16786 +DA:778,16786 +DA:780,16786 +DA:783,16786 +DA:792,16786 +DA:797,16786 +DA:799,16786 +DA:800,0 +DA:801,0 +DA:805,16786 +DA:810,16786 +DA:813,16786 +DA:816,16786 +DA:819,16786 +DA:821,16786 +DA:823,16786 +DA:825,16786 +DA:827,16786 +DA:828,0 +DA:829,0 +DA:830,0 +DA:831,0 +DA:832,0 +DA:833,0 +DA:836,16786 +DA:838,16786 +DA:839,0 +DA:840,0 +DA:846,16786 +DA:847,16786 +DA:848,16786 +DA:849,16786 +DA:852,16786 +DA:853,16786 +DA:854,16786 +DA:856,16786 +DA:857,0 +DA:859,0 +DA:860,0 +DA:867,16786 +DA:868,0 +DA:870,0 +DA:871,0 +DA:878,16786 +DA:879,0 +DA:881,0 +DA:882,0 +DA:890,16786 +DA:891,16786 +DA:893,16786 +DA:894,7 +DA:896,7 +DA:897,0 +DA:898,0 +DA:902,7 +DA:903,7 +DA:909,16786 +DA:910,16786 +DA:911,16786 +DA:913,16786 +DA:914,0 +DA:915,0 +DA:916,0 +DA:917,0 +DA:921,16786 +DA:922,16786 +DA:923,0 +DA:924,0 +DA:927,16786 +DA:931,0 +DA:932,0 +DA:933,0 +DA:936,16786 +DA:938,16786 +DA:940,16786 +DA:941,8 +DA:942,8 +DA:954,8 +DA:957,8 +DA:960,8 +DA:961,1 +DA:963,1 +DA:964,1 +DA:968,7 +DA:970,7 +DA:971,1 +DA:975,7 +DA:979,7 +DA:986,7 +DA:992,7 +DA:995,7 +DA:996,7 +DA:997,7 +DA:999,7 +DA:1000,101 +DA:1001,100 +DA:1003,100 +DA:1005,100 +DA:1006,0 +DA:1007,0 +DA:1011,0 +DA:1016,100 +DA:1017,0 +DA:1019,0 +DA:1020,0 +DA:1021,0 +DA:1022,0 +DA:1024,0 +DA:1028,100 +DA:1029,100 +DA:1030,100 +DA:1033,1 +DA:1034,1 +DA:1035,1 +DA:1043,22796 +DA:1044,2 +DA:1045,22785 +DA:1049,72878 +DA:1059,72878 +DA:1066,72878 +DA:1067,56092 +DA:1068,56092 +DA:1071,16786 +DA:1073,16786 +DA:1075,16786 +DA:1079,16786 +DA:1080,16786 +DA:1081,16786 +DA:1082,16786 +DA:1083,16786 +DA:1093,16786 +DA:1157,6 +DA:1159,6 +DA:1160,0 +DA:1162,6 +DA:1165,16786 +DA:1168,16786 +DA:1171,16786 +DA:1172,0 +DA:1173,16786 +DA:1175,16786 +DA:1176,10521 +DA:1177,10500 +DA:1178,1 +DA:1179,1 +DA:1182,10500 +DA:1183,1 +DA:1184,1 +DA:1187,10500 +DA:1188,1 +DA:1189,1 +DA:1192,10500 +DA:1193,0 +DA:1194,0 +DA:1197,10500 +DA:1198,10500 +DA:1201,21 +DA:1202,21 +DA:1203,21 +DA:1204,21 +DA:1207,16786 +DA:1211,16786 +DA:1217,16786 +DA:1218,0 +DA:1220,16786 +DA:1221,0 +DA:1223,16786 +DA:1224,16786 +DA:1225,0 +DA:1227,16786 +DA:1228,16786 +DA:1230,16786 +DA:1241,16786 +DA:1242,16786 +DA:1247,16786 +DA:1249,16786 +DA:1252,7 +DA:1254,7 +DA:1257,176 +DA:1262,176 +DA:1265,176 +DA:1266,8 +DA:1267,0 +DA:1268,0 +DA:1272,176 +DA:1277,172 +DA:1278,2 +DA:1281,170 +DA:1283,2 +DA:1284,0 +DA:1287,168 +DA:1289,2 +DA:1290,0 +DA:1291,0 +DA:1294,166 +DA:1295,1 +DA:1296,1 +DA:1297,1 +DA:1302,171 +DA:1305,171 +DA:1307,171 +DA:1308,0 +DA:1310,171 +DA:1312,171 +DA:1313,171 +DA:1314,171 +DA:1316,171 +DA:1319,0 +DA:1320,0 +DA:1324,171 +DA:1330,171 +DA:1332,171 +DA:1333,7 +DA:1338,203 +DA:1341,203 +DA:1345,197 +DA:1348,197 +DA:1349,0 +DA:1350,0 +DA:1351,0 +DA:1355,197 +DA:1358,189 +DA:1365,216 +DA:1379,216 +DA:1383,209 +DA:1386,209 +DA:1387,2 +DA:1388,2 +DA:1391,207 +DA:1392,2 +DA:1393,2 +DA:1396,205 +DA:1400,205 +DA:1405,205 +DA:1411,205 +DA:1412,21 +DA:1414,21 +DA:1415,0 +DA:1416,0 +DA:1419,21 +DA:1422,10521 +DA:1423,10500 +DA:1427,10500 +DA:1428,10500 +DA:1430,10500 +DA:1431,10500 +DA:1433,10500 +DA:1435,10500 +DA:1436,10500 +DA:1437,10500 +DA:1440,184 +DA:1447,0 +DA:1449,0 +DA:1450,0 +DA:1451,0 +DA:1452,0 +DA:1453,0 +DA:1455,0 +DA:1456,0 +DA:1457,0 +DA:1458,0 +DA:1459,0 +DA:1462,0 +DA:1463,0 +DA:1466,0 +DA:1467,0 +DA:1471,0 +DA:1472,0 +DA:1474,0 +DA:1475,0 +DA:1477,0 +DA:1479,0 +DA:1480,0 +DA:1481,0 +DA:1487,205 +DA:1490,205 +DA:1492,205 +DA:1493,0 +DA:1495,205 +DA:1497,205 +DA:1498,205 +DA:1499,205 +DA:1501,205 +DA:1502,0 +DA:1503,0 +DA:1509,205 +DA:1510,205 +DA:1512,205 +DA:1513,0 +DA:1514,0 +DA:1518,205 +DA:1519,205 +DA:1521,205 +DA:1522,0 +DA:1523,0 +DA:1528,205 +DA:1533,205 +DA:1534,0 +DA:1537,205 +DA:1539,16 +DA:1542,205 +DA:1543,15 +DA:1546,205 +DA:1547,205 +DA:1549,205 +DA:1550,205 +DA:1552,205 +DA:1554,205 +DA:1555,205 +DA:1556,205 +DA:1558,205 +DA:1559,205 +DA:1561,205 +DA:1563,205 +DA:1565,205 +DA:1568,216 +DA:1574,216 +DA:1583,0 +DA:1590,0 +DA:1594,0 +DA:1597,0 +DA:1598,0 +DA:1599,0 +DA:1600,0 +DA:1604,0 +DA:1614,181 +DA:1619,181 +DA:1623,181 +DA:1624,0 +DA:1625,0 +DA:1629,181 +DA:1631,181 +DA:1633,181 +DA:1635,181 +DA:1636,7 +DA:1638,180 +DA:1640,180 +DA:1641,171 +DA:1644,180 +DA:1647,181 +DA:1649,181 +DA:1652,167 +DA:1654,167 +DA:1657,7 +DA:1662,7 +DA:1665,7 +DA:1666,0 +DA:1667,0 +DA:1670,7 +DA:1672,6 +DA:1673,6 +DA:1676,7 +DA:1679,204 +DA:1685,204 +DA:1689,204 +DA:1690,204 +DA:1692,204 +DA:1696,204 +DA:1698,204 +DA:1699,204 +DA:1701,204 +DA:1703,204 +DA:1705,204 +DA:1706,204 +DA:1708,204 +DA:1709,204 +DA:1712,204 +DA:1713,204 +DA:1714,204 +DA:1717,204 +DA:1718,204 +DA:1719,204 +DA:1722,204 +DA:1724,204 +DA:1725,0 +DA:1726,0 +DA:1729,204 +DA:1730,204 +DA:1733,204 +DA:1736,204 +DA:1738,204 +DA:1741,0 +DA:1746,0 +DA:1749,0 +DA:1750,0 +DA:1751,0 +DA:1754,0 +DA:1755,0 +DA:1756,0 +DA:1759,0 +DA:1760,0 +DA:1761,0 +DA:1762,0 +DA:1766,0 +DA:1768,0 +DA:1769,0 +DA:1770,0 +DA:1774,0 +DA:1775,0 +DA:1776,0 +DA:1778,0 +DA:1779,0 +DA:1781,0 +DA:1782,0 +DA:1785,0 +DA:1788,0 +DA:1791,1 +DA:1793,1 +DA:1796,4 +DA:1801,4 +DA:1804,4 +DA:1805,0 +DA:1806,0 +DA:1809,4 +DA:1810,0 +DA:1811,0 +DA:1812,0 +DA:1816,4 +DA:1819,0 +DA:1822,0 +DA:1825,0 +DA:1826,0 +DA:1829,0 +DA:1830,0 +DA:1835,6001 +DA:1843,6001 +DA:1846,6001 +DA:1847,6001 +DA:1848,6001 +DA:1849,6001 +DA:1850,6001 +DA:1852,6001 +DA:1861,5926 +DA:1863,6036 +DA:1866,23 +DA:1871,23 +DA:1874,6059 +DA:1883,6059 +DA:1887,6053 +DA:1895,6040 +DA:1896,39 +DA:1897,39 +DA:1900,6001 +DA:1901,6001 +DA:1903,6001 +DA:1905,0 +DA:1906,0 +DA:1910,6001 +DA:1913,6001 +DA:1914,0 +DA:1915,0 +DA:1920,6011 +DA:1921,3 +DA:1926,3 +DA:1937,0 +DA:1947,0 +DA:1951,0 +DA:1955,0 +DA:1959,0 +DA:1962,0 +DA:1963,0 +DA:1964,0 +DA:1965,0 +DA:1966,0 +DA:1972,6008 +DA:1976,6008 +DA:1979,6008 +DA:1986,0 +DA:1990,0 +DA:1993,0 +DA:1995,0 +DA:1998,38 +DA:2001,38 +DA:2005,31 +DA:2006,0 +DA:2007,0 +DA:2010,31 +DA:2011,0 +DA:2012,0 +DA:2015,31 +DA:2017,31 +DA:2018,31 +DA:2021,29 +DA:2022,29 +DA:2024,29 +DA:2025,29 +DA:2026,6 +DA:2027,6 +DA:2029,6 +DA:2031,29 +DA:2032,0 +DA:2036,29 +DA:2037,8 +DA:2038,8 +DA:2040,21 +DA:2042,4 +DA:2043,4 +DA:2046,29 +DA:2047,29 +DA:2050,29 +DA:2051,29 +DA:2053,29 +DA:2054,29 +DA:2058,6 +DA:2059,6 +DA:2063,6 +DA:2064,4 +DA:2065,4 +DA:2070,29 +DA:2071,27 +DA:2072,27 +DA:2073,27 +DA:2079,13 +DA:2081,13 +DA:2084,19 +DA:2086,19 +DA:2089,3 +DA:2091,3 +DA:2094,3 +DA:2096,3 +DA:2100,11760 +DA:2102,11760 +DA:2105,11749 +DA:2106,0 +DA:2107,0 +DA:2111,11749 +DA:2114,11751 +DA:2120,11745 +DA:2121,11745 +DA:2122,89 +DA:2123,89 +DA:2125,89 +DA:2126,89 +DA:2127,89 +DA:2128,86 +DA:2129,86 +DA:2132,89 +DA:2134,11745 +DA:2135,0 +DA:2137,11745 +DA:2138,11745 +DA:2140,11745 +DA:2144,89 +DA:2145,89 +DA:2146,89 +DA:2147,86 +DA:2148,86 +DA:2153,89 +DA:2154,64 +DA:2155,64 +DA:2157,89 +DA:2158,62 +DA:2159,62 +DA:2164,11747 +DA:2165,11747 +DA:2167,11747 +DA:2169,11747 +DA:2173,112 +DA:2175,112 +DA:2179,84 +DA:2180,0 +DA:2181,0 +DA:2184,84 +DA:2185,0 +DA:2186,0 +DA:2190,84 +DA:2193,84 +DA:2194,84 +DA:2195,84 +DA:2199,84 +DA:2200,48 +DA:2202,36 +DA:2203,24 +DA:2205,84 +DA:2206,84 +DA:2209,84 +DA:2210,84 +DA:2212,84 +DA:2214,84 +DA:2217,7 +DA:2223,7 +DA:2226,7 +DA:2232,7 +DA:2235,7 +DA:2241,7 +DA:2242,7 +DA:2245,7 +DA:2251,7 +DA:2252,7 +DA:2255,35 +DA:2257,35 +DA:2260,34 +DA:2261,0 +DA:2262,0 +DA:2276,34 +DA:2278,34 +DA:2296,4 +DA:2299,4 +DA:2302,4 +DA:2305,4 +DA:2308,11580 +DA:2311,11580 +DA:2314,4 +DA:2317,4 +DA:2320,7 +DA:2322,7 +DA:2325,7 +DA:2326,0 +DA:2327,0 +DA:2341,7 +DA:2343,7 +DA:2361,7 +DA:2364,7 +DA:2365,7 +DA:2368,7 +DA:2371,7 +DA:2372,7 +DA:2375,18 +DA:2378,18 +DA:2379,18 +DA:2382,7 +DA:2385,7 +DA:2386,7 +DA:2389,28 +DA:2392,28 +DA:2395,28 +DA:2398,28 +DA:2401,28 +DA:2404,28 +DA:2407,28 +DA:2410,28 +DA:2413,0 +DA:2415,0 +DA:2418,0 +DA:2419,0 +DA:2420,0 +DA:2429,0 +DA:2430,0 +DA:2441,37 +DA:2443,37 +DA:2446,36 +DA:2447,0 +DA:2448,0 +DA:2462,36 +DA:2464,36 +DA:2482,6 +DA:2485,6 +DA:2488,6 +DA:2491,6 +DA:2494,42 +DA:2497,42 +DA:2500,6 +DA:2503,6 +DA:2506,7 +DA:2508,7 +DA:2511,7 +DA:2512,0 +DA:2513,0 +DA:2527,7 +DA:2529,7 +DA:2547,7 +DA:2550,7 +DA:2551,7 +DA:2554,7 +DA:2557,7 +DA:2558,7 +DA:2561,14 +DA:2564,14 +DA:2565,14 +DA:2568,7 +DA:2571,7 +DA:2572,7 +DA:2575,3 +DA:2578,3 +DA:2581,3 +DA:2584,3 +DA:2585,3 +DA:2588,11686 +DA:2590,11686 +DA:2593,7 +DA:2595,7 +DA:2598,2 +DA:2600,2 +DA:2603,6 +DA:2605,6 +DA:2608,7 +DA:2611,8 +DA:2614,5 +DA:2617,7 +DA:2620,1 +DA:2623,1 +DA:2626,3 +DA:2629,3 +DA:2632,21 +DA:2634,21 +DA:2637,7 +DA:2639,7 +DA:2642,8 +DA:2644,8 +DA:2647,7 +DA:2649,7 +DA:2652,5 +DA:2655,6 +DA:2658,4 +DA:2661,4 +DA:2664,5 +DA:2667,6 +DA:2670,4 +DA:2673,4 +DA:2676,11729 +DA:2678,11729 +DA:2681,11720 +DA:2682,0 +DA:2683,0 +DA:2686,11720 +DA:2688,11720 +DA:2690,11720 +DA:2692,11720 +DA:2694,11727 +DA:2695,11720 +DA:2696,11720 +DA:2697,21 +DA:2698,21 +DA:2700,21 +DA:2709,11720 +DA:2713,21 +DA:2715,21 +DA:2717,21 +DA:2718,21 +DA:2719,21 +DA:2720,21 +DA:2721,0 +DA:2722,0 +DA:2727,21 +DA:2728,1 +DA:2729,1 +DA:2733,20 +DA:2735,20 +DA:2741,12 +DA:2744,12 +DA:2746,9 +DA:2749,6 +DA:2752,3 +DA:2756,12 +DA:2757,12 +DA:2761,11719 +DA:2762,11719 +DA:2763,11694 +DA:2764,11694 +DA:2765,11694 +DA:2766,25 +DA:2767,25 +DA:2768,25 +DA:2774,11719 +DA:2775,11719 +DA:2778,11719 +DA:2779,11719 +DA:2781,11726 +DA:2782,11719 +DA:2786,21 +DA:2787,21 +DA:2791,21 +DA:2792,15 +DA:2793,15 +DA:2798,11719 +DA:2799,11699 +DA:2802,11699 +DA:2804,11699 +DA:2805,11699 +DA:2806,11699 +DA:2808,20 +DA:2811,20 +DA:2812,20 +DA:2815,20 +DA:2816,20 +DA:2817,20 +DA:2826,11719 +DA:2828,11719 +DA:2831,11721 +DA:2833,11721 +DA:2836,11706 +DA:2837,11706 +DA:2840,0 +DA:2849,0 +DA:2852,0 +DA:2857,0 +DA:2860,0 +DA:2862,0 +DA:2863,0 +DA:2864,0 +DA:2868,0 +DA:2871,0 +DA:2872,0 +DA:2873,0 +DA:2878,0 +DA:2885,0 +DA:2886,0 +DA:2887,0 +DA:2889,0 +DA:2890,0 +DA:2891,0 +DA:2896,0 +DA:2897,0 +DA:2899,0 +DA:2900,0 +DA:2901,0 +DA:2902,0 +DA:2905,0 +DA:2906,0 +DA:2909,0 +DA:2913,0 +DA:2915,0 +DA:2916,0 +DA:2917,0 +DA:2918,0 +DA:2921,0 +DA:2922,0 +DA:2923,0 +DA:2926,0 +DA:2928,0 +DA:2931,0 +DA:2936,0 +DA:2942,1 +DA:2951,1 +DA:2956,1 +DA:2959,1 +DA:2961,1 +DA:2962,0 +DA:2963,0 +DA:2967,1 +DA:2970,1 +DA:2972,1 +DA:2974,1 +DA:2982,0 +DA:2985,0 +DA:2987,0 +DA:2994,0 +DA:3001,0 +DA:3006,0 +DA:3009,0 +DA:3010,0 +DA:3011,0 +DA:3014,0 +DA:3017,0 +DA:3019,0 +DA:3022,0 +DA:3023,0 +DA:3025,0 +DA:3026,0 +DA:3027,0 +DA:3031,0 +DA:3032,0 +DA:3033,0 +DA:3035,0 +DA:3036,0 +DA:3039,0 +DA:3041,0 +DA:3045,0 +DA:3047,0 +DA:3051,0 +DA:3053,0 +DA:3057,0 +DA:3059,0 +DA:3063,0 +DA:3066,0 +DA:3069,0 +DA:3071,0 +DA:3075,0 +DA:3077,0 +DA:3081,0 +DA:3085,0 +DA:3091,0 +DA:3101,0 +DA:3102,0 +DA:3103,0 +DA:3106,0 +DA:3108,0 +DA:3109,0 +DA:3110,0 +DA:3111,0 +DA:3114,0 +DA:3117,0 +DA:3118,0 +DA:3120,0 +DA:3124,0 +DA:3125,0 +DA:3127,0 +DA:3128,0 +DA:3129,0 +DA:3133,0 +DA:3134,0 +DA:3135,0 +DA:3138,0 +DA:3140,0 +DA:3144,0 +DA:3146,0 +DA:3150,0 +DA:3152,0 +DA:3156,0 +DA:3158,0 +DA:3161,0 +DA:3166,0 +DA:3170,0 +DA:3171,0 +DA:3174,0 +DA:3176,0 +DA:3179,0 +DA:3180,0 +DA:3181,0 +DA:3184,0 +DA:3187,0 +DA:3189,0 +DA:3193,0 +DA:3194,0 +DA:3196,0 +DA:3197,0 +DA:3198,0 +DA:3202,0 +DA:3203,0 +DA:3204,0 +DA:3207,0 +DA:3209,0 +DA:3213,0 +DA:3215,0 +DA:3218,0 +DA:3223,0 +DA:3230,16786 +DA:3235,16786 +DA:3236,0 +DA:3241,33572 +DA:3247,16786 +DA:3249,17033 +DA:3251,17033 +DA:3254,0 +DA:3256,0 +DA:3259,0 +DA:3260,0 +DA:3263,0 +DA:3264,0 +DA:3265,0 +DA:3266,0 +DA:3269,0 +DA:3272,0 +DA:3276,0 +DA:3277,0 +DA:3280,0 +DA:3283,0 +DA:3285,0 +DA:3286,0 +DA:3289,0 +DA:3290,0 +DA:3291,0 +DA:3297,0 +DA:3307,0 +DA:3308,0 +DA:3313,0 +DA:3316,0 +DA:3317,0 +DA:3320,0 +DA:3324,0 +DA:3325,0 +DA:3326,0 +DA:3329,0 +DA:3330,0 +DA:3331,0 +DA:3334,7 +DA:3342,7 +DA:3346,7 +DA:3347,7 +DA:3350,0 +DA:3352,0 +DA:3355,0 +DA:3357,0 +DA:3358,0 +DA:3359,0 +DA:3362,0 +DA:3364,0 +DA:3365,0 +DA:3366,0 +DA:3367,0 +DA:3371,0 +DA:3372,0 +DA:3373,0 +DA:3375,0 +DA:3379,0 +DA:3386,0 +DA:3387,0 +DA:3388,0 +DA:3389,0 +DA:3390,0 +DA:3391,0 +DA:3395,0 +DA:3396,0 +DA:3397,0 +DA:3398,0 +DA:3399,0 +DA:3401,0 +DA:3405,0 +DA:3407,0 +DA:3408,0 +DA:3410,0 +DA:3411,0 +DA:3412,0 +DA:3413,0 +DA:3414,0 +DA:3422,14 +DA:3429,14 +DA:3432,21 +DA:3441,21 +DA:3443,21 +DA:3446,15 +DA:3447,0 +DA:3448,0 +DA:3451,15 +DA:3454,15 +DA:3455,0 +DA:3459,0 +DA:3460,0 +DA:3462,0 +DA:3463,0 +DA:3464,0 +DA:3468,0 +DA:3469,0 +DA:3470,0 +DA:3472,0 +DA:3476,0 +DA:3478,0 +DA:3480,0 +DA:3484,0 +DA:3486,0 +DA:3490,0 +DA:3492,0 +DA:3499,0 +DA:3502,0 +DA:3504,0 +DA:3510,0 +DA:3512,0 +DA:3515,0 +DA:3519,0 +DA:3521,0 +DA:3525,0 +DA:3530,0 +DA:3584,18 +DA:3586,18 +DA:3589,18 +DA:3595,15 +DA:3596,11 +DA:3598,11 +DA:3605,25 +DA:3607,25 +DA:3610,25 +DA:3616,22 +DA:3617,16 +DA:3618,16 +DA:3620,16 +DA:3627,25 +DA:3629,25 +DA:3632,25 +DA:3638,22 +DA:3639,16 +DA:3640,16 +DA:3642,16 +DA:3649,22 +DA:3651,22 +DA:3654,22 +DA:3659,21 +DA:3660,15 +DA:3662,15 +DA:3663,0 +DA:3669,22 +DA:3671,22 +DA:3674,22 +DA:3679,21 +DA:3680,15 +DA:3682,15 +DA:3683,0 +DA:3689,11 +DA:3691,11 +DA:3694,11 +DA:3700,9 +DA:3701,7 +DA:3703,2 +DA:3706,5 +DA:3707,0 +DA:3713,1 +DA:3715,1 +DA:3716,0 +DA:3717,0 +DA:3718,0 +DA:3722,1 +DA:3725,10 +DA:3727,10 +DA:3728,0 +DA:3729,0 +DA:3730,0 +DA:3735,10 +DA:3737,10 +DA:3740,10 +DA:3742,10 +DA:3743,0 +DA:3744,0 +DA:3745,0 +DA:3750,10 +DA:3752,10 +DA:3755,2 +DA:3757,2 +DA:3758,0 +DA:3759,0 +DA:3760,0 +DA:3765,2 +DA:3767,2 +DA:3770,0 +DA:3772,0 +DA:3773,0 +DA:3774,0 +DA:3775,0 +DA:3780,0 +DA:3782,0 +DA:3785,0 +DA:3787,0 +DA:3788,0 +DA:3789,0 +DA:3790,0 +DA:3795,0 +DA:3797,0 +DA:3800,0 +DA:3802,0 +DA:3803,0 +DA:3804,0 +DA:3805,0 +DA:3810,0 +DA:3812,0 +DA:3815,0 +DA:3817,0 +DA:3818,0 +DA:3819,0 +DA:3820,0 +DA:3824,0 +DA:3826,0 +DA:3829,0 +DA:3831,0 +DA:3832,0 +DA:3833,0 +DA:3834,0 +DA:3838,0 +DA:3840,0 +DA:3844,33569 +DA:3850,33569 +DA:3854,33571 +DA:3855,33565 +DA:3857,16786 +DA:3881,16786 +DA:3882,0 +DA:3888,33572 +DA:3891,16786 +DA:3894,16786 +DA:3895,16786 +DA:3896,16786 +DA:3897,0 +DA:3900,16786 +DA:3904,16802 +DA:3905,16802 +DA:3907,0 +DA:3910,21 +DA:3913,21 +DA:3914,10 +DA:3929,21 +DA:3930,21 +DA:3931,21 +DA:3939,6411 +DA:3943,6411 +DA:3946,6411 +DA:3947,0 +DA:3949,0 +DA:3950,0 +DA:3951,0 +DA:3953,0 +DA:3957,6411 +DA:3958,6411 +DA:3959,6411 +DA:3962,6008 +DA:3976,6008 +DA:3977,0 +DA:3978,0 +DA:3981,6008 +DA:3982,6008 +DA:3983,5999 +DA:3984,5999 +DA:3989,5999 +DA:3992,5999 +DA:3995,5999 +DA:3997,5999 +DA:4000,5999 +DA:4001,5999 +DA:4004,5999 +DA:4005,5999 +DA:4008,5999 +DA:4009,5999 +DA:4012,5999 +DA:4013,5999 +DA:4014,5999 +DA:4017,6009 +DA:4019,5996 +DA:4022,3 +DA:4023,2 +DA:4029,5999 +DA:4032,5999 +DA:4035,5999 +DA:4036,5998 +DA:4039,1 +DA:4046,5999 +DA:4050,5999 +DA:4052,5998 +DA:4053,5998 +DA:4054,5998 +DA:4056,5998 +DA:4057,5998 +DA:4059,5998 +DA:4060,5998 +DA:4061,5998 +DA:4063,0 +DA:4065,0 +DA:4066,0 +DA:4067,0 +DA:4078,6007 +DA:4079,5996 +DA:4081,5998 +DA:4082,5998 +DA:4083,5998 +DA:4085,5998 +DA:4086,5998 +DA:4090,1 +DA:4094,5999 +DA:4096,5999 +DA:4097,0 +DA:4098,0 +DA:4101,5999 +DA:4104,5999 +DA:4106,5999 +DA:4107,0 +DA:4111,5999 +DA:4112,0 +DA:4118,0 +DA:4119,0 +DA:4120,0 +DA:4121,0 +DA:4124,0 +DA:4128,0 +DA:4129,0 +DA:4130,0 +DA:4131,0 +DA:4132,0 +DA:4135,0 +DA:4139,0 +DA:4141,0 +DA:4142,0 +DA:4146,5999 +DA:4147,0 +DA:4148,0 +DA:4149,0 +DA:4156,5999 +DA:4157,5811 +DA:4159,5999 +DA:4213,5998 +DA:4216,5998 +DA:4217,5998 +DA:4226,5999 +DA:4228,190 +DA:4231,190 +DA:4232,190 +DA:4233,190 +DA:4235,190 +DA:4236,5999 +DA:4237,0 +DA:4239,0 +DA:4240,0 +DA:4244,0 +DA:4250,0 +DA:4253,0 +DA:4254,0 +DA:4264,0 +DA:4265,0 +DA:4267,0 +DA:4269,0 +DA:4272,0 +DA:4274,0 +DA:4276,0 +DA:4278,0 +DA:4281,0 +DA:4289,171 +DA:4296,171 +DA:4300,171 +DA:4304,171 +DA:4305,171 +DA:4307,171 +DA:4308,171 +DA:4310,0 +DA:4312,171 +DA:4315,171 +DA:4318,171 +DA:4321,171 +DA:4322,164 +DA:4326,164 +DA:4327,164 +DA:4332,181 +DA:4338,181 +DA:4342,172 +DA:4346,172 +DA:4347,172 +DA:4349,172 +DA:4352,172 +DA:4357,172 +DA:4358,166 +DA:4368,205 +DA:4374,205 +DA:4377,205 +DA:4380,205 +DA:4384,205 +DA:4388,205 +DA:4389,205 +DA:4390,205 +DA:4391,205 +DA:4393,205 +DA:4394,205 +DA:4396,205 +DA:4397,205 +DA:4399,0 +DA:4401,205 +DA:4404,205 +DA:4406,205 +DA:4412,205 +DA:4415,205 +DA:4416,167 +DA:4420,167 +DA:4421,167 +DA:4427,204 +DA:4433,204 +DA:4436,204 +DA:4439,204 +DA:4443,204 +DA:4447,204 +DA:4448,204 +DA:4449,204 +DA:4451,204 +DA:4454,204 +DA:4461,204 +DA:4462,167 +DA:4472,0 +DA:4478,0 +DA:4479,0 +DA:4480,0 +DA:4483,0 +DA:4484,0 +DA:4485,0 +DA:4488,0 +DA:4492,0 +DA:4496,0 +DA:4497,0 +DA:4498,0 +DA:4500,0 +DA:4503,0 +DA:4508,0 +DA:4509,0 +DA:4519,4 +DA:4525,4 +DA:4526,0 +DA:4527,0 +DA:4531,4 +DA:4535,4 +DA:4537,4 +DA:4540,4 +DA:4545,4 +DA:4546,4 +DA:4556,1 +DA:4562,1 +DA:4565,1 +DA:4569,1 +DA:4573,1 +DA:4574,1 +DA:4584,0 +DA:4591,0 +DA:4595,0 +DA:4596,0 +DA:4597,0 +DA:4600,0 +DA:4601,0 +DA:4603,0 +DA:4604,0 +DA:4605,0 +DA:4608,0 +DA:4612,0 +DA:4613,0 +DA:4614,0 +DA:4616,0 +DA:4618,0 +DA:4621,16802 +DA:4656,16802 +DA:4662,16802 +DA:4664,16802 +DA:4665,16802 +DA:4667,16802 +DA:4669,21 +DA:4670,9 +DA:4671,0 +DA:4672,0 +DA:4675,9 +DA:4681,21 +DA:4688,12 +DA:4691,12 +DA:4694,0 +DA:4696,0 +DA:4699,24 +DA:4700,12 +DA:4704,12 +DA:4705,0 +DA:4706,0 +DA:4709,12 +DA:4710,5 +DA:4712,5 +DA:4717,5 +DA:4721,5 +DA:4723,5 +DA:4724,5 +DA:4725,5 +DA:4726,5 +DA:4727,5 +DA:4728,5 +DA:4730,5 +DA:4731,0 +DA:4734,5 +DA:4735,0 +DA:4736,0 +DA:4738,5 +DA:4739,5 +DA:4742,5 +DA:4743,5 +DA:4747,5 +DA:4751,5 +DA:4752,0 +DA:4754,0 +DA:4755,0 +DA:4758,5 +DA:4764,0 +DA:4767,0 +DA:4772,0 +DA:4773,0 +DA:4778,0 +DA:4779,0 +DA:4780,0 +DA:4785,0 +DA:4787,0 +DA:4789,0 +DA:4790,0 +DA:4791,0 +DA:4792,0 +DA:4794,0 +DA:4800,0 +DA:4807,0 +DA:4812,0 +DA:4814,0 +DA:4818,0 +DA:4819,0 +DA:4820,0 +DA:4826,0 +DA:4829,0 +DA:4831,0 +DA:4834,0 +DA:4836,0 +DA:4839,0 +DA:4846,0 +DA:4850,0 +DA:4852,0 +DA:4853,0 +DA:4858,7 +DA:4861,7 +DA:4866,7 +DA:4867,7 +DA:4870,7 +DA:4956,0 +DA:4958,0 +DA:4960,0 +DA:4961,0 +DA:4973,9 +DA:4974,0 +DA:4982,5834 +DA:4988,5834 +DA:4990,5834 +DA:4991,4 +DA:4992,4 +DA:4996,5830 +DA:4997,5830 +DA:4999,5830 +DA:5001,1 +DA:5002,1 +DA:5004,1 +DA:5005,1 +DA:5008,1 +DA:5009,1 +DA:5010,0 +DA:5013,0 +DA:5015,0 +DA:5016,0 +DA:5020,1 +DA:5023,1 +DA:5027,1 +DA:5028,0 +DA:5050,1 +DA:5054,1 +DA:5055,0 +DA:5058,1 +DA:5060,1 +DA:5061,1 +DA:5065,1 +DA:5066,1 +DA:5070,0 +DA:5076,121 +DA:5082,121 +DA:5083,111 +DA:5087,121 +DA:5088,111 +DA:5108,111 +DA:5111,0 +DA:5114,0 +DA:5126,0 +DA:5129,0 +DA:5132,0 +DA:5135,0 +DA:5137,0 +DA:5139,0 +DA:5140,0 +DA:5141,0 +DA:5145,0 +DA:5147,0 +DA:5148,0 +DA:5150,0 +DA:5155,0 +DA:5157,0 +DA:5161,0 +DA:5167,0 +DA:5170,0 +DA:5174,0 +DA:5175,0 +DA:5177,0 +DA:5182,0 +DA:5184,0 +DA:5187,0 +DA:5193,0 +DA:5194,0 +DA:5197,0 +DA:5198,0 +DA:5214,16786 +DA:5219,16786 +DA:5226,16786 +DA:5227,16786 +DA:5228,16786 +DA:5230,16786 +DA:5234,0 +DA:5235,0 +DA:5238,16786 +DA:5240,16786 +DA:5254,16786 +DA:5256,16786 +DA:5257,16786 +DA:5264,16767 +DA:5265,16767 +DA:5266,8535 +DA:5267,8535 +DA:5269,8232 +DA:5270,8232 +DA:5273,16767 +DA:5279,16767 +DA:5284,16786 +DA:5286,16786 +DA:5287,0 +DA:5288,0 +DA:5289,0 +DA:5294,16786 +DA:5296,0 +DA:5297,0 +DA:5303,16786 +DA:5308,16786 +DA:5311,16786 +DA:5322,16786 +DA:5323,0 +DA:5336,16786 +DA:5337,16786 +DA:5338,16786 +DA:5339,16786 +DA:5341,16786 +DA:5343,16786 +DA:5344,0 +DA:5350,16786 +DA:5351,16786 +DA:5353,16786 +DA:5354,0 +DA:5358,16786 +DA:5362,16786 +DA:5363,16786 +DA:5365,16786 +DA:5366,0 +DA:5370,16786 +DA:5373,16786 +DA:5375,0 +DA:5377,0 +DA:5378,0 +DA:5379,0 +DA:5383,0 +DA:5455,859 +DA:5459,859 +DA:5461,859 +DA:5462,859 +DA:5463,859 +DA:5465,859 +DA:5467,859 +DA:5471,0 +DA:5472,0 +DA:5477,859 +DA:5479,859 +LF:1757 +LH:1014 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/offlinelogstorage/dlt_offline_logstorage.c +FN:43,dlt_logstorage_filter_config_free +FN:122,dlt_logstorage_list_destroy +FN:159,dlt_logstorage_list_add_config +FN:200,dlt_logstorage_list_add +FN:263,dlt_logstorage_list_find +FN:290,dlt_logstorage_count_ids +FN:320,dlt_logstorage_free +FN:347,dlt_logstorage_read_list_of_names +FN:410,dlt_logstorage_set_number +FN:435,dlt_logstorage_read_number +FN:471,dlt_logstorage_get_keys_list +FN:519,dlt_logstorage_check_excluded_ids +FN:569,dlt_logstorage_create_keys_only_ctid +FN:604,dlt_logstorage_create_keys_only_apid +FN:641,dlt_logstorage_create_keys_multi +FN:681,dlt_logstorage_create_keys_only_ecu +FN:719,dlt_logstorage_create_keys +FN:817,dlt_logstorage_prepare_table +FN:908,dlt_logstorage_validate_filter_name +FN:958,dlt_logstorage_filter_set_strategy +FN:978,dlt_logstorage_check_apids +FN:989,dlt_logstorage_check_ctids +FN:998,dlt_logstorage_store_config_excluded_apids +FN:1009,dlt_logstorage_store_config_excluded_ctids +FN:1020,dlt_logstorage_set_loglevel +FN:1032,dlt_logstorage_check_loglevel +FN:1071,dlt_logstorage_check_reset_loglevel +FN:1118,dlt_logstorage_check_filename +FN:1162,dlt_logstorage_check_filesize +FN:1171,dlt_logstorage_check_nofiles +FN:1180,dlt_logstorage_check_specificsize +FN:1189,dlt_logstorage_set_sync_strategy +FN:1217,dlt_logstorage_check_sync_strategy +FN:1267,dlt_logstorage_check_overwrite_strategy +FN:1299,dlt_logstorage_check_disable_network +FN:1331,dlt_logstorage_check_gzip_compression +FN:1364,dlt_logstorage_check_ecuid +FN:1634,dlt_logstorage_check_param +FN:1647,dlt_logstorage_get_filter_section_value +FN:1682,dlt_logstorage_get_filter_value +FN:1725,dlt_logstorage_setup_table +FN:1748,dlt_daemon_offline_setup_filter_properties +FN:1851,dlt_logstorage_check_maintain_logstorage_loglevel +FN:1895,dlt_logstorage_check_general_param +FN:1912,dlt_daemon_setup_general_properties +FN:1970,dlt_logstorage_store_filters +FN:2057,dlt_logstorage_load_config +FN:2112,dlt_logstorage_device_connected +FN:2155,dlt_logstorage_device_disconnected +FN:2201,dlt_logstorage_get_loglevel_by_key +FN:2262,dlt_logstorage_get_config +FN:2407,dlt_logstorage_filter +FN:2508,dlt_logstorage_write +FN:2782,dlt_logstorage_sync_caches +FNDA:27,dlt_logstorage_check_sync_strategy +FNDA:13,dlt_logstorage_list_destroy +FNDA:8,dlt_logstorage_device_disconnected +FNDA:0,dlt_logstorage_create_keys_only_ecu +FNDA:5842,dlt_logstorage_write +FNDA:0,dlt_logstorage_check_general_param +FNDA:0,dlt_daemon_setup_general_properties +FNDA:5,dlt_logstorage_set_loglevel +FNDA:540,dlt_logstorage_get_filter_section_value +FNDA:0,dlt_logstorage_set_sync_strategy +FNDA:36,dlt_daemon_offline_setup_filter_properties +FNDA:1,dlt_logstorage_check_disable_network +FNDA:75,dlt_logstorage_filter_config_free +FNDA:0,dlt_logstorage_check_maintain_logstorage_loglevel +FNDA:78,dlt_logstorage_read_list_of_names +FNDA:0,dlt_logstorage_check_reset_loglevel +FNDA:40315,dlt_logstorage_list_find +FNDA:38,dlt_logstorage_check_apids +FNDA:38,dlt_logstorage_create_keys +FNDA:4,dlt_logstorage_sync_caches +FNDA:38,dlt_logstorage_check_ctids +FNDA:26,dlt_logstorage_check_param +FNDA:5849,dlt_logstorage_filter +FNDA:9,dlt_logstorage_device_connected +FNDA:2,dlt_logstorage_store_config_excluded_ctids +FNDA:39,dlt_logstorage_check_filename +FNDA:36,dlt_logstorage_setup_table +FNDA:34,dlt_logstorage_create_keys_multi +FNDA:11,dlt_logstorage_store_filters +FNDA:38,dlt_logstorage_validate_filter_name +FNDA:19,dlt_logstorage_count_ids +FNDA:540,dlt_logstorage_get_filter_value +FNDA:38,dlt_logstorage_check_nofiles +FNDA:37,dlt_logstorage_get_loglevel_by_key +FNDA:77,dlt_logstorage_list_add_config +FNDA:13,dlt_logstorage_filter_set_strategy +FNDA:7,dlt_logstorage_free +FNDA:38,dlt_logstorage_prepare_table +FNDA:4,dlt_logstorage_create_keys_only_apid +FNDA:0,dlt_logstorage_create_keys_only_ctid +FNDA:5884,dlt_logstorage_get_config +FNDA:81,dlt_logstorage_read_number +FNDA:24,dlt_logstorage_check_excluded_ids +FNDA:12,dlt_logstorage_set_number +FNDA:10,dlt_logstorage_load_config +FNDA:38,dlt_logstorage_check_loglevel +FNDA:0,dlt_logstorage_check_gzip_compression +FNDA:39,dlt_logstorage_check_filesize +FNDA:4,dlt_logstorage_check_specificsize +FNDA:30,dlt_logstorage_check_overwrite_strategy +FNDA:34,dlt_logstorage_check_ecuid +FNDA:76,dlt_logstorage_list_add +FNDA:2,dlt_logstorage_store_config_excluded_apids +FNDA:76,dlt_logstorage_get_keys_list +FNF:54 +FNH:46 +DA:43,75 +DA:48,75 +DA:49,72 +DA:50,72 +DA:53,75 +DA:54,72 +DA:55,72 +DA:58,75 +DA:59,0 +DA:60,0 +DA:63,75 +DA:64,0 +DA:65,0 +DA:68,75 +DA:69,70 +DA:70,70 +DA:73,75 +DA:74,27 +DA:75,27 +DA:78,75 +DA:79,64 +DA:80,64 +DA:83,75 +DA:84,3 +DA:91,75 +DA:92,23 +DA:93,23 +DA:96,75 +DA:98,114 +DA:100,39 +DA:101,39 +DA:102,39 +DA:106,39 +DA:109,75 +DA:122,13 +DA:129,52 +DA:131,39 +DA:132,39 +DA:134,39 +DA:135,39 +DA:138,39 +DA:141,39 +DA:146,39 +DA:148,39 +DA:152,39 +DA:156,13 +DA:159,77 +DA:162,77 +DA:168,77 +DA:169,72 +DA:171,77 +DA:172,72 +DA:174,77 +DA:175,12 +DA:177,77 +DA:178,12 +DA:180,77 +DA:181,70 +DA:183,77 +DA:184,66 +DA:200,76 +DA:207,245 +DA:208,169 +DA:211,76 +DA:213,76 +DA:216,76 +DA:217,76 +DA:218,76 +DA:220,0 +DA:222,0 +DA:226,76 +DA:227,76 +DA:228,76 +DA:230,76 +DA:231,0 +DA:233,0 +DA:235,0 +DA:238,76 +DA:239,0 +DA:241,0 +DA:243,0 +DA:245,0 +DA:248,76 +DA:250,76 +DA:263,40315 +DA:270,460056 +DA:271,833774 +DA:273,419741 +DA:274,419741 +DA:277,5708 +DA:278,5708 +DA:279,5708 +DA:282,419741 +DA:285,40315 +DA:290,19 +DA:293,19 +DA:301,400 +DA:302,322 +DA:303,18 +DA:305,322 +DA:320,7 +DA:322,7 +DA:323,0 +DA:324,0 +DA:327,7 +DA:328,7 +DA:347,78 +DA:355,78 +DA:356,1 +DA:357,1 +DA:361,77 +DA:362,5 +DA:363,5 +DA:366,77 +DA:368,77 +DA:369,0 +DA:371,0 +DA:375,13 +DA:378,77 +DA:380,77 +DA:381,0 +DA:382,0 +DA:385,77 +DA:386,77 +DA:390,169 +DA:391,92 +DA:392,92 +DA:394,92 +DA:396,92 +DA:397,15 +DA:399,92 +DA:401,92 +DA:402,92 +DA:410,12 +DA:412,12 +DA:413,0 +DA:414,0 +DA:417,80 +DA:419,80 +DA:435,81 +DA:441,81 +DA:444,80 +DA:445,80 +DA:448,308 +DA:449,228 +DA:450,0 +DA:451,0 +DA:454,80 +DA:456,80 +DA:471,76 +DA:475,76 +DA:478,76 +DA:481,76 +DA:483,76 +DA:486,76 +DA:488,76 +DA:489,0 +DA:490,0 +DA:493,76 +DA:496,76 +DA:497,0 +DA:498,0 +DA:501,152 +DA:503,76 +DA:504,0 +DA:505,0 +DA:508,76 +DA:510,76 +DA:511,76 +DA:514,76 +DA:516,76 +DA:519,24 +DA:522,24 +DA:525,24 +DA:526,1 +DA:527,1 +DA:530,23 +DA:532,23 +DA:533,0 +DA:534,0 +DA:537,23 +DA:539,23 +DA:540,0 +DA:541,0 +DA:542,0 +DA:545,39 +DA:546,29 +DA:547,13 +DA:548,13 +DA:551,16 +DA:554,10 +DA:555,10 +DA:569,0 +DA:572,0 +DA:576,0 +DA:584,0 +DA:585,0 +DA:586,0 +DA:589,0 +DA:590,0 +DA:591,0 +DA:604,4 +DA:607,4 +DA:611,4 +DA:619,4 +DA:620,4 +DA:621,4 +DA:625,4 +DA:626,4 +DA:627,4 +DA:641,34 +DA:644,34 +DA:648,34 +DA:656,34 +DA:657,34 +DA:658,34 +DA:663,34 +DA:664,34 +DA:665,34 +DA:668,34 +DA:669,34 +DA:670,34 +DA:681,0 +DA:683,0 +DA:688,0 +DA:689,0 +DA:719,38 +DA:726,38 +DA:727,38 +DA:728,38 +DA:729,38 +DA:732,38 +DA:736,38 +DA:737,38 +DA:738,0 +DA:739,0 +DA:740,0 +DA:741,0 +DA:744,0 +DA:747,0 +DA:748,0 +DA:751,38 +DA:752,0 +DA:753,0 +DA:757,38 +DA:758,0 +DA:759,0 +DA:763,38 +DA:764,0 +DA:765,0 +DA:766,0 +DA:769,38 +DA:772,38 +DA:775,38 +DA:776,0 +DA:777,0 +DA:778,0 +DA:782,76 +DA:783,38 +DA:785,76 +DA:786,38 +DA:788,38 +DA:789,0 +DA:790,38 +DA:791,4 +DA:793,34 +DA:795,38 +DA:797,38 +DA:802,38 +DA:803,38 +DA:805,38 +DA:817,38 +DA:821,38 +DA:823,38 +DA:828,38 +DA:829,1 +DA:830,1 +DA:833,37 +DA:839,37 +DA:840,0 +DA:841,0 +DA:845,37 +DA:850,0 +DA:851,0 +DA:852,0 +DA:854,0 +DA:857,37 +DA:858,36 +DA:860,165 +DA:861,139 +DA:867,139 +DA:872,26 +DA:873,36 +DA:874,36 +DA:876,0 +DA:879,0 +DA:881,0 +DA:883,36 +DA:884,36 +DA:885,36 +DA:887,36 +DA:888,10 +DA:890,26 +DA:894,37 +DA:896,37 +DA:908,38 +DA:916,38 +DA:919,37 +DA:922,37 +DA:925,45 +DA:926,8 +DA:932,0 +DA:936,0 +DA:937,0 +DA:943,0 +DA:947,0 +DA:948,0 +DA:958,13 +DA:961,13 +DA:965,13 +DA:967,20 +DA:968,20 +DA:969,20 +DA:972,25 +DA:973,25 +DA:974,25 +DA:978,38 +DA:981,38 +DA:982,1 +DA:983,1 +DA:986,37 +DA:989,38 +DA:992,38 +DA:995,37 +DA:998,2 +DA:1001,2 +DA:1002,1 +DA:1003,1 +DA:1006,1 +DA:1009,2 +DA:1012,2 +DA:1013,1 +DA:1014,1 +DA:1017,1 +DA:1020,5 +DA:1023,37 +DA:1024,37 +DA:1025,0 +DA:1026,0 +DA:1027,0 +DA:1032,38 +DA:1037,38 +DA:1038,1 +DA:1039,0 +DA:1040,1 +DA:1041,1 +DA:1044,37 +DA:1047,36 +DA:1051,32 +DA:1055,32 +DA:1059,0 +DA:1063,0 +DA:1068,5 +DA:1071,0 +DA:1074,0 +DA:1077,0 +DA:1078,0 +DA:1079,0 +DA:1082,0 +DA:1083,0 +DA:1085,0 +DA:1087,0 +DA:1089,0 +DA:1091,0 +DA:1093,0 +DA:1095,0 +DA:1097,0 +DA:1099,0 +DA:1101,0 +DA:1103,0 +DA:1105,0 +DA:1107,0 +DA:1110,0 +DA:1111,0 +DA:1112,0 +DA:1118,39 +DA:1123,39 +DA:1124,1 +DA:1125,1 +DA:1128,38 +DA:1129,2 +DA:1130,2 +DA:1133,38 +DA:1135,38 +DA:1136,0 +DA:1138,0 +DA:1142,38 +DA:1143,37 +DA:1145,37 +DA:1146,0 +DA:1148,0 +DA:1151,37 +DA:1154,1 +DA:1156,1 +DA:1159,37 +DA:1162,39 +DA:1165,39 +DA:1168,38 +DA:1171,38 +DA:1174,38 +DA:1177,37 +DA:1180,4 +DA:1183,4 +DA:1186,4 +DA:1189,0 +DA:1192,0 +DA:1194,0 +DA:1196,0 +DA:1198,0 +DA:1199,0 +DA:1217,27 +DA:1220,27 +DA:1223,26 +DA:1224,1 +DA:1225,1 +DA:1229,25 +DA:1230,8 +DA:1232,25 +DA:1233,4 +DA:1235,25 +DA:1236,0 +DA:1238,25 +DA:1239,4 +DA:1241,25 +DA:1242,12 +DA:1244,25 +DA:1245,1 +DA:1247,1 +DA:1248,1 +DA:1267,30 +DA:1270,30 +DA:1273,30 +DA:1274,12 +DA:1275,18 +DA:1276,18 +DA:1278,0 +DA:1280,0 +DA:1281,0 +DA:1299,1 +DA:1302,1 +DA:1305,1 +DA:1306,1 +DA:1307,0 +DA:1308,0 +DA:1310,0 +DA:1312,0 +DA:1313,0 +DA:1331,0 +DA:1349,0 +DA:1350,0 +DA:1352,0 +DA:1364,34 +DA:1369,34 +DA:1372,33 +DA:1373,1 +DA:1374,1 +DA:1377,33 +DA:1378,33 +DA:1380,33 +DA:1383,33 +DA:1385,33 +DA:1634,26 +DA:1638,26 +DA:1641,25 +DA:1642,25 +DA:1647,540 +DA:1654,540 +DA:1657,540 +DA:1658,504 +DA:1662,504 +DA:1663,0 +DA:1666,0 +DA:1669,504 +DA:1670,197 +DA:1672,197 +DA:1682,540 +DA:1692,540 +DA:1696,540 +DA:1699,540 +DA:1703,0 +DA:1706,0 +DA:1710,0 +DA:1713,0 +DA:1718,0 +DA:1725,36 +DA:1732,36 +DA:1734,36 +DA:1736,36 +DA:1737,0 +DA:1741,36 +DA:1748,36 +DA:1753,36 +DA:1757,36 +DA:1761,36 +DA:1763,36 +DA:1765,576 +DA:1766,540 +DA:1768,540 +DA:1771,540 +DA:1772,233 +DA:1775,307 +DA:1777,307 +DA:1778,0 +DA:1779,0 +DA:1780,0 +DA:1783,0 +DA:1784,0 +DA:1785,0 +DA:1788,0 +DA:1789,0 +DA:1790,0 +DA:1793,0 +DA:1794,0 +DA:1795,0 +DA:1798,0 +DA:1799,0 +DA:1800,0 +DA:1803,0 +DA:1804,0 +DA:1805,0 +DA:1808,0 +DA:1809,0 +DA:1813,0 +DA:1817,36 +DA:1818,0 +DA:1819,0 +DA:1823,36 +DA:1825,36 +DA:1826,0 +DA:1830,36 +DA:1834,36 +DA:1836,36 +DA:1851,0 +DA:1854,0 +DA:1859,0 +DA:1861,0 +DA:1863,0 +DA:1865,0 +DA:1869,0 +DA:1871,0 +DA:1872,0 +DA:1895,0 +DA:1899,0 +DA:1904,0 +DA:1906,0 +DA:1912,0 +DA:1917,0 +DA:1919,0 +DA:1924,0 +DA:1926,0 +DA:1928,0 +DA:1931,0 +DA:1933,0 +DA:1940,0 +DA:1942,0 +DA:1948,0 +DA:1951,0 +DA:1970,11 +DA:1975,11 +DA:1981,11 +DA:1982,1 +DA:1983,1 +DA:1986,10 +DA:1988,10 +DA:1989,0 +DA:1990,0 +DA:1993,10 +DA:1994,10 +DA:1996,46 +DA:1999,36 +DA:2000,0 +DA:2001,0 +DA:2002,0 +DA:2005,36 +DA:2006,0 +DA:2008,0 +DA:2009,0 +DA:2012,36 +DA:2014,36 +DA:2016,36 +DA:2019,36 +DA:2022,0 +DA:2026,0 +DA:2030,36 +DA:2034,0 +DA:2038,10 +DA:2040,10 +DA:2057,10 +DA:2059,10 +DA:2063,10 +DA:2064,9 +DA:2068,9 +DA:2069,0 +DA:2072,0 +DA:2075,9 +DA:2078,9 +DA:2080,0 +DA:2082,0 +DA:2084,9 +DA:2085,9 +DA:2087,9 +DA:2088,0 +DA:2089,0 +DA:2091,9 +DA:2093,0 +DA:2095,0 +DA:2098,9 +DA:2100,9 +DA:2112,9 +DA:2114,9 +DA:2115,1 +DA:2116,1 +DA:2119,8 +DA:2120,0 +DA:2123,0 +DA:2128,8 +DA:2129,8 +DA:2130,8 +DA:2131,8 +DA:2132,8 +DA:2133,8 +DA:2134,8 +DA:2136,8 +DA:2137,8 +DA:2139,8 +DA:2155,8 +DA:2158,8 +DA:2162,7 +DA:2163,6 +DA:2166,7 +DA:2167,7 +DA:2168,7 +DA:2169,7 +DA:2170,7 +DA:2172,39 +DA:2174,32 +DA:2175,32 +DA:2176,32 +DA:2177,32 +DA:2179,32 +DA:2180,23 +DA:2183,32 +DA:2201,37 +DA:2203,37 +DA:2209,37 +DA:2210,37 +DA:2211,36 +DA:2212,36 +DA:2215,36 +DA:2217,36 +DA:2219,0 +DA:2220,0 +DA:2222,36 +DA:2224,36 +DA:2226,36 +DA:2235,0 +DA:2238,0 +DA:2240,0 +DA:2262,5884 +DA:2269,5884 +DA:2279,5884 +DA:2280,5883 +DA:2281,5883 +DA:2295,5883 +DA:2300,5883 +DA:2302,0 +DA:2306,0 +DA:2308,0 +DA:2311,5883 +DA:2312,5883 +DA:2318,5883 +DA:2319,5883 +DA:2327,5883 +DA:2328,5883 +DA:2334,5883 +DA:2335,5883 +DA:2339,5883 +DA:2340,5883 +DA:2342,5883 +DA:2343,5883 +DA:2346,5883 +DA:2348,5883 +DA:2349,5883 +DA:2351,5883 +DA:2352,5883 +DA:2357,5883 +DA:2358,5883 +DA:2365,5883 +DA:2366,5883 +DA:2374,45860 +DA:2376,40278 +DA:2377,40278 +DA:2379,40278 +DA:2381,40278 +DA:2407,5849 +DA:2417,5849 +DA:2421,5848 +DA:2423,5848 +DA:2424,231 +DA:2427,231 +DA:2430,11252 +DA:2432,5635 +DA:2434,0 +DA:2437,0 +DA:2441,5635 +DA:2442,6 +DA:2445,6 +DA:2446,6 +DA:2450,5629 +DA:2451,5629 +DA:2453,0 +DA:2456,0 +DA:2457,0 +DA:2461,5629 +DA:2463,6 +DA:2464,3 +DA:2465,3 +DA:2466,3 +DA:2467,3 +DA:2470,5623 +DA:2472,5617 +DA:2473,3 +DA:2474,3 +DA:2475,3 +DA:2478,6 +DA:2480,6 +DA:2481,3 +DA:2482,3 +DA:2483,3 +DA:2508,5842 +DA:2518,5842 +DA:2536,5842 +DA:2537,5841 +DA:2538,5841 +DA:2539,5841 +DA:2545,5841 +DA:2548,5841 +DA:2549,5 +DA:2551,5841 +DA:2552,2 +DA:2557,5841 +DA:2558,5841 +DA:2561,5841 +DA:2562,0 +DA:2563,0 +DA:2566,5841 +DA:2567,5841 +DA:2569,5841 +DA:2573,5841 +DA:2574,5841 +DA:2576,5841 +DA:2577,231 +DA:2580,231 +DA:2584,0 +DA:2587,0 +DA:2588,0 +DA:2589,0 +DA:2596,0 +DA:2597,0 +DA:2599,0 +DA:2600,0 +DA:2601,0 +DA:2606,11224 +DA:2608,5614 +DA:2610,6 +DA:2613,6 +DA:2618,5608 +DA:2620,0 +DA:2623,0 +DA:2627,5608 +DA:2628,201 +DA:2629,201 +DA:2630,0 +DA:2633,201 +DA:2637,5608 +DA:2639,2156 +DA:2642,2156 +DA:2645,3452 +DA:2646,23250 +DA:2647,23250 +DA:2652,19798 +DA:2655,3452 +DA:2656,0 +DA:2658,0 +DA:2662,3452 +DA:2663,0 +DA:2666,3452 +DA:2669,3452 +DA:2670,3452 +DA:2672,3452 +DA:2673,3452 +DA:2677,3452 +DA:2678,4 +DA:2681,3448 +DA:2682,3428 +DA:2685,339 +DA:2686,0 +DA:2688,0 +DA:2694,339 +DA:2695,332 +DA:2696,332 +DA:2698,339 +DA:2699,339 +DA:2703,3448 +DA:2704,3428 +DA:2706,3428 +DA:2714,3428 +DA:2722,3428 +DA:2724,3089 +DA:2725,1690 +DA:2726,1674 +DA:2727,1674 +DA:2729,1690 +DA:2730,1690 +DA:2735,3428 +DA:2740,3428 +DA:2741,0 +DA:2745,0 +DA:2747,0 +DA:2751,0 +DA:2756,20 +DA:2758,20 +DA:2760,4 +DA:2761,4 +DA:2765,16 +DA:2782,4 +DA:2786,4 +DA:2789,4 +DA:2791,30 +DA:2792,26 +DA:2793,26 +DA:2795,26 +DA:2797,0 +DA:2802,26 +LF:844 +LH:598 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/offlinelogstorage/dlt_offline_logstorage_behavior.c +FN:47,dlt_logstorage_concat_logfile_name +FN:85,dlt_logstorage_log_file_name +FN:168,dlt_logstorage_sort_file_name +FN:212,dlt_logstorage_rearrange_file_name +FN:262,dlt_logstorage_get_idx_of_log_file +FN:302,dlt_logstorage_storage_dir_info +FN:479,dlt_logstorage_open_log_output_file +FN:515,dlt_logstorage_open_log_file +FN:771,dlt_logstorage_find_dlt_header +FN:797,dlt_logstorage_find_last_dlt_header +FN:823,dlt_logstorage_write_to_log +FN:845,dlt_logstorage_check_write_ret +FN:896,dlt_logstorage_close_file +FN:924,dlt_logstorage_sync_to_file +FN:1048,dlt_logstorage_prepare_on_msg +FN:1168,dlt_logstorage_write_on_msg +FN:1222,dlt_logstorage_sync_on_msg +FN:1262,dlt_logstorage_prepare_msg_cache +FN:1380,dlt_logstorage_write_msg_cache +FN:1515,dlt_logstorage_sync_msg_cache +FNDA:86,dlt_logstorage_find_last_dlt_header +FNDA:187,dlt_logstorage_sync_to_file +FNDA:3098,dlt_logstorage_prepare_msg_cache +FNDA:407,dlt_logstorage_get_idx_of_log_file +FNDA:302,dlt_logstorage_sort_file_name +FNDA:306,dlt_logstorage_storage_dir_info +FNDA:363,dlt_logstorage_prepare_on_msg +FNDA:3299,dlt_logstorage_sync_msg_cache +FNDA:3093,dlt_logstorage_write_msg_cache +FNDA:196,dlt_logstorage_open_log_output_file +FNDA:305,dlt_logstorage_open_log_file +FNDA:341,dlt_logstorage_write_on_msg +FNDA:5,dlt_logstorage_write_to_log +FNDA:270,dlt_logstorage_find_dlt_header +FNDA:130,dlt_logstorage_log_file_name +FNDA:200,dlt_logstorage_check_write_ret +FNDA:362,dlt_logstorage_sync_on_msg +FNDA:3,dlt_logstorage_rearrange_file_name +FNDA:4,dlt_logstorage_close_file +FNDA:263,dlt_logstorage_concat_logfile_name +FNF:20 +FNH:20 +DA:47,263 +DA:49,263 +DA:50,263 +DA:52,263 +DA:53,263 +DA:56,0 +DA:59,263 +DA:60,0 +DA:62,263 +DA:85,130 +DA:92,130 +DA:95,129 +DA:96,129 +DA:98,129 +DA:105,129 +DA:109,129 +DA:110,129 +DA:114,129 +DA:115,81 +DA:116,81 +DA:117,0 +DA:119,81 +DA:120,0 +DA:130,129 +DA:131,5 +DA:132,5 +DA:135,5 +DA:136,5 +DA:137,5 +DA:141,5 +DA:142,5 +DA:147,5 +DA:148,0 +DA:151,5 +DA:154,129 +DA:155,129 +DA:156,0 +DA:168,302 +DA:173,302 +DA:176,327 +DA:179,169 +DA:180,169 +DA:184,353 +DA:185,184 +DA:186,184 +DA:188,12 +DA:189,12 +DA:190,12 +DA:195,184 +DA:197,184 +DA:212,3 +DA:220,3 +DA:223,2 +DA:229,4 +DA:233,3 +DA:234,1 +DA:245,1 +DA:246,1 +DA:247,1 +DA:248,1 +DA:262,407 +DA:266,407 +DA:279,406 +DA:280,406 +DA:281,406 +DA:282,406 +DA:284,406 +DA:285,0 +DA:288,406 +DA:302,306 +DA:311,306 +DA:315,306 +DA:316,306 +DA:319,306 +DA:320,306 +DA:321,305 +DA:322,305 +DA:327,305 +DA:329,14 +DA:330,14 +DA:334,14 +DA:335,14 +DA:336,14 +DA:337,0 +DA:339,0 +DA:341,14 +DA:347,305 +DA:349,305 +DA:350,5 +DA:352,5 +DA:355,300 +DA:360,300 +DA:361,300 +DA:362,714 +DA:364,449 +DA:365,449 +DA:367,449 +DA:370,265 +DA:373,300 +DA:375,7205 +DA:377,6905 +DA:379,6905 +DA:381,6905 +DA:382,6905 +DA:383,822 +DA:385,159 +DA:386,73 +DA:387,0 +DA:390,397 +DA:394,663 +DA:395,339 +DA:398,324 +DA:404,425 +DA:405,268 +DA:407,268 +DA:409,0 +DA:410,0 +DA:413,268 +DA:416,157 +DA:418,314 +DA:419,157 +DA:421,157 +DA:423,157 +DA:425,0 +DA:426,0 +DA:430,425 +DA:431,425 +DA:436,425 +DA:437,425 +DA:438,425 +DA:439,425 +DA:440,425 +DA:444,300 +DA:447,300 +DA:448,300 +DA:457,300 +DA:458,0 +DA:462,7205 +DA:463,6905 +DA:465,300 +DA:467,300 +DA:479,196 +DA:483,196 +DA:484,196 +DA:485,0 +DA:486,0 +DA:488,196 +DA:489,196 +DA:495,196 +DA:496,196 +DA:515,305 +DA:523,305 +DA:524,305 +DA:525,305 +DA:532,305 +DA:535,304 +DA:536,0 +DA:537,0 +DA:543,304 +DA:544,304 +DA:549,299 +DA:551,724 +DA:552,425 +DA:554,425 +DA:557,425 +DA:561,299 +DA:562,31 +DA:565,31 +DA:566,31 +DA:572,31 +DA:573,31 +DA:576,31 +DA:578,31 +DA:579,0 +DA:580,0 +DA:583,31 +DA:584,31 +DA:585,31 +DA:594,268 +DA:595,266 +DA:596,265 +DA:597,265 +DA:599,266 +DA:601,268 +DA:603,268 +DA:608,268 +DA:613,268 +DA:614,268 +DA:615,103 +DA:616,165 +DA:617,165 +DA:624,103 +DA:627,65 +DA:632,103 +DA:633,14 +DA:638,14 +DA:639,10 +DA:642,10 +DA:643,10 +DA:647,93 +DA:651,93 +DA:653,2 +DA:656,93 +DA:659,93 +DA:660,93 +DA:670,93 +DA:671,93 +DA:672,93 +DA:678,93 +DA:679,1 +DA:680,1 +DA:681,1 +DA:686,93 +DA:688,93 +DA:693,93 +DA:695,93 +DA:696,0 +DA:697,0 +DA:700,93 +DA:701,93 +DA:702,93 +DA:704,93 +DA:707,93 +DA:708,85 +DA:711,53 +DA:716,53 +DA:717,53 +DA:721,53 +DA:722,0 +DA:724,53 +DA:725,53 +DA:726,53 +DA:728,53 +DA:738,289 +DA:740,0 +DA:741,0 +DA:742,0 +DA:743,0 +DA:745,0 +DA:746,0 +DA:749,0 +DA:750,0 +DA:751,0 +DA:754,0 +DA:755,0 +DA:771,270 +DA:775,270 +DA:776,270 +DA:779,284 +DA:780,283 +DA:781,269 +DA:797,86 +DA:801,86 +DA:802,86 +DA:805,6016 +DA:806,5953 +DA:807,23 +DA:823,5 +DA:833,5 +DA:845,200 +DA:848,200 +DA:849,0 +DA:850,0 +DA:853,200 +DA:854,0 +DA:862,0 +DA:863,0 +DA:868,200 +DA:874,200 +DA:875,0 +DA:878,200 +DA:880,0 +DA:881,0 +DA:896,4 +DA:905,174 +DA:906,280 +DA:907,280 +DA:909,4 +DA:924,187 +DA:937,187 +DA:938,186 +DA:940,1 +DA:941,1 +DA:944,186 +DA:949,2 +DA:950,186 +DA:952,186 +DA:954,0 +DA:955,0 +DA:958,186 +DA:959,0 +DA:960,2 +DA:963,184 +DA:965,184 +DA:968,84 +DA:970,84 +DA:972,84 +DA:973,84 +DA:975,84 +DA:976,22 +DA:978,22 +DA:979,22 +DA:982,0 +DA:983,22 +DA:985,22 +DA:986,22 +DA:991,0 +DA:992,62 +DA:996,184 +DA:997,184 +DA:999,184 +DA:1005,184 +DA:1008,84 +DA:1011,0 +DA:1012,0 +DA:1013,0 +DA:1016,84 +DA:1018,0 +DA:1019,6 +DA:1023,178 +DA:1024,178 +DA:1026,178 +DA:1027,178 +DA:1030,178 +DA:1031,2 +DA:1032,2 +DA:1048,363 +DA:1057,363 +DA:1058,362 +DA:1059,1 +DA:1060,1 +DA:1067,362 +DA:1070,16 +DA:1071,2 +DA:1072,2 +DA:1073,1 +DA:1074,1 +DA:1076,2 +DA:1080,16 +DA:1088,346 +DA:1090,346 +DA:1097,336 +DA:1098,320 +DA:1099,320 +DA:1102,16 +DA:1104,16 +DA:1105,0 +DA:1106,0 +DA:1107,0 +DA:1112,16 +DA:1113,0 +DA:1114,0 +DA:1120,0 +DA:1123,16 +DA:1124,16 +DA:1125,16 +DA:1126,16 +DA:1127,16 +DA:1129,16 +DA:1132,16 +DA:1144,10 +DA:1168,341 +DA:1180,341 +DA:1181,340 +DA:1186,340 +DA:1188,340 +DA:1189,0 +DA:1191,340 +DA:1192,340 +DA:1193,0 +DA:1195,340 +DA:1196,340 +DA:1197,0 +DA:1207,340 +DA:1222,362 +DA:1230,362 +DA:1233,361 +DA:1234,340 +DA:1240,340 +DA:1241,0 +DA:1262,3098 +DA:1268,3098 +DA:1269,3097 +DA:1278,3097 +DA:1279,1675 +DA:1280,1674 +DA:1281,1674 +DA:1282,0 +DA:1283,0 +DA:1285,1675 +DA:1286,1 +DA:1287,1 +DA:1296,3097 +DA:1297,452 +DA:1298,0 +DA:1299,0 +DA:1305,3097 +DA:1306,452 +DA:1307,452 +DA:1309,0 +DA:1312,0 +DA:1315,3097 +DA:1320,29 +DA:1323,4 +DA:1327,25 +DA:1331,29 +DA:1332,29 +DA:1335,5 +DA:1338,5 +DA:1340,24 +DA:1347,24 +DA:1349,24 +DA:1351,0 +DA:1357,24 +DA:1380,3093 +DA:1397,3093 +DA:1398,3092 +DA:1399,3092 +DA:1404,3092 +DA:1407,452 +DA:1411,2640 +DA:1414,3092 +DA:1415,3092 +DA:1416,3092 +DA:1418,3092 +DA:1420,2824 +DA:1421,2824 +DA:1422,2824 +DA:1423,1510 +DA:1427,2824 +DA:1428,2824 +DA:1429,2824 +DA:1430,2824 +DA:1431,2824 +DA:1439,3092 +DA:1442,268 +DA:1444,0 +DA:1445,0 +DA:1449,268 +DA:1452,62 +DA:1456,62 +DA:1458,0 +DA:1459,0 +DA:1462,206 +DA:1466,102 +DA:1470,102 +DA:1472,0 +DA:1473,0 +DA:1476,104 +DA:1477,52 +DA:1478,52 +DA:1481,104 +DA:1484,268 +DA:1487,268 +DA:1488,268 +DA:1489,268 +DA:1492,268 +DA:1493,268 +DA:1494,268 +DA:1495,268 +DA:1496,268 +DA:1515,3299 +DA:1524,3299 +DA:1530,3298 +DA:1532,177 +DA:1534,0 +DA:1536,0 +DA:1539,177 +DA:1542,102 +DA:1546,75 +DA:1549,177 +DA:1552,177 +DA:1555,169 +DA:1559,8 +DA:1560,0 +DA:1564,0 +DA:1566,0 +DA:1567,0 +DA:1574,8 +DA:1576,8 +DA:1577,8 +DA:1582,177 +DA:1583,177 +DA:1586,164 +DA:1590,177 +DA:1593,0 +DA:1594,62 +LF:487 +LH:405 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/shared/dlt_common.c +FN:131,dlt_print_hex +FN:146,dlt_print_hex_string_delim +FN:174,dlt_print_hex_string +FN:179,dlt_print_mixed_string +FN:295,dlt_print_char_string +FN:327,dlt_strnlen_s +FN:339,dlt_print_id +FN:355,dlt_set_id +FN:387,dlt_clean_string +FN:399,dlt_filter_init +FN:411,dlt_filter_free +FN:421,dlt_filter_load +FN:489,dlt_filter_save +FN:530,dlt_filter_find +FN:566,dlt_filter_add +FN:598,dlt_filter_delete +FN:648,dlt_message_init +FN:671,dlt_message_free +FN:688,dlt_message_header +FN:693,dlt_message_header_flags +FN:821,dlt_message_payload +FN:963,dlt_message_filter_check +FN:994,dlt_message_read +FN:1135,dlt_message_get_extraparameters +FN:1163,dlt_message_set_extraparameters +FN:1195,dlt_file_init +FN:1219,dlt_file_set_filter +FN:1232,dlt_file_read_header +FN:1302,dlt_file_read_header_raw +FN:1401,dlt_file_read_header_extended +FN:1444,dlt_file_read_data +FN:1483,dlt_file_open +FN:1528,dlt_file_read +FN:1645,dlt_file_read_raw +FN:1721,dlt_file_close +FN:1736,dlt_file_message +FN:1772,dlt_file_free +FN:1795,dlt_log_set_fifo_basedir +FN:1810,dlt_print_with_attributes +FN:1815,dlt_receiver_init +FN:1852,dlt_receiver_init_global_buffer +FN:1880,dlt_receiver_free +FN:1899,dlt_receiver_free_global_buffer +FN:1915,dlt_receiver_receive +FN:1968,dlt_receiver_remove +FN:1988,dlt_receiver_move_to_begin +FN:2010,dlt_receiver_check_and_get +FN:2044,dlt_set_storageheader +FN:2080,dlt_check_rcv_data_size +FN:2091,dlt_check_storageheader +FN:2103,dlt_buffer_init_static_server +FN:2134,dlt_buffer_init_static_client +FN:2156,dlt_buffer_init_dynamic +FN:2216,dlt_buffer_free_static +FN:2231,dlt_buffer_free_dynamic +FN:2250,dlt_buffer_write_block +FN:2281,dlt_buffer_read_block +FN:2307,dlt_buffer_check_size +FN:2318,dlt_buffer_increase_size +FN:2384,dlt_buffer_minimize_size +FN:2431,dlt_buffer_reset +FN:2454,dlt_buffer_push +FN:2459,dlt_buffer_push3 +FN:2550,dlt_buffer_get +FN:2670,dlt_buffer_pull +FN:2675,dlt_buffer_copy +FN:2680,dlt_buffer_remove +FN:2685,dlt_buffer_info +FN:2698,dlt_buffer_status +FN:2721,dlt_buffer_get_total_size +FN:2730,dlt_buffer_get_used_size +FN:2755,dlt_buffer_get_message_count +FN:2770,dlt_setup_serial +FN:2837,dlt_convert_serial_speed +FN:3018,dlt_get_version +FN:3043,dlt_get_major_version +FN:3053,dlt_get_minor_version +FN:3064,dlt_uptime +FN:3083,dlt_message_print_header +FN:3095,dlt_message_print_hex +FN:3111,dlt_message_print_ascii +FN:3127,dlt_message_print_mixed_plain +FN:3143,dlt_message_print_mixed_html +FN:3160,dlt_message_argument_print +FN:3808,dlt_check_envvar +FN:3852,dlt_set_loginfo_parse_service_id +FN:3880,dlt_getloginfo_conv_ascii_to_uint16_t +FN:3901,dlt_getloginfo_conv_ascii_to_int16_t +FN:3920,dlt_getloginfo_conv_ascii_to_string +FN:3934,dlt_getloginfo_conv_ascii_to_id +FN:3956,dlt_hex_ascii_to_binary +FN:4006,dlt_file_quick_parsing +FN:4082,dlt_execute_command +FN:4148,get_filename_ext +FN:4159,dlt_extract_base_name_without_ext +FNDA:6627,dlt_file_read_header +FNDA:2724,dlt_print_hex_string +FNDA:1062,dlt_print_mixed_string +FNDA:328,dlt_message_print_header +FNDA:1964,dlt_receiver_receive +FNDA:2752,dlt_file_read +FNDA:6247,dlt_message_set_extraparameters +FNDA:1,dlt_filter_free +FNDA:0,dlt_buffer_free_static +FNDA:9,dlt_get_minor_version +FNDA:16786,dlt_check_envvar +FNDA:22,dlt_get_version +FNDA:7,dlt_filter_init +FNDA:6109,dlt_message_init +FNDA:2503,dlt_buffer_get_used_size +FNDA:53,dlt_buffer_read_block +FNDA:6589,dlt_check_storageheader +FNDA:328,dlt_message_print_hex +FNDA:6301,dlt_uptime +FNDA:7,dlt_buffer_increase_size +FNDA:859,dlt_buffer_check_size +FNDA:3,dlt_file_quick_parsing +FNDA:2420,dlt_message_header +FNDA:0,dlt_buffer_init_static_client +FNDA:77315,dlt_set_id +FNDA:0,dlt_print_with_attributes +FNDA:12,dlt_getloginfo_conv_ascii_to_int16_t +FNDA:7,dlt_buffer_remove +FNDA:64,dlt_buffer_get +FNDA:8,dlt_buffer_pull +FNDA:0,dlt_filter_delete +FNDA:0,dlt_file_read_raw +FNDA:15284,dlt_buffer_push3 +FNDA:7516,dlt_buffer_push +FNDA:51,dlt_file_free +FNDA:14,dlt_getloginfo_conv_ascii_to_uint16_t +FNDA:2733,dlt_print_hex_string_delim +FNDA:20,dlt_getloginfo_conv_ascii_to_id +FNDA:3770,dlt_file_message +FNDA:13,dlt_buffer_copy +FNDA:16828,dlt_receiver_init +FNDA:0,dlt_file_read_header_raw +FNDA:328,dlt_message_print_mixed_html +FNDA:0,dlt_buffer_init_static_server +FNDA:16795,dlt_log_set_fifo_basedir +FNDA:6,dlt_extract_base_name_without_ext +FNDA:1159,dlt_clean_string +FNDA:12,dlt_filter_add +FNDA:5122,dlt_message_header_flags +FNDA:9,dlt_check_rcv_data_size +FNDA:2,dlt_set_loginfo_parse_service_id +FNDA:8,dlt_buffer_minimize_size +FNDA:0,dlt_hex_ascii_to_binary +FNDA:8527,dlt_buffer_get_message_count +FNDA:9,dlt_get_major_version +FNDA:328,dlt_message_print_ascii +FNDA:2771,dlt_message_argument_print +FNDA:7222,dlt_message_get_extraparameters +FNDA:742,dlt_message_filter_check +FNDA:0,dlt_execute_command +FNDA:6,dlt_filter_load +FNDA:1661,dlt_print_char_string +FNDA:6680,dlt_message_read +FNDA:4505,dlt_file_read_header_extended +FNDA:6,dlt_file_set_filter +FNDA:9,dlt_buffer_reset +FNDA:0,dlt_print_hex +FNDA:2,dlt_buffer_status +FNDA:0,dlt_setup_serial +FNDA:0,dlt_convert_serial_speed +FNDA:41031,dlt_buffer_write_block +FNDA:5,get_filename_ext +FNDA:16827,dlt_receiver_free +FNDA:11,dlt_getloginfo_conv_ascii_to_string +FNDA:3,dlt_buffer_get_total_size +FNDA:16891,dlt_buffer_free_dynamic +FNDA:12103,dlt_set_storageheader +FNDA:1958,dlt_receiver_move_to_begin +FNDA:50,dlt_file_open +FNDA:5622,dlt_strnlen_s +FNDA:3131,dlt_message_payload +FNDA:0,dlt_file_close +FNDA:54,dlt_file_init +FNDA:6097,dlt_receiver_remove +FNDA:0,dlt_filter_save +FNDA:133,dlt_receiver_check_and_get +FNDA:12,dlt_filter_find +FNDA:3875,dlt_file_read_data +FNDA:107,dlt_message_free +FNDA:9,dlt_receiver_init_global_buffer +FNDA:16916,dlt_buffer_init_dynamic +FNDA:328,dlt_message_print_mixed_plain +FNDA:2,dlt_buffer_info +FNDA:5620,dlt_print_id +FNDA:9,dlt_receiver_free_global_buffer +FNF:95 +FNH:81 +DA:131,0 +DA:135,0 +DA:138,0 +DA:139,0 +DA:140,0 +DA:142,0 +DA:146,2733 +DA:150,2733 +DA:154,2730 +DA:155,0 +DA:158,0 +DA:161,36449 +DA:162,33719 +DA:163,31017 +DA:164,31017 +DA:167,33719 +DA:168,33719 +DA:174,2724 +DA:176,2724 +DA:179,1062 +DA:184,1062 +DA:188,1056 +DA:189,528 +DA:192,528 +DA:196,528 +DA:199,528 +DA:204,1056 +DA:205,0 +DA:208,0 +DA:212,1728 +DA:215,672 +DA:217,672 +DA:218,0 +DA:220,672 +DA:225,672 +DA:226,672 +DA:229,672 +DA:232,672 +DA:237,672 +DA:242,672 +DA:243,336 +DA:244,336 +DA:247,336 +DA:248,336 +DA:253,1056 +DA:255,1056 +DA:258,984 +DA:260,984 +DA:261,0 +DA:263,984 +DA:268,984 +DA:270,984 +DA:273,984 +DA:275,9450 +DA:276,8466 +DA:277,8466 +DA:280,984 +DA:281,984 +DA:286,984 +DA:289,0 +DA:295,1661 +DA:299,1661 +DA:302,1658 +DA:303,0 +DA:306,0 +DA:309,19729 +DA:310,18071 +DA:311,10240 +DA:315,7831 +DA:316,7831 +DA:318,0 +DA:321,18071 +DA:327,5622 +DA:329,5622 +DA:332,24796 +DA:333,22517 +DA:334,3342 +DA:339,5620 +DA:342,5620 +DA:348,5617 +DA:350,5617 +DA:355,77315 +DA:358,77315 +DA:361,77312 +DA:362,77312 +DA:363,77312 +DA:364,70773 +DA:366,77312 +DA:367,49545 +DA:371,49545 +DA:372,49539 +DA:376,49539 +DA:377,49531 +DA:381,49531 +DA:382,49354 +DA:387,1159 +DA:391,1159 +DA:394,10286 +DA:395,9127 +DA:396,0 +DA:399,7 +DA:401,7 +DA:403,7 +DA:406,7 +DA:408,7 +DA:411,1 +DA:413,1 +DA:415,1 +DA:416,0 +DA:421,6 +DA:423,6 +DA:430,6 +DA:432,6 +DA:434,6 +DA:435,0 +DA:436,0 +DA:443,6 +DA:445,18 +DA:446,18 +DA:448,18 +DA:451,12 +DA:456,12 +DA:457,0 +DA:459,12 +DA:461,12 +DA:463,12 +DA:466,12 +DA:471,12 +DA:472,0 +DA:474,12 +DA:476,12 +DA:477,12 +DA:479,0 +DA:484,6 +DA:486,6 +DA:489,0 +DA:491,0 +DA:498,0 +DA:500,0 +DA:502,0 +DA:503,0 +DA:504,0 +DA:507,0 +DA:508,0 +DA:512,0 +DA:516,0 +DA:520,0 +DA:525,0 +DA:527,0 +DA:530,12 +DA:535,12 +DA:537,12 +DA:540,18 +DA:541,6 +DA:543,0 +DA:546,0 +DA:548,0 +DA:549,0 +DA:550,0 +DA:551,0 +DA:552,0 +DA:554,0 +DA:556,0 +DA:557,0 +DA:558,0 +DA:559,0 +DA:566,12 +DA:569,12 +DA:571,12 +DA:574,12 +DA:575,0 +DA:578,0 +DA:582,12 +DA:584,12 +DA:585,12 +DA:586,12 +DA:587,12 +DA:588,12 +DA:590,12 +DA:592,12 +DA:598,0 +DA:604,0 +DA:606,0 +DA:609,0 +DA:611,0 +DA:612,0 +DA:613,0 +DA:614,0 +DA:615,0 +DA:616,0 +DA:622,0 +DA:626,0 +DA:627,0 +DA:628,0 +DA:629,0 +DA:630,0 +DA:632,0 +DA:633,0 +DA:634,0 +DA:635,0 +DA:636,0 +DA:637,0 +DA:640,0 +DA:641,0 +DA:648,6109 +DA:650,6109 +DA:652,6109 +DA:656,6107 +DA:657,6107 +DA:659,6107 +DA:660,6107 +DA:662,6107 +DA:663,6107 +DA:664,6107 +DA:666,6107 +DA:668,6107 +DA:671,107 +DA:673,107 +DA:675,107 +DA:679,105 +DA:680,82 +DA:681,82 +DA:682,82 +DA:688,2420 +DA:690,2420 +DA:693,5122 +DA:698,5122 +DA:700,5122 +DA:703,4926 +DA:706,4926 +DA:709,4926 +DA:711,4926 +DA:713,2826 +DA:714,2826 +DA:715,2826 +DA:716,2826 +DA:717,2826 +DA:720,4926 +DA:722,2826 +DA:723,647 +DA:725,2179 +DA:728,4926 +DA:730,2826 +DA:732,4926 +DA:734,2826 +DA:735,647 +DA:737,2179 +DA:742,4926 +DA:743,2826 +DA:745,2826 +DA:746,1395 +DA:748,1431 +DA:750,2826 +DA:753,4926 +DA:754,2826 +DA:755,1395 +DA:757,1431 +DA:759,2826 +DA:763,4926 +DA:764,2435 +DA:765,1395 +DA:766,1395 +DA:767,1395 +DA:770,2435 +DA:771,1395 +DA:772,1256 +DA:773,1256 +DA:775,1395 +DA:776,0 +DA:777,0 +DA:779,1395 +DA:780,0 +DA:781,0 +DA:783,1395 +DA:784,139 +DA:785,139 +DA:787,1395 +DA:790,2435 +DA:792,1395 +DA:793,1256 +DA:795,139 +DA:797,1395 +DA:800,2435 +DA:802,1395 +DA:805,2491 +DA:806,1431 +DA:808,2491 +DA:809,1431 +DA:811,2491 +DA:812,1431 +DA:814,2491 +DA:815,1431 +DA:821,3131 +DA:839,3131 +DA:841,3131 +DA:842,3072 +DA:845,2941 +DA:846,10 +DA:847,10 +DA:851,2931 +DA:854,2931 +DA:855,526 +DA:858,2405 +DA:859,526 +DA:861,1879 +DA:862,526 +DA:864,1353 +DA:865,1353 +DA:874,1353 +DA:876,537 +DA:877,537 +DA:879,537 +DA:880,0 +DA:882,0 +DA:883,0 +DA:887,537 +DA:888,60 +DA:889,57 +DA:891,3 +DA:892,3 +DA:894,60 +DA:895,60 +DA:898,477 +DA:902,537 +DA:903,4 +DA:904,4 +DA:906,4 +DA:907,3 +DA:909,1 +DA:911,4 +DA:912,2 +DA:916,537 +DA:917,122 +DA:918,122 +DA:922,122 +DA:924,122 +DA:925,6 +DA:926,6 +DA:929,415 +DA:932,537 +DA:941,3361 +DA:942,2545 +DA:943,1743 +DA:944,1743 +DA:948,2545 +DA:949,2545 +DA:952,2545 +DA:954,2545 +DA:955,2545 +DA:963,742 +DA:969,742 +DA:971,742 +DA:974,736 +DA:978,936 +DA:980,624 +DA:981,624 +DA:982,0 +DA:983,0 +DA:984,0 +DA:985,0 +DA:986,0 +DA:994,6680 +DA:998,6680 +DA:1000,6680 +DA:1004,6245 +DA:1007,6245 +DA:1011,6245 +DA:1013,0 +DA:1014,0 +DA:1015,0 +DA:1019,6245 +DA:1021,6245 +DA:1026,0 +DA:1028,0 +DA:1029,0 +DA:1030,0 +DA:1031,0 +DA:1034,0 +DA:1035,0 +DA:1038,0 +DA:1040,0 +DA:1041,0 +DA:1047,6245 +DA:1051,6245 +DA:1054,6245 +DA:1055,6245 +DA:1058,6245 +DA:1060,6245 +DA:1061,6245 +DA:1065,6245 +DA:1068,6245 +DA:1069,0 +DA:1072,0 +DA:1075,6245 +DA:1079,6245 +DA:1080,0 +DA:1085,6245 +DA:1086,6245 +DA:1089,6245 +DA:1090,6245 +DA:1093,6245 +DA:1094,6245 +DA:1095,6245 +DA:1096,6245 +DA:1098,0 +DA:1100,6245 +DA:1104,6245 +DA:1109,6040 +DA:1110,6028 +DA:1111,7 +DA:1112,7 +DA:1113,7 +DA:1118,12 +DA:1119,12 +DA:1122,6040 +DA:1123,0 +DA:1126,0 +DA:1130,6040 +DA:1132,6040 +DA:1135,7222 +DA:1137,7222 +DA:1139,7222 +DA:1142,7220 +DA:1143,7026 +DA:1147,7220 +DA:1148,6730 +DA:1149,6730 +DA:1150,6730 +DA:1153,7220 +DA:1154,14052 +DA:1155,7026 +DA:1156,7026 +DA:1157,7026 +DA:1163,6247 +DA:1165,6247 +DA:1167,6247 +DA:1170,6245 +DA:1171,6049 +DA:1172,6049 +DA:1175,6245 +DA:1176,5999 +DA:1177,5999 +DA:1178,5999 +DA:1179,5999 +DA:1183,6245 +DA:1184,6049 +DA:1185,12098 +DA:1186,6049 +DA:1187,6049 +DA:1188,6049 +DA:1195,54 +DA:1197,54 +DA:1199,54 +DA:1203,54 +DA:1204,54 +DA:1205,54 +DA:1206,54 +DA:1208,54 +DA:1209,54 +DA:1210,54 +DA:1212,54 +DA:1214,54 +DA:1216,54 +DA:1219,6 +DA:1221,6 +DA:1223,6 +DA:1227,6 +DA:1229,6 +DA:1232,6627 +DA:1234,6627 +DA:1236,6627 +DA:1242,13254 +DA:1245,38 +DA:1246,0 +DA:1248,38 +DA:1250,38 +DA:1254,6589 +DA:1255,6589 +DA:1259,6589 +DA:1261,0 +DA:1264,0 +DA:1265,0 +DA:1275,6589 +DA:1276,6589 +DA:1281,6589 +DA:1284,6589 +DA:1285,0 +DA:1288,0 +DA:1290,6589 +DA:1294,6589 +DA:1295,0 +DA:1302,0 +DA:1306,0 +DA:1308,0 +DA:1312,0 +DA:1314,0 +DA:1315,0 +DA:1317,0 +DA:1320,0 +DA:1327,0 +DA:1329,0 +DA:1335,0 +DA:1339,0 +DA:1346,0 +DA:1353,0 +DA:1354,0 +DA:1355,0 +DA:1357,0 +DA:1361,0 +DA:1362,0 +DA:1368,0 +DA:1373,0 +DA:1374,0 +DA:1379,0 +DA:1382,0 +DA:1383,0 +DA:1386,0 +DA:1389,0 +DA:1393,0 +DA:1394,0 +DA:1401,4505 +DA:1403,4505 +DA:1405,4505 +DA:1409,4505 +DA:1410,1530 +DA:1413,0 +DA:1414,0 +DA:1417,765 +DA:1421,4505 +DA:1425,2173 +DA:1426,2173 +DA:1429,0 +DA:1430,0 +DA:1434,2173 +DA:1435,2173 +DA:1436,2173 +DA:1437,2173 +DA:1439,0 +DA:1444,3875 +DA:1446,3875 +DA:1448,3875 +DA:1452,3875 +DA:1453,129 +DA:1454,129 +DA:1457,3875 +DA:1459,168 +DA:1460,168 +DA:1463,3875 +DA:1464,0 +DA:1467,0 +DA:1471,7750 +DA:1472,52 +DA:1473,0 +DA:1476,0 +DA:1483,50 +DA:1485,50 +DA:1487,50 +DA:1491,44 +DA:1492,44 +DA:1493,44 +DA:1494,44 +DA:1495,44 +DA:1496,44 +DA:1498,44 +DA:1499,0 +DA:1502,44 +DA:1504,44 +DA:1505,1 +DA:1506,1 +DA:1509,43 +DA:1510,0 +DA:1511,0 +DA:1514,43 +DA:1516,43 +DA:1517,0 +DA:1518,0 +DA:1521,43 +DA:1523,1 +DA:1528,2752 +DA:1533,2752 +DA:1536,2752 +DA:1537,0 +DA:1540,2752 +DA:1541,350 +DA:1543,350 +DA:1546,350 +DA:1547,312 +DA:1548,312 +DA:1551,350 +DA:1555,2752 +DA:1556,0 +DA:1558,0 +DA:1562,2752 +DA:1563,0 +DA:1566,2752 +DA:1568,38 +DA:1569,0 +DA:1572,38 +DA:1575,2714 +DA:1577,630 +DA:1579,0 +DA:1580,0 +DA:1582,0 +DA:1586,630 +DA:1589,318 +DA:1590,318 +DA:1591,318 +DA:1597,630 +DA:1599,0 +DA:1603,0 +DA:1604,0 +DA:1606,0 +DA:1612,2084 +DA:1613,2084 +DA:1616,0 +DA:1618,0 +DA:1619,0 +DA:1622,0 +DA:1623,0 +DA:1625,0 +DA:1629,2084 +DA:1630,2084 +DA:1631,2084 +DA:1637,2714 +DA:1640,2714 +DA:1642,2714 +DA:1645,0 +DA:1650,0 +DA:1651,0 +DA:1653,0 +DA:1657,0 +DA:1658,0 +DA:1660,0 +DA:1663,0 +DA:1664,0 +DA:1665,0 +DA:1668,0 +DA:1672,0 +DA:1676,0 +DA:1677,0 +DA:1680,0 +DA:1682,0 +DA:1683,0 +DA:1685,0 +DA:1689,0 +DA:1691,0 +DA:1692,0 +DA:1694,0 +DA:1697,0 +DA:1699,0 +DA:1700,0 +DA:1702,0 +DA:1706,0 +DA:1707,0 +DA:1708,0 +DA:1713,0 +DA:1716,0 +DA:1718,0 +DA:1721,0 +DA:1723,0 +DA:1725,0 +DA:1728,0 +DA:1729,0 +DA:1731,0 +DA:1733,0 +DA:1736,3770 +DA:1738,3770 +DA:1740,3770 +DA:1744,3770 +DA:1745,0 +DA:1746,0 +DA:1750,3770 +DA:1751,0 +DA:1752,0 +DA:1753,0 +DA:1757,3770 +DA:1760,3770 +DA:1763,3770 +DA:1767,3770 +DA:1769,3770 +DA:1772,51 +DA:1774,51 +DA:1776,51 +DA:1780,51 +DA:1781,36 +DA:1783,51 +DA:1786,51 +DA:1787,41 +DA:1789,51 +DA:1791,51 +DA:1795,16795 +DA:1798,16795 +DA:1799,16786 +DA:1810,0 +DA:1812,0 +DA:1813,0 +DA:1815,16828 +DA:1817,16828 +DA:1820,16828 +DA:1821,16828 +DA:1826,16828 +DA:1827,0 +DA:1828,0 +DA:1831,16828 +DA:1832,16828 +DA:1833,16828 +DA:1834,16828 +DA:1835,16828 +DA:1836,16828 +DA:1837,16828 +DA:1838,16828 +DA:1841,16828 +DA:1842,0 +DA:1843,0 +DA:1846,16828 +DA:1849,16828 +DA:1852,9 +DA:1854,9 +DA:1857,9 +DA:1861,9 +DA:1863,9 +DA:1867,9 +DA:1868,9 +DA:1869,9 +DA:1870,9 +DA:1871,9 +DA:1872,9 +DA:1873,9 +DA:1874,9 +DA:1875,9 +DA:1877,9 +DA:1880,16827 +DA:1883,16827 +DA:1886,16827 +DA:1887,16825 +DA:1889,16827 +DA:1890,0 +DA:1892,16827 +DA:1893,16827 +DA:1894,16827 +DA:1896,16827 +DA:1899,9 +DA:1902,9 +DA:1905,9 +DA:1906,0 +DA:1908,9 +DA:1909,9 +DA:1910,9 +DA:1912,9 +DA:1915,1964 +DA:1919,1964 +DA:1922,1964 +DA:1925,1963 +DA:1926,1963 +DA:1928,1963 +DA:1929,0 +DA:1930,0 +DA:1931,0 +DA:1934,1963 +DA:1936,431 +DA:1937,431 +DA:1938,431 +DA:1940,1532 +DA:1942,1532 +DA:1943,1532 +DA:1944,1532 +DA:1948,0 +DA:1949,0 +DA:1950,0 +DA:1951,0 +DA:1953,0 +DA:1957,1963 +DA:1958,6 +DA:1959,6 +DA:1962,1957 +DA:1963,1957 +DA:1965,1957 +DA:1968,6097 +DA:1970,6097 +DA:1973,6140 +DA:1976,6140 +DA:1977,0 +DA:1978,0 +DA:1979,0 +DA:1982,6140 +DA:1983,263 +DA:1985,6097 +DA:1988,1958 +DA:1990,1958 +DA:1993,1958 +DA:1996,1958 +DA:1997,0 +DA:1999,0 +DA:2000,0 +DA:2004,0 +DA:2010,133 +DA:2015,133 +DA:2018,133 +DA:2019,88 +DA:2021,133 +DA:2022,133 +DA:2023,133 +DA:2029,133 +DA:2030,88 +DA:2034,133 +DA:2035,0 +DA:2036,0 +DA:2037,0 +DA:2041,133 +DA:2044,12103 +DA:2051,12103 +DA:2058,12103 +DA:2062,12103 +DA:2063,12103 +DA:2064,12103 +DA:2065,12103 +DA:2067,12103 +DA:2073,12103 +DA:2074,12103 +DA:2077,12103 +DA:2080,9 +DA:2083,9 +DA:2084,1 +DA:2088,9 +DA:2091,6589 +DA:2093,6589 +DA:2096,13178 +DA:2097,6589 +DA:2098,6589 +DA:2099,6589 +DA:2100,13178 +DA:2103,0 +DA:2105,0 +DA:2111,0 +DA:2112,0 +DA:2113,0 +DA:2114,0 +DA:2118,0 +DA:2119,0 +DA:2120,0 +DA:2121,0 +DA:2122,0 +DA:2125,0 +DA:2127,0 +DA:2129,0 +DA:2131,0 +DA:2134,0 +DA:2136,0 +DA:2140,0 +DA:2141,0 +DA:2142,0 +DA:2143,0 +DA:2146,0 +DA:2147,0 +DA:2149,0 +DA:2153,0 +DA:2156,16916 +DA:2162,16916 +DA:2166,16908 +DA:2169,16901 +DA:2172,16901 +DA:2176,16901 +DA:2177,16901 +DA:2178,16901 +DA:2181,16901 +DA:2183,16901 +DA:2184,0 +DA:2187,0 +DA:2192,16901 +DA:2193,16901 +DA:2194,16901 +DA:2195,16901 +DA:2197,16901 +DA:2198,0 +DA:2201,0 +DA:2204,16901 +DA:2206,16901 +DA:2211,16901 +DA:2213,16901 +DA:2216,0 +DA:2219,0 +DA:2222,0 +DA:2224,0 +DA:2225,0 +DA:2231,16891 +DA:2234,16891 +DA:2237,16890 +DA:2239,0 +DA:2240,0 +DA:2243,16890 +DA:2244,16890 +DA:2245,16890 +DA:2247,16890 +DA:2250,41031 +DA:2253,41031 +DA:2254,40012 +DA:2255,40012 +DA:2257,40011 +DA:2258,40011 +DA:2264,1 +DA:2266,1 +DA:2267,1 +DA:2268,1 +DA:2273,0 +DA:2277,1019 +DA:2279,41031 +DA:2281,53 +DA:2284,53 +DA:2285,37 +DA:2287,35 +DA:2288,35 +DA:2294,2 +DA:2296,1 +DA:2297,1 +DA:2298,1 +DA:2303,16 +DA:2305,53 +DA:2307,859 +DA:2309,859 +DA:2312,859 +DA:2313,0 +DA:2318,7 +DA:2324,7 +DA:2325,1 +DA:2326,1 +DA:2330,6 +DA:2335,6 +DA:2340,6 +DA:2342,6 +DA:2343,0 +DA:2346,0 +DA:2350,6 +DA:2353,6 +DA:2354,4 +DA:2355,4 +DA:2356,4 +DA:2357,4 +DA:2360,2 +DA:2361,2 +DA:2362,2 +DA:2363,2 +DA:2364,2 +DA:2368,6 +DA:2371,6 +DA:2372,6 +DA:2373,6 +DA:2375,6 +DA:2381,6 +DA:2384,8 +DA:2389,8 +DA:2390,1 +DA:2391,1 +DA:2394,7 +DA:2399,0 +DA:2401,0 +DA:2402,0 +DA:2405,0 +DA:2409,0 +DA:2412,0 +DA:2413,0 +DA:2414,0 +DA:2417,0 +DA:2418,0 +DA:2419,0 +DA:2421,0 +DA:2426,0 +DA:2428,0 +DA:2431,9 +DA:2434,9 +DA:2435,1 +DA:2436,1 +DA:2439,8 +DA:2441,8 +DA:2444,8 +DA:2445,8 +DA:2446,8 +DA:2449,8 +DA:2451,8 +DA:2454,7516 +DA:2456,7516 +DA:2459,15284 +DA:2472,15284 +DA:2475,15216 +DA:2477,0 +DA:2478,0 +DA:2482,15216 +DA:2483,15216 +DA:2484,15216 +DA:2487,15216 +DA:2488,0 +DA:2491,0 +DA:2492,0 +DA:2496,15216 +DA:2497,0 +DA:2498,15216 +DA:2501,15216 +DA:2504,15220 +DA:2506,4 +DA:2512,4 +DA:2513,4 +DA:2516,4 +DA:2517,0 +DA:2518,4 +DA:2521,4 +DA:2527,15216 +DA:2528,15216 +DA:2531,15216 +DA:2533,15216 +DA:2534,15216 +DA:2536,15216 +DA:2537,7702 +DA:2539,15216 +DA:2540,1877 +DA:2543,15216 +DA:2544,15216 +DA:2546,15216 +DA:2550,64 +DA:2554,64 +DA:2558,64 +DA:2561,47 +DA:2563,0 +DA:2564,0 +DA:2568,47 +DA:2569,47 +DA:2570,47 +DA:2573,47 +DA:2574,3 +DA:2577,3 +DA:2578,3 +DA:2582,44 +DA:2583,22 +DA:2584,1 +DA:2587,1 +DA:2590,22 +DA:2594,22 +DA:2595,21 +DA:2597,1 +DA:2600,22 +DA:2601,1 +DA:2604,1 +DA:2605,1 +DA:2609,21 +DA:2612,21 +DA:2613,1 +DA:2614,1 +DA:2615,1 +DA:2618,20 +DA:2619,0 +DA:2620,0 +DA:2621,0 +DA:2625,20 +DA:2626,1 +DA:2629,1 +DA:2630,1 +DA:2634,19 +DA:2635,1 +DA:2641,19 +DA:2643,14 +DA:2645,14 +DA:2647,3 +DA:2650,5 +DA:2652,5 +DA:2653,5 +DA:2655,0 +DA:2659,19 +DA:2660,8 +DA:2662,8 +DA:2664,5 +DA:2667,19 +DA:2670,8 +DA:2672,8 +DA:2675,13 +DA:2677,13 +DA:2680,7 +DA:2682,7 +DA:2685,2 +DA:2688,2 +DA:2689,1 +DA:2690,1 +DA:2693,1 +DA:2695,1 +DA:2698,2 +DA:2703,2 +DA:2704,1 +DA:2705,1 +DA:2709,1 +DA:2712,1 +DA:2713,1 +DA:2714,1 +DA:2716,1 +DA:2721,3 +DA:2724,3 +DA:2727,2 +DA:2730,2503 +DA:2735,2503 +DA:2739,2502 +DA:2742,2502 +DA:2743,2502 +DA:2744,2502 +DA:2746,2502 +DA:2749,2501 +DA:2750,2501 +DA:2752,0 +DA:2755,8527 +DA:2758,8527 +DA:2762,8527 +DA:2765,8527 +DA:2770,0 +DA:2775,0 +DA:2778,0 +DA:2787,0 +DA:2799,0 +DA:2805,0 +DA:2811,0 +DA:2812,0 +DA:2817,0 +DA:2818,0 +DA:2823,0 +DA:2824,0 +DA:2828,0 +DA:2829,0 +DA:2837,0 +DA:2842,0 +DA:2848,0 +DA:2851,0 +DA:2853,0 +DA:2856,0 +DA:2858,0 +DA:2861,0 +DA:2863,0 +DA:2866,0 +DA:2868,0 +DA:2871,0 +DA:2873,0 +DA:2876,0 +DA:2878,0 +DA:2881,0 +DA:2883,0 +DA:2886,0 +DA:2888,0 +DA:2891,0 +DA:2893,0 +DA:2896,0 +DA:2898,0 +DA:2901,0 +DA:2903,0 +DA:2906,0 +DA:2908,0 +DA:2911,0 +DA:2913,0 +DA:2916,0 +DA:2918,0 +DA:2921,0 +DA:2923,0 +DA:2926,0 +DA:2929,0 +DA:2932,0 +DA:2934,0 +DA:2937,0 +DA:2939,0 +DA:2942,0 +DA:2944,0 +DA:2947,0 +DA:2949,0 +DA:2952,0 +DA:2954,0 +DA:2957,0 +DA:2959,0 +DA:2962,0 +DA:2964,0 +DA:2967,0 +DA:2969,0 +DA:2972,0 +DA:2975,0 +DA:2978,0 +DA:2982,0 +DA:2985,0 +DA:2989,0 +DA:2992,0 +DA:2996,0 +DA:2999,0 +DA:3003,0 +DA:3006,0 +DA:3010,0 +DA:3018,22 +DA:3020,22 +DA:3021,0 +DA:3022,0 +DA:3043,9 +DA:3045,9 +DA:3046,0 +DA:3047,0 +DA:3053,9 +DA:3055,9 +DA:3056,0 +DA:3057,0 +DA:3064,6301 +DA:3074,6301 +DA:3075,6301 +DA:3083,328 +DA:3085,328 +DA:3088,316 +DA:3090,316 +DA:3092,316 +DA:3095,328 +DA:3097,328 +DA:3100,316 +DA:3102,316 +DA:3104,316 +DA:3106,316 +DA:3108,316 +DA:3111,328 +DA:3113,328 +DA:3116,316 +DA:3118,316 +DA:3120,316 +DA:3122,316 +DA:3124,316 +DA:3127,328 +DA:3129,328 +DA:3132,316 +DA:3134,316 +DA:3136,316 +DA:3138,316 +DA:3140,316 +DA:3143,328 +DA:3145,328 +DA:3148,316 +DA:3150,316 +DA:3152,316 +DA:3155,316 +DA:3157,316 +DA:3160,2771 +DA:3170,2771 +DA:3185,2756 +DA:3186,2756 +DA:3187,2756 +DA:3188,2756 +DA:3204,2756 +DA:3205,1159 +DA:3207,1159 +DA:3208,1159 +DA:3210,1159 +DA:3213,1159 +DA:3216,0 +DA:3219,1159 +DA:3220,0 +DA:3222,0 +DA:3225,0 +DA:3227,0 +DA:3230,0 +DA:3232,0 +DA:3233,0 +DA:3234,0 +DA:3235,0 +DA:3239,0 +DA:3240,0 +DA:3243,1159 +DA:3245,1159 +DA:3248,1597 +DA:3251,112 +DA:3252,0 +DA:3254,0 +DA:3257,0 +DA:3259,0 +DA:3262,0 +DA:3264,0 +DA:3265,0 +DA:3266,0 +DA:3267,0 +DA:3271,0 +DA:3272,0 +DA:3276,112 +DA:3278,112 +DA:3281,110 +DA:3283,1485 +DA:3285,0 +DA:3286,0 +DA:3288,0 +DA:3289,0 +DA:3291,0 +DA:3294,0 +DA:3295,0 +DA:3298,0 +DA:3304,0 +DA:3305,0 +DA:3307,0 +DA:3308,0 +DA:3310,0 +DA:3313,0 +DA:3314,0 +DA:3317,0 +DA:3323,1485 +DA:3325,0 +DA:3326,0 +DA:3328,0 +DA:3331,0 +DA:3334,0 +DA:3335,0 +DA:3337,0 +DA:3340,0 +DA:3343,0 +DA:3344,0 +DA:3346,0 +DA:3352,0 +DA:3353,0 +DA:3354,0 +DA:3356,0 +DA:3360,0 +DA:3361,0 +DA:3363,0 +DA:3366,0 +DA:3367,0 +DA:3370,1485 +DA:3373,1358 +DA:3374,0 +DA:3376,0 +DA:3379,0 +DA:3380,0 +DA:3382,0 +DA:3385,0 +DA:3387,0 +DA:3390,0 +DA:3392,0 +DA:3393,0 +DA:3394,0 +DA:3395,0 +DA:3399,0 +DA:3400,0 +DA:3402,0 +DA:3407,0 +DA:3409,0 +DA:3410,0 +DA:3413,1358 +DA:3414,0 +DA:3416,0 +DA:3419,0 +DA:3420,0 +DA:3424,0 +DA:3427,0 +DA:3428,0 +DA:3429,0 +DA:3431,0 +DA:3433,0 +DA:3436,0 +DA:3437,0 +DA:3438,0 +DA:3440,0 +DA:3442,0 +DA:3445,0 +DA:3446,0 +DA:3447,0 +DA:3456,1358 +DA:3457,14 +DA:3459,14 +DA:3461,7 +DA:3463,7 +DA:3466,7 +DA:3470,7 +DA:3472,7 +DA:3475,7 +DA:3480,21 +DA:3482,21 +DA:3485,7 +DA:3487,7 +DA:3490,7 +DA:3491,7 +DA:3496,14 +DA:3498,14 +DA:3501,14 +DA:3502,14 +DA:3507,1309 +DA:3509,1309 +DA:3512,287 +DA:3514,287 +DA:3517,287 +DA:3523,1022 +DA:3525,1022 +DA:3528,1022 +DA:3534,14 +DA:3536,14 +DA:3539,7 +DA:3541,7 +DA:3544,7 +DA:3554,7 +DA:3556,7 +DA:3559,7 +DA:3569,0 +DA:3571,0 +DA:3572,0 +DA:3574,0 +DA:3577,0 +DA:3578,0 +DA:3579,0 +DA:3587,127 +DA:3590,14 +DA:3591,0 +DA:3593,0 +DA:3596,0 +DA:3597,0 +DA:3599,0 +DA:3602,0 +DA:3604,0 +DA:3607,0 +DA:3609,0 +DA:3610,0 +DA:3611,0 +DA:3612,0 +DA:3616,0 +DA:3617,0 +DA:3619,0 +DA:3624,0 +DA:3626,0 +DA:3627,0 +DA:3630,14 +DA:3631,0 +DA:3633,0 +DA:3634,0 +DA:3636,0 +DA:3639,0 +DA:3640,0 +DA:3641,0 +DA:3643,0 +DA:3645,0 +DA:3646,0 +DA:3648,0 +DA:3651,0 +DA:3652,0 +DA:3653,0 +DA:3662,7 +DA:3664,7 +DA:3669,7 +DA:3671,7 +DA:3687,7 +DA:3689,7 +DA:3694,7 +DA:3709,0 +DA:3711,0 +DA:3712,0 +DA:3714,0 +DA:3717,0 +DA:3718,0 +DA:3719,0 +DA:3727,113 +DA:3730,112 +DA:3732,112 +DA:3735,110 +DA:3737,110 +DA:3738,0 +DA:3740,0 +DA:3743,0 +DA:3745,0 +DA:3748,0 +DA:3750,0 +DA:3751,0 +DA:3752,0 +DA:3753,0 +DA:3757,0 +DA:3758,0 +DA:3761,110 +DA:3764,9 +DA:3766,9 +DA:3767,9 +DA:3769,1 +DA:3772,0 +DA:3774,0 +DA:3777,0 +DA:3779,0 +DA:3781,0 +DA:3788,2650 +DA:3789,0 +DA:3790,0 +DA:3794,2650 +DA:3795,0 +DA:3797,0 +DA:3799,0 +DA:3800,0 +DA:3808,16786 +DA:3810,16786 +DA:3812,16786 +DA:3813,0 +DA:3815,16786 +DA:3817,16786 +DA:3818,0 +DA:3820,0 +DA:3821,0 +DA:3824,16786 +DA:3826,16786 +DA:3827,0 +DA:3829,0 +DA:3830,0 +DA:3834,16786 +DA:3836,16786 +DA:3837,0 +DA:3839,16786 +DA:3850,16786 +DA:3852,2 +DA:3860,2 +DA:3866,2 +DA:3868,2 +DA:3869,2 +DA:3871,2 +DA:3872,2 +DA:3873,2 +DA:3874,2 +DA:3880,14 +DA:3882,14 +DA:3885,14 +DA:3891,14 +DA:3892,14 +DA:3893,14 +DA:3894,14 +DA:3896,14 +DA:3898,14 +DA:3901,12 +DA:3903,12 +DA:3906,12 +DA:3912,12 +DA:3913,12 +DA:3915,12 +DA:3917,12 +DA:3920,11 +DA:3922,11 +DA:3928,11 +DA:3929,11 +DA:3931,11 +DA:3934,20 +DA:3936,20 +DA:3940,20 +DA:3946,289 +DA:3947,269 +DA:3948,269 +DA:3949,269 +DA:3950,269 +DA:3956,0 +DA:3958,0 +DA:3960,0 +DA:3965,0 +DA:3966,0 +DA:3967,0 +DA:3972,0 +DA:3973,0 +DA:3976,0 +DA:3978,0 +DA:3981,0 +DA:3983,0 +DA:3988,0 +DA:3993,0 +DA:3995,0 +DA:3998,0 +DA:4002,0 +DA:4006,3 +DA:4009,3 +DA:4011,3 +DA:4013,3 +DA:4016,1 +DA:4018,1 +DA:4019,0 +DA:4020,0 +DA:4023,106 +DA:4025,105 +DA:4026,0 +DA:4029,105 +DA:4031,105 +DA:4034,105 +DA:4036,105 +DA:4039,105 +DA:4041,105 +DA:4044,105 +DA:4046,0 +DA:4048,0 +DA:4049,0 +DA:4052,105 +DA:4055,105 +DA:4060,105 +DA:4063,105 +DA:4069,105 +DA:4070,105 +DA:4072,105 +DA:4074,105 +DA:4077,1 +DA:4078,1 +DA:4082,0 +DA:4087,0 +DA:4089,0 +DA:4093,0 +DA:4095,0 +DA:4097,0 +DA:4100,0 +DA:4101,0 +DA:4103,0 +DA:4105,0 +DA:4106,0 +DA:4108,0 +DA:4111,0 +DA:4113,0 +DA:4116,0 +DA:4119,0 +DA:4120,0 +DA:4122,0 +DA:4123,0 +DA:4124,0 +DA:4127,0 +DA:4131,0 +DA:4133,0 +DA:4135,0 +DA:4139,0 +DA:4140,0 +DA:4144,0 +DA:4145,0 +DA:4148,5 +DA:4150,5 +DA:4151,0 +DA:4152,0 +DA:4155,5 +DA:4156,5 +DA:4159,6 +DA:4160,6 +DA:4162,6 +DA:4163,6 +DA:4164,5 +DA:4165,5 +DA:4167,5 +DA:4168,5 +DA:4169,5 +LF:1625 +LH:1005 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/shared/dlt_config_file_parser.c +FN:52,dlt_config_file_trim_line +FN:96,dlt_config_file_is_section_name +FN:122,dlt_config_file_set_section +FN:172,dlt_config_file_set_section_data +FN:252,dlt_config_file_get_section_name_from_string +FN:282,dlt_config_file_get_key_value +FN:322,dlt_config_file_read_line +FN:355,dlt_config_file_read_file +FN:408,dlt_config_file_find_section +FN:429,dlt_config_file_init +FN:463,dlt_config_file_release +FN:492,dlt_config_file_get_section_name +FN:505,dlt_config_file_get_num_sections +FN:519,dlt_config_file_get_value +FN:556,dlt_config_file_check_section_name_exists +FNDA:14,dlt_config_file_read_file +FNDA:40,dlt_config_file_set_section +FNDA:4,dlt_config_file_check_section_name_exists +FNDA:14,dlt_config_file_release +FNDA:339,dlt_config_file_set_section_data +FNDA:339,dlt_config_file_get_key_value +FNDA:536,dlt_config_file_get_value +FNDA:14,dlt_config_file_get_num_sections +FNDA:14,dlt_config_file_init +FNDA:40,dlt_config_file_is_section_name +FNDA:540,dlt_config_file_find_section +FNDA:40,dlt_config_file_get_section_name +FNDA:379,dlt_config_file_trim_line +FNDA:379,dlt_config_file_read_line +FNDA:40,dlt_config_file_get_section_name_from_string +FNF:15 +FNH:15 +DA:52,379 +DA:54,379 +DA:60,6683 +DA:61,6304 +DA:63,6304 +DA:64,5925 +DA:67,379 +DA:80,406 +DA:96,40 +DA:100,40 +DA:103,179 +DA:104,139 +DA:106,139 +DA:122,40 +DA:124,40 +DA:127,40 +DA:128,0 +DA:129,0 +DA:133,40 +DA:134,0 +DA:135,0 +DA:138,40 +DA:141,40 +DA:143,40 +DA:144,0 +DA:145,0 +DA:148,40 +DA:150,40 +DA:151,0 +DA:152,0 +DA:153,0 +DA:154,0 +DA:158,40 +DA:159,40 +DA:172,339 +DA:176,339 +DA:179,339 +DA:180,339 +DA:182,339 +DA:183,0 +DA:184,0 +DA:188,339 +DA:190,339 +DA:192,40 +DA:194,40 +DA:195,0 +DA:196,0 +DA:199,40 +DA:202,299 +DA:204,1589 +DA:205,1290 +DA:208,299 +DA:210,299 +DA:211,0 +DA:212,0 +DA:216,339 +DA:217,339 +DA:218,339 +DA:220,339 +DA:222,339 +DA:237,379 +DA:252,40 +DA:257,40 +DA:260,386 +DA:261,386 +DA:262,40 +DA:263,346 +DA:266,306 +DA:282,339 +DA:288,339 +DA:291,339 +DA:293,339 +DA:295,339 +DA:300,339 +DA:302,339 +DA:304,339 +DA:309,339 +DA:322,379 +DA:324,379 +DA:334,40 +DA:337,40 +DA:341,339 +DA:342,0 +DA:355,14 +DA:358,14 +DA:359,14 +DA:360,14 +DA:365,434 +DA:366,406 +DA:369,27 +DA:370,27 +DA:373,379 +DA:376,379 +DA:378,379 +DA:379,40 +DA:382,40 +DA:386,339 +DA:388,339 +DA:389,339 +DA:392,0 +DA:393,0 +DA:397,14 +DA:408,540 +DA:413,540 +DA:414,0 +DA:415,0 +DA:418,2490 +DA:419,2486 +DA:421,2486 +DA:422,536 +DA:429,14 +DA:434,14 +DA:435,0 +DA:436,0 +DA:439,14 +DA:441,14 +DA:442,0 +DA:443,0 +DA:446,14 +DA:449,14 +DA:450,0 +DA:451,0 +DA:452,0 +DA:455,14 +DA:458,14 +DA:460,14 +DA:463,14 +DA:467,14 +DA:468,14 +DA:470,54 +DA:471,40 +DA:472,40 +DA:473,40 +DA:475,40 +DA:476,40 +DA:478,379 +DA:480,339 +DA:481,339 +DA:482,339 +DA:483,339 +DA:487,14 +DA:488,14 +DA:490,14 +DA:492,40 +DA:496,40 +DA:499,40 +DA:500,40 +DA:502,40 +DA:505,14 +DA:507,14 +DA:514,14 +DA:516,14 +DA:519,536 +DA:527,536 +DA:533,536 +DA:535,536 +DA:538,536 +DA:540,536 +DA:542,3465 +DA:543,3264 +DA:544,335 +DA:545,335 +DA:548,2929 +DA:552,201 +DA:553,201 +DA:556,4 +DA:561,4 +DA:564,4 +DA:565,4 +DA:566,4 +LF:170 +LH:142 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/shared/dlt_log.c +FN:55,dlt_log_set_filename +FN:67,dlt_log_set_level +FN:80,dlt_log_init +FN:86,dlt_log_init_multiple_logfiles_support +FN:116,dlt_log_init_single_logfile +FN:129,dlt_log_init_multiple_logfiles +FN:164,dlt_user_printf +FN:191,dlt_log +FN:267,dlt_vlog +FN:288,dlt_vnlog +FN:315,dlt_log_multiple_files_write +FN:325,dlt_log_free +FN:336,dlt_log_free_single_logfile +FN:343,dlt_log_free_multiple_logfiles +FN:351,dlt_is_log_in_multiple_files_active +FNDA:37,dlt_is_log_in_multiple_files_active +FNDA:15,dlt_log_free +FNDA:12,dlt_log_multiple_files_write +FNDA:37361,dlt_vlog +FNDA:4,dlt_log_init_single_logfile +FNDA:23464,dlt_log +FNDA:2,dlt_log_free_single_logfile +FNDA:12,dlt_log_init +FNDA:19,dlt_log_set_level +FNDA:17,dlt_log_set_filename +FNDA:2852,dlt_user_printf +FNDA:3,dlt_log_free_multiple_logfiles +FNDA:26,dlt_log_init_multiple_logfiles_support +FNDA:16780,dlt_vnlog +FNDA:4,dlt_log_init_multiple_logfiles +FNF:15 +FNH:15 +DA:55,17 +DA:58,17 +DA:59,1 +DA:60,1 +DA:64,16 +DA:67,19 +DA:69,19 +DA:70,0 +DA:71,0 +DA:73,0 +DA:76,19 +DA:78,19 +DA:80,12 +DA:82,12 +DA:83,12 +DA:86,26 +DA:89,26 +DA:90,0 +DA:91,0 +DA:94,26 +DA:96,26 +DA:101,7 +DA:102,4 +DA:103,4 +DA:104,4 +DA:105,1 +DA:106,1 +DA:109,3 +DA:110,3 +DA:116,4 +DA:119,4 +DA:120,4 +DA:122,4 +DA:123,0 +DA:124,0 +DA:129,4 +DA:133,4 +DA:135,4 +DA:136,4 +DA:139,4 +DA:141,4 +DA:143,4 +DA:145,3 +DA:146,3 +DA:148,3 +DA:158,3 +DA:164,2852 +DA:166,2852 +DA:169,2852 +DA:173,2852 +DA:174,8 +DA:179,8 +DA:180,8 +DA:181,2844 +DA:182,2844 +DA:183,2844 +DA:186,2852 +DA:188,2852 +DA:191,23464 +DA:200,23464 +DA:203,23463 +DA:206,22547 +DA:209,22547 +DA:211,22547 +DA:212,525 +DA:214,1050 +DA:215,525 +DA:216,525 +DA:218,525 +DA:220,525 +DA:221,525 +DA:222,21985 +DA:224,43970 +DA:225,21985 +DA:226,21985 +DA:228,21985 +DA:231,0 +DA:234,0 +DA:235,0 +DA:237,0 +DA:238,0 +DA:240,0 +DA:242,0 +DA:244,0 +DA:245,32 +DA:248,32 +DA:249,24 +DA:250,12 +DA:252,20 +DA:253,40 +DA:254,20 +DA:255,20 +DA:267,37361 +DA:269,37361 +DA:273,37361 +DA:276,37361 +DA:279,5693 +DA:281,5693 +DA:283,5693 +DA:285,5693 +DA:288,16780 +DA:294,16780 +DA:297,16780 +DA:300,16780 +DA:303,16780 +DA:305,16780 +DA:307,16780 +DA:309,16780 +DA:312,16780 +DA:315,12 +DA:317,12 +DA:319,12 +DA:321,12 +DA:322,12 +DA:323,12 +DA:325,15 +DA:327,15 +DA:328,5 +DA:329,3 +DA:331,2 +DA:334,15 +DA:336,2 +DA:338,2 +DA:339,2 +DA:341,2 +DA:343,3 +DA:345,3 +DA:348,3 +DA:351,37 +DA:353,37 +LF:130 +LH:115 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/shared/dlt_multiple_files.c +FN:44,multiple_files_buffer_storage_dir_info +FN:118,multiple_files_buffer_file_name +FN:134,multiple_files_buffer_get_idx_of_log_file +FN:148,multiple_files_buffer_create_new_file +FN:226,multiple_files_buffer_get_total_size +FN:269,multiple_files_buffer_delete_oldest_file +FN:347,multiple_files_buffer_check_size +FN:378,multiple_files_buffer_open_file_for_append +FN:408,multiple_files_buffer_init +FN:440,multiple_files_buffer_rotate_file +FN:456,multiple_files_buffer_write_chunk +FN:474,multiple_files_buffer_write +FN:486,multiple_files_buffer_free +FNDA:12,multiple_files_buffer_rotate_file +FNDA:12,multiple_files_buffer_check_size +FNDA:9,multiple_files_buffer_create_new_file +FNDA:12,multiple_files_buffer_write_chunk +FNDA:9,multiple_files_buffer_file_name +FNDA:12,multiple_files_buffer_storage_dir_info +FNDA:53,multiple_files_buffer_get_idx_of_log_file +FNDA:3,multiple_files_buffer_open_file_for_append +FNDA:3,multiple_files_buffer_free +FNDA:3,multiple_files_buffer_init +FNDA:12,multiple_files_buffer_write +FNDA:9,multiple_files_buffer_delete_oldest_file +FNDA:21,multiple_files_buffer_get_total_size +FNF:13 +FNH:13 +DA:44,12 +DA:49,12 +DA:53,12 +DA:54,0 +DA:55,0 +DA:58,12 +DA:59,12 +DA:61,434 +DA:63,422 +DA:65,422 +DA:66,110 +DA:67,48 +DA:69,48 +DA:70,48 +DA:72,36 +DA:75,20 +DA:81,48 +DA:82,32 +DA:84,20 +DA:87,20 +DA:94,12 +DA:95,12 +DA:97,12 +DA:98,0 +DA:102,12 +DA:104,12 +DA:105,0 +DA:111,434 +DA:113,12 +DA:115,12 +DA:118,9 +DA:124,9 +DA:127,9 +DA:128,9 +DA:131,9 +DA:132,9 +DA:134,53 +DA:136,53 +DA:138,53 +DA:141,53 +DA:143,53 +DA:145,53 +DA:148,9 +DA:150,9 +DA:151,0 +DA:152,0 +DA:162,9 +DA:165,0 +DA:166,0 +DA:167,0 +DA:169,0 +DA:171,0 +DA:172,0 +DA:174,0 +DA:176,0 +DA:177,0 +DA:178,0 +DA:182,0 +DA:184,0 +DA:185,0 +DA:186,0 +DA:190,9 +DA:191,9 +DA:193,9 +DA:194,9 +DA:200,9 +DA:202,9 +DA:204,9 +DA:206,9 +DA:207,0 +DA:208,0 +DA:213,9 +DA:214,9 +DA:217,9 +DA:219,0 +DA:220,0 +DA:226,21 +DA:228,21 +DA:229,0 +DA:230,0 +DA:239,21 +DA:240,21 +DA:241,0 +DA:242,0 +DA:245,779 +DA:247,758 +DA:253,80 +DA:254,80 +DA:255,80 +DA:256,80 +DA:258,0 +DA:263,21 +DA:266,21 +DA:269,9 +DA:271,9 +DA:272,0 +DA:273,0 +DA:284,9 +DA:285,9 +DA:288,9 +DA:290,9 +DA:293,345 +DA:294,336 +DA:300,44 +DA:302,0 +DA:305,44 +DA:306,0 +DA:307,0 +DA:308,0 +DA:309,0 +DA:310,0 +DA:312,0 +DA:315,0 +DA:319,44 +DA:320,44 +DA:324,18 +DA:330,9 +DA:333,9 +DA:334,9 +DA:335,0 +DA:336,0 +DA:339,0 +DA:340,0 +DA:344,9 +DA:347,12 +DA:349,12 +DA:350,0 +DA:351,0 +DA:357,12 +DA:358,12 +DA:359,0 +DA:360,0 +DA:363,12 +DA:364,0 +DA:365,0 +DA:370,21 +DA:372,9 +DA:375,12 +DA:378,3 +DA:379,3 +DA:381,3 +DA:382,3 +DA:385,3 +DA:386,3 +DA:389,0 +DA:396,3 +DA:397,0 +DA:398,0 +DA:402,3 +DA:403,3 +DA:405,3 +DA:408,3 +DA:417,3 +DA:418,0 +DA:419,0 +DA:423,3 +DA:424,3 +DA:425,3 +DA:426,3 +DA:427,3 +DA:428,3 +DA:429,3 +DA:430,3 +DA:431,3 +DA:433,3 +DA:435,3 +DA:436,3 +DA:437,3 +DA:440,12 +DA:443,12 +DA:446,9 +DA:447,9 +DA:450,9 +DA:453,9 +DA:456,12 +DA:460,12 +DA:461,0 +DA:462,0 +DA:465,12 +DA:466,12 +DA:467,0 +DA:468,0 +DA:474,12 +DA:478,12 +DA:480,12 +DA:483,12 +DA:486,3 +DA:488,3 +DA:489,0 +DA:490,0 +DA:493,3 +DA:496,3 +DA:498,3 +LF:193 +LH:133 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/shared/dlt_offline_trace.c +FN:69,dlt_offline_trace_write +FNDA:0,dlt_offline_trace_write +FNF:1 +FNH:0 +DA:69,0 +DA:78,0 +DA:80,0 +DA:83,0 +DA:84,0 +DA:85,0 +LF:6 +LH:0 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/shared/dlt_protocol.c +FN:71,dlt_get_service_name +FNDA:11,dlt_get_service_name +FNF:1 +FNH:1 +DA:71,11 +DA:73,11 +DA:75,11 +DA:76,11 +DA:78,11 +DA:79,11 +DA:81,0 +LF:7 +LH:6 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/shared/dlt_user_shared.c +FN:79,dlt_user_set_userheader +FN:96,dlt_user_check_userheader +FN:107,dlt_user_log_out2 +FN:129,dlt_user_log_out2_with_timeout +FN:151,dlt_user_log_out3 +FN:203,dlt_user_log_out3_with_timeout +FNDA:11831,dlt_user_check_userheader +FNDA:432,dlt_user_log_out2 +FNDA:6809,dlt_user_set_userheader +FNDA:0,dlt_user_log_out3_with_timeout +FNDA:51,dlt_user_log_out2_with_timeout +FNDA:6375,dlt_user_log_out3 +FNF:6 +FNH:5 +DA:79,6809 +DA:81,6809 +DA:84,6809 +DA:87,6809 +DA:88,6809 +DA:89,6809 +DA:90,6809 +DA:91,6809 +DA:93,6809 +DA:96,11831 +DA:98,11831 +DA:101,23662 +DA:102,11831 +DA:103,23662 +DA:104,11831 +DA:107,432 +DA:112,432 +DA:116,94 +DA:117,94 +DA:118,94 +DA:119,94 +DA:121,94 +DA:123,94 +DA:124,0 +DA:129,51 +DA:131,51 +DA:136,867 +DA:137,51 +DA:139,51 +DA:140,51 +DA:144,51 +DA:145,51 +DA:151,6375 +DA:156,6375 +DA:160,5856 +DA:161,5856 +DA:162,5856 +DA:163,5856 +DA:164,5856 +DA:165,5856 +DA:167,5856 +DA:169,5856 +DA:170,2 +DA:186,0 +DA:188,0 +DA:197,0 +DA:203,0 +DA:205,0 +DA:210,0 +DA:211,0 +DA:213,0 +DA:214,0 +DA:218,0 +DA:219,0 +LF:54 +LH:42 +end_of_record diff --git a/dlt_lcov_report/emerald.png b/dlt_lcov_report/emerald.png new file mode 100644 index 0000000000000000000000000000000000000000..38ad4f4068b935643d2486f323005fb294a9bd7e GIT binary patch literal 141 zcmeAS@N?(olHy`uVBq!ia0vp^j3CU&3?x-=hn)ga>?NMQuI!iC1^Jb!lvI6;R0X`wF(yt=9xVZRt1vCRixIA4P dLn>}1Cji+@42)0J?}79&c)I$ztaD0e0sy@GAL0N2 literal 0 HcmV?d00001 diff --git a/dlt_lcov_report/gateway/dlt_gateway.c.func-sort-c.html b/dlt_lcov_report/gateway/dlt_gateway.c.func-sort-c.html new file mode 100644 index 000000000..a0cdcae7e --- /dev/null +++ b/dlt_lcov_report/gateway/dlt_gateway.c.func-sort-c.html @@ -0,0 +1,184 @@ + + + + + + + LCOV - dlt_final_coverage.info - gateway/dlt_gateway.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - gateway - dlt_gateway.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:38563360.8 %
Date:2024-12-05 09:07:13Functions:232882.1 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_gateway_check_general_param0
dlt_gateway_check_interval0
dlt_gateway_forward_control_message0
dlt_gateway_get_connection0
dlt_gateway_parse_get_default_log_level0
dlt_gateway_control_service_logstorage1
dlt_gateway_check_periodic_control_messages2
dlt_gateway_process_gateway_timer2
dlt_gateway_add_to_event_loop3
dlt_gateway_parse_get_log_info3
dlt_gateway_process_on_demand_request3
dlt_gateway_init4
dlt_gateway_process_passive_node_messages4
dlt_gateway_configure5
dlt_gateway_check_control_messages6
dlt_gateway_check_ecu6
dlt_gateway_check_send_serial6
dlt_gateway_establish_connections6
dlt_gateway_get_connection_receiver6
dlt_gateway_check_connect_trigger7
dlt_gateway_check_ip7
dlt_gateway_check_timeout7
dlt_gateway_store_connection7
dlt_gateway_check_port9
dlt_gateway_deinit10
dlt_gateway_send_control_message12
dlt_gateway_allocate_control_messages17
dlt_gateway_check_param32
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/gateway/dlt_gateway.c.func.html b/dlt_lcov_report/gateway/dlt_gateway.c.func.html new file mode 100644 index 000000000..dc12135a9 --- /dev/null +++ b/dlt_lcov_report/gateway/dlt_gateway.c.func.html @@ -0,0 +1,184 @@ + + + + + + + LCOV - dlt_final_coverage.info - gateway/dlt_gateway.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - gateway - dlt_gateway.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:38563360.8 %
Date:2024-12-05 09:07:13Functions:232882.1 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_gateway_add_to_event_loop3
dlt_gateway_allocate_control_messages17
dlt_gateway_check_connect_trigger7
dlt_gateway_check_control_messages6
dlt_gateway_check_ecu6
dlt_gateway_check_general_param0
dlt_gateway_check_interval0
dlt_gateway_check_ip7
dlt_gateway_check_param32
dlt_gateway_check_periodic_control_messages2
dlt_gateway_check_port9
dlt_gateway_check_send_serial6
dlt_gateway_check_timeout7
dlt_gateway_configure5
dlt_gateway_control_service_logstorage1
dlt_gateway_deinit10
dlt_gateway_establish_connections6
dlt_gateway_forward_control_message0
dlt_gateway_get_connection0
dlt_gateway_get_connection_receiver6
dlt_gateway_init4
dlt_gateway_parse_get_default_log_level0
dlt_gateway_parse_get_log_info3
dlt_gateway_process_gateway_timer2
dlt_gateway_process_on_demand_request3
dlt_gateway_process_passive_node_messages4
dlt_gateway_send_control_message12
dlt_gateway_store_connection7
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/gateway/dlt_gateway.c.gcov.html b/dlt_lcov_report/gateway/dlt_gateway.c.gcov.html new file mode 100644 index 000000000..5c0abf1a5 --- /dev/null +++ b/dlt_lcov_report/gateway/dlt_gateway.c.gcov.html @@ -0,0 +1,1858 @@ + + + + + + + LCOV - dlt_final_coverage.info - gateway/dlt_gateway.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - gateway - dlt_gateway.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:38563360.8 %
Date:2024-12-05 09:07:13Functions:232882.1 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2015 Advanced Driver Information Technology.
+       5             :  * This code is developed by Advanced Driver Information Technology.
+       6             :  * Copyright of Advanced Driver Information Technology, Bosch and DENSO.
+       7             :  *
+       8             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       9             :  *
+      10             :  * This Source Code Form is subject to the terms of the
+      11             :  * Mozilla Public License (MPL), v. 2.0.
+      12             :  * If a copy of the MPL was not distributed with this file,
+      13             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      14             :  *
+      15             :  * For further information see http://www.covesa.org/.
+      16             :  */
+      17             : 
+      18             : /*!
+      19             :  * \author
+      20             :  * Christoph Lipka <clipka@jp.adit-jv.com>
+      21             :  * Saya Sugiura <ssugiura@jp.adit-jv.com>
+      22             :  *
+      23             :  * \copyright Copyright © 2015-2018 Advanced Driver Information Technology. \n
+      24             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      25             :  *
+      26             :  * \file dlt_gateway.c
+      27             :  */
+      28             : 
+      29             : #include <stdlib.h>
+      30             : #include <stdio.h>
+      31             : #include <string.h>
+      32             : #include <syslog.h>
+      33             : #include <arpa/inet.h>
+      34             : #include <sys/socket.h>
+      35             : #include <netinet/in.h>
+      36             : #include <netdb.h>
+      37             : #include <limits.h>
+      38             : #include <errno.h>
+      39             : #include "dlt_gateway.h"
+      40             : #include "dlt_gateway_internal.h"
+      41             : #include "dlt_config_file_parser.h"
+      42             : #include "dlt_common.h"
+      43             : #include "dlt_log.h"
+      44             : #include "dlt-daemon_cfg.h"
+      45             : #include "dlt_daemon_common_cfg.h"
+      46             : #include "dlt_daemon_event_handler.h"
+      47             : #include "dlt_daemon_connection.h"
+      48             : #include "dlt_daemon_client.h"
+      49             : #include "dlt_daemon_offline_logstorage.h"
+      50             : 
+      51             : /**
+      52             :  * Check if given string is a valid IP address
+      53             :  *
+      54             :  * @param con   DltGatewayConnection to be updated
+      55             :  * @param value string to be tested
+      56             :  * @return Value from DltReturnValue enum
+      57             :  */
+      58           7 : DLT_STATIC DltReturnValue dlt_gateway_check_ip(DltGatewayConnection *con, char *value)
+      59             : {
+      60           7 :     if ((con == NULL) || (value == NULL)) {
+      61           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+      62           1 :         return DLT_RETURN_WRONG_PARAMETER;
+      63             :     }
+      64             : 
+      65             :     int ret = DLT_RETURN_ERROR;
+      66             : #ifdef DLT_USE_IPv6
+      67             :     struct sockaddr_in6 sa6;
+      68           6 :     ret = inet_pton(AF_INET6, value, &(sa6.sin6_addr));
+      69             : #else
+      70             :     struct sockaddr_in sa;
+      71             :     ret = inet_pton(AF_INET, value, &(sa.sin_addr));
+      72             : #endif
+      73             : 
+      74             :     /* valid IP address */
+      75           6 :     if (ret != 0) {
+      76           6 :         con->ip_address = strdup(value);
+      77             : 
+      78           6 :         if (con->ip_address == NULL) {
+      79           0 :             dlt_log(LOG_ERR, "Cannot copy passive node IP address string\n");
+      80           0 :             return DLT_RETURN_ERROR;
+      81             :         }
+      82             : 
+      83             :         return DLT_RETURN_OK;
+      84             :     }
+      85             :     else {
+      86           0 :         dlt_log(LOG_ERR, "IP address is not valid\n");
+      87             :     }
+      88             : 
+      89           0 :     return DLT_RETURN_ERROR;
+      90             : }
+      91             : 
+      92             : /**
+      93             :  * Check port number
+      94             :  *
+      95             :  * @param con     DltGatewayConnection to be updated
+      96             :  * @param value   string to be tested
+      97             :  * @return Value from DltReturnValue enum
+      98             :  */
+      99           9 : DLT_STATIC DltReturnValue dlt_gateway_check_port(DltGatewayConnection *con,
+     100             :                                                  char *value)
+     101             : {
+     102             :     long int tmp = -1;
+     103             : 
+     104           9 :     if ((con == NULL) || (value == NULL)) {
+     105           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     106           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     107             :     }
+     108             : 
+     109           8 :     errno = 0;
+     110           8 :     tmp = strtol(value, NULL, 10);
+     111           8 :     if ((errno == ERANGE && (tmp == LONG_MAX || tmp == LONG_MIN))
+     112           8 :          || (errno != 0 && tmp == 0)) {
+     113           0 :         dlt_vlog(LOG_ERR, "%s: cannot convert port number\n", __func__);
+     114           0 :         return DLT_RETURN_ERROR;
+     115             :     }
+     116             : 
+     117             :     /* port ranges for unprivileged applications */
+     118           8 :     if ((tmp > IPPORT_RESERVED) && ((unsigned)tmp <= USHRT_MAX))
+     119             :     {
+     120           6 :         con->port = (int)tmp;
+     121           6 :         return DLT_RETURN_OK;
+     122             :     }
+     123             :     else {
+     124           2 :         dlt_log(LOG_ERR, "Port number is invalid\n");
+     125             :     }
+     126             : 
+     127           2 :     return DLT_RETURN_ERROR;
+     128             : }
+     129             : 
+     130             : /**
+     131             :  * Check ECU name
+     132             :  *
+     133             :  * @param con     DltGatewayConnection to be updated
+     134             :  * @param value   string to be used as ECU identifier
+     135             :  * @return Value from DltReturnValue enum
+     136             :  */
+     137           6 : DLT_STATIC DltReturnValue dlt_gateway_check_ecu(DltGatewayConnection *con,
+     138             :                                                 char *value)
+     139             : {
+     140           6 :     if ((con == NULL) || (value == NULL)) {
+     141           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     142           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     143             :     }
+     144             : 
+     145           5 :     con->ecuid = strdup(value);
+     146             : 
+     147           5 :     if (con->ecuid == NULL)
+     148           0 :         return DLT_RETURN_ERROR;
+     149             : 
+     150             :     return DLT_RETURN_OK;
+     151             : }
+     152             : 
+     153             : /**
+     154             :  * Check connection trigger
+     155             :  *
+     156             :  * @param con     DltGatewayConnection to be updated
+     157             :  * @param value   string to be tested
+     158             :  * @return Value from DltReturnValue enum
+     159             :  */
+     160           7 : DLT_STATIC DltReturnValue dlt_gateway_check_connect_trigger(DltGatewayConnection *con,
+     161             :                                                             char *value)
+     162             : {
+     163           7 :     if ((con == NULL) || (value == NULL)) {
+     164           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     165           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     166             :     }
+     167             : 
+     168           6 :     if (strncasecmp(value, "OnStartup", strlen("OnStartup")) == 0) {
+     169           5 :         con->trigger = DLT_GATEWAY_ON_STARTUP;
+     170             :     }
+     171           1 :     else if (strncasecmp(value, "OnDemand", strlen("OnDemand")) == 0)
+     172             :     {
+     173           0 :         con->trigger = DLT_GATEWAY_ON_DEMAND;
+     174             :     }
+     175             :     else {
+     176           1 :         dlt_log(LOG_ERR, "Wrong connection trigger state given.\n");
+     177           1 :         con->trigger = DLT_GATEWAY_UNDEFINED;
+     178           1 :         return DLT_RETURN_ERROR;
+     179             :     }
+     180             : 
+     181             :     return DLT_RETURN_OK;
+     182             : }
+     183             : 
+     184             : /**
+     185             :  * Check connection timeout value
+     186             :  *
+     187             :  * @param con     DltGatewayConnection to be updated
+     188             :  * @param value   string to be tested
+     189             :  * @return Value from DltReturnValue enum
+     190             :  */
+     191           7 : DLT_STATIC DltReturnValue dlt_gateway_check_timeout(DltGatewayConnection *con,
+     192             :                                                     char *value)
+     193             : {
+     194           7 :     if ((con == NULL) || (value == NULL)) {
+     195           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     196           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     197             :     }
+     198             : 
+     199           6 :     con->timeout = (int)strtol(value, NULL, 10);
+     200             : 
+     201             : 
+     202           6 :     if (con->timeout >= 0)
+     203           5 :         return DLT_RETURN_OK;
+     204             : 
+     205             :     return DLT_RETURN_ERROR;
+     206             : }
+     207             : 
+     208             : /**
+     209             :  * Check connection interval value in General section
+     210             :  *
+     211             :  * @param con     DltGateway to be updated
+     212             :  * @param value   string to be tested
+     213             :  * @return Value from DltReturnValue enum
+     214             :  */
+     215           0 : DLT_STATIC DltReturnValue dlt_gateway_check_interval(DltGateway *gateway,
+     216             :                                                     char *value)
+     217             : {
+     218           0 :     if ((gateway == NULL) || (value == NULL)) {
+     219           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     220           0 :         return DLT_RETURN_WRONG_PARAMETER;
+     221             :     }
+     222             : 
+     223           0 :     gateway->interval = (int)strtol(value, NULL, 10);
+     224             : 
+     225           0 :     if (gateway->interval > 0)
+     226           0 :         return DLT_RETURN_OK;
+     227             : 
+     228             :     return DLT_RETURN_ERROR;
+     229             : }
+     230             : 
+     231             : /**
+     232             :  * Check the value for SendSerialHeader
+     233             :  *
+     234             :  * @param con   DltGatewayConnection to be updated
+     235             :  * @param value string to be tested
+     236             :  * @return Value from DltReturnValue enum
+     237             :  */
+     238           6 : DLT_STATIC DltReturnValue dlt_gateway_check_send_serial(DltGatewayConnection *con,
+     239             :                                                         char *value)
+     240             : {
+     241           6 :     if ((con == NULL) || (value == NULL)) {
+     242           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     243           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     244             :     }
+     245             : 
+     246           5 :     con->send_serial = !!((int)strtol(value, NULL, 10));
+     247             : 
+     248           5 :     return DLT_RETURN_OK;
+     249             : }
+     250             : 
+     251             : /**
+     252             :  * Allocate passive control messages
+     253             :  *
+     254             :  * @param con   DltGatewayConnection to be updated
+     255             :  * @return Value from DltReturnValue enum
+     256             :  */
+     257          17 : DLT_STATIC DltReturnValue dlt_gateway_allocate_control_messages(DltGatewayConnection *con)
+     258             : {
+     259          17 :     if (con == NULL) {
+     260           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     261           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     262             :     }
+     263             : 
+     264          16 :     if (con->p_control_msgs == NULL) {
+     265           7 :         con->p_control_msgs = calloc(1, sizeof(DltPassiveControlMessage));
+     266             : 
+     267           7 :         if (!con->p_control_msgs) {
+     268           0 :             dlt_log(LOG_ERR,
+     269             :                     "Passive Control Message could not be allocated\n");
+     270           0 :             return DLT_RETURN_ERROR;
+     271             :         }
+     272             :     }
+     273             :     else {
+     274           9 :         con->p_control_msgs->next = calloc(1, sizeof(DltPassiveControlMessage));
+     275             : 
+     276           9 :         if (!con->p_control_msgs->next) {
+     277           0 :             dlt_log(LOG_ERR,
+     278             :                     "Passive Control Message could not be allocated\n");
+     279           0 :             return DLT_RETURN_ERROR;
+     280             :         }
+     281             : 
+     282           9 :         con->p_control_msgs = con->p_control_msgs->next;
+     283             :     }
+     284             : 
+     285             :     return DLT_RETURN_OK;
+     286             : }
+     287             : 
+     288             : /**
+     289             :  * Check the specified control messages identifier
+     290             :  *
+     291             :  * @param con   DltGatewayConnection to be updated
+     292             :  * @param value string to be tested
+     293             :  * @return Value from DltReturnValue enum
+     294             :  */
+     295           6 : DLT_STATIC DltReturnValue dlt_gateway_check_control_messages(DltGatewayConnection *con,
+     296             :                                                              char *value)
+     297             : {
+     298             :     /* list of allowed clients given */
+     299             :     char *token = NULL;
+     300           6 :     char *rest = NULL;
+     301             :     DltPassiveControlMessage *head = NULL;
+     302             : 
+     303           6 :     if ((con == NULL) || (value == NULL)) {
+     304           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     305           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     306             :     }
+     307             : 
+     308           5 :     if (strlen(value) == 0)
+     309             :         return DLT_RETURN_OK;
+     310             : 
+     311             :     /* set on startup control msg id and interval*/
+     312           5 :     token = strtok_r(value, ",", &rest);
+     313             : 
+     314          18 :     while (token != NULL) {
+     315          13 :         if (dlt_gateway_allocate_control_messages(con) != DLT_RETURN_OK) {
+     316           0 :             dlt_log(LOG_ERR,
+     317             :                     "Passive Control Message could not be allocated\n");
+     318           0 :             return DLT_RETURN_ERROR;
+     319             :         }
+     320             : 
+     321          13 :         con->p_control_msgs->id = strtol(token, NULL, 16);
+     322          13 :         con->p_control_msgs->user_id = DLT_SERVICE_ID_PASSIVE_NODE_CONNECT;
+     323          13 :         con->p_control_msgs->type = CONTROL_MESSAGE_ON_STARTUP;
+     324          13 :         con->p_control_msgs->req = CONTROL_MESSAGE_NOT_REQUESTED;
+     325          13 :         con->p_control_msgs->interval = -1;
+     326             : 
+     327          13 :         if (head == NULL)
+     328             :             head = con->p_control_msgs;
+     329             : 
+     330          13 :         if ((errno == EINVAL) || (errno == ERANGE)) {
+     331           0 :             dlt_vlog(LOG_ERR,
+     332             :                      "Control message ID is not an integer: %s\n",
+     333             :                      token);
+     334           0 :             return DLT_RETURN_ERROR;
+     335             :         }
+     336          13 :         else if ((con->p_control_msgs->id < DLT_SERVICE_ID_SET_LOG_LEVEL) ||
+     337             :                  (con->p_control_msgs->id >= DLT_SERVICE_ID_LAST_ENTRY))
+     338             :         {
+     339           0 :             dlt_vlog(LOG_ERR,
+     340             :                      "Control message ID is not valid: %s\n",
+     341             :                      token);
+     342           0 :             return DLT_RETURN_ERROR;
+     343             :         }
+     344             : 
+     345          13 :         token = strtok_r(NULL, ",", &rest);
+     346             :     }
+     347             : 
+     348             :     /* get back to head */
+     349           5 :     con->p_control_msgs = head;
+     350           5 :     con->head = head;
+     351             : 
+     352           5 :     return DLT_RETURN_OK;
+     353             : }
+     354             : 
+     355             : /**
+     356             :  * Check the specified periodic control messages identifier
+     357             :  *
+     358             :  * @param con   DltGatewayConnection to be updated
+     359             :  * @param value string to be tested
+     360             :  * @return Value from DltReturnValue enum
+     361             :  */
+     362           2 : DLT_STATIC DltReturnValue dlt_gateway_check_periodic_control_messages(
+     363             :     DltGatewayConnection *con,
+     364             :     char *value)
+     365             : {
+     366             :     char *token = NULL;
+     367           2 :     char *rest = NULL;
+     368             :     DltPassiveControlMessage *head = NULL;
+     369             : 
+     370           2 :     if ((con == NULL) || (value == NULL)) {
+     371           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     372           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     373             :     }
+     374             : 
+     375           1 :     if (strlen(value) == 0)
+     376             :         return DLT_RETURN_OK;
+     377             : 
+     378             :     /* store head address */
+     379           1 :     head = con->p_control_msgs;
+     380             : 
+     381             :     /* set periodic control msg id and interval*/
+     382           1 :     token = strtok_r(value, ",", &rest);
+     383             : 
+     384           3 :     while (token != NULL) {
+     385             :         char *p_token = NULL;
+     386           2 :         char *p_rest = NULL;
+     387             :         uint32_t id = 0;
+     388             : 
+     389           2 :         p_token = strtok_r(token, ":", &p_rest);
+     390             : 
+     391           2 :         if ((p_token != NULL) && (strlen(p_token) != 0)) {
+     392           2 :             id = strtol(p_token, NULL, 16);
+     393             : 
+     394             :             /* get back to head */
+     395           2 :             con->p_control_msgs = head;
+     396             : 
+     397             :             /* check if there is already id set in p_control_msgs */
+     398           3 :             while (con->p_control_msgs != NULL) {
+     399           1 :                 if (con->p_control_msgs->id == id) {
+     400           0 :                     con->p_control_msgs->type = CONTROL_MESSAGE_BOTH;
+     401           0 :                     con->p_control_msgs->interval = strtol(p_rest, NULL, 10);
+     402             : 
+     403           0 :                     if (con->p_control_msgs->interval <= 0)
+     404           0 :                         dlt_vlog(LOG_WARNING,
+     405             :                                  "%s interval is %d. It won't be send periodically.\n",
+     406             :                                  dlt_get_service_name(con->p_control_msgs->id),
+     407             :                                  con->p_control_msgs->interval);
+     408             : 
+     409             :                     break;
+     410             :                 }
+     411             : 
+     412           1 :                 con->p_control_msgs = con->p_control_msgs->next;
+     413             :             }
+     414             : 
+     415             :             /* if the id is not added yet, p_control_msgs supposed to be NULL */
+     416           2 :             if (con->p_control_msgs == NULL) {
+     417             :                 /* get back to head */
+     418           2 :                 con->p_control_msgs = head;
+     419             : 
+     420             :                 /* go to last pointer */
+     421           2 :                 while (con->p_control_msgs != NULL) {
+     422           1 :                     if (con->p_control_msgs->next == NULL)
+     423             :                         break;
+     424             : 
+     425           0 :                     con->p_control_msgs = con->p_control_msgs->next;
+     426             :                 }
+     427             : 
+     428           2 :                 if (dlt_gateway_allocate_control_messages(con) != DLT_RETURN_OK) {
+     429           0 :                     dlt_log(LOG_ERR,
+     430             :                             "Passive Control Message could not be allocated\n");
+     431           0 :                     return DLT_RETURN_ERROR;
+     432             :                 }
+     433             : 
+     434           2 :                 con->p_control_msgs->id = id;
+     435           2 :                 con->p_control_msgs->user_id = DLT_SERVICE_ID_PASSIVE_NODE_CONNECT;
+     436           2 :                 con->p_control_msgs->type = CONTROL_MESSAGE_PERIODIC;
+     437           2 :                 con->p_control_msgs->req = CONTROL_MESSAGE_NOT_REQUESTED;
+     438           2 :                 con->p_control_msgs->interval = strtol(p_rest, NULL, 10);
+     439             : 
+     440           2 :                 if (con->p_control_msgs->interval <= 0)
+     441           0 :                     dlt_vlog(LOG_WARNING,
+     442             :                              "%s interval is %d. It won't be send periodically.\n",
+     443             :                              dlt_get_service_name(con->p_control_msgs->id),
+     444             :                              con->p_control_msgs->interval);
+     445             : 
+     446           2 :                 if (head == NULL)
+     447           1 :                     head = con->p_control_msgs;
+     448             :             }
+     449             :         }
+     450             : 
+     451           2 :         if ((errno == EINVAL) || (errno == ERANGE)) {
+     452           0 :             dlt_vlog(LOG_ERR,
+     453             :                      "Control message ID is not an integer: %s\n",
+     454             :                      p_token);
+     455           0 :             return DLT_RETURN_ERROR;
+     456             :         }
+     457           2 :         else if ((con->p_control_msgs->id < DLT_SERVICE_ID_SET_LOG_LEVEL) ||
+     458             :                  (con->p_control_msgs->id >= DLT_SERVICE_ID_LAST_ENTRY))
+     459             :         {
+     460           0 :             dlt_vlog(LOG_ERR,
+     461             :                      "Control message ID is not valid: %s\n",
+     462             :                      p_token);
+     463           0 :             return DLT_RETURN_ERROR;
+     464             :         }
+     465             : 
+     466           2 :         token = strtok_r(NULL, ",", &rest);
+     467             :     }
+     468             : 
+     469             :     /* get back to head */
+     470           1 :     con->p_control_msgs = head;
+     471           1 :     con->head = head;
+     472             : 
+     473           1 :     return DLT_RETURN_OK;
+     474             : }
+     475             : 
+     476             : /**
+     477             :  * Expected entries for a passive node configuration
+     478             :  * Caution: after changing entries here,
+     479             :  * dlt_gateway_check_param needs to be updated as well
+     480             :  * */
+     481             : DLT_STATIC DltGatewayConf configuration_entries[GW_CONF_COUNT] = {
+     482             :     [GW_CONF_IP_ADDRESS] = {
+     483             :         .key = "IPaddress",
+     484             :         .func = dlt_gateway_check_ip,
+     485             :         .is_opt = 0
+     486             :     },
+     487             :     [GW_CONF_PORT] = {
+     488             :         .key = "Port",
+     489             :         .func = dlt_gateway_check_port,
+     490             :         .is_opt = 1
+     491             :     },
+     492             :     [GW_CONF_ECUID] = {
+     493             :         .key = "EcuID",
+     494             :         .func = dlt_gateway_check_ecu,
+     495             :         .is_opt = 0
+     496             :     },
+     497             :     [GW_CONF_CONNECT] = {
+     498             :         .key = "Connect",
+     499             :         .func = dlt_gateway_check_connect_trigger,
+     500             :         .is_opt = 1
+     501             :     },
+     502             :     [GW_CONF_TIMEOUT] = {
+     503             :         .key = "Timeout",
+     504             :         .func = dlt_gateway_check_timeout,
+     505             :         .is_opt = 0
+     506             :     },
+     507             :     [GW_CONF_SEND_CONTROL] = {
+     508             :         .key = "SendControl",
+     509             :         .func = dlt_gateway_check_control_messages,
+     510             :         .is_opt = 1
+     511             :     },
+     512             :     [GW_CONF_SEND_PERIODIC_CONTROL] = {
+     513             :         .key = "SendPeriodicControl",
+     514             :         .func = dlt_gateway_check_periodic_control_messages,
+     515             :         .is_opt = 1
+     516             :     },
+     517             :     [GW_CONF_SEND_SERIAL_HEADER] = {
+     518             :         .key = "SendSerialHeader",
+     519             :         .func = dlt_gateway_check_send_serial,
+     520             :         .is_opt = 1
+     521             :     }
+     522             : };
+     523             : 
+     524             : DLT_STATIC DltGatewayGeneralConf general_entries[GW_CONF_COUNT] = {
+     525             :     [GW_CONF_GENERAL_INTERVAL] = {
+     526             :         .key = "Interval",
+     527             :         .func = dlt_gateway_check_interval,
+     528             :         .is_opt = 1
+     529             :     }
+     530             : };
+     531             : 
+     532             : #define DLT_GATEWAY_NUM_PROPERTIES_MAX GW_CONF_COUNT
+     533             : 
+     534             : /**
+     535             :  * Check if gateway connection general configuration parameter is valid.
+     536             :  *
+     537             :  * @param gateway    DltGateway
+     538             :  * @param ctype      DltGatwayGeneralConnection property
+     539             :  * @param value      specified property value from configuration file
+     540             :  * @return Value from DltReturnValue enum
+     541             :  */
+     542           0 : DLT_STATIC DltReturnValue dlt_gateway_check_general_param(DltGateway *gateway,
+     543             :                                                   DltGatewayGeneralConfType ctype,
+     544             :                                                   char *value)
+     545             : {
+     546           0 :     if ((gateway == NULL) || (value == NULL)) {
+     547           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     548           0 :         return DLT_RETURN_WRONG_PARAMETER;
+     549             :     }
+     550             : 
+     551           0 :     if (ctype < GW_CONF_GENEREL_COUNT)
+     552           0 :         return general_entries[ctype].func(gateway, value);
+     553             : 
+     554             :     return DLT_RETURN_ERROR;
+     555             : }
+     556             : 
+     557             : /**
+     558             :  * Check if gateway connection configuration parameter is valid.
+     559             :  *
+     560             :  * @param gateway    DltGateway
+     561             :  * @param con        DltGatewayConnection
+     562             :  * @param ctype      DltGatwayConnection property
+     563             :  * @param value      specified property value from configuration file
+     564             :  * @return Value from DltReturnValue enum
+     565             :  */
+     566          32 : DLT_STATIC DltReturnValue dlt_gateway_check_param(DltGateway *gateway,
+     567             :                                                   DltGatewayConnection *con,
+     568             :                                                   DltGatewayConfType ctype,
+     569             :                                                   char *value)
+     570             : {
+     571          32 :     if ((gateway == NULL) || (con == NULL) || (value == NULL)) {
+     572           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     573           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     574             :     }
+     575             : 
+     576          31 :     if (ctype < GW_CONF_COUNT)
+     577          31 :         return configuration_entries[ctype].func(con, value);
+     578             : 
+     579             :     return DLT_RETURN_ERROR;
+     580             : }
+     581             : 
+     582             : /**
+     583             :  * Store gateway connection in internal data structure
+     584             :  *
+     585             :  * @param gateway    DltGatway
+     586             :  * @param tmp        DltGatewayConnection
+     587             :  * @param verbose    verbose flag
+     588             :  * @return 0 on success, -1 otherwise
+     589             :  */
+     590           7 : int dlt_gateway_store_connection(DltGateway *gateway,
+     591             :                                  DltGatewayConnection *tmp,
+     592             :                                  int verbose)
+     593             : {
+     594             :     int i = 0;
+     595             : 
+     596           7 :     PRINT_FUNCTION_VERBOSE(verbose);
+     597             : 
+     598           7 :     if ((gateway == NULL) || (tmp == NULL)) {
+     599           2 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     600           2 :         return DLT_RETURN_WRONG_PARAMETER;
+     601             :     }
+     602             : 
+     603             :     /* find next free entry in connection array */
+     604           5 :     while (i < gateway->num_connections) {
+     605           5 :         if (gateway->connections[i].status == DLT_GATEWAY_UNINITIALIZED)
+     606             :             break;
+     607             : 
+     608           0 :         i++;
+     609             :     }
+     610             : 
+     611             :     /* store values */
+     612           5 :     gateway->connections[i].ip_address = strdup(tmp->ip_address);
+     613           5 :     gateway->connections[i].ecuid = strdup(tmp->ecuid);
+     614           5 :     gateway->connections[i].sock_domain = tmp->sock_domain;
+     615           5 :     gateway->connections[i].sock_type = tmp->sock_type;
+     616           5 :     gateway->connections[i].sock_protocol = tmp->sock_protocol;
+     617           5 :     gateway->connections[i].port = tmp->port;
+     618           5 :     gateway->connections[i].trigger = tmp->trigger;
+     619           5 :     gateway->connections[i].timeout = tmp->timeout;
+     620           5 :     gateway->connections[i].handle = 0;
+     621           5 :     gateway->connections[i].status = DLT_GATEWAY_INITIALIZED;
+     622           5 :     gateway->connections[i].p_control_msgs = tmp->p_control_msgs;
+     623           5 :     gateway->connections[i].head = tmp->head;
+     624           5 :     gateway->connections[i].send_serial = tmp->send_serial;
+     625             : 
+     626           5 :     if (dlt_client_init_port(&gateway->connections[i].client,
+     627             :                              gateway->connections[i].port,
+     628             :                              verbose) != 0) {
+     629           0 :         free(gateway->connections[i].ip_address);
+     630           0 :         gateway->connections[i].ip_address = NULL;
+     631           0 :         free(gateway->connections[i].ecuid);
+     632           0 :         gateway->connections[i].ecuid = NULL;
+     633           0 :         free(gateway->connections[i].p_control_msgs);
+     634           0 :         gateway->connections[i].p_control_msgs = NULL;
+     635           0 :         dlt_log(LOG_CRIT, "dlt_client_init_port() failed for gateway connection\n");
+     636           0 :         return DLT_RETURN_ERROR;
+     637             :     }
+     638             : 
+     639             :     /* setup DltClient Structure */
+     640           5 :     if (dlt_client_set_server_ip(&gateway->connections[i].client,
+     641           5 :                                  gateway->connections[i].ip_address) == -1) {
+     642           0 :         dlt_log(LOG_ERR,
+     643             :                 "dlt_client_set_server_ip() failed for gateway connection \n");
+     644           0 :         return DLT_RETURN_ERROR;
+     645             :     }
+     646             : 
+     647             :     return DLT_RETURN_OK;
+     648             : }
+     649             : 
+     650             : /**
+     651             :  * Read configuration file and initialize connection data structures
+     652             :  *
+     653             :  * @param gateway       DltGateway
+     654             :  * @param config_file   Gateway configuration
+     655             :  * @param verbose       verbose flag
+     656             :  * @return 0 on success, -1 otherwise
+     657             :  */
+     658           5 : int dlt_gateway_configure(DltGateway *gateway, char *config_file, int verbose)
+     659             : {
+     660             :     int ret = 0;
+     661             :     int i = 0;
+     662             :     DltConfigFile *file = NULL;
+     663           5 :     int num_sections = 0;
+     664             : 
+     665           5 :     PRINT_FUNCTION_VERBOSE(verbose);
+     666             : 
+     667           5 :     if ((gateway == NULL) || (config_file == 0) || (config_file[0] == '\0')) {
+     668           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     669           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     670             :     }
+     671             : 
+     672             :     /* read configuration file */
+     673           4 :     file = dlt_config_file_init(config_file);
+     674           4 :     if(file == NULL) {
+     675             :         return DLT_RETURN_ERROR;
+     676             :     }
+     677             : 
+     678             :     /* get number of entries and allocate memory to store information */
+     679           4 :     ret = dlt_config_file_get_num_sections(file, &num_sections);
+     680           4 :     if (ret != 0) {
+     681           0 :         dlt_config_file_release(file);
+     682           0 :         dlt_log(LOG_ERR, "Invalid number of sections in configuration file\n");
+     683           0 :         return DLT_RETURN_ERROR;
+     684             :     }
+     685             : 
+     686           4 :     ret = dlt_config_file_check_section_name_exists(file, DLT_GATEWAY_GENERAL_SECTION_NAME);
+     687           4 :     if (ret == -1) {
+     688             :         /*
+     689             :          * No General section in configuration file.
+     690             :          * Try to use default for interval.
+     691             :          */
+     692           4 :         gateway->num_connections = num_sections;
+     693           4 :         dlt_vlog(LOG_WARNING,
+     694             :                 "Missing General section in gateway. Using default interval %d (secs)\n",
+     695             :                 gateway->interval);
+     696             :     }
+     697             :     else {
+     698             :         /*
+     699             :          * Since the General section is also counted in num_sections,
+     700             :          * so number of connections must be number of sections - 1.
+     701             :          */
+     702           0 :         gateway->num_connections = num_sections - 1;
+     703             :     }
+     704             : 
+     705           4 :     gateway->connections = calloc(gateway->num_connections,
+     706             :                                 sizeof(DltGatewayConnection));
+     707             : 
+     708           4 :     if (gateway->connections == NULL) {
+     709           0 :         dlt_config_file_release(file);
+     710           0 :         dlt_log(LOG_CRIT, "Memory allocation for gateway connections failed\n");
+     711           0 :         return DLT_RETURN_ERROR;
+     712             :     }
+     713             : 
+     714           8 :     for (i = 0; i < num_sections; i++) {
+     715             :         DltGatewayConnection tmp;
+     716             :         int invalid = 0;
+     717             :         DltGatewayConfType j = 0;
+     718             :         DltGatewayGeneralConfType g = 0;
+     719           4 :         char section[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = { '\0' };
+     720           4 :         char value[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = { '\0' };
+     721             : 
+     722             :         memset(&tmp, 0, sizeof(tmp));
+     723             : 
+     724             :         /* Set default */
+     725           4 :         tmp.send_serial = gateway->send_serial;
+     726           4 :         tmp.port = DLT_DAEMON_TCP_PORT;
+     727             : 
+     728           4 :         ret = dlt_config_file_get_section_name(file, i, section);
+     729           4 :         if (ret != 0) {
+     730           0 :             dlt_log(LOG_WARNING, "Get section name failed\n");
+     731           0 :             continue;
+     732             :         }
+     733             : 
+     734           4 :         if (strncmp(section, DLT_GATEWAY_GENERAL_SECTION_NAME,
+     735             :                 sizeof(DLT_GATEWAY_GENERAL_SECTION_NAME)) == 0) {
+     736           0 :             for (g = 0; g < GW_CONF_GENEREL_COUNT; g++) {
+     737           0 :                 ret = dlt_config_file_get_value(file,
+     738             :                                                 section,
+     739           0 :                                                 general_entries[g].key,
+     740             :                                                 value);
+     741             : 
+     742           0 :                 if ((ret != 0) && general_entries[g].is_opt) {
+     743             :                     /* Use default values for this key */
+     744           0 :                     dlt_vlog(LOG_WARNING,
+     745             :                              "Using default for %s.\n",
+     746             :                              general_entries[g].key);
+     747           0 :                     continue;
+     748             :                 }
+     749           0 :                 else if (ret != 0)
+     750             :                 {
+     751           0 :                     dlt_vlog(LOG_WARNING,
+     752             :                              "Missing configuration for %s.\n",
+     753             :                              general_entries[g].key);
+     754           0 :                     break;
+     755             :                 }
+     756             : 
+     757             :                 /* check value and store general configuration */
+     758           0 :                 ret = dlt_gateway_check_general_param(gateway, g, value);
+     759             : 
+     760           0 :                 if (ret != 0)
+     761           0 :                     dlt_vlog(LOG_ERR,
+     762             :                              "Configuration %s = %s is invalid. Using default.\n",
+     763             :                              general_entries[g].key, value);
+     764             :             }
+     765             :         }
+     766             :         else {
+     767          36 :             for (j = 0; j < GW_CONF_COUNT; j++) {
+     768          32 :                 ret = dlt_config_file_get_value(file,
+     769             :                                                 section,
+     770          32 :                                                 configuration_entries[j].key,
+     771             :                                                 value);
+     772             : 
+     773          32 :                 if ((ret != 0) && configuration_entries[j].is_opt) {
+     774             :                     /* Use default values for this key */
+     775           4 :                     dlt_vlog(LOG_WARNING,
+     776             :                              "Using default for %s.\n",
+     777             :                              configuration_entries[j].key);
+     778           4 :                     continue;
+     779             :                 }
+     780          28 :                 else if (ret != 0)
+     781             :                 {
+     782           0 :                     dlt_vlog(LOG_WARNING,
+     783             :                              "Missing configuration for %s.\n",
+     784             :                              configuration_entries[j].key);
+     785             :                     invalid = 1;
+     786           0 :                     break;
+     787             :                 }
+     788             : 
+     789             :                 /* check value and store temporary */
+     790          28 :                 ret = dlt_gateway_check_param(gateway, &tmp, j, value);
+     791             : 
+     792          28 :                 if (ret != 0)
+     793           0 :                     dlt_vlog(LOG_ERR,
+     794             :                              "Configuration %s = %s is invalid.\n"
+     795             :                              "Using default.\n",
+     796             :                              configuration_entries[j].key, value);
+     797             :             }
+     798             : 
+     799           4 :             if (!tmp.ip_address) {
+     800             :                 invalid = 1;
+     801             :             }
+     802             : 
+     803           4 :             if (invalid) {
+     804           0 :                 dlt_vlog(LOG_ERR,
+     805             :                          "%s configuration is invalid.\n"
+     806             :                          "Ignoring.\n",
+     807             :                          section);
+     808             :             }
+     809             :             else {
+     810           4 :                 ret = dlt_gateway_store_connection(gateway, &tmp, verbose);
+     811             : 
+     812           4 :                 if (ret != 0)
+     813           0 :                     dlt_log(LOG_ERR, "Storing gateway connection data failed\n");
+     814             :             }
+     815             :         }
+     816             : 
+     817             :         /* strdup used inside some get_value function */
+     818           4 :         if (tmp.ecuid != NULL) {
+     819           4 :             free(tmp.ecuid);
+     820           4 :             tmp.ecuid = NULL;
+     821             :         }
+     822           4 :         if (tmp.ip_address != NULL) {
+     823           4 :             free(tmp.ip_address);
+     824             :             tmp.ip_address = NULL;
+     825             :         }
+     826             :     }
+     827             : 
+     828           4 :     dlt_config_file_release(file);
+     829           4 :     return ret;
+     830             : }
+     831             : 
+     832           4 : int dlt_gateway_init(DltDaemonLocal *daemon_local, int verbose)
+     833             : {
+     834           4 :     PRINT_FUNCTION_VERBOSE(verbose);
+     835             : 
+     836           4 :     if (daemon_local == NULL) {
+     837           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     838           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     839             :     }
+     840             : 
+     841           3 :     DltGateway *gateway = &daemon_local->pGateway;
+     842             : 
+     843             :     if (gateway != NULL) {
+     844             :         /* Get default value from daemon_local */
+     845           3 :         gateway->send_serial = daemon_local->flags.lflag;
+     846           3 :         gateway->interval = DLT_GATEWAY_TIMER_DEFAULT_INTERVAL;
+     847             : 
+     848           3 :         if (dlt_gateway_configure(gateway,
+     849           3 :                                   daemon_local->flags.gatewayConfigFile,
+     850             :                                   verbose) != 0) {
+     851           0 :             dlt_log(LOG_ERR, "Gateway initialization failed\n");
+     852           0 :             return DLT_RETURN_ERROR;
+     853             :         }
+     854             :     }
+     855             :     else {
+     856             :         dlt_log(LOG_CRIT, "Pointer to Gateway structure is NULL\n");
+     857             :         return DLT_RETURN_ERROR;
+     858             :     }
+     859             : 
+     860             :     /* ignore return value */
+     861           3 :     dlt_gateway_establish_connections(gateway, daemon_local, verbose);
+     862             : 
+     863           3 :     return DLT_RETURN_OK;
+     864             : }
+     865             : 
+     866          10 : void dlt_gateway_deinit(DltGateway *gateway, int verbose)
+     867             : {
+     868             :     DltPassiveControlMessage *msg;
+     869             :     int i = 0;
+     870             : 
+     871          10 :     if (gateway == NULL) {
+     872           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     873           0 :         return;
+     874             :     }
+     875             : 
+     876          10 :     PRINT_FUNCTION_VERBOSE(verbose);
+     877             : 
+     878          12 :     for (i = 0; i < gateway->num_connections; i++) {
+     879           2 :         DltGatewayConnection *c = &gateway->connections[i];
+     880           2 :         dlt_client_cleanup(&c->client, verbose);
+     881           2 :         free(c->ip_address);
+     882           2 :         c->ip_address = NULL;
+     883           2 :         free(c->ecuid);
+     884           2 :         c->ecuid = NULL;
+     885             : 
+     886           6 :         while (c->p_control_msgs != NULL) {
+     887           4 :             msg = c->p_control_msgs->next;
+     888           4 :             free(c->p_control_msgs);
+     889           4 :             c->p_control_msgs = msg;
+     890             :         }
+     891             :     }
+     892             : 
+     893          10 :     free(gateway->connections);
+     894          10 :     gateway->connections = NULL;
+     895             : }
+     896             : 
+     897             : /**
+     898             :  * If connection to passive node established, add to event loop
+     899             :  *
+     900             :  * @param daemon_local  DltDaemonLocal
+     901             :  * @param con           DltGatewayConnection
+     902             :  * @param verbose       verbose flag
+     903             :  * @return 0 on success, -1 otherwise
+     904             :  */
+     905           3 : DLT_STATIC int dlt_gateway_add_to_event_loop(DltDaemonLocal *daemon_local,
+     906             :                                              DltGatewayConnection *con,
+     907             :                                              int verbose)
+     908             : {
+     909             :     DltPassiveControlMessage *control_msg = NULL;
+     910             :     int sendtime = 1;
+     911             : 
+     912           3 :     if ((daemon_local == NULL) || (con == NULL)) {
+     913           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     914           0 :         return DLT_RETURN_WRONG_PARAMETER;
+     915             :     }
+     916             : 
+     917             :     /* connection to passive node established, add to event loop */
+     918           3 :     con->status = DLT_GATEWAY_CONNECTED;
+     919           3 :     con->reconnect_cnt = 0;
+     920           3 :     con->timeout_cnt = 0;
+     921           3 :     con->sendtime_cnt = 0;
+     922             : 
+     923             :     /* setup dlt connection and add to poll event loop here */
+     924           3 :     if (dlt_connection_create(daemon_local,
+     925             :                               &daemon_local->pEvent,
+     926             :                               con->client.sock,
+     927             :                               POLLIN,
+     928             :                               DLT_CONNECTION_GATEWAY) != 0) {
+     929           0 :         dlt_log(LOG_ERR, "Gateway connection creation failed\n");
+     930           0 :         return DLT_RETURN_ERROR;
+     931             :     }
+     932             : 
+     933             :     /* immediately send configured control messages */
+     934           3 :     control_msg = con->p_control_msgs;
+     935             : 
+     936           9 :     while (control_msg != NULL) {
+     937           6 :         if ((control_msg->type == CONTROL_MESSAGE_ON_STARTUP) ||
+     938             :             (control_msg->type == CONTROL_MESSAGE_BOTH)) {
+     939           6 :             if (dlt_gateway_send_control_message(con,
+     940             :                                                  control_msg,
+     941             :                                                  NULL,
+     942             :                                                  verbose) == DLT_RETURN_OK)
+     943           6 :                 control_msg->req = CONTROL_MESSAGE_REQUESTED;
+     944             :         }
+     945             : 
+     946             :         /* multiply periodic sending time */
+     947           6 :         if (((control_msg->type == CONTROL_MESSAGE_PERIODIC) ||
+     948           0 :              (control_msg->type == CONTROL_MESSAGE_BOTH)) &&
+     949           0 :             (control_msg->interval > 0))
+     950           0 :             sendtime *= control_msg->interval;
+     951             : 
+     952           6 :         control_msg = control_msg->next;
+     953             :     }
+     954             : 
+     955             :     /* set periodic sending time */
+     956           3 :     con->sendtime = sendtime;
+     957           3 :     con->sendtime_cnt = con->sendtime;
+     958             : 
+     959           3 :     return DLT_RETURN_OK;
+     960             : }
+     961             : 
+     962           6 : int dlt_gateway_establish_connections(DltGateway *gateway,
+     963             :                                       DltDaemonLocal *daemon_local,
+     964             :                                       int verbose)
+     965             : {
+     966             :     int i = 0;
+     967             :     int ret = 0;
+     968             : 
+     969           6 :     PRINT_FUNCTION_VERBOSE(verbose);
+     970             : 
+     971           6 :     if ((gateway == NULL) || (daemon_local == NULL)) {
+     972           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     973           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     974             :     }
+     975             : 
+     976          10 :     for (i = 0; i < gateway->num_connections; i++) {
+     977           5 :         DltGatewayConnection *con = &(gateway->connections[i]);
+     978             :         DltPassiveControlMessage *control_msg = NULL;
+     979             : 
+     980           5 :         if ((con->status != DLT_GATEWAY_CONNECTED) &&
+     981           5 :             (con->trigger != DLT_GATEWAY_ON_DEMAND) &&
+     982             :             (con->trigger != DLT_GATEWAY_DISABLED)) {
+     983           5 :             ret = dlt_client_connect(&con->client, verbose);
+     984             : 
+     985           5 :             if (ret == 0) {
+     986             :                 /* setup dlt connection and add to poll event loop here */
+     987           3 :                 if (dlt_gateway_add_to_event_loop(daemon_local, con, verbose) != DLT_RETURN_OK) {
+     988           0 :                     dlt_log(LOG_ERR, "Gateway connection creation failed\n");
+     989           0 :                     return DLT_RETURN_ERROR;
+     990             :                 }
+     991             :             }
+     992             :             else {
+     993           2 :                 dlt_log(LOG_DEBUG,
+     994             :                         "Passive Node is not up. Connection failed.\n");
+     995             : 
+     996           2 :                 con->timeout_cnt++;
+     997             : 
+     998           2 :                 if (con->timeout > 0) {
+     999           0 :                     if (con->timeout_cnt > con->timeout) {
+    1000           0 :                         con->trigger = DLT_GATEWAY_DISABLED;
+    1001           0 :                         dlt_log(LOG_WARNING,
+    1002             :                                 "Passive Node connection retry timed out. "
+    1003             :                                 "Give up.\n");
+    1004             :                     }
+    1005             :                 }
+    1006           2 :                 else if (con->timeout == 0) {
+    1007           2 :                     dlt_vlog(LOG_DEBUG, "Retried [%d] times\n", con->timeout_cnt);
+    1008             :                 }
+    1009             :             }
+    1010             :         }
+    1011           0 :         else if ((con->status == DLT_GATEWAY_CONNECTED) &&
+    1012           0 :                  (con->trigger != DLT_GATEWAY_DISABLED))
+    1013             :         {
+    1014             :             /* setup dlt connection and add to poll event loop here */
+    1015           0 :             if (dlt_connection_create(daemon_local,
+    1016             :                                       &daemon_local->pEvent,
+    1017             :                                       con->client.sock,
+    1018             :                                       POLLIN,
+    1019             :                                       DLT_CONNECTION_GATEWAY) != 0) {
+    1020           0 :                 dlt_log(LOG_ERR, "Gateway connection creation failed\n");
+    1021           0 :                 return DLT_RETURN_ERROR;
+    1022             :             }
+    1023             : 
+    1024             :             /* immediately send periodic configured control messages */
+    1025           0 :             control_msg = con->p_control_msgs;
+    1026             : 
+    1027           0 :             while (control_msg != NULL) {
+    1028           0 :                 if ((control_msg->type == CONTROL_MESSAGE_PERIODIC) ||
+    1029             :                     (control_msg->type == CONTROL_MESSAGE_BOTH)) {
+    1030           0 :                     if (dlt_gateway_send_control_message(con,
+    1031             :                                                          control_msg,
+    1032             :                                                          NULL,
+    1033             :                                                          verbose) == DLT_RETURN_OK)
+    1034           0 :                         control_msg->req = CONTROL_MESSAGE_REQUESTED;
+    1035             :                 }
+    1036             : 
+    1037           0 :                 control_msg = control_msg->next;
+    1038             :             }
+    1039             : 
+    1040             :             /* check sendtime counter */
+    1041           0 :             if (con->sendtime_cnt > 0)
+    1042           0 :                 con->sendtime_cnt--;
+    1043             : 
+    1044           0 :             if (con->sendtime_cnt == 0)
+    1045           0 :                 con->sendtime_cnt = con->sendtime;
+    1046             :         }
+    1047             :     }
+    1048             : 
+    1049             :     return DLT_RETURN_OK;
+    1050             : }
+    1051             : 
+    1052           6 : DltReceiver *dlt_gateway_get_connection_receiver(DltGateway *gateway, int fd)
+    1053             : {
+    1054             :     int i = 0;
+    1055             : 
+    1056           6 :     if (gateway == NULL) {
+    1057           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+    1058           1 :         return NULL;
+    1059             :     }
+    1060             : 
+    1061           6 :     for (i = 0; i < gateway->num_connections; i++) {
+    1062           5 :         DltGatewayConnection *c = &gateway->connections[i];
+    1063             : 
+    1064           5 :         if ((c->status == DLT_GATEWAY_CONNECTED) && (c->client.sock == fd))
+    1065           4 :             return &c->client.receiver;
+    1066             :     }
+    1067             : 
+    1068             :     return NULL;
+    1069             : }
+    1070             : 
+    1071             : /**
+    1072             :  * Parse GET_LOG_INFO
+    1073             :  *
+    1074             :  * @param daemon          DltDaemon
+    1075             :  * @param ecu             Ecu ID
+    1076             :  * @param msg             DltMessage
+    1077             :  * @param req             1 if requested from gateway, 0 otherwise
+    1078             :  * @param verbose verbose flag
+    1079             :  * @return Value from DltReturnValue enum
+    1080             :  */
+    1081           3 : DLT_STATIC DltReturnValue dlt_gateway_parse_get_log_info(DltDaemon *daemon,
+    1082             :                                                          char *ecu,
+    1083             :                                                          DltMessage *msg,
+    1084             :                                                          int req,
+    1085             :                                                          int verbose)
+    1086             : {
+    1087           3 :     char resp_text[DLT_RECEIVE_BUFSIZE] = { '\0' };
+    1088             :     DltServiceGetLogInfoResponse *resp = NULL;
+    1089             :     AppIDsType app;
+    1090             :     ContextIDsInfoType con;
+    1091             :     int i = 0;
+    1092             :     int j = 0;
+    1093             : 
+    1094           3 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1095             : 
+    1096           3 :     if ((msg == NULL) || (msg->databuffer == NULL)) {
+    1097           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+    1098           1 :         return DLT_RETURN_WRONG_PARAMETER;
+    1099             :     }
+    1100             : 
+    1101           2 :     if (dlt_check_rcv_data_size(msg->datasize, sizeof(DltServiceGetLogInfoResponse)) < 0)
+    1102             :         return DLT_RETURN_ERROR;
+    1103             : 
+    1104             :     /* if the request was send from gateway, clear all application and context list */
+    1105           1 :     if (req == CONTROL_MESSAGE_REQUESTED) {
+    1106             :         /* clear application list */
+    1107           0 :         if (dlt_daemon_applications_clear(daemon, ecu, verbose) == DLT_RETURN_ERROR) {
+    1108           0 :             dlt_log(LOG_ERR, "Cannot clear applications list\n");
+    1109           0 :             return DLT_RETURN_ERROR;
+    1110             :         }
+    1111             : 
+    1112             :         /* clear context list */
+    1113           0 :         if (dlt_daemon_contexts_clear(daemon, ecu, verbose) == DLT_RETURN_ERROR) {
+    1114           0 :             dlt_log(LOG_ERR, "Cannot clear contexts list\n");
+    1115           0 :             return DLT_RETURN_ERROR;
+    1116             :         }
+    1117             :     }
+    1118             : 
+    1119             :     /* check response */
+    1120           1 :     if (dlt_message_payload(msg,
+    1121             :                             resp_text,
+    1122             :                             DLT_RECEIVE_BUFSIZE,
+    1123             :                             DLT_OUTPUT_ASCII, 0) != DLT_RETURN_OK) {
+    1124           0 :         dlt_log(LOG_ERR, "GET_LOG_INFO payload failed\n");
+    1125           0 :         return DLT_RETURN_ERROR;
+    1126             :     }
+    1127             : 
+    1128             :     /* prepare pointer to message request */
+    1129           1 :     resp = (DltServiceGetLogInfoResponse *)calloc(1, sizeof(DltServiceGetLogInfoResponse));
+    1130             : 
+    1131           1 :     if (resp == NULL) {
+    1132           0 :         dlt_log(LOG_ERR,
+    1133             :                 "Get Log Info Response could not be allocated\n");
+    1134           0 :         return DLT_RETURN_ERROR;
+    1135             :     }
+    1136             : 
+    1137           1 :     if (dlt_set_loginfo_parse_service_id(resp_text, &resp->service_id, &resp->status) != DLT_RETURN_OK) {
+    1138           0 :         dlt_log(LOG_ERR, "Parsing GET_LOG_INFO failed\n");
+    1139           0 :         dlt_client_cleanup_get_log_info(resp);
+    1140           0 :         return DLT_RETURN_ERROR;
+    1141             :     }
+    1142             : 
+    1143           1 :     if (dlt_client_parse_get_log_info_resp_text(resp, resp_text) != DLT_RETURN_OK) {
+    1144           0 :         dlt_log(LOG_ERR, "Parsing GET_LOG_INFO failed\n");
+    1145           0 :         dlt_client_cleanup_get_log_info(resp);
+    1146           0 :         return DLT_RETURN_ERROR;
+    1147             :     }
+    1148             : 
+    1149           2 :     for (i = 0; i < resp->log_info_type.count_app_ids; i++) {
+    1150           1 :         app = resp->log_info_type.app_ids[i];
+    1151             : 
+    1152             :         /* add application */
+    1153           1 :         if (dlt_daemon_application_add(daemon,
+    1154             :                                        app.app_id,
+    1155             :                                        0,
+    1156             :                                        app.app_description,
+    1157             :                                        -1,
+    1158             :                                        ecu,
+    1159             :                                        verbose) == 0) {
+    1160           0 :             dlt_vlog(LOG_WARNING,
+    1161             :                      "%s: dlt_daemon_application_add failed\n",
+    1162             :                      __func__);
+    1163           0 :             dlt_client_cleanup_get_log_info(resp);
+    1164           0 :             return DLT_RETURN_ERROR;
+    1165             :         }
+    1166             : 
+    1167           2 :         for (j = 0; j < app.count_context_ids; j++) {
+    1168           1 :             con = app.context_id_info[j];
+    1169             : 
+    1170             :             /* add context */
+    1171           1 :             if (dlt_daemon_context_add(daemon,
+    1172             :                                        app.app_id,
+    1173             :                                        con.context_id,
+    1174           1 :                                        con.log_level,
+    1175           1 :                                        con.trace_status,
+    1176             :                                        0,
+    1177             :                                        -1,
+    1178             :                                        con.context_description,
+    1179             :                                        ecu,
+    1180             :                                        verbose) == 0) {
+    1181           0 :                 dlt_vlog(LOG_WARNING,
+    1182             :                          "%s: dlt_daemon_context_add failed for %4s\n",
+    1183             :                          __func__,
+    1184             :                          app.app_id);
+    1185           0 :                 dlt_client_cleanup_get_log_info(resp);
+    1186           0 :                 return DLT_RETURN_ERROR;
+    1187             :             }
+    1188             :         }
+    1189             :     }
+    1190             : 
+    1191             :     /* free response */
+    1192           1 :     dlt_client_cleanup_get_log_info(resp);
+    1193             : 
+    1194           1 :     return DLT_RETURN_OK;
+    1195             : }
+    1196             : 
+    1197             : /**
+    1198             :  * Parse GET_DEFAULT_LOG_LEVEL
+    1199             :  *
+    1200             :  * @param daemon          DltDaemon
+    1201             :  * @param daemon_local    DltDaemonLocal
+    1202             :  * @param ecu             Ecu ID
+    1203             :  * @param msg             DltMessage
+    1204             :  * @param verbose verbose flag
+    1205             :  * @return 0 on success, -1 otherwise
+    1206             :  */
+    1207           0 : DLT_STATIC int dlt_gateway_parse_get_default_log_level(DltDaemon *daemon,
+    1208             :                                                        DltDaemonLocal *daemon_local,
+    1209             :                                                        char *ecu,
+    1210             :                                                        DltMessage *msg,
+    1211             :                                                        int verbose)
+    1212             : {
+    1213             :     DltServiceGetDefaultLogLevelResponse *resp = NULL;
+    1214             :     DltGatewayConnection *con = NULL;
+    1215             : 
+    1216           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1217             : 
+    1218           0 :     if ((daemon == NULL) || (daemon_local == NULL)) {
+    1219           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+    1220           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    1221             :     }
+    1222             : 
+    1223           0 :     if (dlt_check_rcv_data_size(msg->datasize,
+    1224             :                                 sizeof(DltServiceGetDefaultLogLevelResponse)) < 0) {
+    1225           0 :         dlt_log(LOG_ERR, "Received data incomplete.\n");
+    1226           0 :         return DLT_RETURN_ERROR;
+    1227             :     }
+    1228             : 
+    1229             :     /* prepare pointer to message request */
+    1230           0 :     resp = (DltServiceGetDefaultLogLevelResponse *)(msg->databuffer);
+    1231             : 
+    1232           0 :     con = dlt_gateway_get_connection(&daemon_local->pGateway,
+    1233             :                                      ecu,
+    1234             :                                      verbose);
+    1235             : 
+    1236           0 :     if (con == NULL) {
+    1237           0 :         dlt_vlog(LOG_ERR, "No information about passive ECU: %s\n",
+    1238             :                  ecu);
+    1239             : 
+    1240           0 :         return DLT_RETURN_ERROR;
+    1241             :     }
+    1242             : 
+    1243           0 :     con->default_log_level = resp->log_level;
+    1244             : 
+    1245           0 :     return DLT_RETURN_OK;
+    1246             : }
+    1247             : 
+    1248             : /**
+    1249             :  * Service offline logstorage
+    1250             :  *
+    1251             :  * @param daemon       DltDaemon
+    1252             :  * @param daemon_local DltDaemonLocal
+    1253             :  * @param verbose      int
+    1254             :  * @return 0 on success, -1 otherwise
+    1255             :  */
+    1256           1 : DLT_STATIC int dlt_gateway_control_service_logstorage(DltDaemon *daemon,
+    1257             :                                                       DltDaemonLocal *daemon_local,
+    1258             :                                                       int verbose)
+    1259             : {
+    1260             :     unsigned int connection_type = 0;
+    1261             :     int i = 0;
+    1262             : 
+    1263           1 :     if (daemon_local->flags.offlineLogstorageMaxDevices <= 0) {
+    1264           1 :         dlt_log(LOG_INFO,
+    1265             :                 "Logstorage functionality not enabled or MAX device set is 0\n");
+    1266           1 :         return DLT_RETURN_ERROR;
+    1267             :     }
+    1268             : 
+    1269           0 :     for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++) {
+    1270           0 :         connection_type = daemon->storage_handle[i].connection_type;
+    1271             : 
+    1272           0 :         if (connection_type == DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED)
+    1273             :             /* Check if log level of running application needs an update */
+    1274           0 :             dlt_daemon_logstorage_update_application_loglevel(daemon,
+    1275             :                                                               daemon_local,
+    1276             :                                                               i,
+    1277             :                                                               verbose);
+    1278             :     }
+    1279             : 
+    1280             :     return DLT_RETURN_OK;
+    1281             : }
+    1282             : 
+    1283           4 : DltReturnValue dlt_gateway_process_passive_node_messages(DltDaemon *daemon,
+    1284             :                                                          DltDaemonLocal *daemon_local,
+    1285             :                                                          DltReceiver *receiver,
+    1286             :                                                          int verbose)
+    1287             : {
+    1288             :     int i = 0;
+    1289             :     DltGateway *gateway = NULL;
+    1290             :     DltGatewayConnection *con = NULL;
+    1291           4 :     DltMessage msg = { 0 };
+    1292             :     bool b_reset_receiver = false;
+    1293             : 
+    1294           4 :     if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
+    1295           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+    1296           1 :         return DLT_RETURN_WRONG_PARAMETER;
+    1297             :     }
+    1298             : 
+    1299           3 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1300             : 
+    1301             :     gateway = &daemon_local->pGateway;
+    1302             : 
+    1303             :     if (gateway == NULL) {
+    1304             :         dlt_log(LOG_ERR, "Gateway structure is NULL\n");
+    1305             :         return DLT_RETURN_ERROR;
+    1306             :     }
+    1307             : 
+    1308           3 :     for (i = 0; i < gateway->num_connections; i++)
+    1309           3 :         if ((gateway->connections[i].status == DLT_GATEWAY_CONNECTED) && (gateway->connections[i].client.sock == receiver->fd)) {
+    1310             :             con = &gateway->connections[i];
+    1311             :             break;
+    1312             :         }
+    1313             : 
+    1314           3 :     if (con == NULL) {
+    1315           0 :         dlt_log(LOG_ERR, "Cannot associate fd to passive Node connection\n");
+    1316           0 :         return DLT_RETURN_ERROR;
+    1317             :     }
+    1318             : 
+    1319             :     /* now the corresponding passive node connection is available */
+    1320           3 :     if (dlt_message_init(&msg, verbose) == -1) {
+    1321           0 :         dlt_log(LOG_ERR,
+    1322             :                 "Cannot initialize DLT message for passive node forwarding\n");
+    1323           0 :         return DLT_RETURN_ERROR;
+    1324             :     }
+    1325             : 
+    1326             :     /* nearly copy and paste of dlt_client_main_loop function */
+    1327           3 :     if (dlt_receiver_receive(receiver) <= 0) {
+    1328             :         /* No more data to be received */
+    1329           1 :         if (dlt_message_free(&msg, verbose) < 0) {
+    1330           0 :             dlt_log(LOG_ERR, "Cannot free DLT message\n");
+    1331           0 :             return DLT_RETURN_ERROR;
+    1332             :         }
+    1333             : 
+    1334           1 :         dlt_log(LOG_WARNING, "Connection to passive node lost\n");
+    1335             : 
+    1336           1 :         if (con->reconnect_cnt < DLT_GATEWAY_RECONNECT_MAX) {
+    1337           1 :             dlt_log(LOG_WARNING, "Try to reconnect.\n");
+    1338           1 :             con->reconnect_cnt += 1;
+    1339           1 :             con->timeout_cnt = 0;
+    1340             :         }
+    1341             :         else {
+    1342           0 :             con->status = DLT_GATEWAY_DISCONNECTED;
+    1343             : 
+    1344           0 :             if (dlt_event_handler_unregister_connection(&daemon_local->pEvent,
+    1345             :                                                         daemon_local,
+    1346             :                                                         receiver->fd) != 0)
+    1347           0 :                 dlt_log(LOG_ERR, "Remove passive node Connection failed\n");
+    1348             :         }
+    1349             : 
+    1350           1 :         return DLT_RETURN_OK;
+    1351             :     }
+    1352             : 
+    1353          13 :     while (dlt_message_read(&msg,
+    1354          13 :                             (unsigned char *)receiver->buf,
+    1355          13 :                             receiver->bytesRcvd,
+    1356             :                             0,
+    1357          13 :                             verbose) == DLT_MESSAGE_ERROR_OK) {
+    1358             :         DltStandardHeaderExtra *header = (DltStandardHeaderExtra *)
+    1359             :             (msg.headerbuffer +
+    1360             :              sizeof(DltStorageHeader) +
+    1361             :              sizeof(DltStandardHeader));
+    1362             : 
+    1363             :         /* only forward messages if the received ECUid is the expected one */
+    1364          11 :         if (strncmp(header->ecu, con->ecuid, DLT_ID_SIZE) == 0) {
+    1365             :             uint32_t id;
+    1366             :             uint32_t id_tmp;
+    1367          11 :             DltPassiveControlMessage *control_msg = con->p_control_msgs;
+    1368             : 
+    1369          11 :             dlt_vlog(LOG_DEBUG,
+    1370             :                      "Received ECUid (%.*s) similar to configured ECUid(%s). "
+    1371             :                      "Forwarding message (%s).\n",
+    1372             :                      DLT_ID_SIZE,
+    1373             :                      header->ecu,
+    1374             :                      con->ecuid,
+    1375             :                      msg.databuffer);
+    1376             : 
+    1377          11 :             id_tmp = *((uint32_t *)(msg.databuffer));
+    1378          11 :             id = DLT_ENDIAN_GET_32(msg.standardheader->htyp, id_tmp);
+    1379             : 
+    1380             :             /* if ID is GET_LOG_INFO, parse msg */
+    1381          11 :             if (id == DLT_SERVICE_ID_GET_LOG_INFO) {
+    1382           1 :                 while (control_msg) {
+    1383           1 :                     if (control_msg->id == id) {
+    1384           1 :                         if (dlt_gateway_parse_get_log_info(daemon,
+    1385             :                                                            header->ecu,
+    1386             :                                                            &msg,
+    1387           1 :                                                            control_msg->req,
+    1388             :                                                            verbose) == DLT_RETURN_ERROR)
+    1389           1 :                             dlt_log(LOG_WARNING, "Parsing GET_LOG_INFO message failed!\n");
+    1390             : 
+    1391             :                         /* Check for logstorage */
+    1392           1 :                         dlt_gateway_control_service_logstorage(daemon,
+    1393             :                                                                daemon_local,
+    1394             :                                                                verbose);
+    1395             : 
+    1396             :                         /* initialize the flag */
+    1397           1 :                         control_msg->req = CONTROL_MESSAGE_NOT_REQUESTED;
+    1398           1 :                         break;
+    1399             :                     }
+    1400             : 
+    1401           0 :                     control_msg = control_msg->next;
+    1402             :                 }
+    1403             :             }
+    1404          10 :             else if (id == DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL)
+    1405             :             {
+    1406           0 :                 if (dlt_gateway_parse_get_default_log_level(
+    1407             :                         daemon,
+    1408             :                         daemon_local,
+    1409             :                         header->ecu,
+    1410             :                         &msg,
+    1411             :                         verbose) == DLT_RETURN_ERROR)
+    1412           0 :                     dlt_log(LOG_WARNING,
+    1413             :                             "Parsing GET_DEFAULT_LOG_LEVEL message failed!\n");
+    1414             :             }
+    1415             : 
+    1416             :             /* prepare storage header */
+    1417          11 :             if (dlt_set_storageheader(msg.storageheader,
+    1418             :                                       msg.headerextra.ecu) == DLT_RETURN_ERROR) {
+    1419           0 :                 dlt_vlog(LOG_ERR, "%s: Can't set storage header\n", __func__);
+    1420           0 :                 return DLT_RETURN_ERROR;
+    1421             :             }
+    1422             : 
+    1423          11 :             dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL,
+    1424             :                                        daemon,
+    1425             :                                        daemon_local,
+    1426             :                                        msg.headerbuffer,
+    1427             :                                        sizeof(DltStorageHeader),
+    1428             :                                        msg.headerbuffer + sizeof(DltStorageHeader),
+    1429          11 :                                        msg.headersize - sizeof(DltStorageHeader),
+    1430          11 :                                        msg.databuffer,
+    1431             :                                        msg.datasize,
+    1432             :                                        verbose);
+    1433             :         } else { /* otherwise remove this connection and do not connect again */
+    1434           0 :             dlt_vlog(LOG_WARNING,
+    1435             :                      "Received ECUid (%.*s) differs to configured ECUid(%s). "
+    1436             :                      "Discard this message.\n",
+    1437             :                      DLT_ID_SIZE,
+    1438             :                      header->ecu,
+    1439             :                      con->ecuid);
+    1440             : 
+    1441             :             /* disconnect from passive node */
+    1442           0 :             con->status = DLT_GATEWAY_DISCONNECTED;
+    1443           0 :             con->trigger = DLT_GATEWAY_DISABLED;
+    1444             : 
+    1445           0 :             if (dlt_event_handler_unregister_connection(&daemon_local->pEvent,
+    1446             :                                                         daemon_local,
+    1447             :                                                         receiver->fd)
+    1448             :                 != 0)
+    1449           0 :                 dlt_log(LOG_ERR, "Remove passive node Connection failed\n");
+    1450             : 
+    1451           0 :             dlt_log(LOG_WARNING,
+    1452             :                     "Disconnect from passive node due to invalid ECUid\n");
+    1453             : 
+    1454             :             /* it is possible that a partial log was received through the last recv call */
+    1455             :             /* however, the rest will never be received since the socket will be closed by above method */
+    1456             :             /* as such, we need to reset the receiver to prevent permanent corruption */
+    1457             :             b_reset_receiver = true;
+    1458             :         }
+    1459             : 
+    1460          11 :         if (msg.found_serialheader) {
+    1461           0 :             if (dlt_receiver_remove(receiver,
+    1462           0 :                                     msg.headersize +
+    1463           0 :                                     msg.datasize -
+    1464           0 :                                     sizeof(DltStorageHeader) +
+    1465             :                                     sizeof(dltSerialHeader)) == -1) {
+    1466             :                 /* Return value ignored */
+    1467           0 :                 dlt_message_free(&msg, verbose);
+    1468           0 :                 return DLT_RETURN_ERROR;
+    1469             :             }
+    1470             :         }
+    1471          11 :         else if (dlt_receiver_remove(receiver,
+    1472          11 :                                      msg.headersize +
+    1473          11 :                                      msg.datasize -
+    1474             :                                      sizeof(DltStorageHeader)) == -1) {
+    1475             :             /* Return value ignored */
+    1476           0 :             dlt_message_free(&msg, verbose);
+    1477           0 :             return DLT_RETURN_ERROR;
+    1478             :         }
+    1479             :     }
+    1480             : 
+    1481           2 :     if (b_reset_receiver)
+    1482           0 :         dlt_receiver_remove(receiver, receiver->bytesRcvd);
+    1483             : 
+    1484           2 :     if (dlt_receiver_move_to_begin(receiver) == -1) {
+    1485             :         /* Return value ignored */
+    1486           0 :         dlt_message_free(&msg, verbose);
+    1487           0 :         return DLT_RETURN_ERROR;
+    1488             :     }
+    1489             : 
+    1490           2 :     if (dlt_message_free(&msg, verbose) == -1)
+    1491           0 :         return DLT_RETURN_ERROR;
+    1492             : 
+    1493             :     return DLT_RETURN_OK;
+    1494             : }
+    1495             : 
+    1496           2 : int dlt_gateway_process_gateway_timer(DltDaemon *daemon,
+    1497             :                                       DltDaemonLocal *daemon_local,
+    1498             :                                       DltReceiver *receiver,
+    1499             :                                       int verbose)
+    1500             : {
+    1501           2 :     uint64_t expir = 0;
+    1502             :     ssize_t res = 0;
+    1503             : 
+    1504           2 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1505             : 
+    1506           2 :     if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
+    1507           1 :         dlt_vlog(LOG_ERR,
+    1508             :                  "%s: invalid parameters\n",
+    1509             :                  __func__);
+    1510           1 :         return DLT_RETURN_WRONG_PARAMETER;
+    1511             :     }
+    1512             : 
+    1513           1 :     res = read(receiver->fd, &expir, sizeof(expir));
+    1514             : 
+    1515           1 :     if (res < 0)
+    1516           1 :         dlt_vlog(LOG_WARNING,
+    1517             :                  "%s: Fail to read timer (%s)\n",
+    1518             :                  __func__,
+    1519           1 :                  strerror(errno));
+    1520             :         /* Activity received on timer_wd, but unable to read the fd:
+    1521             :          * let's go on sending notification */
+    1522             : 
+    1523             :     /* try to connect to passive nodes */
+    1524           1 :     dlt_gateway_establish_connections(&daemon_local->pGateway,
+    1525             :                                       daemon_local,
+    1526             :                                       verbose);
+    1527             : 
+    1528           1 :     dlt_log(LOG_DEBUG, "Gateway Timer\n");
+    1529             : 
+    1530           1 :     return DLT_RETURN_OK;
+    1531             : }
+    1532             : 
+    1533           0 : int dlt_gateway_forward_control_message(DltGateway *gateway,
+    1534             :                                         DltDaemonLocal *daemon_local,
+    1535             :                                         DltMessage *msg,
+    1536             :                                         char *ecu,
+    1537             :                                         int verbose)
+    1538             : {
+    1539             :     int i = 0;
+    1540             :     int ret = 0;
+    1541             :     DltGatewayConnection *con = NULL;
+    1542             :     uint32_t id_tmp;
+    1543             :     uint32_t id;
+    1544             : 
+    1545           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1546             : 
+    1547           0 :     if ((gateway == NULL) || (daemon_local == NULL) || (msg == NULL) || (ecu == NULL)) {
+    1548           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+    1549           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    1550             :     }
+    1551             : 
+    1552           0 :     for (i = 0; i < gateway->num_connections; i++)
+    1553           0 :         if (strncmp(gateway->connections[i].ecuid,
+    1554             :                     ecu,
+    1555             :                     DLT_ID_SIZE) == 0) {
+    1556             :             con = &gateway->connections[i];
+    1557             :             break;
+    1558             :         }
+    1559             : 
+    1560             : 
+    1561             : 
+    1562           0 :     if (con == NULL) {
+    1563           0 :         dlt_log(LOG_WARNING, "Unknown passive node identifier\n");
+    1564           0 :         return DLT_RETURN_ERROR;
+    1565             :     }
+    1566             : 
+    1567           0 :     if (con->status != DLT_GATEWAY_CONNECTED) {
+    1568           0 :         dlt_log(LOG_INFO, "Passive node is not connected\n");
+    1569           0 :         return DLT_RETURN_ERROR;
+    1570             :     }
+    1571             : 
+    1572           0 :     if (con->send_serial) { /* send serial header */
+    1573           0 :         ret = send(con->client.sock,
+    1574             :                    (void *)dltSerialHeader,
+    1575             :                    sizeof(dltSerialHeader),
+    1576             :                    0);
+    1577             : 
+    1578           0 :         if (ret == -1) {
+    1579           0 :             dlt_log(LOG_ERR, "Sending message to passive DLT Daemon failed\n");
+    1580           0 :             return DLT_RETURN_ERROR;
+    1581             :         }
+    1582             :     }
+    1583             : 
+    1584           0 :     ret = send(con->client.sock,
+    1585             :                msg->headerbuffer + sizeof(DltStorageHeader),
+    1586           0 :                msg->headersize - sizeof(DltStorageHeader),
+    1587             :                0);
+    1588             : 
+    1589           0 :     if (ret == -1) {
+    1590           0 :         dlt_log(LOG_ERR, "Sending message to passive DLT Daemon failed\n");
+    1591           0 :         return DLT_RETURN_ERROR;
+    1592             :     }
+    1593             :     else {
+    1594           0 :         ret = send(con->client.sock, msg->databuffer, msg->datasize, 0);
+    1595             : 
+    1596           0 :         if (ret == -1) {
+    1597           0 :             dlt_log(LOG_ERR, "Sending message to passive DLT Daemon failed\n");
+    1598           0 :             return DLT_RETURN_ERROR;
+    1599             :         }
+    1600             :     }
+    1601             : 
+    1602           0 :     id_tmp = *((uint32_t *)(msg->databuffer));
+    1603           0 :     id = DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp);
+    1604             : 
+    1605           0 :     dlt_vlog(LOG_INFO,
+    1606             :              "Control message forwarded : %s\n",
+    1607             :              dlt_get_service_name(id));
+    1608           0 :     return DLT_RETURN_OK;
+    1609             : }
+    1610             : 
+    1611           3 : int dlt_gateway_process_on_demand_request(DltGateway *gateway,
+    1612             :                                           DltDaemonLocal *daemon_local,
+    1613             :                                           char node_id[DLT_ID_SIZE],
+    1614             :                                           int connection_status,
+    1615             :                                           int verbose)
+    1616             : {
+    1617             :     int i = 0;
+    1618             :     DltGatewayConnection *con = NULL;
+    1619             : 
+    1620           3 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1621             : 
+    1622           3 :     if ((gateway == NULL) || (daemon_local == NULL) || (node_id == NULL)) {
+    1623           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+    1624           1 :         return DLT_RETURN_WRONG_PARAMETER;
+    1625             :     }
+    1626             : 
+    1627             :     /* find connection by ECU id */
+    1628           2 :     for (i = 0; i < gateway->num_connections; i++) {
+    1629           2 :         if (strncmp(node_id, gateway->connections[i].ecuid, DLT_ID_SIZE) == 0) {
+    1630             :             con = &gateway->connections[i];
+    1631             :             break;
+    1632             :         }
+    1633             :     }
+    1634             : 
+    1635           2 :     if (con == NULL) {
+    1636           0 :         dlt_log(LOG_WARNING, "Specified ECUid not found\n");
+    1637           0 :         return DLT_RETURN_ERROR;
+    1638             :     }
+    1639             : 
+    1640           2 :     if (connection_status == 1) { /* try to connect */
+    1641             : 
+    1642           2 :         if (con->status != DLT_GATEWAY_CONNECTED) {
+    1643           1 :             if (dlt_client_connect(&con->client, verbose) == 0) {
+    1644             :                 /* setup dlt connection and add to poll event loop here */
+    1645           0 :                 if (dlt_gateway_add_to_event_loop(daemon_local, con, verbose) != DLT_RETURN_OK) {
+    1646           0 :                     dlt_log(LOG_ERR, "Gateway connection creation failed\n");
+    1647           0 :                     return DLT_RETURN_ERROR;
+    1648             :                 }
+    1649             :             }
+    1650             :             else {
+    1651           1 :                 dlt_log(LOG_ERR, "Could not connect to passive node\n");
+    1652           1 :                 return DLT_RETURN_ERROR;
+    1653             :             }
+    1654             :         }
+    1655             :         else {
+    1656           1 :             dlt_log(LOG_INFO, "Passive node already connected\n");
+    1657             :         }
+    1658             :     }
+    1659           0 :     else if (connection_status == 0) /* disconnect*/
+    1660             :     {
+    1661             : 
+    1662           0 :         con->status = DLT_GATEWAY_DISCONNECTED;
+    1663           0 :         con->trigger = DLT_GATEWAY_ON_DEMAND;
+    1664             : 
+    1665           0 :         if (dlt_event_handler_unregister_connection(&daemon_local->pEvent,
+    1666             :                                                     daemon_local,
+    1667             :                                                     con->client.sock) != 0)
+    1668           0 :             dlt_log(LOG_ERR,
+    1669             :                     "Remove passive node event handler connection failed\n");
+    1670             :     }
+    1671             :     else {
+    1672           0 :         dlt_log(LOG_ERR, "Unknown command (connection_status)\n");
+    1673           0 :         return DLT_RETURN_ERROR;
+    1674             :     }
+    1675             : 
+    1676             :     return DLT_RETURN_OK;
+    1677             : }
+    1678             : 
+    1679          12 : int dlt_gateway_send_control_message(DltGatewayConnection *con,
+    1680             :                                      DltPassiveControlMessage *control_msg,
+    1681             :                                      void *data,
+    1682             :                                      int verbose)
+    1683             : {
+    1684             :     int ret = DLT_RETURN_OK;
+    1685             : 
+    1686          12 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1687             : 
+    1688          12 :     if (con == NULL) {
+    1689           1 :         dlt_vlog(LOG_WARNING,
+    1690             :                  "%s: Invalid parameter given\n",
+    1691             :                  __func__);
+    1692           1 :         return DLT_RETURN_WRONG_PARAMETER;
+    1693             :     }
+    1694             : 
+    1695             :     /* no (more) control message to be send */
+    1696          11 :     if (control_msg->id == 0)
+    1697             :         return DLT_RETURN_ERROR;
+    1698             : 
+    1699             :     /* check sendtime counter and message interval */
+    1700             :     /* sendtime counter is 0 on startup, otherwise positive value */
+    1701          11 :     if ((control_msg->type != CONTROL_MESSAGE_ON_DEMAND) && (con->sendtime_cnt > 0)) {
+    1702           0 :         if (control_msg->interval <= 0)
+    1703             :             return DLT_RETURN_ERROR;
+    1704             : 
+    1705           0 :         if ((control_msg->type == CONTROL_MESSAGE_PERIODIC) ||
+    1706             :             (control_msg->type == CONTROL_MESSAGE_BOTH)) {
+    1707           0 :             if ((con->sendtime_cnt - 1) % control_msg->interval != 0)
+    1708             :                 return DLT_RETURN_ERROR;
+    1709             :         }
+    1710             :     }
+    1711             : 
+    1712          11 :     if (con->send_serial) { /* send serial header */
+    1713           0 :         ret = send(con->client.sock,
+    1714             :                    (void *)dltSerialHeader,
+    1715             :                    sizeof(dltSerialHeader),
+    1716             :                    0);
+    1717             : 
+    1718           0 :         if (ret == -1) {
+    1719           0 :             dlt_log(LOG_ERR, "Sending message to passive DLT Daemon failed\n");
+    1720           0 :             return DLT_RETURN_ERROR;
+    1721             :         }
+    1722             :     }
+    1723             : 
+    1724          11 :     switch (control_msg->id) {
+    1725           4 :     case DLT_SERVICE_ID_GET_LOG_INFO:
+    1726           4 :         return dlt_client_get_log_info(&con->client);
+    1727             :         break;
+    1728           1 :     case DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL:
+    1729           1 :         return dlt_client_get_default_log_level(&con->client);
+    1730             :         break;
+    1731           4 :     case DLT_SERVICE_ID_GET_SOFTWARE_VERSION:
+    1732           4 :         return dlt_client_get_software_version(&con->client);
+    1733             :         break;
+    1734           2 :     case DLT_SERVICE_ID_SET_LOG_LEVEL:
+    1735             : 
+    1736           2 :         if (data == NULL) {
+    1737           1 :             dlt_vlog(LOG_WARNING,
+    1738             :                      "Insufficient data for %s received. Send control request failed.\n",
+    1739             :                      dlt_get_service_name(control_msg->id));
+    1740           1 :             return DLT_RETURN_ERROR;
+    1741             :         }
+    1742             : 
+    1743             :         DltServiceSetLogLevel *req = (DltServiceSetLogLevel *)data;
+    1744           1 :         return dlt_client_send_log_level(&con->client,
+    1745           1 :                                          req->apid,
+    1746           1 :                                          req->ctid,
+    1747           1 :                                          req->log_level);
+    1748             :         break;
+    1749           0 :     default:
+    1750           0 :         dlt_vlog(LOG_WARNING,
+    1751             :                  "Cannot forward request: %s.\n",
+    1752             :                  dlt_get_service_name(control_msg->id));
+    1753             :     }
+    1754             : 
+    1755           0 :     return DLT_RETURN_OK;
+    1756             : }
+    1757             : 
+    1758           0 : DltGatewayConnection *dlt_gateway_get_connection(DltGateway *gateway,
+    1759             :                                                  char *ecu,
+    1760             :                                                  int verbose)
+    1761             : {
+    1762             :     DltGatewayConnection *con = NULL;
+    1763             :     int i = 0;
+    1764             : 
+    1765           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1766             : 
+    1767           0 :     if ((gateway == NULL) || (ecu == NULL)) {
+    1768           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+    1769           0 :         return con;
+    1770             :     }
+    1771             : 
+    1772           0 :     for (i = 0; i < gateway->num_connections; i++) {
+    1773           0 :         con = &gateway->connections[i];
+    1774             : 
+    1775           0 :         if (strncmp(con->ecuid, ecu, DLT_ID_SIZE) == 0)
+    1776           0 :             return con;
+    1777             :     }
+    1778             : 
+    1779           0 :     dlt_vlog(LOG_ERR, "%s: No connection found\n", ecu);
+    1780             : 
+    1781           0 :     return con;
+    1782             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/gateway/index-sort-f.html b/dlt_lcov_report/gateway/index-sort-f.html new file mode 100644 index 000000000..0550cf1af --- /dev/null +++ b/dlt_lcov_report/gateway/index-sort-f.html @@ -0,0 +1,93 @@ + + + + + + + LCOV - dlt_final_coverage.info - gateway + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - gatewayHitTotalCoverage
Test:dlt_final_coverage.infoLines:38563360.8 %
Date:2024-12-05 09:07:13Functions:232882.1 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_gateway.c +
60.8%60.8%
+
60.8 %385 / 63382.1 %23 / 28
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/gateway/index-sort-l.html b/dlt_lcov_report/gateway/index-sort-l.html new file mode 100644 index 000000000..77778c7a8 --- /dev/null +++ b/dlt_lcov_report/gateway/index-sort-l.html @@ -0,0 +1,93 @@ + + + + + + + LCOV - dlt_final_coverage.info - gateway + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - gatewayHitTotalCoverage
Test:dlt_final_coverage.infoLines:38563360.8 %
Date:2024-12-05 09:07:13Functions:232882.1 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_gateway.c +
60.8%60.8%
+
60.8 %385 / 63382.1 %23 / 28
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/gateway/index.html b/dlt_lcov_report/gateway/index.html new file mode 100644 index 000000000..c9af9a7d3 --- /dev/null +++ b/dlt_lcov_report/gateway/index.html @@ -0,0 +1,93 @@ + + + + + + + LCOV - dlt_final_coverage.info - gateway + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - gatewayHitTotalCoverage
Test:dlt_final_coverage.infoLines:38563360.8 %
Date:2024-12-05 09:07:13Functions:232882.1 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_gateway.c +
60.8%60.8%
+
60.8 %385 / 63382.1 %23 / 28
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/gcov.css b/dlt_lcov_report/gcov.css new file mode 100644 index 000000000..bfd0a83e1 --- /dev/null +++ b/dlt_lcov_report/gcov.css @@ -0,0 +1,519 @@ +/* All views: initial background and text color */ +body +{ + color: #000000; + background-color: #FFFFFF; +} + +/* All views: standard link format*/ +a:link +{ + color: #284FA8; + text-decoration: underline; +} + +/* All views: standard link - visited format */ +a:visited +{ + color: #00CB40; + text-decoration: underline; +} + +/* All views: standard link - activated format */ +a:active +{ + color: #FF0040; + text-decoration: underline; +} + +/* All views: main title format */ +td.title +{ + text-align: center; + padding-bottom: 10px; + font-family: sans-serif; + font-size: 20pt; + font-style: italic; + font-weight: bold; +} + +/* All views: header item format */ +td.headerItem +{ + text-align: right; + padding-right: 6px; + font-family: sans-serif; + font-weight: bold; + vertical-align: top; + white-space: nowrap; +} + +/* All views: header item value format */ +td.headerValue +{ + text-align: left; + color: #284FA8; + font-family: sans-serif; + font-weight: bold; + white-space: nowrap; +} + +/* All views: header item coverage table heading */ +td.headerCovTableHead +{ + text-align: center; + padding-right: 6px; + padding-left: 6px; + padding-bottom: 0px; + font-family: sans-serif; + font-size: 80%; + white-space: nowrap; +} + +/* All views: header item coverage table entry */ +td.headerCovTableEntry +{ + text-align: right; + color: #284FA8; + font-family: sans-serif; + font-weight: bold; + white-space: nowrap; + padding-left: 12px; + padding-right: 4px; + background-color: #DAE7FE; +} + +/* All views: header item coverage table entry for high coverage rate */ +td.headerCovTableEntryHi +{ + text-align: right; + color: #000000; + font-family: sans-serif; + font-weight: bold; + white-space: nowrap; + padding-left: 12px; + padding-right: 4px; + background-color: #A7FC9D; +} + +/* All views: header item coverage table entry for medium coverage rate */ +td.headerCovTableEntryMed +{ + text-align: right; + color: #000000; + font-family: sans-serif; + font-weight: bold; + white-space: nowrap; + padding-left: 12px; + padding-right: 4px; + background-color: #FFEA20; +} + +/* All views: header item coverage table entry for ow coverage rate */ +td.headerCovTableEntryLo +{ + text-align: right; + color: #000000; + font-family: sans-serif; + font-weight: bold; + white-space: nowrap; + padding-left: 12px; + padding-right: 4px; + background-color: #FF0000; +} + +/* All views: header legend value for legend entry */ +td.headerValueLeg +{ + text-align: left; + color: #000000; + font-family: sans-serif; + font-size: 80%; + white-space: nowrap; + padding-top: 4px; +} + +/* All views: color of horizontal ruler */ +td.ruler +{ + background-color: #6688D4; +} + +/* All views: version string format */ +td.versionInfo +{ + text-align: center; + padding-top: 2px; + font-family: sans-serif; + font-style: italic; +} + +/* Directory view/File view (all)/Test case descriptions: + table headline format */ +td.tableHead +{ + text-align: center; + color: #FFFFFF; + background-color: #6688D4; + font-family: sans-serif; + font-size: 120%; + font-weight: bold; + white-space: nowrap; + padding-left: 4px; + padding-right: 4px; +} + +span.tableHeadSort +{ + padding-right: 4px; +} + +/* Directory view/File view (all): filename entry format */ +td.coverFile +{ + text-align: left; + padding-left: 10px; + padding-right: 20px; + color: #284FA8; + background-color: #DAE7FE; + font-family: monospace; +} + +/* Directory view/File view (all): bar-graph entry format*/ +td.coverBar +{ + padding-left: 10px; + padding-right: 10px; + background-color: #DAE7FE; +} + +/* Directory view/File view (all): bar-graph outline color */ +td.coverBarOutline +{ + background-color: #000000; +} + +/* Directory view/File view (all): percentage entry for files with + high coverage rate */ +td.coverPerHi +{ + text-align: right; + padding-left: 10px; + padding-right: 10px; + background-color: #A7FC9D; + font-weight: bold; + font-family: sans-serif; +} + +/* Directory view/File view (all): line count entry for files with + high coverage rate */ +td.coverNumHi +{ + text-align: right; + padding-left: 10px; + padding-right: 10px; + background-color: #A7FC9D; + white-space: nowrap; + font-family: sans-serif; +} + +/* Directory view/File view (all): percentage entry for files with + medium coverage rate */ +td.coverPerMed +{ + text-align: right; + padding-left: 10px; + padding-right: 10px; + background-color: #FFEA20; + font-weight: bold; + font-family: sans-serif; +} + +/* Directory view/File view (all): line count entry for files with + medium coverage rate */ +td.coverNumMed +{ + text-align: right; + padding-left: 10px; + padding-right: 10px; + background-color: #FFEA20; + white-space: nowrap; + font-family: sans-serif; +} + +/* Directory view/File view (all): percentage entry for files with + low coverage rate */ +td.coverPerLo +{ + text-align: right; + padding-left: 10px; + padding-right: 10px; + background-color: #FF0000; + font-weight: bold; + font-family: sans-serif; +} + +/* Directory view/File view (all): line count entry for files with + low coverage rate */ +td.coverNumLo +{ + text-align: right; + padding-left: 10px; + padding-right: 10px; + background-color: #FF0000; + white-space: nowrap; + font-family: sans-serif; +} + +/* File view (all): "show/hide details" link format */ +a.detail:link +{ + color: #B8D0FF; + font-size:80%; +} + +/* File view (all): "show/hide details" link - visited format */ +a.detail:visited +{ + color: #B8D0FF; + font-size:80%; +} + +/* File view (all): "show/hide details" link - activated format */ +a.detail:active +{ + color: #FFFFFF; + font-size:80%; +} + +/* File view (detail): test name entry */ +td.testName +{ + text-align: right; + padding-right: 10px; + background-color: #DAE7FE; + font-family: sans-serif; +} + +/* File view (detail): test percentage entry */ +td.testPer +{ + text-align: right; + padding-left: 10px; + padding-right: 10px; + background-color: #DAE7FE; + font-family: sans-serif; +} + +/* File view (detail): test lines count entry */ +td.testNum +{ + text-align: right; + padding-left: 10px; + padding-right: 10px; + background-color: #DAE7FE; + font-family: sans-serif; +} + +/* Test case descriptions: test name format*/ +dt +{ + font-family: sans-serif; + font-weight: bold; +} + +/* Test case descriptions: description table body */ +td.testDescription +{ + padding-top: 10px; + padding-left: 30px; + padding-bottom: 10px; + padding-right: 30px; + background-color: #DAE7FE; +} + +/* Source code view: function entry */ +td.coverFn +{ + text-align: left; + padding-left: 10px; + padding-right: 20px; + color: #284FA8; + background-color: #DAE7FE; + font-family: monospace; +} + +/* Source code view: function entry zero count*/ +td.coverFnLo +{ + text-align: right; + padding-left: 10px; + padding-right: 10px; + background-color: #FF0000; + font-weight: bold; + font-family: sans-serif; +} + +/* Source code view: function entry nonzero count*/ +td.coverFnHi +{ + text-align: right; + padding-left: 10px; + padding-right: 10px; + background-color: #DAE7FE; + font-weight: bold; + font-family: sans-serif; +} + +/* Source code view: source code format */ +pre.source +{ + font-family: monospace; + white-space: pre; + margin-top: 2px; +} + +/* Source code view: line number format */ +span.lineNum +{ + background-color: #EFE383; +} + +/* Source code view: format for lines which were executed */ +td.lineCov, +span.lineCov +{ + background-color: #CAD7FE; +} + +/* Source code view: format for Cov legend */ +span.coverLegendCov +{ + padding-left: 10px; + padding-right: 10px; + padding-bottom: 2px; + background-color: #CAD7FE; +} + +/* Source code view: format for lines which were not executed */ +td.lineNoCov, +span.lineNoCov +{ + background-color: #FF6230; +} + +/* Source code view: format for NoCov legend */ +span.coverLegendNoCov +{ + padding-left: 10px; + padding-right: 10px; + padding-bottom: 2px; + background-color: #FF6230; +} + +/* Source code view (function table): standard link - visited format */ +td.lineNoCov > a:visited, +td.lineCov > a:visited +{ + color: black; + text-decoration: underline; +} + +/* Source code view: format for lines which were executed only in a + previous version */ +span.lineDiffCov +{ + background-color: #B5F7AF; +} + +/* Source code view: format for branches which were executed + * and taken */ +span.branchCov +{ + background-color: #CAD7FE; +} + +/* Source code view: format for branches which were executed + * but not taken */ +span.branchNoCov +{ + background-color: #FF6230; +} + +/* Source code view: format for branches which were not executed */ +span.branchNoExec +{ + background-color: #FF6230; +} + +/* Source code view: format for the source code heading line */ +pre.sourceHeading +{ + white-space: pre; + font-family: monospace; + font-weight: bold; + margin: 0px; +} + +/* All views: header legend value for low rate */ +td.headerValueLegL +{ + font-family: sans-serif; + text-align: center; + white-space: nowrap; + padding-left: 4px; + padding-right: 2px; + background-color: #FF0000; + font-size: 80%; +} + +/* All views: header legend value for med rate */ +td.headerValueLegM +{ + font-family: sans-serif; + text-align: center; + white-space: nowrap; + padding-left: 2px; + padding-right: 2px; + background-color: #FFEA20; + font-size: 80%; +} + +/* All views: header legend value for hi rate */ +td.headerValueLegH +{ + font-family: sans-serif; + text-align: center; + white-space: nowrap; + padding-left: 2px; + padding-right: 4px; + background-color: #A7FC9D; + font-size: 80%; +} + +/* All views except source code view: legend format for low coverage */ +span.coverLegendCovLo +{ + padding-left: 10px; + padding-right: 10px; + padding-top: 2px; + background-color: #FF0000; +} + +/* All views except source code view: legend format for med coverage */ +span.coverLegendCovMed +{ + padding-left: 10px; + padding-right: 10px; + padding-top: 2px; + background-color: #FFEA20; +} + +/* All views except source code view: legend format for hi coverage */ +span.coverLegendCovHi +{ + padding-left: 10px; + padding-right: 10px; + padding-top: 2px; + background-color: #A7FC9D; +} diff --git a/dlt_lcov_report/glass.png b/dlt_lcov_report/glass.png new file mode 100644 index 0000000000000000000000000000000000000000..e1abc00680a3093c49fdb775ae6bdb6764c95af2 GIT binary patch literal 167 zcmeAS@N?(olHy`uVBq!ia0vp^j3CU&3?x-=hn)gaEa{HEjtmSN`?>!lvI6;R0X`wF z|Ns97GD8ntt^-nxB|(0{3=Yq3q=7g|-tI089jvk*Kn`btM`SSr1Gf+eGhVt|_XjA* zUgGKN%6^Gmn4d%Ph(nkFP>9RZ#WAE}PI3Z}&BVayv3^M*kj3EX>gTe~DWM4f=_Dpv literal 0 HcmV?d00001 diff --git a/dlt_lcov_report/index-sort-f.html b/dlt_lcov_report/index-sort-f.html new file mode 100644 index 000000000..33753a1b9 --- /dev/null +++ b/dlt_lcov_report/index-sort-f.html @@ -0,0 +1,153 @@ + + + + + + + LCOV - dlt_final_coverage.info + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top levelHitTotalCoverage
Test:dlt_final_coverage.infoLines:61351117554.9 %
Date:2024-12-05 09:07:13Functions:49066573.7 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Directory Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
console/logstorage +
22.7%22.7%
+
22.7 %75 / 33034.4 %11 / 32
lib +
48.1%48.1%
+
48.1 %1262 / 262264.3 %128 / 199
daemon +
49.3%49.3%
+
49.3 %1693 / 343270.1 %110 / 157
console +
42.7%42.7%
+
42.7 %274 / 64275.9 %22 / 29
gateway +
60.8%60.8%
+
60.8 %385 / 63382.1 %23 / 28
shared +
66.0%66.0%
+
66.0 %1443 / 218589.0 %130 / 146
offlinelogstorage +
75.4%75.4%
+
75.4 %1003 / 133189.2 %66 / 74
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/index-sort-l.html b/dlt_lcov_report/index-sort-l.html new file mode 100644 index 000000000..7e933b2a4 --- /dev/null +++ b/dlt_lcov_report/index-sort-l.html @@ -0,0 +1,153 @@ + + + + + + + LCOV - dlt_final_coverage.info + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top levelHitTotalCoverage
Test:dlt_final_coverage.infoLines:61351117554.9 %
Date:2024-12-05 09:07:13Functions:49066573.7 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Directory Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
console/logstorage +
22.7%22.7%
+
22.7 %75 / 33034.4 %11 / 32
console +
42.7%42.7%
+
42.7 %274 / 64275.9 %22 / 29
lib +
48.1%48.1%
+
48.1 %1262 / 262264.3 %128 / 199
daemon +
49.3%49.3%
+
49.3 %1693 / 343270.1 %110 / 157
gateway +
60.8%60.8%
+
60.8 %385 / 63382.1 %23 / 28
shared +
66.0%66.0%
+
66.0 %1443 / 218589.0 %130 / 146
offlinelogstorage +
75.4%75.4%
+
75.4 %1003 / 133189.2 %66 / 74
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/index.html b/dlt_lcov_report/index.html new file mode 100644 index 000000000..d44ad6b1d --- /dev/null +++ b/dlt_lcov_report/index.html @@ -0,0 +1,153 @@ + + + + + + + LCOV - dlt_final_coverage.info + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top levelHitTotalCoverage
Test:dlt_final_coverage.infoLines:61351117554.9 %
Date:2024-12-05 09:07:13Functions:49066573.7 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Directory Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
console +
42.7%42.7%
+
42.7 %274 / 64275.9 %22 / 29
console/logstorage +
22.7%22.7%
+
22.7 %75 / 33034.4 %11 / 32
daemon +
49.3%49.3%
+
49.3 %1693 / 343270.1 %110 / 157
gateway +
60.8%60.8%
+
60.8 %385 / 63382.1 %23 / 28
lib +
48.1%48.1%
+
48.1 %1262 / 262264.3 %128 / 199
offlinelogstorage +
75.4%75.4%
+
75.4 %1003 / 133189.2 %66 / 74
shared +
66.0%66.0%
+
66.0 %1443 / 218589.0 %130 / 146
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/lib/dlt_client.c.func-sort-c.html b/dlt_lcov_report/lib/dlt_client.c.func-sort-c.html new file mode 100644 index 000000000..fcf58ea4e --- /dev/null +++ b/dlt_lcov_report/lib/dlt_client.c.func-sort-c.html @@ -0,0 +1,196 @@ + + + + + + + LCOV - dlt_final_coverage.info - lib/dlt_client.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - lib - dlt_client.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:24053444.9 %
Date:2024-12-05 09:07:13Functions:153148.4 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_client_free_calloc_failed_get_log_info0
dlt_client_register_fetch_next_message_callback0
dlt_client_send_all_log_level0
dlt_client_send_all_trace_status0
dlt_client_send_default_log_level0
dlt_client_send_default_trace_status0
dlt_client_send_inject_msg0
dlt_client_send_reset_to_factory_default0
dlt_client_send_store_config0
dlt_client_send_timing_pakets0
dlt_client_send_trace_status0
dlt_client_set_host_if_address0
dlt_client_set_mode0
dlt_client_set_serial_device0
dlt_client_set_socket_path0
dlt_client_setbaudrate0
dlt_client_get_default_log_level1
dlt_client_send_log_level1
dlt_client_cleanup_get_log_info2
dlt_client_parse_get_log_info_resp_text2
dlt_client_send_message_to_socket2
dlt_client_init3
dlt_client_main_loop3
dlt_client_register_message_callback3
dlt_client_get_log_info4
dlt_client_get_software_version4
dlt_client_cleanup5
dlt_client_set_server_ip6
dlt_client_init_port8
dlt_client_connect9
dlt_client_send_ctrl_msg10
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/lib/dlt_client.c.func.html b/dlt_lcov_report/lib/dlt_client.c.func.html new file mode 100644 index 000000000..81b687d26 --- /dev/null +++ b/dlt_lcov_report/lib/dlt_client.c.func.html @@ -0,0 +1,196 @@ + + + + + + + LCOV - dlt_final_coverage.info - lib/dlt_client.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - lib - dlt_client.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:24053444.9 %
Date:2024-12-05 09:07:13Functions:153148.4 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_client_cleanup5
dlt_client_cleanup_get_log_info2
dlt_client_connect9
dlt_client_free_calloc_failed_get_log_info0
dlt_client_get_default_log_level1
dlt_client_get_log_info4
dlt_client_get_software_version4
dlt_client_init3
dlt_client_init_port8
dlt_client_main_loop3
dlt_client_parse_get_log_info_resp_text2
dlt_client_register_fetch_next_message_callback0
dlt_client_register_message_callback3
dlt_client_send_all_log_level0
dlt_client_send_all_trace_status0
dlt_client_send_ctrl_msg10
dlt_client_send_default_log_level0
dlt_client_send_default_trace_status0
dlt_client_send_inject_msg0
dlt_client_send_log_level1
dlt_client_send_message_to_socket2
dlt_client_send_reset_to_factory_default0
dlt_client_send_store_config0
dlt_client_send_timing_pakets0
dlt_client_send_trace_status0
dlt_client_set_host_if_address0
dlt_client_set_mode0
dlt_client_set_serial_device0
dlt_client_set_server_ip6
dlt_client_set_socket_path0
dlt_client_setbaudrate0
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/lib/dlt_client.c.gcov.html b/dlt_lcov_report/lib/dlt_client.c.gcov.html new file mode 100644 index 000000000..bf6dc6531 --- /dev/null +++ b/dlt_lcov_report/lib/dlt_client.c.gcov.html @@ -0,0 +1,1480 @@ + + + + + + + LCOV - dlt_final_coverage.info - lib/dlt_client.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - lib - dlt_client.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:24053444.9 %
Date:2024-12-05 09:07:13Functions:153148.4 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2011-2015, BMW AG
+       5             :  *
+       6             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       7             :  *
+       8             :  * This Source Code Form is subject to the terms of the
+       9             :  * Mozilla Public License (MPL), v. 2.0.
+      10             :  * If a copy of the MPL was not distributed with this file,
+      11             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      12             :  *
+      13             :  * For further information see http://www.covesa.org/.
+      14             :  */
+      15             : 
+      16             : /*!
+      17             :  * \author Alexander Wenzel <alexander.aw.wenzel@bmw.de>
+      18             :  *
+      19             :  * \copyright Copyright © 2011-2015 BMW AG. \n
+      20             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      21             :  *
+      22             :  * \file dlt_client.c
+      23             :  */
+      24             : 
+      25             : /*******************************************************************************
+      26             : **                                                                            **
+      27             : **  SRC-MODULE: dlt_client.c                                                  **
+      28             : **                                                                            **
+      29             : **  TARGET    : linux                                                         **
+      30             : **                                                                            **
+      31             : **  PROJECT   : DLT                                                           **
+      32             : **                                                                            **
+      33             : **  AUTHOR    : Alexander Wenzel Alexander.AW.Wenzel@bmw.de                   **
+      34             : **              Markus Klein                                                  **
+      35             : **                                                                            **
+      36             : **  PURPOSE   :                                                               **
+      37             : **                                                                            **
+      38             : **  REMARKS   :                                                               **
+      39             : **                                                                            **
+      40             : **  PLATFORM DEPENDANT [yes/no]: yes                                          **
+      41             : **                                                                            **
+      42             : **  TO BE CHANGED BY USER [yes/no]: no                                        **
+      43             : **                                                                            **
+      44             : *******************************************************************************/
+      45             : 
+      46             : /*******************************************************************************
+      47             : **                      Author Identity                                       **
+      48             : ********************************************************************************
+      49             : **                                                                            **
+      50             : ** Initials     Name                       Company                            **
+      51             : ** --------     -------------------------  ---------------------------------- **
+      52             : **  aw          Alexander Wenzel           BMW                                **
+      53             : **  mk          Markus Klein               Fraunhofer ESK                     **
+      54             : *******************************************************************************/
+      55             : 
+      56             : /*******************************************************************************
+      57             : **                      Revision Control History                              **
+      58             : *******************************************************************************/
+      59             : 
+      60             : /*
+      61             :  * $LastChangedRevision$
+      62             :  * $LastChangedDate$
+      63             :  * $LastChangedBy$
+      64             :  * Initials    Date         Comment
+      65             :  * aw          12.07.2010   initial
+      66             :  */
+      67             : 
+      68             : #include <stdio.h>
+      69             : 
+      70             : #if defined (__WIN32__) || defined (_MSC_VER)
+      71             : #   pragma warning(disable : 4996) /* Switch off C4996 warnings */
+      72             : #   include <winsock2.h> /* for socket(), connect(), send(), and recv() */
+      73             : #else
+      74             : #   include <sys/socket.h> /* for socket(), connect(), send(), and recv() */
+      75             : #   include <arpa/inet.h> /* for sockaddr_in and inet_addr() */
+      76             : #   include <netdb.h>
+      77             : #   include <sys/stat.h>
+      78             : #   include <sys/un.h>
+      79             : #endif
+      80             : 
+      81             : #if defined(_MSC_VER)
+      82             : #   include <io.h>
+      83             : #else
+      84             : #   include <unistd.h>
+      85             : #   include <syslog.h>
+      86             : #endif
+      87             : 
+      88             : #include <fcntl.h>
+      89             : 
+      90             : #include <stdlib.h> /* for malloc(), free() */
+      91             : #include <string.h> /* for strlen(), memcmp(), memmove() */
+      92             : #include <errno.h>
+      93             : #include <limits.h>
+      94             : #include <poll.h>
+      95             : 
+      96             : #include "dlt_types.h"
+      97             : #include "dlt_log.h"
+      98             : #include "dlt_client.h"
+      99             : #include "dlt_client_cfg.h"
+     100             : 
+     101             : static int (*message_callback_function)(DltMessage *message, void *data) = NULL;
+     102             : static bool (*fetch_next_message_callback_function)(void *data) = NULL;
+     103             : 
+     104           3 : void dlt_client_register_message_callback(int (*registerd_callback)(DltMessage *message, void *data))
+     105             : {
+     106           3 :     message_callback_function = registerd_callback;
+     107           3 : }
+     108             : 
+     109           0 : void dlt_client_register_fetch_next_message_callback(bool (*registerd_callback)(void *data))
+     110             : {
+     111           0 :     fetch_next_message_callback_function = registerd_callback;
+     112           0 : }
+     113             : 
+     114           8 : DltReturnValue dlt_client_init_port(DltClient *client, int port, int verbose)
+     115             : {
+     116           8 :     if (verbose && (port != DLT_DAEMON_TCP_PORT))
+     117           0 :         dlt_vlog(LOG_INFO,
+     118             :                  "%s: Init dlt client struct with port %d\n",
+     119             :                  __func__,
+     120             :                  port);
+     121             : 
+     122           8 :     if (client == NULL)
+     123             :         return DLT_RETURN_ERROR;
+     124             : 
+     125           8 :     client->sock = -1;
+     126           8 :     client->servIP = NULL;
+     127           8 :     client->serialDevice = NULL;
+     128           8 :     client->baudrate = DLT_CLIENT_INITIAL_BAUDRATE;
+     129           8 :     client->port = port;
+     130           8 :     client->socketPath = NULL;
+     131           8 :     client->mode = DLT_CLIENT_MODE_TCP;
+     132           8 :     client->receiver.buffer = NULL;
+     133           8 :     client->receiver.buf = NULL;
+     134           8 :     client->receiver.backup_buf = NULL;
+     135           8 :     client->hostip = NULL;
+     136             : 
+     137           8 :     return DLT_RETURN_OK;
+     138             : }
+     139             : 
+     140           3 : DltReturnValue dlt_client_init(DltClient *client, int verbose)
+     141             : {
+     142             :     char *env_daemon_port;
+     143             :     int tmp_port;
+     144             :     /* the port may be specified by an environment variable, defaults to DLT_DAEMON_TCP_PORT */
+     145             :     unsigned short servPort = DLT_DAEMON_TCP_PORT;
+     146             : 
+     147             :     /* the port may be specified by an environment variable */
+     148           3 :     env_daemon_port = getenv(DLT_CLIENT_ENV_DAEMON_TCP_PORT);
+     149             : 
+     150           3 :     if (env_daemon_port != NULL) {
+     151             :         tmp_port = atoi(env_daemon_port);
+     152             : 
+     153           0 :         if ((tmp_port < IPPORT_RESERVED) || ((unsigned)tmp_port > USHRT_MAX)) {
+     154           0 :             dlt_vlog(LOG_ERR,
+     155             :                      "%s: Specified port is out of possible range: %d.\n",
+     156             :                      __func__,
+     157             :                      tmp_port);
+     158           0 :             return DLT_RETURN_ERROR;
+     159             :         }
+     160             :         else {
+     161           0 :             servPort = (unsigned short)tmp_port;
+     162             :         }
+     163             :     }
+     164             : 
+     165           3 :     if (verbose)
+     166           0 :         dlt_vlog(LOG_INFO,
+     167             :                  "%s: Init dlt client struct with default port: %hu.\n",
+     168             :                  __func__,
+     169             :                  servPort);
+     170           3 :     return dlt_client_init_port(client, servPort, verbose);
+     171             : }
+     172             : 
+     173           9 : DltReturnValue dlt_client_connect(DltClient *client, int verbose)
+     174             : {
+     175           9 :     const int yes = 1;
+     176           9 :     char portnumbuffer[33] = {0};
+     177             :     struct addrinfo hints, *servinfo, *p;
+     178             :     struct sockaddr_un addr;
+     179             :     int rv;
+     180             :     struct ip_mreq mreq;
+     181             :     DltReceiverType receiver_type = DLT_RECEIVE_FD;
+     182             : 
+     183             :     struct pollfd pfds[1];
+     184             :     int ret;
+     185             :     int n;
+     186           9 :     socklen_t m = sizeof(n);
+     187             :     int connect_errno = 0;
+     188             : 
+     189             :     memset(&hints, 0, sizeof(hints));
+     190           9 :     hints.ai_socktype = SOCK_STREAM;
+     191             : 
+     192           9 :     if (client == 0)
+     193             :         return DLT_RETURN_ERROR;
+     194             : 
+     195           9 :     switch (client->mode) {
+     196           7 :     case DLT_CLIENT_MODE_TCP:
+     197           7 :         snprintf(portnumbuffer, 32, "%d", client->port);
+     198             : 
+     199           7 :         if ((rv = getaddrinfo(client->servIP, portnumbuffer, &hints, &servinfo)) != 0) {
+     200           0 :             dlt_vlog(LOG_ERR,
+     201             :                     "%s: getaddrinfo: %s\n",
+     202             :                      __func__,
+     203             :                      gai_strerror(rv));
+     204           3 :             return DLT_RETURN_ERROR;
+     205             :         }
+     206             : 
+     207          11 :         for (p = servinfo; p != NULL; p = p->ai_next) {
+     208           8 :             if ((client->sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) < 0) {
+     209           0 :                 dlt_vlog(LOG_WARNING,
+     210             :                          "%s: socket() failed! %s\n",
+     211             :                          __func__,
+     212           0 :                          strerror(errno));
+     213           0 :                 continue;
+     214             :             }
+     215             : 
+     216             :             /* Set socket to Non-blocking mode */
+     217           8 :             if(fcntl(client->sock, F_SETFL, fcntl(client->sock,F_GETFL,0) | O_NONBLOCK) < 0)
+     218             :             {
+     219           0 :                 dlt_vlog(LOG_WARNING,
+     220             :                  "%s: Socket cannot be changed to NON BLOCK: %s\n",
+     221           0 :                  __func__, strerror(errno));
+     222           0 :                 close(client->sock);
+     223           0 :                 continue;
+     224             :             }
+     225             : 
+     226           8 :             if (connect(client->sock, p->ai_addr, p->ai_addrlen) < 0) {
+     227           8 :                 if (errno == EINPROGRESS) {
+     228           8 :                     pfds[0].fd = client->sock;
+     229           8 :                     pfds[0].events = POLLOUT;
+     230             :                     ret = poll(pfds, 1, 500);
+     231           8 :                     if (ret < 0) {
+     232           0 :                         dlt_vlog(LOG_ERR, "%s: Failed to poll with err [%s]\n",
+     233             :                         __func__, strerror(errno));
+     234           0 :                         close(client->sock);
+     235           0 :                         continue;
+     236             :                     }
+     237          16 :                     else if ((pfds[0].revents & POLLOUT) &&
+     238           8 :                             getsockopt(client->sock, SOL_SOCKET,
+     239             :                                     SO_ERROR, (void*)&n, &m) == 0) {
+     240           8 :                         if (n == 0) {
+     241           4 :                             dlt_vlog(LOG_DEBUG, "%s: Already connect\n", __func__);
+     242           4 :                             if(fcntl(client->sock, F_SETFL,
+     243           4 :                                     fcntl(client->sock,F_GETFL,0) & ~O_NONBLOCK) < 0) {
+     244           0 :                                 dlt_vlog(LOG_WARNING,
+     245             :                                 "%s: Socket cannot be changed to BLOCK with err [%s]\n",
+     246             :                                 __func__, strerror(errno));
+     247           0 :                                 close(client->sock);
+     248           0 :                                 continue;
+     249             :                             }
+     250             :                         }
+     251             :                         else {
+     252             :                             connect_errno = n;
+     253           4 :                             close(client->sock);
+     254           4 :                             continue;
+     255             :                         }
+     256             :                     }
+     257             :                     else {
+     258           0 :                         connect_errno = errno;
+     259           0 :                         close(client->sock);
+     260           0 :                         continue;
+     261             :                     }
+     262             :                 }
+     263             :                 else {
+     264             :                     connect_errno = errno;
+     265           0 :                     close(client->sock);
+     266           0 :                     continue;
+     267             :                 }
+     268             :             }
+     269             : 
+     270             :             break;
+     271             :         }
+     272             : 
+     273           7 :         freeaddrinfo(servinfo);
+     274             : 
+     275           7 :         if (p == NULL) {
+     276           3 :             dlt_vlog(LOG_ERR,
+     277             :                      "%s: ERROR: failed to connect! %s\n",
+     278             :                      __func__,
+     279             :                      strerror(connect_errno));
+     280           3 :             return DLT_RETURN_ERROR;
+     281             :         }
+     282             : 
+     283           4 :         if (verbose) {
+     284           1 :             dlt_vlog(LOG_INFO,
+     285             :                      "%s: Connected to DLT daemon (%s)\n",
+     286             :                      __func__,
+     287             :                      client->servIP);
+     288             :         }
+     289             : 
+     290             :         receiver_type = DLT_RECEIVE_SOCKET;
+     291             : 
+     292           6 :         break;
+     293           0 :     case DLT_CLIENT_MODE_SERIAL:
+     294             :         /* open serial connection */
+     295           0 :         client->sock = open(client->serialDevice, O_RDWR);
+     296             : 
+     297           0 :         if (client->sock < 0) {
+     298           0 :             dlt_vlog(LOG_ERR,
+     299             :                      "%s: ERROR: Failed to open device %s\n",
+     300             :                      __func__,
+     301             :                      client->serialDevice);
+     302           0 :             return DLT_RETURN_ERROR;
+     303             :         }
+     304             : 
+     305           0 :         if (isatty(client->sock)) {
+     306             :             #if !defined (__WIN32__)
+     307             : 
+     308           0 :             if (dlt_setup_serial(client->sock, client->baudrate) < DLT_RETURN_OK) {
+     309           0 :                 dlt_vlog(LOG_ERR,
+     310             :                          "%s: ERROR: Failed to configure serial device %s (%s) \n",
+     311             :                          __func__,
+     312             :                          client->serialDevice,
+     313           0 :                          strerror(errno));
+     314           0 :                 return DLT_RETURN_ERROR;
+     315             :             }
+     316             : 
+     317             :             #else
+     318             :             return DLT_RETURN_ERROR;
+     319             :             #endif
+     320             :         }
+     321             :         else {
+     322           0 :             if (verbose)
+     323           0 :                 dlt_vlog(LOG_ERR,
+     324             :                          "%s: ERROR: Device is not a serial device, device = %s (%s) \n",
+     325             :                          __func__,
+     326             :                          client->serialDevice,
+     327           0 :                          strerror(errno));
+     328             : 
+     329           0 :             return DLT_RETURN_ERROR;
+     330             :         }
+     331             : 
+     332           0 :         if (verbose)
+     333           0 :             dlt_vlog(LOG_INFO,
+     334             :                          "%s: Connected to %s\n",
+     335             :                          __func__,
+     336             :                          client->serialDevice);
+     337             : 
+     338             :         receiver_type = DLT_RECEIVE_FD;
+     339             : 
+     340             :         break;
+     341           2 :     case DLT_CLIENT_MODE_UNIX:
+     342             : 
+     343           2 :         if ((client->sock = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
+     344           0 :             dlt_vlog(LOG_ERR,
+     345             :                      "%s: ERROR: (unix) socket error: %s\n",
+     346             :                      __func__,
+     347           0 :                      strerror(errno));
+     348             : 
+     349           0 :             return DLT_RETURN_ERROR;
+     350             :         }
+     351             : 
+     352             :         memset(&addr, 0, sizeof(addr));
+     353           2 :         addr.sun_family = AF_UNIX;
+     354           2 :         strncpy(addr.sun_path, client->socketPath, sizeof(addr.sun_path) - 1);
+     355             : 
+     356           2 :         if (connect(client->sock,
+     357             :                     (struct sockaddr *) &addr,
+     358             :                     sizeof(addr)) == -1) {
+     359           0 :             dlt_vlog(LOG_ERR,
+     360             :                      "%s: ERROR: (unix) connect error: %s\n",
+     361             :                      __func__,
+     362           0 :                      strerror(errno));
+     363             : 
+     364           0 :             return DLT_RETURN_ERROR;
+     365             :         }
+     366             : 
+     367           2 :         if (client->sock < 0) {
+     368           0 :             dlt_vlog(LOG_ERR,
+     369             :                      "%s: ERROR: Failed to open device %s\n",
+     370             :                      __func__,
+     371             :                      client->socketPath);
+     372             : 
+     373           0 :             return DLT_RETURN_ERROR;
+     374             :         }
+     375             : 
+     376             :         receiver_type = DLT_RECEIVE_SOCKET;
+     377             : 
+     378             :         break;
+     379           0 :     case DLT_CLIENT_MODE_UDP_MULTICAST:
+     380             : 
+     381           0 :         if ((client->sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
+     382             :         {
+     383           0 :             dlt_vlog(LOG_ERR,
+     384             :                      "%s: ERROR: socket error: %s\n",
+     385             :                      __func__,
+     386           0 :                      strerror(errno));
+     387             : 
+     388           0 :             return DLT_RETURN_ERROR;
+     389             :         }
+     390             : 
+     391             :         /* allow multiple sockets to use the same PORT number */
+     392           0 :         if (setsockopt(client->sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) < 0)
+     393             :         {
+     394           0 :             dlt_vlog(LOG_ERR,
+     395             :                      "%s: ERROR: Reusing address failed: %s\n",
+     396             :                      __func__,
+     397           0 :                      strerror(errno));
+     398             : 
+     399           0 :             return DLT_RETURN_ERROR;
+     400             :         }
+     401             : 
+     402           0 :         memset(&client->receiver.addr, 0, sizeof(client->receiver.addr));
+     403           0 :         client->receiver.addr.sin_family = AF_INET;
+     404             :         client->receiver.addr.sin_addr.s_addr = htonl(INADDR_ANY);
+     405           0 :         client->receiver.addr.sin_port = htons(client->port);
+     406             : 
+     407             :         /* bind to receive address */
+     408           0 :         if (bind(client->sock, (struct sockaddr*) &client->receiver.addr, sizeof(client->receiver.addr)) < 0)
+     409             :         {
+     410           0 :             dlt_vlog(LOG_ERR,
+     411             :                      "%s: ERROR: bind failed: %s\n",
+     412             :                      __func__,
+     413           0 :                      strerror(errno));
+     414             : 
+     415           0 :             return DLT_RETURN_ERROR;
+     416             :         }
+     417             : 
+     418           0 :         mreq.imr_interface.s_addr = htonl(INADDR_ANY);
+     419           0 :         if (client->hostip)
+     420             :         {
+     421           0 :             mreq.imr_interface.s_addr = inet_addr(client->hostip);
+     422             :         }
+     423           0 :         if (client->servIP == NULL)
+     424             :         {
+     425           0 :             dlt_vlog(LOG_ERR,
+     426             :                      "%s: ERROR: server address not set\n",
+     427             :                      __func__);
+     428             : 
+     429           0 :             return DLT_RETURN_ERROR;
+     430             :         }
+     431             : 
+     432           0 :         char delimiter[] = ",";
+     433           0 :         char* servIP = strtok(client->servIP, delimiter);
+     434             : 
+     435           0 :         while(servIP != NULL) {
+     436           0 :             mreq.imr_multiaddr.s_addr = inet_addr(servIP);
+     437           0 :             if (mreq.imr_multiaddr.s_addr == (in_addr_t)-1)
+     438             :             {
+     439           0 :                 dlt_vlog(LOG_ERR,
+     440             :                          "%s: ERROR: server address not not valid %s\n",
+     441             :                          __func__,
+     442             :                          servIP);
+     443             : 
+     444           0 :                 return DLT_RETURN_ERROR;
+     445             :             }
+     446             : 
+     447           0 :             if (setsockopt(client->sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *)&mreq, sizeof(mreq)) < 0)
+     448             :             {
+     449           0 :                 dlt_vlog(LOG_ERR,
+     450             :                          "%s: ERROR: setsockopt add membership failed: %s\n",
+     451             :                          __func__,
+     452           0 :                          strerror(errno));
+     453             : 
+     454           0 :                 return DLT_RETURN_ERROR;
+     455             :             }
+     456           0 :             servIP = strtok(NULL, delimiter);
+     457             :         }
+     458             :         receiver_type = DLT_RECEIVE_UDP_SOCKET;
+     459             : 
+     460             :         break;
+     461           0 :     default:
+     462           0 :         dlt_vlog(LOG_ERR,
+     463             :                  "%s: ERROR: Mode not supported: %d\n",
+     464             :                  __func__,
+     465             :                  client->mode);
+     466             : 
+     467           0 :         return DLT_RETURN_ERROR;
+     468             :     }
+     469             : 
+     470           6 :     if (dlt_receiver_init(&(client->receiver), client->sock, receiver_type, DLT_RECEIVE_BUFSIZE) != DLT_RETURN_OK) {
+     471           0 :         dlt_vlog(LOG_ERR, "%s: ERROR initializing receiver\n", __func__);
+     472           0 :         return DLT_RETURN_ERROR;
+     473             :     }
+     474             : 
+     475             :     return DLT_RETURN_OK;
+     476             : }
+     477             : 
+     478           5 : DltReturnValue dlt_client_cleanup(DltClient *client, int verbose)
+     479             : {
+     480             :     int ret = DLT_RETURN_OK;
+     481             : 
+     482           5 :     if (verbose)
+     483           0 :         dlt_vlog(LOG_INFO, "%s: Cleanup dlt client\n", __func__);
+     484             : 
+     485           5 :     if (client == NULL)
+     486             :         return DLT_RETURN_WRONG_PARAMETER;
+     487             : 
+     488           5 :     if (client->sock != -1)
+     489           5 :         close(client->sock);
+     490             : 
+     491           5 :     if (dlt_receiver_free(&(client->receiver)) != DLT_RETURN_OK) {
+     492           0 :         dlt_vlog(LOG_WARNING, "%s: Failed to free receiver\n", __func__);
+     493             :                 ret = DLT_RETURN_ERROR;
+     494             :     }
+     495             : 
+     496           5 :     if (client->serialDevice) {
+     497           0 :         free(client->serialDevice);
+     498           0 :         client->serialDevice = NULL;
+     499             :     }
+     500             : 
+     501           5 :     if (client->servIP) {
+     502           3 :         free(client->servIP);
+     503           3 :         client->servIP = NULL;
+     504             :     }
+     505             : 
+     506           5 :     if (client->socketPath) {
+     507           2 :         free(client->socketPath);
+     508           2 :         client->socketPath = NULL;
+     509             :     }
+     510             : 
+     511           5 :     if (client->hostip) {
+     512           0 :         free(client->hostip);
+     513           0 :         client->hostip = NULL;
+     514             :     }
+     515             :     return ret;
+     516             : }
+     517             : 
+     518           3 : DltReturnValue dlt_client_main_loop(DltClient *client, void *data, int verbose)
+     519             : {
+     520             :     DltMessage msg;
+     521             :     int ret;
+     522             : 
+     523           3 :     if (client == 0)
+     524             :         return DLT_RETURN_ERROR;
+     525             : 
+     526           3 :     if (dlt_message_init(&msg, verbose) == DLT_RETURN_ERROR)
+     527             :         return DLT_RETURN_ERROR;
+     528             : 
+     529             :     bool fetch_next_message = true;
+     530         414 :     while (fetch_next_message) {
+     531             :         /* wait for data from socket or serial connection */
+     532         414 :         ret = dlt_receiver_receive(&(client->receiver));
+     533             : 
+     534         414 :         if (ret <= 0) {
+     535             :             /* No more data to be received */
+     536           3 :             if (dlt_message_free(&msg, verbose) == DLT_RETURN_ERROR)
+     537             :                 return DLT_RETURN_ERROR;
+     538             : 
+     539           3 :             return DLT_RETURN_TRUE;
+     540             :         }
+     541             : 
+     542         619 :         while (dlt_message_read(&msg, (unsigned char *)(client->receiver.buf),
+     543         619 :                                 client->receiver.bytesRcvd,
+     544             :                                 client->resync_serial_header,
+     545         619 :                                 verbose) == DLT_MESSAGE_ERROR_OK)
+     546             :         {
+     547             :             /* Call callback function */
+     548         208 :             if (message_callback_function)
+     549         208 :                 (*message_callback_function)(&msg, data);
+     550             : 
+     551         208 :             if (msg.found_serialheader) {
+     552           0 :                 if (dlt_receiver_remove(&(client->receiver),
+     553           0 :                                         (int) (msg.headersize + msg.datasize - sizeof(DltStorageHeader) +
+     554             :                                         sizeof(dltSerialHeader))) ==
+     555             :                     DLT_RETURN_ERROR) {
+     556             :                     /* Return value ignored */
+     557           0 :                     dlt_message_free(&msg, verbose);
+     558           0 :                     return DLT_RETURN_ERROR;
+     559             :                 }
+     560             :             }
+     561         208 :             else if (dlt_receiver_remove(&(client->receiver),
+     562         208 :                                          (int) (msg.headersize + msg.datasize - sizeof(DltStorageHeader))) ==
+     563             :                      DLT_RETURN_ERROR) {
+     564             :                 /* Return value ignored */
+     565           0 :                 dlt_message_free(&msg, verbose);
+     566           0 :                 return DLT_RETURN_ERROR;
+     567             :             }
+     568             :         }
+     569             : 
+     570         411 :         if (dlt_receiver_move_to_begin(&(client->receiver)) == DLT_RETURN_ERROR) {
+     571             :             /* Return value ignored */
+     572           0 :             dlt_message_free(&msg, verbose);
+     573           0 :             return DLT_RETURN_ERROR;
+     574             :         }
+     575         411 :         if (fetch_next_message_callback_function)
+     576           0 :           fetch_next_message = (*fetch_next_message_callback_function)(data);
+     577             :     }
+     578             : 
+     579           0 :     if (dlt_message_free(&msg, verbose) == DLT_RETURN_ERROR)
+     580           0 :         return DLT_RETURN_ERROR;
+     581             : 
+     582             :     return DLT_RETURN_OK;
+     583             : }
+     584             : 
+     585           2 : DltReturnValue dlt_client_send_message_to_socket(DltClient *client, DltMessage *msg)
+     586             : {
+     587             :     int ret = 0;
+     588             : 
+     589           2 :     if ((client == NULL) || (client->sock < 0)
+     590           2 :         || (msg == NULL) || (msg->databuffer == NULL))
+     591             :     {
+     592           0 :         dlt_log(LOG_ERR, "Invalid parameters\n");
+     593           0 :         return DLT_RETURN_ERROR;
+     594             :     }
+     595             : 
+     596           2 :     if (client->send_serial_header)
+     597             :     {
+     598           0 :         ret = send(client->sock, (const char *)dltSerialHeader,
+     599             :                    sizeof(dltSerialHeader), 0);
+     600           0 :         if (ret < 0)
+     601             :         {
+     602           0 :             dlt_vlog(LOG_ERR, "Sending serial header failed: %s\n",
+     603           0 :                         strerror(errno));
+     604           0 :             return DLT_RETURN_ERROR;
+     605             :         }
+     606             :     }
+     607             : 
+     608           4 :     ret = send(client->sock,
+     609             :                (const char *)(msg->headerbuffer + sizeof(DltStorageHeader)),
+     610           2 :                msg->headersize - sizeof(DltStorageHeader), 0);
+     611           2 :     if (ret < 0)
+     612             :     {
+     613           0 :         dlt_vlog(LOG_ERR, "Sending message header failed: %s\n", strerror(errno));
+     614           0 :         return DLT_RETURN_ERROR;
+     615             :     }
+     616             : 
+     617           2 :     ret = send(client->sock, (const char *)msg->databuffer, msg->datasize, 0);
+     618           2 :     if ( ret < 0)
+     619             :     {
+     620           0 :         dlt_vlog(LOG_ERR, "Sending message failed: %s\n", strerror(errno));
+     621           0 :         return DLT_RETURN_ERROR;
+     622             :     }
+     623             : 
+     624             :     return DLT_RETURN_OK;
+     625             : }
+     626             : 
+     627          10 : DltReturnValue dlt_client_send_ctrl_msg(DltClient *client, char *apid, char *ctid, uint8_t *payload, uint32_t size)
+     628             : {
+     629             :     DltMessage msg;
+     630             :     int ret;
+     631             : 
+     632             :     int32_t len;
+     633             :     uint32_t id_tmp;
+     634             :     uint32_t id;
+     635             : 
+     636          10 :     if ((client == 0) || (client->sock < 0) || (apid == 0) || (ctid == 0))
+     637             :         return DLT_RETURN_ERROR;
+     638             : 
+     639             :     /* initialise new message */
+     640          10 :     if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+     641             :         return DLT_RETURN_ERROR;
+     642             : 
+     643             :     /* prepare payload of data */
+     644          10 :     msg.datasize = size;
+     645             : 
+     646          10 :     if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
+     647           0 :         free(msg.databuffer);
+     648           0 :         msg.databuffer = 0;
+     649             :     }
+     650             : 
+     651          10 :     if (msg.databuffer == 0) {
+     652          10 :         msg.databuffer = (uint8_t *)malloc(msg.datasize);
+     653          10 :         msg.databuffersize = msg.datasize;
+     654             :     }
+     655             : 
+     656          10 :     if (msg.databuffer == 0) {
+     657           0 :         dlt_message_free(&msg, 0);
+     658           0 :         return DLT_RETURN_ERROR;
+     659             :     }
+     660             : 
+     661             :     /* copy data */
+     662          10 :     memcpy(msg.databuffer, payload, size);
+     663             : 
+     664             :     /* prepare storage header */
+     665          10 :     msg.storageheader = (DltStorageHeader *)msg.headerbuffer;
+     666             : 
+     667          10 :     if (dlt_set_storageheader(msg.storageheader, "") == DLT_RETURN_ERROR) {
+     668           0 :         dlt_message_free(&msg, 0);
+     669           0 :         return DLT_RETURN_ERROR;
+     670             :     }
+     671             : 
+     672             :     /* prepare standard header */
+     673          10 :     msg.standardheader = (DltStandardHeader *)(msg.headerbuffer + sizeof(DltStorageHeader));
+     674          10 :     msg.standardheader->htyp = DLT_HTYP_WEID | DLT_HTYP_WTMS | DLT_HTYP_UEH | DLT_HTYP_PROTOCOL_VERSION1;
+     675             : 
+     676             :     #if (BYTE_ORDER == BIG_ENDIAN)
+     677             :     msg.standardheader->htyp = (msg.standardheader->htyp | DLT_HTYP_MSBF);
+     678             :     #endif
+     679             : 
+     680          10 :     msg.standardheader->mcnt = 0;
+     681             : 
+     682             :     /* Set header extra parameters */
+     683          10 :     dlt_set_id(msg.headerextra.ecu, client->ecuid);
+     684             :     /*msg.headerextra.seid = 0; */
+     685          10 :     msg.headerextra.tmsp = dlt_uptime();
+     686             : 
+     687             :     /* Copy header extra parameters to headerbuffer */
+     688          10 :     if (dlt_message_set_extraparameters(&msg, 0) == DLT_RETURN_ERROR) {
+     689           0 :         dlt_message_free(&msg, 0);
+     690           0 :         return DLT_RETURN_ERROR;
+     691             :     }
+     692             : 
+     693             :     /* prepare extended header */
+     694          10 :     msg.extendedheader = (DltExtendedHeader *)(msg.headerbuffer +
+     695             :                                                sizeof(DltStorageHeader) +
+     696          10 :                                                sizeof(DltStandardHeader) +
+     697          10 :                                                DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp));
+     698             : 
+     699          10 :     msg.extendedheader->msin = DLT_MSIN_CONTROL_REQUEST;
+     700             : 
+     701          10 :     msg.extendedheader->noar = 1; /* number of arguments */
+     702             : 
+     703          19 :     dlt_set_id(msg.extendedheader->apid, (apid[0] == '\0') ? DLT_CLIENT_DUMMY_APP_ID : apid);
+     704          19 :     dlt_set_id(msg.extendedheader->ctid, (ctid[0] == '\0') ? DLT_CLIENT_DUMMY_CON_ID : ctid);
+     705             : 
+     706             :     /* prepare length information */
+     707          10 :     msg.headersize = (uint32_t) (sizeof(DltStorageHeader) +
+     708             :         sizeof(DltStandardHeader) +
+     709             :         sizeof(DltExtendedHeader) +
+     710          10 :         DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp));
+     711             : 
+     712          10 :     len = (int32_t) (msg.headersize - sizeof(DltStorageHeader) + msg.datasize);
+     713             : 
+     714          10 :     if (len > UINT16_MAX) {
+     715           0 :         dlt_vlog(LOG_ERR,
+     716             :                  "%s: Critical: Huge injection message discarded!\n",
+     717             :                  __func__);
+     718             : 
+     719           0 :                 dlt_message_free(&msg, 0);
+     720             : 
+     721           0 :         return DLT_RETURN_ERROR;
+     722             :     }
+     723             : 
+     724          10 :     msg.standardheader->len = DLT_HTOBE_16(len);
+     725             : 
+     726             :     /* Send data (without storage header) */
+     727          10 :     if ((client->mode == DLT_CLIENT_MODE_TCP) || (client->mode == DLT_CLIENT_MODE_SERIAL)) {
+     728             :         /* via FileDescriptor */
+     729          10 :         if (client->send_serial_header)
+     730             :         {
+     731           0 :             ret = write(client->sock, dltSerialHeader, sizeof(dltSerialHeader));
+     732           0 :             if (ret < 0)
+     733             :             {
+     734           0 :                 dlt_log(LOG_ERR, "Sending message failed\n");
+     735           0 :                 dlt_message_free(&msg, 0);
+     736           0 :                 return DLT_RETURN_ERROR;
+     737             :             }
+     738             :         }
+     739          10 :         ret =
+     740          10 :             (int) write(client->sock, msg.headerbuffer + sizeof(DltStorageHeader), msg.headersize - sizeof(DltStorageHeader));
+     741             : 
+     742          10 :         if (0 > ret) {
+     743           0 :             dlt_vlog(LOG_ERR, "%s: Sending message failed\n", __func__);
+     744           0 :             dlt_message_free(&msg, 0);
+     745           0 :             return DLT_RETURN_ERROR;
+     746             :         }
+     747             : 
+     748          10 :         ret = (int) write(client->sock, msg.databuffer, msg.datasize);
+     749             : 
+     750          10 :         if (0 > ret) {
+     751           0 :             dlt_vlog(LOG_ERR, "%s: Sending message failed\n", __func__);
+     752           0 :             dlt_message_free(&msg, 0);
+     753           0 :             return DLT_RETURN_ERROR;
+     754             :         }
+     755             : 
+     756          10 :         id_tmp = *((uint32_t *)(msg.databuffer));
+     757          10 :         id = DLT_ENDIAN_GET_32(msg.standardheader->htyp, id_tmp);
+     758             : 
+     759          10 :         dlt_vlog(LOG_INFO,
+     760             :                  "%s: Control message forwarded : %s\n",
+     761             :                  __func__,
+     762             :                  dlt_get_service_name(id));
+     763             :     }
+     764             :     else {
+     765             :         /* via Socket */
+     766           0 :         if (dlt_client_send_message_to_socket(client, &msg) == DLT_RETURN_ERROR)
+     767             :         {
+     768           0 :             dlt_log(LOG_ERR, "Sending message to socket failed\n");
+     769           0 :             dlt_message_free(&msg, 0);
+     770           0 :             return DLT_RETURN_ERROR;
+     771             :         }
+     772             :     }
+     773             : 
+     774             :     /* free message */
+     775          10 :     if (dlt_message_free(&msg, 0) == DLT_RETURN_ERROR)
+     776           0 :         return DLT_RETURN_ERROR;
+     777             : 
+     778             :     return DLT_RETURN_OK;
+     779             : }
+     780             : 
+     781           0 : DltReturnValue dlt_client_send_inject_msg(DltClient *client,
+     782             :                                           char *apid,
+     783             :                                           char *ctid,
+     784             :                                           uint32_t serviceID,
+     785             :                                           uint8_t *buffer,
+     786             :                                           uint32_t size)
+     787             : {
+     788             :     uint8_t *payload;
+     789             :     int offset;
+     790             : 
+     791           0 :     payload = (uint8_t *)malloc(sizeof(uint32_t) + sizeof(uint32_t) + size);
+     792             : 
+     793           0 :     if (payload == 0)
+     794             :         return DLT_RETURN_ERROR;
+     795             : 
+     796             :     offset = 0;
+     797             :     memcpy(payload, &serviceID, sizeof(serviceID));
+     798             :     offset += (int) sizeof(uint32_t);
+     799           0 :     memcpy(payload + offset, &size, sizeof(size));
+     800             :     offset += (int) sizeof(uint32_t);
+     801           0 :     memcpy(payload + offset, buffer, size);
+     802             : 
+     803             :     /* free message */
+     804           0 :     if (dlt_client_send_ctrl_msg(client, apid, ctid, payload,
+     805             :                                  (uint32_t) (sizeof(uint32_t) + sizeof(uint32_t) + size)) == DLT_RETURN_ERROR) {
+     806           0 :         free(payload);
+     807           0 :         return DLT_RETURN_ERROR;
+     808             :     }
+     809             : 
+     810           0 :     free(payload);
+     811             : 
+     812           0 :     return DLT_RETURN_OK;
+     813             : 
+     814             : }
+     815             : 
+     816           1 : DltReturnValue dlt_client_send_log_level(DltClient *client, char *apid, char *ctid, uint8_t logLevel)
+     817             : {
+     818             :     DltServiceSetLogLevel *req;
+     819             :     int ret = DLT_RETURN_ERROR;
+     820             : 
+     821           1 :     if (client == NULL)
+     822             :         return ret;
+     823             : 
+     824           1 :     req = calloc(1, sizeof(DltServiceSetLogLevel));
+     825             : 
+     826           1 :     if (req == NULL)
+     827             :         return ret;
+     828             : 
+     829           1 :     req->service_id = DLT_SERVICE_ID_SET_LOG_LEVEL;
+     830           1 :     dlt_set_id(req->apid, apid);
+     831           1 :     dlt_set_id(req->ctid, ctid);
+     832           1 :     req->log_level = logLevel;
+     833           1 :     dlt_set_id(req->com, "remo");
+     834             : 
+     835             :     /* free message */
+     836           1 :     ret = dlt_client_send_ctrl_msg(client,
+     837             :                                    "APP",
+     838             :                                    "CON",
+     839             :                                    (uint8_t *)req,
+     840             :                                    sizeof(DltServiceSetLogLevel));
+     841             : 
+     842             : 
+     843           1 :     free(req);
+     844             : 
+     845           1 :     return ret;
+     846             : }
+     847             : 
+     848           4 : DltReturnValue dlt_client_get_log_info(DltClient *client)
+     849             : {
+     850             :     DltServiceGetLogInfoRequest *req;
+     851             :     int ret = DLT_RETURN_ERROR;
+     852             : 
+     853           4 :     if (client == NULL)
+     854             :         return ret;
+     855             : 
+     856           4 :     req = (DltServiceGetLogInfoRequest *)malloc(sizeof(DltServiceGetLogInfoRequest));
+     857             : 
+     858           4 :     if (req == NULL)
+     859             :         return ret;
+     860             : 
+     861           4 :     req->service_id = DLT_SERVICE_ID_GET_LOG_INFO;
+     862           4 :     req->options = 7;
+     863           4 :     dlt_set_id(req->apid, "");
+     864           4 :     dlt_set_id(req->ctid, "");
+     865           4 :     dlt_set_id(req->com, "remo");
+     866             : 
+     867             :     /* send control message to daemon*/
+     868           4 :     ret = dlt_client_send_ctrl_msg(client,
+     869             :                                    "",
+     870             :                                    "",
+     871             :                                    (uint8_t *)req,
+     872             :                                    sizeof(DltServiceGetLogInfoRequest));
+     873             : 
+     874           4 :     free(req);
+     875             : 
+     876           4 :     return ret;
+     877             : }
+     878             : 
+     879           1 : DltReturnValue dlt_client_get_default_log_level(DltClient *client)
+     880             : {
+     881             :     DltServiceGetDefaultLogLevelRequest *req;
+     882             :     int ret = DLT_RETURN_ERROR;
+     883             : 
+     884           1 :     if (client == NULL)
+     885             :         return ret;
+     886             : 
+     887             :     req = (DltServiceGetDefaultLogLevelRequest *)
+     888           1 :         malloc(sizeof(DltServiceGetDefaultLogLevelRequest));
+     889             : 
+     890           1 :     if (req == NULL)
+     891             :         return ret;
+     892             : 
+     893           1 :     req->service_id = DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL;
+     894             : 
+     895             :     /* send control message to daemon*/
+     896           1 :     ret = dlt_client_send_ctrl_msg(client,
+     897             :                                    "",
+     898             :                                    "",
+     899             :                                    (uint8_t *)req,
+     900             :                                    sizeof(DltServiceGetDefaultLogLevelRequest));
+     901             : 
+     902           1 :     free(req);
+     903             : 
+     904           1 :     return ret;
+     905             : }
+     906             : 
+     907           4 : DltReturnValue dlt_client_get_software_version(DltClient *client)
+     908             : {
+     909             :     DltServiceGetSoftwareVersion *req;
+     910             :     int ret = DLT_RETURN_ERROR;
+     911             : 
+     912           4 :     if (client == NULL)
+     913             :         return ret;
+     914             : 
+     915           4 :     req = (DltServiceGetSoftwareVersion *)malloc(sizeof(DltServiceGetSoftwareVersion));
+     916             : 
+     917           4 :     req->service_id = DLT_SERVICE_ID_GET_SOFTWARE_VERSION;
+     918             : 
+     919             :     /* send control message to daemon*/
+     920           4 :     ret = dlt_client_send_ctrl_msg(client,
+     921             :                                    "",
+     922             :                                    "",
+     923             :                                    (uint8_t *)req,
+     924             :                                    sizeof(DltServiceGetSoftwareVersion));
+     925             : 
+     926           4 :     free(req);
+     927             : 
+     928           4 :     return ret;
+     929             : }
+     930             : 
+     931           0 : DltReturnValue dlt_client_send_trace_status(DltClient *client, char *apid, char *ctid, uint8_t traceStatus)
+     932             : {
+     933             :     DltServiceSetLogLevel *req;
+     934             : 
+     935           0 :     req = calloc(1,sizeof(DltServiceSetLogLevel));
+     936             : 
+     937           0 :     if (req == 0)
+     938             :         return DLT_RETURN_ERROR;
+     939             : 
+     940           0 :     req->service_id = DLT_SERVICE_ID_SET_TRACE_STATUS;
+     941           0 :     dlt_set_id(req->apid, apid);
+     942           0 :     dlt_set_id(req->ctid, ctid);
+     943           0 :     req->log_level = traceStatus;
+     944           0 :     dlt_set_id(req->com, "remo");
+     945             : 
+     946             :     /* free message */
+     947           0 :     if (dlt_client_send_ctrl_msg(client, "APP", "CON", (uint8_t*) req,
+     948             :                                  sizeof(DltServiceSetLogLevel)) == DLT_RETURN_ERROR) {
+     949           0 :         free(req);
+     950           0 :         return DLT_RETURN_ERROR;
+     951             :     }
+     952             : 
+     953           0 :     free(req);
+     954             : 
+     955           0 :     return DLT_RETURN_OK;
+     956             : }
+     957             : 
+     958           0 : DltReturnValue dlt_client_send_default_log_level(DltClient *client, uint8_t defaultLogLevel)
+     959             : {
+     960             :     DltServiceSetDefaultLogLevel *req;
+     961             : 
+     962           0 :     req = calloc(1, sizeof(DltServiceSetDefaultLogLevel));
+     963             : 
+     964           0 :     if (req == 0)
+     965             :         return DLT_RETURN_ERROR;
+     966             : 
+     967           0 :     req->service_id = DLT_SERVICE_ID_SET_DEFAULT_LOG_LEVEL;
+     968           0 :     req->log_level = defaultLogLevel;
+     969           0 :     dlt_set_id(req->com, "remo");
+     970             : 
+     971             :     /* free message */
+     972           0 :     if (dlt_client_send_ctrl_msg(client, "APP", "CON", (uint8_t*) req,
+     973             :                                  sizeof(DltServiceSetDefaultLogLevel)) == DLT_RETURN_ERROR) {
+     974           0 :         free(req);
+     975           0 :         return DLT_RETURN_ERROR;
+     976             :     }
+     977             : 
+     978           0 :     free(req);
+     979             : 
+     980           0 :     return DLT_RETURN_OK;
+     981             : }
+     982             : 
+     983           0 : DltReturnValue dlt_client_send_all_log_level(DltClient *client, uint8_t LogLevel)
+     984             : {
+     985             :     DltServiceSetDefaultLogLevel *req;
+     986             : 
+     987           0 :     req = calloc(1, sizeof(DltServiceSetDefaultLogLevel));
+     988             : 
+     989           0 :     if (req == 0)
+     990             :         return DLT_RETURN_ERROR;
+     991             : 
+     992           0 :     req->service_id = DLT_SERVICE_ID_SET_ALL_LOG_LEVEL;
+     993           0 :     req->log_level = LogLevel;
+     994           0 :     dlt_set_id(req->com, "remo");
+     995             : 
+     996             :     /* free message */
+     997           0 :     if (dlt_client_send_ctrl_msg(client, "APP", "CON", (uint8_t*) req,
+     998             :                                  sizeof(DltServiceSetDefaultLogLevel)) == -1) {
+     999           0 :         free(req);
+    1000           0 :         return DLT_RETURN_ERROR;
+    1001             :     }
+    1002             : 
+    1003           0 :     free(req);
+    1004             : 
+    1005           0 :     return DLT_RETURN_OK;
+    1006             : }
+    1007             : 
+    1008           0 : DltReturnValue dlt_client_send_default_trace_status(DltClient *client, uint8_t defaultTraceStatus)
+    1009             : {
+    1010             :     DltServiceSetDefaultLogLevel *req;
+    1011             : 
+    1012           0 :     req = calloc(1, sizeof(DltServiceSetDefaultLogLevel));
+    1013             : 
+    1014           0 :     if (req == 0)
+    1015             :         return DLT_RETURN_ERROR;
+    1016             : 
+    1017           0 :     req->service_id = DLT_SERVICE_ID_SET_DEFAULT_TRACE_STATUS;
+    1018           0 :     req->log_level = defaultTraceStatus;
+    1019           0 :     dlt_set_id(req->com, "remo");
+    1020             : 
+    1021             :     /* free message */
+    1022           0 :     if (dlt_client_send_ctrl_msg(client, "APP", "CON", (uint8_t*) req,
+    1023             :                                  sizeof(DltServiceSetDefaultLogLevel)) == DLT_RETURN_ERROR) {
+    1024           0 :         free(req);
+    1025           0 :         return DLT_RETURN_ERROR;
+    1026             :     }
+    1027             : 
+    1028           0 :     free(req);
+    1029             : 
+    1030           0 :     return DLT_RETURN_OK;
+    1031             : }
+    1032             : 
+    1033           0 : DltReturnValue dlt_client_send_all_trace_status(DltClient *client, uint8_t traceStatus)
+    1034             : {
+    1035             :     DltServiceSetDefaultLogLevel *req;
+    1036             : 
+    1037           0 :     if (client == NULL) {
+    1038           0 :         dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
+    1039           0 :         return DLT_RETURN_ERROR;
+    1040             :     }
+    1041             : 
+    1042           0 :     req = calloc(1, sizeof(DltServiceSetDefaultLogLevel));
+    1043             : 
+    1044           0 :     if (req == 0) {
+    1045           0 :         dlt_vlog(LOG_ERR, "%s: Could not allocate memory %zu\n", __func__, sizeof(DltServiceSetDefaultLogLevel));
+    1046           0 :         return DLT_RETURN_ERROR;
+    1047             :     }
+    1048             : 
+    1049           0 :     req->service_id = DLT_SERVICE_ID_SET_ALL_TRACE_STATUS;
+    1050           0 :     req->log_level = traceStatus;
+    1051           0 :     dlt_set_id(req->com, "remo");
+    1052             : 
+    1053             :     /* free message */
+    1054           0 :     if (dlt_client_send_ctrl_msg(client, "APP", "CON", (uint8_t*) req,
+    1055             :                                  sizeof(DltServiceSetDefaultLogLevel)) == -1) {
+    1056           0 :         free(req);;
+    1057           0 :         return DLT_RETURN_ERROR;
+    1058             :     }
+    1059             : 
+    1060           0 :     free(req);
+    1061             : 
+    1062           0 :     return DLT_RETURN_OK;
+    1063             : }
+    1064             : 
+    1065           0 : DltReturnValue dlt_client_send_timing_pakets(DltClient *client, uint8_t timingPakets)
+    1066             : {
+    1067             :     DltServiceSetVerboseMode *req;
+    1068             : 
+    1069           0 :     req = calloc(1, sizeof(DltServiceSetVerboseMode));
+    1070             : 
+    1071           0 :     if (req == 0)
+    1072             :         return DLT_RETURN_ERROR;
+    1073             : 
+    1074           0 :     req->service_id = DLT_SERVICE_ID_SET_TIMING_PACKETS;
+    1075           0 :     req->new_status = timingPakets;
+    1076             : 
+    1077             :     /* free message */
+    1078           0 :     if (dlt_client_send_ctrl_msg(client, "APP", "CON", (uint8_t*) req,
+    1079             :                                  sizeof(DltServiceSetVerboseMode)) == DLT_RETURN_ERROR) {
+    1080           0 :         free(req);
+    1081           0 :         return DLT_RETURN_ERROR;
+    1082             :     }
+    1083             : 
+    1084           0 :     free(req);
+    1085             : 
+    1086           0 :     return DLT_RETURN_OK;
+    1087             : }
+    1088             : 
+    1089           0 : DltReturnValue dlt_client_send_store_config(DltClient *client)
+    1090             : {
+    1091             :     uint32_t service_id;
+    1092             : 
+    1093           0 :     service_id = DLT_SERVICE_ID_STORE_CONFIG;
+    1094             : 
+    1095             :     /* free message */
+    1096           0 :     if (dlt_client_send_ctrl_msg(client, "APP", "CON", (uint8_t *)&service_id, sizeof(uint32_t)) == DLT_RETURN_ERROR)
+    1097           0 :         return DLT_RETURN_ERROR;
+    1098             : 
+    1099             :     return DLT_RETURN_OK;
+    1100             : }
+    1101             : 
+    1102           0 : DltReturnValue dlt_client_send_reset_to_factory_default(DltClient *client)
+    1103             : {
+    1104             :     uint32_t service_id;
+    1105             : 
+    1106           0 :     service_id = DLT_SERVICE_ID_RESET_TO_FACTORY_DEFAULT;
+    1107             : 
+    1108             :     /* free message */
+    1109           0 :     if (dlt_client_send_ctrl_msg(client, "APP", "CON", (uint8_t *)&service_id, sizeof(uint32_t)) == DLT_RETURN_ERROR)
+    1110           0 :         return DLT_RETURN_ERROR;
+    1111             : 
+    1112             :     return DLT_RETURN_OK;
+    1113             : }
+    1114             : 
+    1115           0 : DltReturnValue dlt_client_setbaudrate(DltClient *client, int baudrate)
+    1116             : {
+    1117           0 :     if (client == 0)
+    1118             :         return DLT_RETURN_ERROR;
+    1119             : 
+    1120           0 :     client->baudrate = dlt_convert_serial_speed(baudrate);
+    1121             : 
+    1122           0 :     return DLT_RETURN_OK;
+    1123             : }
+    1124             : 
+    1125           0 : DltReturnValue dlt_client_set_mode(DltClient *client, DltClientMode mode)
+    1126             : {
+    1127           0 :     if (client == 0)
+    1128             :         return DLT_RETURN_ERROR;
+    1129             : 
+    1130           0 :     client->mode = mode;
+    1131           0 :     return DLT_RETURN_OK;
+    1132             : 
+    1133             : }
+    1134             : 
+    1135           6 : int dlt_client_set_server_ip(DltClient *client, char *ipaddr)
+    1136             : {
+    1137           6 :     client->servIP = strdup(ipaddr);
+    1138             : 
+    1139           6 :     if (client->servIP == NULL) {
+    1140           0 :         dlt_vlog(LOG_ERR, "%s: ERROR: failed to duplicate server IP\n", __func__);
+    1141           0 :         return DLT_RETURN_ERROR;
+    1142             :     }
+    1143             : 
+    1144             :     return DLT_RETURN_OK;
+    1145             : }
+    1146             : 
+    1147           0 : int dlt_client_set_host_if_address(DltClient *client, char *hostip)
+    1148             : {
+    1149           0 :     client->hostip = strdup(hostip);
+    1150             : 
+    1151           0 :     if (client->hostip == NULL) {
+    1152           0 :         dlt_vlog(LOG_ERR, "%s: ERROR: failed to duplicate UDP interface address\n", __func__);
+    1153           0 :         return DLT_RETURN_ERROR;
+    1154             :     }
+    1155             : 
+    1156             :     return DLT_RETURN_OK;
+    1157             : }
+    1158             : 
+    1159           0 : int dlt_client_set_serial_device(DltClient *client, char *serial_device)
+    1160             : {
+    1161           0 :     client->serialDevice = strdup(serial_device);
+    1162             : 
+    1163           0 :     if (client->serialDevice == NULL) {
+    1164           0 :         dlt_vlog(LOG_ERR, "%s: ERROR: failed to duplicate serial device\n", __func__);
+    1165           0 :         return DLT_RETURN_ERROR;
+    1166             :     }
+    1167             : 
+    1168             :     return DLT_RETURN_OK;
+    1169             : }
+    1170             : 
+    1171           0 : int dlt_client_set_socket_path(DltClient *client, char *socket_path)
+    1172             : {
+    1173           0 :     client->socketPath = strdup(socket_path);
+    1174             : 
+    1175           0 :     if (client->socketPath == NULL) {
+    1176           0 :         dlt_vlog(LOG_ERR, "%s: ERROR: failed to duplicate socket path\n", __func__);
+    1177           0 :         return DLT_RETURN_ERROR;
+    1178             :     }
+    1179             : 
+    1180             :     return DLT_RETURN_OK;
+    1181             : }
+    1182             : /**
+    1183             :  * free allocation when calloc failed
+    1184             :  *
+    1185             :  * @param resp          DltServiceGetLogInfoResponse
+    1186             :  * @param count_app_ids number of app_ids which needs to be freed
+    1187             :  */
+    1188           0 : DLT_STATIC void dlt_client_free_calloc_failed_get_log_info(DltServiceGetLogInfoResponse *resp,
+    1189             :                                                            int count_app_ids)
+    1190             : {
+    1191             :     AppIDsType *app = NULL;
+    1192             :     ContextIDsInfoType *con = NULL;
+    1193             :     int i = 0;
+    1194             :     int j = 0;
+    1195             : 
+    1196           0 :     for (i = 0; i < count_app_ids; i++) {
+    1197           0 :         app = &(resp->log_info_type.app_ids[i]);
+    1198             : 
+    1199           0 :         for (j = 0; j < app->count_context_ids; j++) {
+    1200           0 :             con = &(app->context_id_info[j]);
+    1201             : 
+    1202           0 :             free(con->context_description);
+    1203           0 :             con->context_description = NULL;
+    1204             :         }
+    1205             : 
+    1206           0 :         free(app->app_description);
+    1207           0 :         app->app_description = NULL;
+    1208             : 
+    1209           0 :         free(app->context_id_info);
+    1210           0 :         app->context_id_info = NULL;
+    1211             :     }
+    1212             : 
+    1213           0 :     free(resp->log_info_type.app_ids);
+    1214           0 :     resp->log_info_type.app_ids = NULL;
+    1215           0 :     resp->log_info_type.count_app_ids = 0;
+    1216             : 
+    1217           0 :     return;
+    1218             : }
+    1219             : 
+    1220           2 : DltReturnValue dlt_client_parse_get_log_info_resp_text(DltServiceGetLogInfoResponse *resp,
+    1221             :                                                        char *resp_text)
+    1222             : {
+    1223             :     AppIDsType *app = NULL;
+    1224             :     ContextIDsInfoType *con = NULL;
+    1225             :     int i = 0;
+    1226             :     int j = 0;
+    1227             :     char *rp = NULL;
+    1228           2 :     int rp_count = 0;
+    1229             : 
+    1230           2 :     if ((resp == NULL) || (resp_text == NULL))
+    1231             :         return DLT_RETURN_WRONG_PARAMETER;
+    1232             : 
+    1233             :     /* ------------------------------------------------------
+    1234             :     *  get_log_info data structure(all data is ascii)
+    1235             :     *
+    1236             :     *  get_log_info, aa, bb bb cc cc cc cc dd dd ee ee ee ee ff gg hh hh ii ii ii .. ..
+    1237             :     *                ~~  ~~~~~ ~~~~~~~~~~~ ~~~~~ ~~~~~~~~~~~~~~
+    1238             :     *                          cc cc cc cc dd dd ee ee ee ee ff gg hh hh ii ii ii .. ..
+    1239             :     *                    jj jj kk kk kk .. ..
+    1240             :     *                          ~~~~~~~~~~~ ~~~~~ ~~~~~~~~~~~~~~
+    1241             :     *  aa         : get mode (fix value at 0x07)
+    1242             :     *  bb bb      : list num of apid (little endian)
+    1243             :     *  cc cc cc cc: apid
+    1244             :     *  dd dd      : list num of ctid (little endian)
+    1245             :     *  ee ee ee ee: ctid
+    1246             :     *  ff         : log level
+    1247             :     *  gg         : trace status
+    1248             :     *  hh hh      : description length of ctid
+    1249             :     *  ii ii ..   : description text of ctid
+    1250             :     *  jj jj      : description length of apid
+    1251             :     *  kk kk ..   : description text of apid
+    1252             :     *  ------------------------------------------------------ */
+    1253             : 
+    1254           2 :     rp = resp_text + DLT_GET_LOG_INFO_HEADER;
+    1255             :     rp_count = 0;
+    1256             : 
+    1257             :     /* check if status is acceptable */
+    1258           2 :     if ((resp->status < GET_LOG_INFO_STATUS_MIN) ||
+    1259             :         (resp->status > GET_LOG_INFO_STATUS_MAX)) {
+    1260           0 :         if (resp->status == GET_LOG_INFO_STATUS_NO_MATCHING_CTX)
+    1261           0 :             dlt_vlog(LOG_WARNING,
+    1262             :                      "%s: The status(%d) is invalid: NO matching Context IDs\n",
+    1263             :                      __func__,
+    1264             :                      resp->status);
+    1265           0 :         else if (resp->status == GET_LOG_INFO_STATUS_RESP_DATA_OVERFLOW)
+    1266           0 :             dlt_vlog(LOG_WARNING,
+    1267             :                      "%s: The status(%d) is invalid: Response data over flow\n",
+    1268             :                      __func__,
+    1269             :                      resp->status);
+    1270             :         else
+    1271           0 :             dlt_vlog(LOG_WARNING,
+    1272             :                      "%s: The status(%d) is invalid\n",
+    1273             :                      __func__,
+    1274             :                      resp->status);
+    1275             : 
+    1276           0 :         return DLT_RETURN_ERROR;
+    1277             :     }
+    1278             : 
+    1279             :     /* count_app_ids */
+    1280           2 :     int16_t ret = dlt_getloginfo_conv_ascii_to_uint16_t(rp, &rp_count);
+    1281           2 :     if (ret >= 0)
+    1282           2 :         resp->log_info_type.count_app_ids = ret;
+    1283             : 
+    1284           2 :     resp->log_info_type.app_ids = (AppIDsType *)calloc
+    1285           2 :             (resp->log_info_type.count_app_ids, sizeof(AppIDsType));
+    1286             : 
+    1287           2 :     if (resp->log_info_type.app_ids == NULL) {
+    1288           0 :         dlt_vlog(LOG_ERR, "%s: calloc failed for app_ids\n", __func__);
+    1289           0 :         dlt_client_free_calloc_failed_get_log_info(resp, 0);
+    1290           0 :         return DLT_RETURN_ERROR;
+    1291             :     }
+    1292             : 
+    1293           5 :     for (i = 0; i < resp->log_info_type.count_app_ids; i++) {
+    1294           3 :         app = &(resp->log_info_type.app_ids[i]);
+    1295             :         /* get app id */
+    1296           3 :         dlt_getloginfo_conv_ascii_to_id(rp, &rp_count, app->app_id, DLT_ID_SIZE);
+    1297             : 
+    1298             :         /* count_con_ids */
+    1299           3 :         ret = dlt_getloginfo_conv_ascii_to_uint16_t(rp, &rp_count);
+    1300           3 :         if (ret >= 0)
+    1301           3 :             app->count_context_ids = ret;
+    1302             : 
+    1303           3 :         app->context_id_info = (ContextIDsInfoType *)calloc
+    1304           3 :                 (app->count_context_ids, sizeof(ContextIDsInfoType));
+    1305             : 
+    1306           3 :         if (app->context_id_info == NULL) {
+    1307           0 :             dlt_vlog(LOG_ERR,
+    1308             :                      "%s: calloc failed for context_id_info\n", __func__);
+    1309           0 :             dlt_client_free_calloc_failed_get_log_info(resp, i);
+    1310           0 :             return DLT_RETURN_ERROR;
+    1311             :         }
+    1312             : 
+    1313           9 :         for (j = 0; j < app->count_context_ids; j++) {
+    1314           6 :             con = &(app->context_id_info[j]);
+    1315             :             /* get con id */
+    1316           6 :             dlt_getloginfo_conv_ascii_to_id(rp,
+    1317             :                                             &rp_count,
+    1318           6 :                                             con->context_id,
+    1319             :                                             DLT_ID_SIZE);
+    1320             : 
+    1321             :             /* log_level */
+    1322           6 :             if ((resp->status == 4) || (resp->status == 6) || (resp->status == 7))
+    1323           6 :                 con->log_level = dlt_getloginfo_conv_ascii_to_int16_t(rp,
+    1324             :                                                                       &rp_count);
+    1325             : 
+    1326             :             /* trace status */
+    1327           6 :             if ((resp->status == 5) || (resp->status == 6) || (resp->status == 7))
+    1328           6 :                 con->trace_status = dlt_getloginfo_conv_ascii_to_int16_t(rp,
+    1329             :                                                                          &rp_count);
+    1330             : 
+    1331             :             /* context desc */
+    1332           6 :             if (resp->status == 7) {
+    1333           6 :                 con->len_context_description = (uint16_t) dlt_getloginfo_conv_ascii_to_uint16_t(rp,
+    1334             :                                                                                      &rp_count);
+    1335           6 :                 con->context_description = (char *)calloc
+    1336           6 :                         ((size_t) (con->len_context_description + 1), sizeof(char));
+    1337             : 
+    1338           6 :                 if (con->context_description == NULL) {
+    1339           0 :                     dlt_vlog(LOG_ERR, "%s: calloc failed for context description\n", __func__);
+    1340           0 :                     dlt_client_free_calloc_failed_get_log_info(resp, i);
+    1341           0 :                     return DLT_RETURN_ERROR;
+    1342             :                 }
+    1343             : 
+    1344           6 :                 dlt_getloginfo_conv_ascii_to_string(rp,
+    1345             :                                                 &rp_count,
+    1346             :                                                 con->context_description,
+    1347             :                                                 con->len_context_description);
+    1348             :             }
+    1349             :         }
+    1350             : 
+    1351             :         /* application desc */
+    1352           3 :         if (resp->status == 7) {
+    1353           3 :             app->len_app_description = (uint16_t) dlt_getloginfo_conv_ascii_to_uint16_t(rp,
+    1354             :                                                                              &rp_count);
+    1355           3 :             app->app_description = (char *)calloc
+    1356           3 :                     ((size_t) (app->len_app_description + 1), sizeof(char));
+    1357             : 
+    1358           3 :             if (app->app_description == NULL) {
+    1359           0 :                 dlt_vlog(LOG_ERR, "%s: calloc failed for application description\n", __func__);
+    1360           0 :                 dlt_client_free_calloc_failed_get_log_info(resp, i);
+    1361           0 :                 return DLT_RETURN_ERROR;
+    1362             :             }
+    1363             : 
+    1364           3 :             dlt_getloginfo_conv_ascii_to_string(rp,
+    1365             :                                             &rp_count,
+    1366             :                                             app->app_description,
+    1367             :                                             app->len_app_description);
+    1368             :         }
+    1369             :     }
+    1370             : 
+    1371             :     return DLT_RETURN_OK;
+    1372             : }
+    1373             : 
+    1374           2 : int dlt_client_cleanup_get_log_info(DltServiceGetLogInfoResponse *resp)
+    1375             : {
+    1376             :     AppIDsType app;
+    1377             :     int i = 0;
+    1378             :     int j = 0;
+    1379             : 
+    1380           2 :     if (resp == NULL)
+    1381             :         return DLT_RETURN_OK;
+    1382             : 
+    1383           5 :     for (i = 0; i < resp->log_info_type.count_app_ids; i++) {
+    1384           3 :         app = resp->log_info_type.app_ids[i];
+    1385             : 
+    1386           9 :         for (j = 0; j < app.count_context_ids; j++) {
+    1387           6 :             free(app.context_id_info[j].context_description);
+    1388           6 :             app.context_id_info[j].context_description = NULL;
+    1389             :         }
+    1390             : 
+    1391           3 :         free(app.context_id_info);
+    1392             :         app.context_id_info = NULL;
+    1393           3 :         free(app.app_description);
+    1394             :         app.app_description = NULL;
+    1395             :     }
+    1396             : 
+    1397           2 :     free(resp->log_info_type.app_ids);
+    1398             :     resp->log_info_type.app_ids = NULL;
+    1399             : 
+    1400           2 :     free(resp);
+    1401             :     resp = NULL;
+    1402             : 
+    1403           2 :     return DLT_RETURN_OK;
+    1404             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/lib/dlt_env_ll.c.func-sort-c.html b/dlt_lcov_report/lib/dlt_env_ll.c.func-sort-c.html new file mode 100644 index 000000000..e78470dc9 --- /dev/null +++ b/dlt_lcov_report/lib/dlt_env_ll.c.func-sort-c.html @@ -0,0 +1,120 @@ + + + + + + + LCOV - dlt_final_coverage.info - lib/dlt_env_ll.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - lib - dlt_env_ll.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:81326.1 %
Date:2024-12-05 09:07:13Functions:21216.7 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_env_extract_id0
dlt_env_extract_ll0
dlt_env_extract_ll_item0
dlt_env_extract_ll_set0
dlt_env_extract_symbolic_ll0
dlt_env_helper_to_lower0
dlt_env_ids_match0
dlt_env_increase_ll_set0
dlt_env_init_ll_set0
dlt_env_ll_item_get_matching_prio0
dlt_env_adjust_ll_from_env205
dlt_env_free_ll_set16786
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/lib/dlt_env_ll.c.func.html b/dlt_lcov_report/lib/dlt_env_ll.c.func.html new file mode 100644 index 000000000..1ce1433af --- /dev/null +++ b/dlt_lcov_report/lib/dlt_env_ll.c.func.html @@ -0,0 +1,120 @@ + + + + + + + LCOV - dlt_final_coverage.info - lib/dlt_env_ll.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - lib - dlt_env_ll.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:81326.1 %
Date:2024-12-05 09:07:13Functions:21216.7 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_env_adjust_ll_from_env205
dlt_env_extract_id0
dlt_env_extract_ll0
dlt_env_extract_ll_item0
dlt_env_extract_ll_set0
dlt_env_extract_symbolic_ll0
dlt_env_free_ll_set16786
dlt_env_helper_to_lower0
dlt_env_ids_match0
dlt_env_increase_ll_set0
dlt_env_init_ll_set0
dlt_env_ll_item_get_matching_prio0
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/lib/dlt_env_ll.c.gcov.html b/dlt_lcov_report/lib/dlt_env_ll.c.gcov.html new file mode 100644 index 000000000..04bb3f552 --- /dev/null +++ b/dlt_lcov_report/lib/dlt_env_ll.c.gcov.html @@ -0,0 +1,576 @@ + + + + + + + LCOV - dlt_final_coverage.info - lib/dlt_env_ll.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - lib - dlt_env_ll.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:81326.1 %
Date:2024-12-05 09:07:13Functions:21216.7 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2015  Intel Corporation
+       5             :  *
+       6             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       7             :  *
+       8             :  * This Source Code Form is subject to the terms of the
+       9             :  * Mozilla Public License (MPL), v. 2.0.
+      10             :  * If a copy of the MPL was not distributed with this file,
+      11             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      12             :  *
+      13             :  * For further information see http://www.covesa.org/.
+      14             :  */
+      15             : 
+      16             : /*!
+      17             :  * \author Stefan Vacek <stefan.vacek@intel.com> Intel Corporation
+      18             :  *
+      19             :  * \copyright Copyright © 2015 Intel Corporation. \n
+      20             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      21             :  *
+      22             :  * \file dlt_env_ll.c
+      23             :  */
+      24             : 
+      25             : #include "dlt_user.h"
+      26             : #include <string.h>
+      27             : #include <stdlib.h>
+      28             : 
+      29             : #define DLT_ENV_LL_SET_INCREASE 10
+      30             : 
+      31             : 
+      32             : /* a generic entry looks like:
+      33             :  * ll_item ::= apid:ctid:ll
+      34             :  * ll_set  ::= ll_item |
+      35             :  *             ll_set;ll_item
+      36             :  */
+      37             : 
+      38             : /**
+      39             :  * @brief extract id out of given string
+      40             :  *
+      41             :  * Extract 4-byte string out of given environment string, the pointer of the
+      42             :  * environment string is moved to the next un-used character and the extracted
+      43             :  * id is copied into \param id
+      44             :  *
+      45             :  * Example:
+      46             :  * env[] = "abcd:1234:3"
+      47             :  * char res[4u];
+      48             :  * char * tmp = &env[0];
+      49             :  * int ret = extract_id(&tmp, res);
+      50             :  * assert(ret == 0);
+      51             :  * assert(*tmp == ':');
+      52             :  * assert(res[3] == 'd');
+      53             :  *
+      54             :  * @param env    Environment variable
+      55             :  * @param id     Extracted ID
+      56             :  * @return 0 if successful, -1 else
+      57             :  */
+      58           0 : int dlt_env_extract_id(char **const env, char *id)
+      59             : {
+      60             :     int i;
+      61             : 
+      62           0 :     if (!env || !id) {
+      63             :         return -1;
+      64             :     }
+      65             : 
+      66           0 :     if (!(*env)) {
+      67             :         return -1;
+      68             :     }
+      69             : 
+      70             :     memset(id, 0, 4);
+      71             : 
+      72           0 :     for (i = 0; (i < 4) && (**env != ':') && (**env != 0); ++i) {
+      73           0 :         *id++ = *((*env)++);
+      74             :     }
+      75             : 
+      76             :     /* the next/last character must be ':' */
+      77           0 :     if ((0 != **env) && (':' == **env)) {
+      78           0 :         return 0;
+      79             :     }
+      80             : 
+      81             :     return -1;
+      82             : }
+      83             : 
+      84             : 
+      85             : /**
+      86             :  * @brief convert a given string to lower-case
+      87             :  *
+      88             :  * Stops end of string or if ';' is detected
+      89             :  */
+      90           0 : int dlt_env_helper_to_lower(char **const env, char *result, int const res_len)
+      91             : {
+      92             :     int count = 0;
+      93             :     char ch;
+      94             : 
+      95           0 :     if (!env || !result) {
+      96             :         return -1;
+      97             :     }
+      98             : 
+      99           0 :     if (!(*env)) {
+     100             :         return -1;
+     101             :     }
+     102             : 
+     103           0 :     ch = *(*env);
+     104             : 
+     105           0 :     while (ch && (count < res_len - 1) && (ch != ';')) {
+     106           0 :         if ((ch >= 'A') && (ch <= 'Z')) {
+     107           0 :             result[count] = ch + 'a' - 'A';
+     108             :         } else {
+     109           0 :             result[count] = ch;
+     110             :         }
+     111             : 
+     112           0 :         ch = *(++(*env));
+     113           0 :         ++count;
+     114             :     }
+     115             : 
+     116           0 :     result[count] = 0;
+     117             : 
+     118           0 :     if (!ch || (ch == ';')) { /* full input was parsed */
+     119             :         return 0;
+     120             :     } else {
+     121           0 :         return -1;
+     122             :     }
+     123             : }
+     124             : 
+     125             : 
+     126           0 : int dlt_env_extract_symbolic_ll(char **const env, int8_t *ll)
+     127           0 : {
+     128             :     char result[strlen("verbose") + 1];
+     129             : 
+     130           0 :     if (!env || !ll) {
+     131             :         return -1;
+     132             :     }
+     133             : 
+     134           0 :     if (!(*env)) {
+     135             :         return -1;
+     136             :     }
+     137             : 
+     138           0 :     if (dlt_env_helper_to_lower(env, &result[0], sizeof(result)) == 0) {
+     139           0 :         if (strncmp("default", result, sizeof(result)) == 0) {
+     140           0 :             *ll = -1;
+     141           0 :         } else if (strncmp("off", result, sizeof(result)) == 0) {
+     142           0 :             *ll = 0;
+     143           0 :         } else if (strncmp("fatal", result, sizeof(result)) == 0) {
+     144           0 :             *ll = 1;
+     145           0 :         } else if (strncmp("error", result, sizeof(result)) == 0) {
+     146           0 :             *ll = 2;
+     147           0 :         } else if (strncmp("warning", result, sizeof(result)) == 0) {
+     148           0 :             *ll = 3;
+     149           0 :         } else if (strncmp("info", result, sizeof(result)) == 0) {
+     150           0 :             *ll = 4;
+     151           0 :         } else if (strncmp("debug", result, sizeof(result)) == 0) {
+     152           0 :             *ll = 5;
+     153           0 :         } else if (strncmp("verbose", result, sizeof(result)) == 0) {
+     154           0 :             *ll = 6;
+     155             :         } else {
+     156             :             return -1;
+     157             :         }
+     158             : 
+     159           0 :         if (**env != 0) {
+     160           0 :             (*env)++;
+     161             :         }
+     162             : 
+     163           0 :         return 0;
+     164             :     } else {
+     165             :         return -1;
+     166             :     }
+     167             : }
+     168             : 
+     169             : 
+     170             : /**
+     171             :  * @brief extract log-level out of given string
+     172             :  *
+     173             :  * A valid log-level is a numeric value in the range of -1 .. 6, with:
+     174             :  * -1: default
+     175             :  *  0: off
+     176             :  *  1: fatal
+     177             :  *  2: error
+     178             :  *  3: warning
+     179             :  *  4: info
+     180             :  *  5: debug
+     181             :  *  6: verbose
+     182             :  * During parsing, the environment string is moved to the next un-used character and the extracted
+     183             :  * log-level is written into \param ll
+     184             :  *
+     185             :  * Example:
+     186             :  * env[] = "abcd:1234:6"
+     187             :  * int ll;
+     188             :  * char ** tmp = &env[10]; // tmp points to '6'!
+     189             :  * int ret = extract_ll(&tmp, &ll);
+     190             :  * assert(ret == 0);
+     191             :  * assert(*tmp == NULL);
+     192             :  * assert(ll == 6);
+     193             :  *
+     194             :  * @param env    Environment variable
+     195             :  * @param ll     Extracted log level
+     196             :  * @return 0 if successful, -1 else
+     197             :  */
+     198           0 : int dlt_env_extract_ll(char **const env, int8_t *ll)
+     199             : {
+     200           0 :     if (!env || !ll) {
+     201             :         return -1;
+     202             :     }
+     203             : 
+     204           0 :     if (!(*env)) {
+     205             :         return -1;
+     206             :     }
+     207             : 
+     208             :     /* extract number */
+     209           0 :     if (**env == '-') {
+     210           0 :         (*env)++;
+     211             : 
+     212           0 :         if (**env == '1') {
+     213           0 :             *ll = -1;
+     214           0 :             (*env)++;
+     215             :         }
+     216             :     } else {
+     217           0 :         if ((**env >= '0') && (**env < '7')) {
+     218           0 :             *ll = **env - '0';
+     219           0 :             (*env)++;
+     220           0 :         } else if (dlt_env_extract_symbolic_ll(env, ll) != 0) {
+     221             :             return -1;
+     222             :         }
+     223             :     }
+     224             : 
+     225             :     /* check end, either next char is NULL or ';' */
+     226           0 :     if ((**env == ';') || (**env == 0)) {
+     227           0 :         return 0;
+     228             :     }
+     229             : 
+     230             :     return -1;
+     231             : }
+     232             : 
+     233             : 
+     234             : /**
+     235             :  * @brief extract one item out of string
+     236             :  *
+     237             :  * @return 0 if successful, -1 else
+     238             :  */
+     239           0 : int dlt_env_extract_ll_item(char **const env, dlt_env_ll_item *const item)
+     240             : {
+     241             :     int ret = -1;
+     242             : 
+     243           0 :     if (!env || !item) {
+     244             :         return -1;
+     245             :     }
+     246             : 
+     247           0 :     if (!(*env)) {
+     248             :         return -1;
+     249             :     }
+     250             : 
+     251             :     memset(item, 0, sizeof(dlt_env_ll_item));
+     252           0 :     ret = dlt_env_extract_id(env, item->appId);
+     253             : 
+     254           0 :     if (ret == -1) {
+     255             :         return -1;
+     256             :     }
+     257             : 
+     258           0 :     (*env)++;
+     259           0 :     ret = dlt_env_extract_id(env, item->ctxId);
+     260             : 
+     261           0 :     if (ret == -1) {
+     262             :         return -1;
+     263             :     }
+     264             : 
+     265           0 :     (*env)++;
+     266           0 :     ret = dlt_env_extract_ll(env, &item->ll);
+     267             : 
+     268           0 :     if (ret == -1) {
+     269           0 :         return -1;
+     270             :     }
+     271             : 
+     272             :     return 0;
+     273             : }
+     274             : 
+     275             : 
+     276             : /**
+     277             :  * @brief initialize ll_set
+     278             :  *
+     279             :  * Must call release_ll_set before exit to release all memory
+     280             :  *
+     281             :  * @return -1 if memory could not be allocated
+     282             :  * @return 0 on success
+     283             :  */
+     284           0 : int dlt_env_init_ll_set(dlt_env_ll_set *const ll_set)
+     285             : {
+     286           0 :     if (!ll_set) {
+     287             :         return -1;
+     288             :     }
+     289             : 
+     290           0 :     ll_set->array_size = DLT_ENV_LL_SET_INCREASE;
+     291           0 :     ll_set->item = (dlt_env_ll_item *)malloc(sizeof(dlt_env_ll_item) * ll_set->array_size);
+     292             : 
+     293           0 :     if (!ll_set->item) {
+     294             :         /* should trigger a warning: no memory left */
+     295           0 :         ll_set->array_size = 0;
+     296           0 :         return -1;
+     297             :     }
+     298             : 
+     299           0 :     ll_set->num_elem = 0u;
+     300           0 :     return 0;
+     301             : }
+     302             : 
+     303             : 
+     304             : /**
+     305             :  * @brief release ll_set
+     306             :  */
+     307       16786 : void dlt_env_free_ll_set(dlt_env_ll_set *const ll_set)
+     308             : {
+     309       16786 :     if (!ll_set) {
+     310             :         return;
+     311             :     }
+     312             : 
+     313       16786 :     if (ll_set->item != NULL) {
+     314           0 :         free(ll_set->item);
+     315           0 :         ll_set->item = NULL;
+     316             :     }
+     317             : 
+     318       16786 :     ll_set->array_size = 0u;
+     319       16786 :     ll_set->num_elem = 0u;
+     320             : }
+     321             : 
+     322             : 
+     323             : /**
+     324             :  * @brief increase size of ll_set by LL_SET_INCREASE elements
+     325             :  *
+     326             :  * @return -1 if memory could not be allocated
+     327             :  * @return 0 on success
+     328             :  */
+     329           0 : int dlt_env_increase_ll_set(dlt_env_ll_set *const ll_set)
+     330             : {
+     331             :     dlt_env_ll_item *old_set;
+     332             :     size_t old_size;
+     333             : 
+     334           0 :     if (!ll_set) {
+     335             :         return -1;
+     336             :     }
+     337             : 
+     338           0 :     old_set = ll_set->item;
+     339           0 :     old_size = ll_set->array_size;
+     340             : 
+     341           0 :     ll_set->array_size += DLT_ENV_LL_SET_INCREASE;
+     342           0 :     ll_set->item = (dlt_env_ll_item *)malloc(sizeof(dlt_env_ll_item) * ll_set->array_size);
+     343             : 
+     344           0 :     if (!ll_set->item) {
+     345             :         /* should trigger a warning: no memory left */
+     346           0 :         ll_set->array_size -= DLT_ENV_LL_SET_INCREASE;
+     347           0 :         return -1;
+     348             :     } else {
+     349           0 :         memcpy(ll_set->item, old_set, sizeof(dlt_env_ll_item) * old_size);
+     350           0 :         free(old_set);
+     351           0 :         return 0;
+     352             :     }
+     353             : }
+     354             : 
+     355             : 
+     356             : /**
+     357             :  * @brief extract all items out of string
+     358             :  *
+     359             :  * The given set is initialized within this function (memory is allocated).
+     360             :  * Make sure, that the caller frees this memory when it is no longer needed!
+     361             :  *
+     362             :  * @return 0 if successful, -1 else
+     363             :  */
+     364           0 : int dlt_env_extract_ll_set(char **const env, dlt_env_ll_set *const ll_set)
+     365             : {
+     366           0 :     if (!env || !ll_set) {
+     367             :         return -1;
+     368             :     }
+     369             : 
+     370           0 :     if (!(*env)) {
+     371             :         return -1;
+     372             :     }
+     373             : 
+     374           0 :     if (dlt_env_init_ll_set(ll_set) == -1) {
+     375             :         return -1;
+     376             :     }
+     377             : 
+     378             :     do {
+     379           0 :         if (ll_set->num_elem == ll_set->array_size) {
+     380           0 :             if (dlt_env_increase_ll_set(ll_set) == -1) {
+     381             :                 return -1;
+     382             :             }
+     383             :         }
+     384             : 
+     385           0 :         if (dlt_env_extract_ll_item(env, &ll_set->item[ll_set->num_elem++]) == -1) {
+     386             :             return -1;
+     387             :         }
+     388             : 
+     389           0 :         if (**env == ';') {
+     390           0 :             (*env)++;
+     391             :         }
+     392           0 :     } while (**env != 0);
+     393             : 
+     394             :     return 0;
+     395             : }
+     396             : 
+     397             : 
+     398             : /**
+     399             :  * @brief check if two ids match
+     400             :  *
+     401             :  * @return 1 if matching, 0 if not
+     402             :  */
+     403           0 : int dlt_env_ids_match(char const *const a, char const *const b)
+     404             : {
+     405           0 :     if (a[0] != b[0]) {
+     406             :         return 0;
+     407             :     }
+     408             : 
+     409           0 :     if (a[1] != b[1]) {
+     410             :         return 0;
+     411             :     }
+     412             : 
+     413           0 :     if (a[2] != b[2]) {
+     414             :         return 0;
+     415             :     }
+     416             : 
+     417           0 :     if (a[3] != b[3]) {
+     418           0 :         return 0;
+     419             :     }
+     420             : 
+     421             :     return 1;
+     422             : }
+     423             : 
+     424             : 
+     425             : /**
+     426             :  * @brief check if (and how) apid and ctid match with given item
+     427             :  *
+     428             :  * Resulting priorities:
+     429             :  * - no apid, no ctid only ll given in item: use ll with prio 1
+     430             :  * - no apid, ctid matches: use ll with prio 2
+     431             :  * - no ctid, apid matches: use ll with prio 3
+     432             :  * - apid, ctid matches: use ll with prio 4
+     433             :  *
+     434             :  * In case of error, -1 is returned.
+     435             :  */
+     436           0 : int dlt_env_ll_item_get_matching_prio(dlt_env_ll_item const *const item,
+     437             :                                       char const *const apid,
+     438             :                                       char const *const ctid)
+     439             : {
+     440           0 :     if ((!item) || (!apid) || (!ctid)) {
+     441             :         return -1;
+     442             :     }
+     443             : 
+     444           0 :     if (item->appId[0] == 0) {
+     445           0 :         if (item->ctxId[0] == 0) {
+     446             :             return 1;
+     447           0 :         } else if (dlt_env_ids_match(item->ctxId, ctid)) {
+     448           0 :             return 2;
+     449             :         }
+     450           0 :     } else if (dlt_env_ids_match(item->appId, apid)) {
+     451           0 :         if (item->ctxId[0] == 0) {
+     452             :             return 3;
+     453           0 :         } else if (dlt_env_ids_match(item->ctxId, ctid)) {
+     454           0 :             return 4;
+     455             :         }
+     456             :     }
+     457             : 
+     458             :     return 0;
+     459             : }
+     460             : 
+     461             : 
+     462             : /**
+     463             :  * @brief adjust log-level based on values given through environment
+     464             :  *
+     465             :  * Iterate over the set of items, and find the best match (\see ll_item_get_matching_prio)
+     466             :  * For any item that matches, the one with the highest priority is selected and that
+     467             :  * log-level is returned.
+     468             :  *
+     469             :  * If no item matches or in case of error, the original log-level (\param ll) is returned
+     470             :  */
+     471         205 : int dlt_env_adjust_ll_from_env(dlt_env_ll_set const *const ll_set,
+     472             :                                char const *const apid,
+     473             :                                char const *const ctid,
+     474             :                                int const ll)
+     475             : {
+     476         205 :     if ((!ll_set) || (!apid) || (!ctid)) {
+     477             :         return ll;
+     478             :     }
+     479             : 
+     480             :     int res = ll;
+     481             :     int prio = 0; /* no match so far */
+     482             :     size_t i;
+     483             : 
+     484         205 :     for (i = 0; i < ll_set->num_elem; ++i) {
+     485           0 :         int p = dlt_env_ll_item_get_matching_prio(&ll_set->item[i], apid, ctid);
+     486             : 
+     487           0 :         if (p > prio) {
+     488             :             prio = p;
+     489           0 :             res = ll_set->item[i].ll;
+     490             : 
+     491           0 :             if (p == 4) { /* maximum reached, immediate return */
+     492           0 :                 return res;
+     493             :             }
+     494             :         }
+     495             :     }
+     496             : 
+     497             :     return res;
+     498             : }
+     499             : 
+     500             : 
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/lib/dlt_filetransfer.c.func-sort-c.html b/dlt_lcov_report/lib/dlt_filetransfer.c.func-sort-c.html new file mode 100644 index 000000000..5a81c3342 --- /dev/null +++ b/dlt_lcov_report/lib/dlt_filetransfer.c.func-sort-c.html @@ -0,0 +1,144 @@ + + + + + + + LCOV - dlt_final_coverage.info - lib/dlt_filetransfer.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - lib - dlt_filetransfer.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:01990.0 %
Date:2024-12-05 09:07:13Functions:0180.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
checkUserBufferForFreeSpace0
dlt_user_log_file_complete0
dlt_user_log_file_data0
dlt_user_log_file_data_cancelable0
dlt_user_log_file_end0
dlt_user_log_file_errorMessage0
dlt_user_log_file_header0
dlt_user_log_file_header_alias0
dlt_user_log_file_infoAbout0
dlt_user_log_file_packagesCount0
doRemoveFile0
doTimeout0
getFileCreationDate0
getFileCreationDate20
getFileSerialNumber0
getFilesize0
isFile0
stringHash0
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/lib/dlt_filetransfer.c.func.html b/dlt_lcov_report/lib/dlt_filetransfer.c.func.html new file mode 100644 index 000000000..cc96e0d83 --- /dev/null +++ b/dlt_lcov_report/lib/dlt_filetransfer.c.func.html @@ -0,0 +1,144 @@ + + + + + + + LCOV - dlt_final_coverage.info - lib/dlt_filetransfer.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - lib - dlt_filetransfer.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:01990.0 %
Date:2024-12-05 09:07:13Functions:0180.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
checkUserBufferForFreeSpace0
dlt_user_log_file_complete0
dlt_user_log_file_data0
dlt_user_log_file_data_cancelable0
dlt_user_log_file_end0
dlt_user_log_file_errorMessage0
dlt_user_log_file_header0
dlt_user_log_file_header_alias0
dlt_user_log_file_infoAbout0
dlt_user_log_file_packagesCount0
doRemoveFile0
doTimeout0
getFileCreationDate0
getFileCreationDate20
getFileSerialNumber0
getFilesize0
isFile0
stringHash0
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/lib/dlt_filetransfer.c.gcov.html b/dlt_lcov_report/lib/dlt_filetransfer.c.gcov.html new file mode 100644 index 000000000..feadcca8e --- /dev/null +++ b/dlt_lcov_report/lib/dlt_filetransfer.c.gcov.html @@ -0,0 +1,856 @@ + + + + + + + LCOV - dlt_final_coverage.info - lib/dlt_filetransfer.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - lib - dlt_filetransfer.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:01990.0 %
Date:2024-12-05 09:07:13Functions:0180.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2011-2015, BMW AG
+       5             :  *
+       6             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       7             :  *
+       8             :  * This Source Code Form is subject to the terms of the
+       9             :  * Mozilla Public License (MPL), v. 2.0.
+      10             :  * If a copy of the MPL was not distributed with this file,
+      11             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      12             :  *
+      13             :  * For further information see http://www.covesa.org/.
+      14             :  */
+      15             : 
+      16             : /*!
+      17             :  * \author Alexander Wenzel <alexander.aw.wenzel@bmw.de>
+      18             :  *
+      19             :  * \copyright Copyright © 2011-2015 BMW AG. \n
+      20             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      21             :  *
+      22             :  * \file dlt_filetransfer.c
+      23             :  */
+      24             : 
+      25             : /*******************************************************************************
+      26             : **                                                                            **
+      27             : **  SRC-MODULE: dlt-test-client.c                                             **
+      28             : **                                                                            **
+      29             : **  TARGET    : linux                                                         **
+      30             : **                                                                            **
+      31             : **  PROJECT   : DLT                                                           **
+      32             : **                                                                            **
+      33             : **  AUTHOR    : Alexander Wenzel Alexander.AW.Wenzel@bmw.de                   **
+      34             : **                                                                            **
+      35             : **  PURPOSE   :                                                               **
+      36             : **                                                                            **
+      37             : **  REMARKS   :                                                               **
+      38             : **                                                                            **
+      39             : **  PLATFORM DEPENDANT [yes/no]: yes                                          **
+      40             : **                                                                            **
+      41             : **  TO BE CHANGED BY USER [yes/no]: no                                        **
+      42             : **                                                                            **
+      43             : *******************************************************************************/
+      44             : 
+      45             : /*******************************************************************************
+      46             : **                      Author Identity                                       **
+      47             : ********************************************************************************
+      48             : **                                                                            **
+      49             : ** Initials     Name                       Company                            **
+      50             : ** --------     -------------------------  ---------------------------------- **
+      51             : **  aw          Alexander Wenzel           BMW                                **
+      52             : *******************************************************************************/
+      53             : 
+      54             : #include <errno.h>
+      55             : #include <stdio.h>
+      56             : #include <string.h>
+      57             : #include "dlt_filetransfer.h"
+      58             : #include "dlt_common.h"
+      59             : #include "dlt_user_macros.h"
+      60             : 
+      61             : /*!Defines the buffer size of a single file package which will be logged to dlt */
+      62             : #define BUFFER_SIZE 1024
+      63             : 
+      64             : /*!Defines the minimum timeout between two dlt logs. This is important because dlt should not be flooded with too many logs in a short period of time. */
+      65             : #define MIN_TIMEOUT 20
+      66             : 
+      67             : 
+      68             : #define DLT_FILETRANSFER_TRANSFER_ALL_PACKAGES INT_MAX
+      69             : 
+      70             : #define NANOSEC_PER_MILLISEC 1000000
+      71             : #define NANOSEC_PER_SEC 1000000000
+      72             : 
+      73             : 
+      74             : /*!Buffer for dlt file transfer. The size is defined by BUFFER_SIZE */
+      75             : unsigned char buffer[BUFFER_SIZE];
+      76             : 
+      77             : 
+      78             : /*!Get some information about the file size of a file */
+      79             : /**See stat(2) for more informations.
+      80             :  * @param file Absolute file path
+      81             :  * @param ok Result of stat
+      82             :  * @return Returns the size of the file (if it is a regular file or a symbolic link) in bytes.
+      83             :  */
+      84           0 : uint32_t getFilesize(const char *file, int *ok)
+      85             : {
+      86             :     struct stat st;
+      87             : 
+      88           0 :     if (-1 == stat(file, &st)) {
+      89             :         /*we can only return 0, as the value is unsigned */
+      90           0 :         *ok = 0;
+      91           0 :         return 0;
+      92             :     }
+      93             : 
+      94           0 :     *ok = 1;
+      95           0 :     return (uint32_t)st.st_size;
+      96             : }
+      97             : 
+      98             : /** A simple Hash function for C-strings
+      99             :  * @param str input string. E.g. a file path.
+     100             :  * @param hash start and result value for hash computation
+     101             :  *
+     102             :  */
+     103           0 : void stringHash(const char *str, uint32_t *hash)
+     104             : {
+     105           0 :     if (!str || !hash) {
+     106             :         return;
+     107             :     }
+     108             : 
+     109           0 :     unsigned int len = strlen(str);
+     110             : 
+     111             :     unsigned int i = 0;
+     112             : 
+     113           0 :     if (len <= 0) {
+     114             :         return;
+     115             :     }
+     116             : 
+     117           0 :     for (i = 0; i < len; i++) {
+     118           0 :         *hash = 53 * *hash + str[i];
+     119             :     }
+     120             : }
+     121             : 
+     122             : 
+     123             : /*!Get some information about the file serial number of a file */
+     124             : /** See stat(2) for more informations.
+     125             :  * @param file Absolute file path
+     126             :  * @param ok *ok == 0 -> error; *ok == 1 -> ok
+     127             :  * @return Returns a unique number associated with each filename
+     128             :  */
+     129           0 : uint32_t getFileSerialNumber(const char *file, int *ok)
+     130             : {
+     131             :     struct stat st;
+     132             :     uint32_t ret;
+     133             : 
+     134           0 :     if (-1 == stat(file, &st)) {
+     135           0 :         *ok = 0;
+     136           0 :         ret = 0;
+     137             :     } else {
+     138           0 :         *ok = 1;
+     139           0 :         ret = st.st_ino;
+     140           0 :         ret = ret << (sizeof(ret) * 8) / 2;
+     141           0 :         ret |= st.st_size;
+     142           0 :         ret ^= st.st_ctime;
+     143           0 :         stringHash(file, &ret);
+     144             :     }
+     145             : 
+     146           0 :     return ret;
+     147             : }
+     148             : 
+     149             : /*!Returns the creation date of a file */
+     150             : /** See stat(2) for more informations.
+     151             :  * @param file Absolute file path
+     152             :  * @param ok Result of stat
+     153             :  * @return Returns the creation date of a file
+     154             :  */
+     155           0 : time_t getFileCreationDate(const char *file, int *ok)
+     156             : {
+     157             :     struct stat st;
+     158             : 
+     159           0 :     if (-1 == stat(file, &st)) {
+     160           0 :         *ok = 0;
+     161           0 :         return 0;
+     162             :     }
+     163             : 
+     164           0 :     *ok = 1;
+     165           0 :     return st.st_ctime;
+     166             : }
+     167             : 
+     168             : /*!Returns the creation date of a file */
+     169             : /** Format of the creation date is Day Mon dd hh:mm:ss yyyy
+     170             :  * @param file Absolute file path
+     171             :  * @param ok Result of stat
+     172             :  * @param date Local time
+     173             :  * @return Returns the creation date of a file
+     174             :  */
+     175           0 : void getFileCreationDate2(const char *file, int *ok, char *date)
+     176             : {
+     177             :     struct stat st;
+     178             :     struct tm ts;
+     179             : 
+     180           0 :     if (-1 == stat(file, &st)) {
+     181           0 :         *ok = 0;
+     182             :         date = 0;
+     183           0 :         return;
+     184             :     }
+     185             : 
+     186           0 :     *ok = 1;
+     187           0 :     tzset();
+     188           0 :     localtime_r(&st.st_ctime, &ts);
+     189           0 :     asctime_r(&ts, date);
+     190             : }
+     191             : 
+     192             : /*!Checks if the file exists */
+     193             : /**@param file Absolute file path
+     194             :  * @return Returns 1 if the file exists, 0 if the file does not exist
+     195             :  */
+     196           0 : int isFile (const char *file)
+     197             : {
+     198             :     struct stat st;
+     199           0 :     return stat (file, &st) == 0;
+     200             : }
+     201             : 
+     202             : /*!Waits a period of time */
+     203             : /**Waits a period of time. The minimal time to wait is MIN_TIMEOUT. This makes sure that the FIFO of dlt is not flooded.
+     204             :  * @param timeout Timeout to in ms but can not be smaller as MIN_TIMEOUT
+     205             :  */
+     206           0 : void doTimeout(int timeout)
+     207             : {
+     208             :     struct timespec ts;
+     209           0 :     ts.tv_sec = (timeout * NANOSEC_PER_MILLISEC) / NANOSEC_PER_SEC;
+     210           0 :     ts.tv_nsec = (timeout * NANOSEC_PER_MILLISEC) % NANOSEC_PER_SEC;
+     211           0 :     nanosleep(&ts, NULL);
+     212           0 : }
+     213             : 
+     214             : /*!Checks free space of the user buffer */
+     215             : /**
+     216             :  * @return -1 if more than 50% space in the user buffer is free. Otherwise 1 will be returned.
+     217             :  */
+     218           0 : int checkUserBufferForFreeSpace()
+     219             : {
+     220             :     int total_size, used_size;
+     221             : 
+     222           0 :     dlt_user_check_buffer(&total_size, &used_size);
+     223             : 
+     224           0 :     if ((total_size - used_size) < (total_size / 2)) {
+     225           0 :         return -1;
+     226             :     }
+     227             : 
+     228             :     return 1;
+     229             : }
+     230             : 
+     231             : /*!Deletes the given file */
+     232             : /**
+     233             :  * @param filename Absolute file path
+     234             :  * @return If the file is successfully deleted, a zero value is returned.If the file can not be deleted a nonzero value is returned.
+     235             :  */
+     236           0 : int doRemoveFile(const char *filename)
+     237             : {
+     238           0 :     return remove(filename);
+     239             : }
+     240             : 
+     241           0 : void dlt_user_log_file_errorMessage(DltContext *fileContext, const char *filename, int errorCode)
+     242             : {
+     243             : 
+     244           0 :     if (errno != ENOENT) {
+     245           0 :         int ok = 0;
+     246           0 :         uint32_t fserial = getFileSerialNumber(filename, &ok);
+     247             : 
+     248           0 :         if (!ok) {
+     249           0 :             DLT_LOG(*fileContext, DLT_LOG_ERROR,
+     250             :                     DLT_STRING("dlt_user_log_file_errorMessage, error in getFileSerialNumber for: "),
+     251             :                     DLT_STRING(filename));
+     252             :         }
+     253             : 
+     254           0 :         uint32_t fsize = getFilesize(filename, &ok);
+     255             : 
+     256           0 :         if (!ok) {
+     257           0 :             DLT_LOG(*fileContext,
+     258             :                     DLT_LOG_ERROR,
+     259             :                     DLT_STRING("dlt_user_log_file_errorMessage, error in getFilesize for: "),
+     260             :                     DLT_STRING(filename));
+     261             :         }
+     262             : 
+     263           0 :         char fcreationdate[50] = {0};
+     264           0 :         getFileCreationDate2(filename, &ok, fcreationdate);
+     265             : 
+     266           0 :         if (!ok) {
+     267           0 :             DLT_LOG(*fileContext,
+     268             :                     DLT_LOG_ERROR,
+     269             :                     DLT_STRING("dlt_user_log_file_errorMessage, error in getFilesize for: "),
+     270             :                     DLT_STRING(filename));
+     271             :         }
+     272             : 
+     273           0 :         int package_count = dlt_user_log_file_packagesCount(fileContext, filename);
+     274             : 
+     275           0 :         DLT_LOG(*fileContext, DLT_LOG_ERROR,
+     276             :                 DLT_STRING("FLER"),
+     277             :                 DLT_INT(errorCode),
+     278             :                 DLT_INT(-errno),
+     279             :                 DLT_UINT(fserial),
+     280             :                 DLT_STRING(filename),
+     281             :                 DLT_UINT(fsize),
+     282             :                 DLT_STRING(fcreationdate),
+     283             :                 DLT_INT(package_count),
+     284             :                 DLT_UINT(BUFFER_SIZE),
+     285             :                 DLT_STRING("FLER")
+     286             :                 );
+     287             :     } else {
+     288           0 :         DLT_LOG(*fileContext, DLT_LOG_ERROR,
+     289             :                 DLT_STRING("FLER"),
+     290             :                 DLT_INT(errorCode),
+     291             :                 DLT_INT(-errno),
+     292             :                 DLT_STRING(filename),
+     293             :                 DLT_STRING("FLER")
+     294             :                 );
+     295             :     }
+     296           0 : }
+     297             : 
+     298             : 
+     299             : 
+     300             : /*!Logs specific file inforamtions to dlt */
+     301             : /**The filename, file size, file serial number and the number of packages will be logged to dlt.
+     302             :  * @param fileContext Specific context
+     303             :  * @param filename Absolute file path
+     304             :  * @return Returns 0 if everything was okey.If there was a failure a value < 0 will be returned.
+     305             :  */
+     306           0 : int dlt_user_log_file_infoAbout(DltContext *fileContext, const char *filename)
+     307             : {
+     308             : 
+     309           0 :     if (isFile(filename)) {
+     310             :         int ok;
+     311             : 
+     312           0 :         uint32_t fsize = getFilesize(filename, &ok);
+     313             : 
+     314           0 :         if (!ok) {
+     315           0 :             DLT_LOG(*fileContext,
+     316             :                     DLT_LOG_ERROR,
+     317             :                     DLT_STRING("dlt_user_log_file_infoAbout, Error getting size of file:"),
+     318             :                     DLT_STRING(filename));
+     319             :         }
+     320             : 
+     321           0 :         uint32_t fserialnumber = getFileSerialNumber(filename, &ok);
+     322             : 
+     323           0 :         if (!ok) {
+     324           0 :             DLT_LOG(*fileContext,
+     325             :                     DLT_LOG_ERROR,
+     326             :                     DLT_STRING("dlt_user_log_file_infoAbout, Error getting serial number of file:"),
+     327             :                     DLT_STRING(filename));
+     328             :         }
+     329             : 
+     330           0 :         char creationdate[50] = {0};
+     331           0 :         getFileCreationDate2(filename, &ok, creationdate);
+     332             : 
+     333           0 :         if (!ok) {
+     334           0 :             DLT_LOG(*fileContext,
+     335             :                     DLT_LOG_ERROR,
+     336             :                     DLT_STRING("dlt_user_log_file_infoAbout, Error getting creation date of file:"),
+     337             :                     DLT_STRING(filename));
+     338             :         }
+     339             : 
+     340           0 :         DLT_LOG(*fileContext, DLT_LOG_INFO,
+     341             :                 DLT_STRING("FLIF"),
+     342             :                 DLT_STRING("file serialnumber"), DLT_UINT(fserialnumber),
+     343             :                 DLT_STRING("filename"), DLT_STRING(filename),
+     344             :                 DLT_STRING("file size in bytes"), DLT_UINT(fsize),
+     345             :                 DLT_STRING("file creation date"), DLT_STRING(creationdate),
+     346             :                 DLT_STRING("number of packages"),
+     347             :                 DLT_UINT(dlt_user_log_file_packagesCount(fileContext, filename)),
+     348             :                 DLT_STRING("FLIF")
+     349             :                 );
+     350             :         return 0;
+     351             :     } else {
+     352           0 :         dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_INFO_ABOUT);
+     353           0 :         return DLT_FILETRANSFER_ERROR_INFO_ABOUT;
+     354             :     }
+     355             : }
+     356             : 
+     357             : /*!Transfer the complete file as several dlt logs. */
+     358             : /**This method transfer the complete file as several dlt logs. At first it will be checked that the file exist.
+     359             :  * In the next step some generic informations about the file will be logged to dlt.
+     360             :  * Now the header will be logged to dlt. See the method dlt_user_log_file_header for more informations.
+     361             :  * Then the method dlt_user_log_data will be called with the parameter to log all packages in a loop with some timeout.
+     362             :  * At last dlt_user_log_end is called to signal that the complete file transfer was okey. This is important for the plugin of the dlt viewer.
+     363             :  * @param fileContext Specific context to log the file to dlt
+     364             :  * @param filename Absolute file path
+     365             :  * @param deleteFlag Flag if the file will be deleted after transfer. 1->delete, 0->notDelete
+     366             :  * @param timeout Timeout in ms to wait between some logs. Important that the FIFO of dlt will not be flooded with to many messages in a short period of time.
+     367             :  * @return Returns 0 if everything was okey. If there was a failure a value < 0 will be returned.
+     368             :  */
+     369           0 : int dlt_user_log_file_complete(DltContext *fileContext,
+     370             :                                const char *filename,
+     371             :                                int deleteFlag,
+     372             :                                int timeout)
+     373             : {
+     374           0 :     if (!isFile(filename)) {
+     375           0 :         dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_FILE_COMPLETE);
+     376           0 :         return DLT_FILETRANSFER_ERROR_FILE_COMPLETE;
+     377             :     }
+     378             : 
+     379           0 :     if (dlt_user_log_file_header(fileContext, filename) != 0) {
+     380             :         return DLT_FILETRANSFER_ERROR_FILE_COMPLETE1;
+     381             :     }
+     382             : 
+     383           0 :     if (dlt_user_log_file_data(fileContext, filename, DLT_FILETRANSFER_TRANSFER_ALL_PACKAGES,
+     384             :                                timeout) != 0) {
+     385             :         return DLT_FILETRANSFER_ERROR_FILE_COMPLETE2;
+     386             :     }
+     387             : 
+     388           0 :     if (dlt_user_log_file_end(fileContext, filename, deleteFlag) != 0) {
+     389           0 :         return DLT_FILETRANSFER_ERROR_FILE_COMPLETE3;
+     390             :     }
+     391             : 
+     392             :     return 0;
+     393             : }
+     394             : 
+     395             : /*!This method gives information about the number of packages the file have */
+     396             : /**Every file will be divided into several packages. Every package will be logged as a single dlt log.
+     397             :  * The number of packages depends on the BUFFER_SIZE.
+     398             :  * At first it will be checked if the file exist. Then the file will be divided into
+     399             :  * several packages depending on the buffer size.
+     400             :  * @param fileContext Specific context to log the file to dlt
+     401             :  * @param filename Absolute file path
+     402             :  * @return Returns the number of packages if everything was okey. If there was a failure a value < 0 will be returned.
+     403             :  */
+     404           0 : int dlt_user_log_file_packagesCount(DltContext *fileContext, const char *filename)
+     405             : {
+     406             :     int packages;
+     407             :     uint32_t filesize;
+     408             : 
+     409           0 :     if (isFile(filename)) {
+     410             :         packages = 1;
+     411             :         int ok;
+     412           0 :         filesize = getFilesize(filename, &ok);
+     413             : 
+     414           0 :         if (!ok) {
+     415           0 :             DLT_LOG(*fileContext,
+     416             :                     DLT_LOG_ERROR,
+     417             :                     DLT_STRING("Error in: dlt_user_log_file_packagesCount, isFile"),
+     418             :                     DLT_STRING(filename),
+     419             :                     DLT_INT(DLT_FILETRANSFER_ERROR_PACKAGE_COUNT));
+     420           0 :             return -1;
+     421             :         }
+     422             : 
+     423           0 :         if (filesize < BUFFER_SIZE) {
+     424             :             return packages;
+     425             :         } else {
+     426           0 :             packages = filesize / BUFFER_SIZE;
+     427             : 
+     428           0 :             if (filesize % BUFFER_SIZE == 0) {
+     429             :                 return packages;
+     430             :             } else {
+     431           0 :                 return packages + 1;
+     432             :             }
+     433             :         }
+     434             :     } else {
+     435           0 :         DLT_LOG(*fileContext,
+     436             :                 DLT_LOG_ERROR,
+     437             :                 DLT_STRING("Error in: dlt_user_log_file_packagesCount, !isFile"),
+     438             :                 DLT_STRING(filename),
+     439             :                 DLT_INT(DLT_FILETRANSFER_ERROR_PACKAGE_COUNT));
+     440           0 :         return -1;
+     441             :     }
+     442             : }
+     443             : 
+     444             : /*!Transfer the head of the file as a dlt logs. */
+     445             : /**The head of the file must be logged to dlt because the head contains inforamtion about the file serial number,
+     446             :  * the file name, the file size, package number the file have and the buffer size.
+     447             :  * All these informations are needed from the plugin of the dlt viewer.
+     448             :  * See the Mainpages.c for more informations.
+     449             :  * @param fileContext Specific context to log the file to dlt
+     450             :  * @param filename Absolute file path
+     451             :  * @param alias Alias for the file. An alternative name to show in the receiving end
+     452             :  * @return Returns 0 if everything was okey. If there was a failure a value < 0 will be returned.
+     453             :  */
+     454           0 : int dlt_user_log_file_header_alias(DltContext *fileContext, const char *filename, const char *alias)
+     455             : {
+     456             : 
+     457           0 :     if (isFile(filename)) {
+     458             :         int ok;
+     459             : 
+     460           0 :         uint32_t fserialnumber = getFileSerialNumber(filename, &ok);
+     461             : 
+     462           0 :         if (!ok) {
+     463           0 :             DLT_LOG(*fileContext, DLT_LOG_ERROR,
+     464             :                     DLT_STRING(
+     465             :                         "dlt_user_log_file_header_alias, Error getting serial number of file:"),
+     466             :                     DLT_STRING(filename));
+     467           0 :             return DLT_FILETRANSFER_FILE_SERIAL_NUMBER;
+     468             :         }
+     469             : 
+     470           0 :         uint32_t fsize = getFilesize(filename, &ok);
+     471             : 
+     472           0 :         if (!ok) {
+     473           0 :             DLT_LOG(*fileContext, DLT_LOG_ERROR,
+     474             :                     DLT_STRING(
+     475             :                         "dlt_user_log_file_header_alias, Error getting size of file:"),
+     476             :                     DLT_STRING(filename));
+     477             :         }
+     478             : 
+     479           0 :         char fcreationdate[50] = {0};
+     480           0 :         getFileCreationDate2(filename, &ok, fcreationdate);
+     481             : 
+     482           0 :         if (!ok) {
+     483           0 :             DLT_LOG(*fileContext, DLT_LOG_ERROR,
+     484             :                     DLT_STRING(
+     485             :                         "dlt_user_log_file_header_alias, Error getting creation date of file:"),
+     486             :                     DLT_STRING(filename));
+     487             :         }
+     488             : 
+     489           0 :         DLT_LOG(*fileContext, DLT_LOG_INFO,
+     490             :                 DLT_STRING("FLST"),
+     491             :                 DLT_UINT(fserialnumber),
+     492             :                 DLT_STRING(alias),
+     493             :                 DLT_UINT(fsize),
+     494             :                 DLT_STRING(fcreationdate);
+     495             :                 DLT_UINT(dlt_user_log_file_packagesCount(fileContext, filename)),
+     496             :                 DLT_UINT(BUFFER_SIZE),
+     497             :                 DLT_STRING("FLST")
+     498             :                 );
+     499             : 
+     500           0 :         return 0;
+     501             :     } else {
+     502           0 :         dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_FILE_HEAD);
+     503           0 :         return DLT_FILETRANSFER_ERROR_FILE_HEAD;
+     504             :     }
+     505             : }
+     506             : 
+     507             : /*!Transfer the head of the file as a dlt logs. */
+     508             : /**The head of the file must be logged to dlt because the head contains inforamtion about the file serial number,
+     509             :  * the file name, the file size, package number the file have and the buffer size.
+     510             :  * All these informations are needed from the plugin of the dlt viewer.
+     511             :  * See the Mainpages.c for more informations.
+     512             :  * @param fileContext Specific context to log the file to dlt
+     513             :  * @param filename Absolute file path
+     514             :  * @return Returns 0 if everything was okey. If there was a failure a value < 0 will be returned.
+     515             :  */
+     516           0 : int dlt_user_log_file_header(DltContext *fileContext, const char *filename)
+     517             : {
+     518             : 
+     519           0 :     if (isFile(filename)) {
+     520             :         int ok;
+     521             : 
+     522           0 :         uint32_t fserialnumber = getFileSerialNumber(filename, &ok);
+     523             : 
+     524           0 :         if (!ok) {
+     525           0 :             DLT_LOG(*fileContext, DLT_LOG_ERROR,
+     526             :                     DLT_STRING(
+     527             :                         "dlt_user_log_file_header, Error getting serial number of file:"),
+     528             :                     DLT_STRING(filename));
+     529             :         }
+     530             : 
+     531           0 :         uint32_t fsize = getFilesize(filename, &ok);
+     532             : 
+     533           0 :         if (!ok) {
+     534           0 :             DLT_LOG(*fileContext,
+     535             :                     DLT_LOG_ERROR,
+     536             :                     DLT_STRING("dlt_user_log_file_header, Error getting size of file:"),
+     537             :                     DLT_STRING(filename));
+     538             :         }
+     539             : 
+     540           0 :         char fcreationdate[50] = {0};
+     541           0 :         getFileCreationDate2(filename, &ok, fcreationdate);
+     542             : 
+     543           0 :         if (!ok) {
+     544           0 :             DLT_LOG(*fileContext, DLT_LOG_ERROR,
+     545             :                     DLT_STRING(
+     546             :                         "dlt_user_log_file_header, Error getting creation date of file:"),
+     547             :                     DLT_STRING(filename));
+     548             :         }
+     549             : 
+     550           0 :         DLT_LOG(*fileContext, DLT_LOG_INFO,
+     551             :                 DLT_STRING("FLST"),
+     552             :                 DLT_UINT(fserialnumber),
+     553             :                 DLT_STRING(filename),
+     554             :                 DLT_UINT(fsize),
+     555             :                 DLT_STRING(fcreationdate);
+     556             :                 DLT_UINT(dlt_user_log_file_packagesCount(fileContext, filename)),
+     557             :                 DLT_UINT(BUFFER_SIZE),
+     558             :                 DLT_STRING("FLST")
+     559             :                 );
+     560             : 
+     561             :         return 0;
+     562             :     } else {
+     563           0 :         dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_FILE_HEAD);
+     564           0 :         return DLT_FILETRANSFER_ERROR_FILE_HEAD;
+     565             :     }
+     566             : }
+     567             : 
+     568             : /*!Transfer the content data of a file. */
+     569             : /**See the Mainpages.c for more informations.
+     570             :  * @param fileContext Specific context to log the file to dlt
+     571             :  * @param filename Absolute file path
+     572             :  * @param packageToTransfer Package number to transfer. If this param is LONG_MAX, the whole file will be transferred with a specific timeout
+     573             :  * @param timeout Timeout to wait between dlt logs. Important because the dlt FIFO should not be flooded. Default is defined by MIN_TIMEOUT. The given timeout in ms can not be smaller than MIN_TIMEOUT.
+     574             :  * @return Returns 0 if everything was okey. If there was a failure a value < 0 will be returned.
+     575             :  */
+     576           0 : int dlt_user_log_file_data(DltContext *fileContext,
+     577             :                            const char *filename,
+     578             :                            int packageToTransfer,
+     579             :                            int timeout)
+     580             : {
+     581           0 :     bool fileCancelTransferFlag = false;
+     582           0 :     return dlt_user_log_file_data_cancelable(fileContext, filename, packageToTransfer, timeout, &fileCancelTransferFlag);
+     583             : }
+     584             : 
+     585             : /* !Transfer the content data of a cancelable file*/
+     586             : /**See the Mainpages.c for more informations.
+     587             :  * @param fileContext Specific context to log the file to dlt
+     588             :  * @param filename Absolute file path
+     589             :  * @param packageToTransfer Package number to transfer. If this param is LONG_MAX, the whole file will be transferred with a specific timeout
+     590             :  * @param timeout Timeout to wait between dlt logs. Important because the dlt FIFO should not be flooded. Default is defined by MIN_TIMEOUT. The given timeout in ms can not be smaller than MIN_TIMEOUT.
+     591             :  * @param fileCancelTransferFlag is a bool pointer to cancel the filetransfer on demand. For example in case of application shutdown event outstanding file transfer should abort and return
+     592             :  * @return Returns 0 if everything was okey. If there was a failure value < 0 will be returned.
+     593             :  */
+     594           0 : int dlt_user_log_file_data_cancelable(DltContext *fileContext,
+     595             :                            const char *filename,
+     596             :                            int packageToTransfer,
+     597             :                            int timeout,
+     598             :                            bool *const fileCancelTransferFlag)
+     599             : {
+     600             :     FILE *file;
+     601             :     int pkgNumber;
+     602             :     uint32_t readBytes;
+     603             : 
+     604           0 :     if (isFile(filename)) {
+     605             : 
+     606           0 :         file = fopen (filename, "rb");
+     607             : 
+     608           0 :         if (file == NULL) {
+     609           0 :             dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_FILE_DATA);
+     610           0 :             return DLT_FILETRANSFER_ERROR_FILE_DATA;
+     611             :         }
+     612             : 
+     613           0 :         if (((packageToTransfer != DLT_FILETRANSFER_TRANSFER_ALL_PACKAGES) &&
+     614             :              (packageToTransfer >
+     615           0 :               dlt_user_log_file_packagesCount(fileContext,
+     616           0 :                                               filename))) || (packageToTransfer <= 0)) {
+     617           0 :             DLT_LOG(*fileContext, DLT_LOG_ERROR,
+     618             :                     DLT_STRING("Error at dlt_user_log_file_data: packageToTransfer out of scope"),
+     619             :                     DLT_STRING("packageToTransfer:"),
+     620             :                     DLT_UINT(packageToTransfer),
+     621             :                     DLT_STRING("numberOfMaximalPackages:"),
+     622             :                     DLT_UINT(dlt_user_log_file_packagesCount(fileContext, filename)),
+     623             :                     DLT_STRING("for File:"),
+     624             :                     DLT_STRING(filename)
+     625             :                     );
+     626           0 :             fclose(file);
+     627           0 :             return DLT_FILETRANSFER_ERROR_FILE_DATA;
+     628             :         }
+     629             : 
+     630             :         readBytes = 0;
+     631             : 
+     632           0 :         if (packageToTransfer != DLT_FILETRANSFER_TRANSFER_ALL_PACKAGES) {
+     633             : /*                If a single package should be transferred. The user has to check that the free space in the user buffer > 50% */
+     634             : /*                if(checkUserBufferForFreeSpace()<0) */
+     635             : /*                    return DLT_FILETRANSFER_ERROR_FILE_DATA_USER_BUFFER_FAILED; */
+     636             : 
+     637           0 :             if (0 != fseek (file, (packageToTransfer - 1) * BUFFER_SIZE, SEEK_SET)) {
+     638           0 :                 DLT_LOG(*fileContext, DLT_LOG_ERROR,
+     639             :                         DLT_STRING("failed to fseek in file: "),
+     640             :                         DLT_STRING(filename),
+     641             :                         DLT_STRING("ferror:"),
+     642             :                         DLT_INT(ferror(file))
+     643             :                         );
+     644             : 
+     645           0 :                 fclose (file);
+     646           0 :                 return -1;
+     647             :             }
+     648             : 
+     649             :             readBytes = fread(buffer, sizeof(char), BUFFER_SIZE, file);
+     650             :             int ok;
+     651             : 
+     652           0 :             uint32_t fserial = getFileSerialNumber(filename, &ok);
+     653             : 
+     654           0 :             if (1 != ok) {
+     655           0 :                 DLT_LOG(*fileContext, DLT_LOG_ERROR,
+     656             :                         DLT_STRING("failed to get FileSerialNumber for: "),
+     657             :                         DLT_STRING(filename));
+     658           0 :                 fclose (file);
+     659           0 :                 return DLT_FILETRANSFER_FILE_SERIAL_NUMBER;
+     660             :             }
+     661             : 
+     662           0 :             DLT_LOG(*fileContext, DLT_LOG_INFO,
+     663             :                     DLT_STRING("FLDA"),
+     664             :                     DLT_UINT(fserial),
+     665             :                     DLT_UINT(packageToTransfer),
+     666             :                     DLT_RAW(buffer, readBytes),
+     667             :                     DLT_STRING("FLDA")
+     668             :                     );
+     669             : 
+     670           0 :             if(*fileCancelTransferFlag) {
+     671           0 :                     DLT_LOG(*fileContext, DLT_LOG_ERROR,
+     672             :                             DLT_STRING("FLER"),
+     673             :                             DLT_INT(DLT_FILETRANSFER_ERROR_FILE_END_USER_CANCELLED)
+     674             :                             );
+     675           0 :                 return DLT_FILETRANSFER_ERROR_FILE_END_USER_CANCELLED;
+     676             :             }
+     677           0 :             doTimeout(timeout);
+     678             :         } else {
+     679             :             pkgNumber = 0;
+     680             : 
+     681           0 :             while (!feof(file)) {
+     682             : /*                If the complete file should be transferred, the user buffer will be checked. */
+     683             : /*                If free space < 50% the package won't be transferred. */
+     684           0 :                 if (checkUserBufferForFreeSpace() > 0) {
+     685           0 :                     pkgNumber++;
+     686           0 :                     readBytes = fread(buffer, sizeof(char), BUFFER_SIZE, file);
+     687             : 
+     688           0 :                     if (readBytes == 0) {
+     689             :                         // If the file size is divisible by the package size don't send
+     690             :                         // one empty FLDA. Also we send the correct number of FLDAs too.
+     691             :                         break;
+     692             :                     }
+     693             : 
+     694             :                     int ok;
+     695             : 
+     696           0 :                     uint32_t fserial = getFileSerialNumber(filename, &ok);
+     697             : 
+     698           0 :                     if (1 != ok) {
+     699           0 :                         DLT_LOG(*fileContext, DLT_LOG_ERROR,
+     700             :                                 DLT_STRING("failed to get FileSerialNumber for: "),
+     701             :                                 DLT_STRING(filename));
+     702           0 :                         fclose(file);
+     703           0 :                         return DLT_FILETRANSFER_FILE_SERIAL_NUMBER;
+     704             :                     }
+     705             : 
+     706           0 :                     DLT_LOG(*fileContext, DLT_LOG_INFO,
+     707             :                             DLT_STRING("FLDA"),
+     708             :                             DLT_UINT(fserial),
+     709             :                             DLT_UINT(pkgNumber),
+     710             :                             DLT_RAW(buffer, readBytes),
+     711             :                             DLT_STRING("FLDA")
+     712             :                             );
+     713           0 :                     if(*fileCancelTransferFlag) {
+     714           0 :                         DLT_LOG(*fileContext, DLT_LOG_ERROR,
+     715             :                             DLT_STRING("FLER"),
+     716             :                             DLT_INT(DLT_FILETRANSFER_ERROR_FILE_END_USER_CANCELLED)
+     717             :                             );
+     718           0 :                         return DLT_FILETRANSFER_ERROR_FILE_END_USER_CANCELLED;
+     719             :                     }
+     720             :                 }  else {
+     721           0 :                     fclose(file);
+     722           0 :                     return DLT_FILETRANSFER_ERROR_FILE_DATA_USER_BUFFER_FAILED;
+     723             :                 }
+     724           0 :                 doTimeout(timeout);
+     725             :             }
+     726             :         }
+     727             : 
+     728           0 :         fclose(file);
+     729             : 
+     730           0 :         return 0;
+     731             :     } else {
+     732           0 :         dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_FILE_DATA);
+     733           0 :         return DLT_FILETRANSFER_ERROR_FILE_DATA;
+     734             :     }
+     735             : }
+     736             : /*!Transfer the end of the file as a dlt logs. */
+     737             : /**The end of the file must be logged to dlt because the end contains inforamtion about the file serial number.
+     738             :  * This informations is needed from the plugin of the dlt viewer.
+     739             :  * See the Mainpages.c for more informations.
+     740             :  * @param fileContext Specific context to log the file to dlt
+     741             :  * @param filename Absolute file path
+     742             :  * @param deleteFlag Flag to delete the file after the whole file is transferred (logged to dlt).1->delete,0->NotDelete
+     743             :  * @return Returns 0 if everything was okey. If there was a failure a value < 0 will be returned.
+     744             :  */
+     745           0 : int dlt_user_log_file_end(DltContext *fileContext, const char *filename, int deleteFlag)
+     746             : {
+     747             : 
+     748           0 :     if (isFile(filename)) {
+     749             : 
+     750             :         int ok;
+     751           0 :         uint32_t fserial = getFileSerialNumber(filename, &ok);
+     752             : 
+     753           0 :         if (1 != ok) {
+     754           0 :             DLT_LOG(*fileContext, DLT_LOG_ERROR,
+     755             :                     DLT_STRING("failed to get FileSerialNumber for: "),
+     756             :                     DLT_STRING(filename));
+     757           0 :             return DLT_FILETRANSFER_FILE_SERIAL_NUMBER;
+     758             :         }
+     759             : 
+     760           0 :         DLT_LOG(*fileContext, DLT_LOG_INFO,
+     761             :                 DLT_STRING("FLFI"),
+     762             :                 DLT_UINT(fserial),
+     763             :                 DLT_STRING("FLFI")
+     764             :                 );
+     765             : 
+     766           0 :         if (deleteFlag) {
+     767           0 :             if (doRemoveFile(filename) != 0) {
+     768           0 :                 dlt_user_log_file_errorMessage(fileContext,
+     769             :                                                filename,
+     770             :                                                DLT_FILETRANSFER_ERROR_FILE_END);
+     771           0 :                 return -1;
+     772             :             }
+     773             :         }
+     774             : 
+     775           0 :         return 0;
+     776             :     } else {
+     777           0 :         dlt_user_log_file_errorMessage(fileContext, filename, DLT_FILETRANSFER_ERROR_FILE_END);
+     778           0 :         return DLT_FILETRANSFER_ERROR_FILE_END;
+     779             :     }
+     780             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/lib/dlt_user.c.func-sort-c.html b/dlt_lcov_report/lib/dlt_user.c.func-sort-c.html new file mode 100644 index 000000000..9b5375de6 --- /dev/null +++ b/dlt_lcov_report/lib/dlt_user.c.func-sort-c.html @@ -0,0 +1,624 @@ + + + + + + + LCOV - dlt_final_coverage.info - lib/dlt_user.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - lib - dlt_user.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:1014175757.7 %
Date:2024-12-05 09:07:13Functions:11113880.4 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
check_buffer0
dlt_disable_local_print0
dlt_enable_local_print0
dlt_fork_child_fork_handler0
dlt_get_appid0
dlt_init_file0
dlt_init_message_queue0
dlt_register_context_llccb0
dlt_register_injection_callback0
dlt_register_injection_callback_with_id0
dlt_send_app_ll_ts_limit0
dlt_set_application_ll_ts_limit0
dlt_set_filesize_max0
dlt_set_resend_timeout_atexit0
dlt_user_check_buffer0
dlt_user_log_send_overflow0
dlt_user_log_write_finish_w_given_buffer0
dlt_user_log_write_ptr0
dlt_user_log_write_start_w_given_buffer0
dlt_user_print_msg0
dlt_user_trace_network_segmented_end0
dlt_user_trace_network_segmented_segment0
dlt_user_trace_network_segmented_start0
dlt_user_trace_network_segmented_thread_segmenter0
dlt_with_ecu_id0
dlt_with_session_id0
dlt_with_timestamp0
dlt_get_log_state1
dlt_log_marker1
dlt_register_log_level_changed_callback1
dlt_user_log_send_marker1
dlt_user_log_write_sized_constant_string1
dlt_use_extended_header_for_non_verbose2
dlt_user_log_write_sized_string2
dlt_user_log_write_bool3
dlt_user_log_write_bool_attr3
dlt_user_log_write_raw_attr3
dlt_user_log_write_raw_formatted_attr3
dlt_user_log_write_sized_constant_string_attr3
dlt_set_log_mode4
dlt_user_log_send_log_mode4
dlt_user_log_write_constant_utf8_string_attr4
dlt_user_log_write_sized_constant_utf8_string_attr4
dlt_user_log_write_uint164
dlt_user_log_write_uint644
dlt_user_log_write_uint84
dlt_user_log_write_constant_string_attr5
dlt_user_log_write_constant_utf8_string5
dlt_user_log_write_sized_constant_utf8_string5
dlt_user_log_write_int166
dlt_user_log_write_int646
dlt_user_log_write_int86
dlt_user_log_write_sized_string_attr6
dlt_check_library_version7
dlt_unregister_app_flush_buffered_logs7
dlt_user_atexit_blow_out_user_buffer7
dlt_user_check_library_version7
dlt_user_log_write_constant_string7
dlt_user_log_write_float327
dlt_user_log_write_float32_attr7
dlt_user_log_write_float647
dlt_user_log_write_float64_attr7
dlt_user_log_write_int16_attr7
dlt_user_log_write_int64_attr7
dlt_user_log_write_int8_attr7
dlt_user_log_write_int_attr7
dlt_user_log_write_sized_utf8_string_attr7
dlt_user_log_write_string_attr7
dlt_user_log_write_uint16_attr7
dlt_user_log_write_uint64_attr7
dlt_user_log_write_uint8_attr7
dlt_user_log_write_uint_attr7
dlt_user_log_write_utf8_string_attr7
dlt_user_trace_network_segmented7
dlt_user_atexit_handler8
dlt_user_log_write_sized_utf8_string8
dlt_nonverbose_mode10
dlt_verbose_mode10
dlt_log_raw11
dlt_user_log_write_raw13
dlt_user_log_write_int32_attr14
dlt_user_trace_network14
dlt_log_string18
dlt_user_log_write_uint32_attr18
dlt_user_log_write_raw_formatted19
dlt_user_log_write_utf8_string21
dlt_user_trace_network_truncated21
dlt_log_int22
dlt_log_uint22
dlt_user_log_write_start_id23
dlt_log_string_int25
dlt_log_string_uint25
dlt_user_log_write_uint16_formatted28
dlt_user_log_write_uint32_formatted28
dlt_user_log_write_uint64_formatted28
dlt_user_log_write_uint8_formatted28
dlt_user_log_write_uint35
dlt_user_log_write_int37
dlt_user_log_write_raw_internal38
dlt_user_log_write_int3242
dlt_user_log_write_generic_formatted112
dlt_user_log_reattach_to_daemon121
dlt_unregister_app167
dlt_user_log_send_register_application171
dlt_register_app176
dlt_unregister_app_util181
dlt_user_log_send_unregister_application181
dlt_register_context203
dlt_unregister_context204
dlt_user_log_send_unregister_context204
dlt_user_log_send_register_context205
dlt_register_context_ll_ts216
dlt_register_context_ll_ts_llccb216
dlt_user_log_out_error_handling859
dlt_user_log_resend_buffer5834
dlt_user_log_write_start5926
dlt_user_log_write_start_init6001
dlt_user_log_send_log6008
dlt_user_log_write_finish6008
dlt_user_log_write_start_internal6059
dlt_user_log_init6411
dlt_user_log_write_uint3211580
dlt_user_log_write_string11686
dlt_user_log_write_string_utils_attr11721
dlt_user_log_write_sized_string_utils_attr11729
dlt_user_log_write_generic_attr11760
dlt_initialize_fifo_connection16786
dlt_start_threads16786
dlt_stop_threads16786
dlt_init_common16787
dlt_user_log_check_user_message16802
dlt_user_cleanup_handler33569
dlt_lock_mutex33572
dlt_user_housekeeperthread_function33572
dlt_user_trace_network_segmented_thread33572
dlt_unlock_mutex50356
dlt_free72878
dlt_init59636257
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/lib/dlt_user.c.func.html b/dlt_lcov_report/lib/dlt_user.c.func.html new file mode 100644 index 000000000..a3166ae3b --- /dev/null +++ b/dlt_lcov_report/lib/dlt_user.c.func.html @@ -0,0 +1,624 @@ + + + + + + + LCOV - dlt_final_coverage.info - lib/dlt_user.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - lib - dlt_user.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:1014175757.7 %
Date:2024-12-05 09:07:13Functions:11113880.4 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
check_buffer0
dlt_check_library_version7
dlt_disable_local_print0
dlt_enable_local_print0
dlt_fork_child_fork_handler0
dlt_free72878
dlt_get_appid0
dlt_get_log_state1
dlt_init59636257
dlt_init_common16787
dlt_init_file0
dlt_init_message_queue0
dlt_initialize_fifo_connection16786
dlt_lock_mutex33572
dlt_log_int22
dlt_log_marker1
dlt_log_raw11
dlt_log_string18
dlt_log_string_int25
dlt_log_string_uint25
dlt_log_uint22
dlt_nonverbose_mode10
dlt_register_app176
dlt_register_context203
dlt_register_context_ll_ts216
dlt_register_context_ll_ts_llccb216
dlt_register_context_llccb0
dlt_register_injection_callback0
dlt_register_injection_callback_with_id0
dlt_register_log_level_changed_callback1
dlt_send_app_ll_ts_limit0
dlt_set_application_ll_ts_limit0
dlt_set_filesize_max0
dlt_set_log_mode4
dlt_set_resend_timeout_atexit0
dlt_start_threads16786
dlt_stop_threads16786
dlt_unlock_mutex50356
dlt_unregister_app167
dlt_unregister_app_flush_buffered_logs7
dlt_unregister_app_util181
dlt_unregister_context204
dlt_use_extended_header_for_non_verbose2
dlt_user_atexit_blow_out_user_buffer7
dlt_user_atexit_handler8
dlt_user_check_buffer0
dlt_user_check_library_version7
dlt_user_cleanup_handler33569
dlt_user_housekeeperthread_function33572
dlt_user_log_check_user_message16802
dlt_user_log_init6411
dlt_user_log_out_error_handling859
dlt_user_log_reattach_to_daemon121
dlt_user_log_resend_buffer5834
dlt_user_log_send_log6008
dlt_user_log_send_log_mode4
dlt_user_log_send_marker1
dlt_user_log_send_overflow0
dlt_user_log_send_register_application171
dlt_user_log_send_register_context205
dlt_user_log_send_unregister_application181
dlt_user_log_send_unregister_context204
dlt_user_log_write_bool3
dlt_user_log_write_bool_attr3
dlt_user_log_write_constant_string7
dlt_user_log_write_constant_string_attr5
dlt_user_log_write_constant_utf8_string5
dlt_user_log_write_constant_utf8_string_attr4
dlt_user_log_write_finish6008
dlt_user_log_write_finish_w_given_buffer0
dlt_user_log_write_float327
dlt_user_log_write_float32_attr7
dlt_user_log_write_float647
dlt_user_log_write_float64_attr7
dlt_user_log_write_generic_attr11760
dlt_user_log_write_generic_formatted112
dlt_user_log_write_int37
dlt_user_log_write_int166
dlt_user_log_write_int16_attr7
dlt_user_log_write_int3242
dlt_user_log_write_int32_attr14
dlt_user_log_write_int646
dlt_user_log_write_int64_attr7
dlt_user_log_write_int86
dlt_user_log_write_int8_attr7
dlt_user_log_write_int_attr7
dlt_user_log_write_ptr0
dlt_user_log_write_raw13
dlt_user_log_write_raw_attr3
dlt_user_log_write_raw_formatted19
dlt_user_log_write_raw_formatted_attr3
dlt_user_log_write_raw_internal38
dlt_user_log_write_sized_constant_string1
dlt_user_log_write_sized_constant_string_attr3
dlt_user_log_write_sized_constant_utf8_string5
dlt_user_log_write_sized_constant_utf8_string_attr4
dlt_user_log_write_sized_string2
dlt_user_log_write_sized_string_attr6
dlt_user_log_write_sized_string_utils_attr11729
dlt_user_log_write_sized_utf8_string8
dlt_user_log_write_sized_utf8_string_attr7
dlt_user_log_write_start5926
dlt_user_log_write_start_id23
dlt_user_log_write_start_init6001
dlt_user_log_write_start_internal6059
dlt_user_log_write_start_w_given_buffer0
dlt_user_log_write_string11686
dlt_user_log_write_string_attr7
dlt_user_log_write_string_utils_attr11721
dlt_user_log_write_uint35
dlt_user_log_write_uint164
dlt_user_log_write_uint16_attr7
dlt_user_log_write_uint16_formatted28
dlt_user_log_write_uint3211580
dlt_user_log_write_uint32_attr18
dlt_user_log_write_uint32_formatted28
dlt_user_log_write_uint644
dlt_user_log_write_uint64_attr7
dlt_user_log_write_uint64_formatted28
dlt_user_log_write_uint84
dlt_user_log_write_uint8_attr7
dlt_user_log_write_uint8_formatted28
dlt_user_log_write_uint_attr7
dlt_user_log_write_utf8_string21
dlt_user_log_write_utf8_string_attr7
dlt_user_print_msg0
dlt_user_trace_network14
dlt_user_trace_network_segmented7
dlt_user_trace_network_segmented_end0
dlt_user_trace_network_segmented_segment0
dlt_user_trace_network_segmented_start0
dlt_user_trace_network_segmented_thread33572
dlt_user_trace_network_segmented_thread_segmenter0
dlt_user_trace_network_truncated21
dlt_verbose_mode10
dlt_with_ecu_id0
dlt_with_session_id0
dlt_with_timestamp0
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/lib/dlt_user.c.gcov.html b/dlt_lcov_report/lib/dlt_user.c.gcov.html new file mode 100644 index 000000000..96e1f46e1 --- /dev/null +++ b/dlt_lcov_report/lib/dlt_user.c.gcov.html @@ -0,0 +1,5556 @@ + + + + + + + LCOV - dlt_final_coverage.info - lib/dlt_user.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - lib - dlt_user.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:1014175757.7 %
Date:2024-12-05 09:07:13Functions:11113880.4 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2011-2015, BMW AG
+       5             :  *
+       6             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       7             :  *
+       8             :  * This Source Code Form is subject to the terms of the
+       9             :  * Mozilla Public License (MPL), v. 2.0.
+      10             :  * If a copy of the MPL was not distributed with this file,
+      11             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      12             :  *
+      13             :  * For further information see http://www.covesa.org/.
+      14             :  */
+      15             : 
+      16             : /*!
+      17             :  * \author
+      18             :  * Alexander Wenzel <alexander.aw.wenzel@bmw.de>
+      19             :  * Markus Klein <Markus.Klein@esk.fraunhofer.de>
+      20             :  * Mikko Rapeli <mikko.rapeli@bmw.de>
+      21             :  *
+      22             :  * \copyright Copyright © 2011-2015 BMW AG. \n
+      23             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      24             :  *
+      25             :  * \file dlt_user.c
+      26             :  */
+      27             : 
+      28             : #include <stdlib.h> /* for getenv(), free(), atexit() */
+      29             : #include <string.h> /* for strcmp(), strncmp(), strlen(), memset(), memcpy() */
+      30             : #include <signal.h> /* for signal(), SIGPIPE, SIG_IGN */
+      31             : 
+      32             : #if !defined (__WIN32__)
+      33             : #   include <syslog.h> /* for LOG_... */
+      34             : #   include <semaphore.h>
+      35             : #   include <pthread.h> /* POSIX Threads */
+      36             : #endif
+      37             : 
+      38             : #include <sys/time.h>
+      39             : #include <math.h>
+      40             : 
+      41             : #include <sys/stat.h>
+      42             : #include <fcntl.h>
+      43             : #include <errno.h>
+      44             : 
+      45             : #include <sys/uio.h> /* writev() */
+      46             : #include <poll.h>
+      47             : 
+      48             : #include <limits.h>
+      49             : #ifdef linux
+      50             : #   include <sys/prctl.h> /* for PR_SET_NAME */
+      51             : #endif
+      52             : 
+      53             : #include <sys/types.h> /* needed for getpid() */
+      54             : #include <unistd.h>
+      55             : 
+      56             : #include <stdbool.h>
+      57             : 
+      58             : #include <stdatomic.h>
+      59             : 
+      60             : #if defined DLT_LIB_USE_UNIX_SOCKET_IPC || defined DLT_LIB_USE_VSOCK_IPC
+      61             : #   include <sys/socket.h>
+      62             : #endif
+      63             : #ifdef DLT_LIB_USE_UNIX_SOCKET_IPC
+      64             : #   include <sys/un.h>
+      65             : #endif
+      66             : #ifdef DLT_LIB_USE_VSOCK_IPC
+      67             : #   ifdef linux
+      68             : #       include <linux/vm_sockets.h>
+      69             : #   endif
+      70             : #   ifdef __QNX__
+      71             : #       include <vm_sockets.h>
+      72             : #   endif
+      73             : #endif
+      74             : 
+      75             : #include "dlt_user.h"
+      76             : #include "dlt_common.h"
+      77             : #include "dlt_log.h"
+      78             : #include "dlt_user_shared.h"
+      79             : #include "dlt_user_shared_cfg.h"
+      80             : #include "dlt_user_cfg.h"
+      81             : 
+      82             : #ifdef DLT_FATAL_LOG_RESET_ENABLE
+      83             : #   define DLT_LOG_FATAL_RESET_TRAP(LOGLEVEL) \
+      84             :     do {                                   \
+      85             :         if (LOGLEVEL == DLT_LOG_FATAL) {   \
+      86             :             int *p = NULL;                 \
+      87             :             *p = 0;                        \
+      88             :         }                                  \
+      89             :     } while (false)
+      90             : #else /* DLT_FATAL_LOG_RESET_ENABLE */
+      91             : #   define DLT_LOG_FATAL_RESET_TRAP(LOGLEVEL)
+      92             : #endif /* DLT_FATAL_LOG_RESET_ENABLE */
+      93             : 
+      94             : enum InitState {
+      95             :     INIT_UNITIALIZED,
+      96             :     INIT_IN_PROGRESS,
+      97             :     INIT_ERROR,
+      98             :     INIT_DONE
+      99             : };
+     100             : 
+     101             : static DltUser dlt_user;
+     102             : static _Atomic enum InitState dlt_user_init_state = INIT_UNITIALIZED;
+     103             : #define DLT_USER_INITALIZED (dlt_user_init_state == INIT_DONE)
+     104             : #define DLT_USER_INIT_ERROR (dlt_user_init_state == INIT_ERROR)
+     105             : #define DLT_USER_INITALIZED_NOT_FREEING (DLT_USER_INITALIZED && (dlt_user_freeing == 0))
+     106             : 
+     107             : static _Atomic int dlt_user_freeing = 0;
+     108             : static bool dlt_user_file_reach_max = false;
+     109             : 
+     110             : #ifdef DLT_LIB_USE_FIFO_IPC
+     111             : static char dlt_user_dir[DLT_PATH_MAX];
+     112             : static char dlt_daemon_fifo[DLT_PATH_MAX];
+     113             : #endif
+     114             : 
+     115             : static pthread_mutex_t dlt_mutex;
+     116             : static pthread_mutexattr_t dlt_mutex_attr;
+     117             : static pthread_t dlt_housekeeperthread_handle;
+     118             : 
+     119             : /* Sync housekeeper thread start */
+     120             : pthread_mutex_t dlt_housekeeper_running_mutex = PTHREAD_MUTEX_INITIALIZER;
+     121             : pthread_cond_t dlt_housekeeper_running_cond;
+     122             : 
+     123             : /* calling dlt_user_atexit_handler() second time fails with error message */
+     124             : static int atexit_registered = 0;
+     125             : 
+     126             : /* used to disallow DLT usage in fork() child */
+     127             : static int g_dlt_is_child = 0;
+     128             : /* String truncate message */
+     129             : static const char STR_TRUNCATED_MESSAGE[] = "... <<Message truncated, too long>>";
+     130             : 
+     131             : /* Enum for type of string */
+     132             : enum StringType
+     133             : {
+     134             :     ASCII_STRING = 0,
+     135             :     UTF8_STRING = 1
+     136             : };
+     137             : 
+     138             : /* Data type holding "Variable Info" (VARI) properties
+     139             :  * Some of the supported data types (eg. bool, string, raw) have only "name", but not "unit".
+     140             :  */
+     141             : typedef struct VarInfo
+     142             : {
+     143             :     const char *name;  // the "name" attribute (can be NULL)
+     144             :     const char *unit;  // the "unit" attribute (can be NULL)
+     145             :     bool with_unit;    // true if the "unit" field is to be considered
+     146             : } VarInfo;
+     147             : 
+     148             : #define DLT_UNUSED(x) (void)(x)
+     149             : 
+     150             : /* Network trace */
+     151             : #ifdef DLT_NETWORK_TRACE_ENABLE
+     152             : #define DLT_USER_SEGMENTED_THREAD (1<<2)
+     153             : 
+     154             : /* Segmented Network Trace */
+     155             : #define DLT_MAX_TRACE_SEGMENT_SIZE 1024
+     156             : #define DLT_MESSAGE_QUEUE_NAME "/dlt_message_queue"
+     157             : #define DLT_DELAYED_RESEND_INDICATOR_PATTERN 0xFFFF
+     158             : 
+     159             : /* Mutex to wait on while message queue is not initialized */
+     160             : pthread_mutex_t mq_mutex = PTHREAD_MUTEX_INITIALIZER;
+     161             : pthread_cond_t mq_init_condition;
+     162             : #endif /* DLT_NETWORK_TRACE_ENABLE */
+     163             : 
+     164       33572 : void dlt_lock_mutex(pthread_mutex_t *mutex)
+     165             : {
+     166       33572 :     int32_t lock_mutex_result = pthread_mutex_lock(mutex);
+     167             : 
+     168       33572 :     if (lock_mutex_result != 0)
+     169           0 :         dlt_vlog(LOG_ERR,
+     170             :                  "Mutex lock failed unexpected pid=%i with result %i!\n",
+     171             :                  getpid(), lock_mutex_result);
+     172       33572 : }
+     173             : 
+     174       50356 : void dlt_unlock_mutex(pthread_mutex_t *mutex)
+     175             : {
+     176       50356 :     pthread_mutex_unlock(mutex);
+     177       50356 : }
+     178             : 
+     179             : /* Structure to pass data to segmented thread */
+     180             : typedef struct
+     181             : {
+     182             :     DltContext *handle;
+     183             :     uint32_t id;
+     184             :     DltNetworkTraceType nw_trace_type;
+     185             :     uint32_t header_len;
+     186             :     void *header;
+     187             :     uint32_t payload_len;
+     188             :     void *payload;
+     189             : } s_segmented_data;
+     190             : 
+     191             : /* Function prototypes for internally used functions */
+     192             : static void dlt_user_housekeeperthread_function(void *ptr);
+     193             : static void dlt_user_atexit_handler(void);
+     194             : static DltReturnValue dlt_user_log_init(DltContext *handle, DltContextData *log);
+     195             : static DltReturnValue dlt_user_log_send_log(DltContextData *log, int mtype, int *sent_size);
+     196             : static DltReturnValue dlt_user_log_send_register_application(void);
+     197             : static DltReturnValue dlt_user_log_send_unregister_application(void);
+     198             : static DltReturnValue dlt_user_log_send_register_context(DltContextData *log);
+     199             : static DltReturnValue dlt_user_log_send_unregister_context(DltContextData *log);
+     200             : static DltReturnValue dlt_send_app_ll_ts_limit(const char *apid,
+     201             :                                                DltLogLevelType loglevel,
+     202             :                                                DltTraceStatusType tracestatus);
+     203             : static DltReturnValue dlt_user_log_send_log_mode(DltUserLogMode mode);
+     204             : static DltReturnValue dlt_user_log_send_marker();
+     205             : static DltReturnValue dlt_user_print_msg(DltMessage *msg, DltContextData *log);
+     206             : static DltReturnValue dlt_user_log_check_user_message(void);
+     207             : static void dlt_user_log_reattach_to_daemon(void);
+     208             : static DltReturnValue dlt_user_log_send_overflow(void);
+     209             : static DltReturnValue dlt_user_log_out_error_handling(void *ptr1,
+     210             :                                                       size_t len1,
+     211             :                                                       void *ptr2,
+     212             :                                                       size_t len2,
+     213             :                                                       void *ptr3,
+     214             :                                                       size_t len3);
+     215             : static void dlt_user_cleanup_handler(void *arg);
+     216             : static int dlt_start_threads();
+     217             : static void dlt_stop_threads();
+     218             : static void dlt_fork_child_fork_handler();
+     219             : #ifdef DLT_NETWORK_TRACE_ENABLE
+     220             : static void dlt_user_trace_network_segmented_thread(void *unused);
+     221             : static void dlt_user_trace_network_segmented_thread_segmenter(s_segmented_data *data);
+     222             : #endif
+     223             : 
+     224             : static DltReturnValue dlt_user_log_write_string_utils_attr(DltContextData *log, const char *text, const enum StringType type, const char *name, bool with_var_info);
+     225             : static DltReturnValue dlt_user_log_write_sized_string_utils_attr(DltContextData *log, const char *text, size_t length, const enum StringType type, const char *name, bool with_var_info);
+     226             : 
+     227             : 
+     228             : static DltReturnValue dlt_unregister_app_util(bool force_sending_messages);
+     229             : 
+     230             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+     231             : /* For trace load control feature */
+     232             : static DltReturnValue dlt_user_output_internal_msg(DltLogLevelType loglevel, const char *text, void* params);
+     233             : DltTraceLoadSettings* trace_load_settings = NULL;
+     234             : uint32_t trace_load_settings_count = 0;
+     235             : pthread_rwlock_t trace_load_rw_lock = PTHREAD_RWLOCK_INITIALIZER;
+     236             : #endif
+     237             : 
+     238           7 : DltReturnValue dlt_user_check_library_version(const char *user_major_version, const char *user_minor_version)
+     239             : {
+     240             :     char lib_major_version[DLT_USER_MAX_LIB_VERSION_LENGTH];
+     241             :     char lib_minor_version[DLT_USER_MAX_LIB_VERSION_LENGTH];
+     242             : 
+     243           7 :     dlt_get_major_version(lib_major_version, DLT_USER_MAX_LIB_VERSION_LENGTH);
+     244           7 :     dlt_get_minor_version(lib_minor_version, DLT_USER_MAX_LIB_VERSION_LENGTH);
+     245             : 
+     246           7 :     if ((strcmp(lib_major_version, user_major_version) != 0) || (strcmp(lib_minor_version, user_minor_version) != 0)) {
+     247           0 :         dlt_vnlog(LOG_WARNING,
+     248             :                   DLT_USER_BUFFER_LENGTH,
+     249             :                   "DLT Library version check failed! Installed DLT library version is %s.%s - Application using DLT library version %s.%s\n",
+     250             :                   lib_major_version,
+     251             :                   lib_minor_version,
+     252             :                   user_major_version,
+     253             :                   user_minor_version);
+     254             : 
+     255           0 :         return DLT_RETURN_ERROR;
+     256             :     }
+     257             : 
+     258             :     return DLT_RETURN_OK;
+     259             : }
+     260             : 
+     261             : #if defined DLT_LIB_USE_UNIX_SOCKET_IPC || defined DLT_LIB_USE_VSOCK_IPC
+     262             : static DltReturnValue dlt_socket_set_nonblock_and_linger(int sockfd)
+     263             : {
+     264             :     int status;
+     265             :     struct linger l_opt;
+     266             : 
+     267             :     status = fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFL, 0) | O_NONBLOCK);
+     268             :     if (status == -1) {
+     269             :         dlt_log(LOG_INFO, "Socket cannot be changed to NON BLOCK\n");
+     270             :         return DLT_RETURN_ERROR;
+     271             :     }
+     272             : 
+     273             :     l_opt.l_onoff = 1;
+     274             :     l_opt.l_linger = 10;
+     275             : 
+     276             :     if (setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &l_opt, sizeof l_opt) < 0)
+     277             :         dlt_log(LOG_WARNING, "Failed to set socket linger option\n");
+     278             : 
+     279             :     return DLT_RETURN_OK;
+     280             : }
+     281             : #endif
+     282             : 
+     283             : #ifdef DLT_LIB_USE_UNIX_SOCKET_IPC
+     284             : static DltReturnValue dlt_initialize_socket_connection(void)
+     285             : {
+     286             :     struct sockaddr_un remote;
+     287             :     char dltSockBaseDir[DLT_IPC_PATH_MAX];
+     288             : 
+     289             :     DLT_SEM_LOCK();
+     290             :     int sockfd = socket(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
+     291             : 
+     292             :     if (sockfd == DLT_FD_INIT) {
+     293             :         dlt_log(LOG_CRIT, "Failed to create socket\n");
+     294             :         DLT_SEM_FREE();
+     295             :         return DLT_RETURN_ERROR;
+     296             :     }
+     297             : 
+     298             :     if (dlt_socket_set_nonblock_and_linger(sockfd) != DLT_RETURN_OK) {
+     299             :         close(sockfd);
+     300             :         DLT_SEM_FREE();
+     301             :         return DLT_RETURN_ERROR;
+     302             :     }
+     303             : 
+     304             :     remote.sun_family = AF_UNIX;
+     305             :     snprintf(dltSockBaseDir, DLT_IPC_PATH_MAX, "%s/dlt", DLT_USER_IPC_PATH);
+     306             :     strncpy(remote.sun_path, dltSockBaseDir, sizeof(remote.sun_path));
+     307             : 
+     308             :     if (strlen(DLT_USER_IPC_PATH) > DLT_IPC_PATH_MAX)
+     309             :         dlt_vlog(LOG_INFO,
+     310             :                  "Provided path too long...trimming it to path[%s]\n",
+     311             :                  dltSockBaseDir);
+     312             : 
+     313             :     if (connect(sockfd, (struct sockaddr *)&remote, sizeof(remote)) == -1) {
+     314             :         if (dlt_user.connection_state != DLT_USER_RETRY_CONNECT) {
+     315             :             dlt_vlog(LOG_INFO,
+     316             :                      "Socket %s cannot be opened (errno=%d). Retrying later...\n",
+     317             :                      dltSockBaseDir, errno);
+     318             :             dlt_user.connection_state = DLT_USER_RETRY_CONNECT;
+     319             :         }
+     320             : 
+     321             :         close(sockfd);
+     322             :         dlt_user.dlt_log_handle = -1;
+     323             :     }
+     324             :     else {
+     325             :         dlt_user.dlt_log_handle = sockfd;
+     326             :         dlt_user.connection_state = DLT_USER_CONNECTED;
+     327             : 
+     328             :         if (dlt_receiver_init(&(dlt_user.receiver),
+     329             :                               sockfd,
+     330             :                               DLT_RECEIVE_SOCKET,
+     331             :                               DLT_USER_RCVBUF_MAX_SIZE) == DLT_RETURN_ERROR) {
+     332             :             dlt_user_init_state = INIT_UNITIALIZED;
+     333             :             close(sockfd);
+     334             :             DLT_SEM_FREE();
+     335             :             return DLT_RETURN_ERROR;
+     336             :         }
+     337             :     }
+     338             : 
+     339             :     DLT_SEM_FREE();
+     340             : 
+     341             :     return DLT_RETURN_OK;
+     342             : }
+     343             : #elif defined DLT_LIB_USE_VSOCK_IPC
+     344             : static DltReturnValue dlt_initialize_vsock_connection()
+     345             : {
+     346             :     struct sockaddr_vm remote;
+     347             : 
+     348             :     DLT_SEM_LOCK();
+     349             :     int sockfd = socket(AF_VSOCK, SOCK_STREAM, 0);
+     350             : 
+     351             :     if (sockfd == DLT_FD_INIT) {
+     352             :         dlt_log(LOG_CRIT, "Failed to create VSOCK socket\n");
+     353             :         DLT_SEM_FREE();
+     354             :         return DLT_RETURN_ERROR;
+     355             :     }
+     356             : 
+     357             :     memset(&remote, 0, sizeof(remote));
+     358             :     remote.svm_family = AF_VSOCK;
+     359             :     remote.svm_port = DLT_VSOCK_PORT;
+     360             :     remote.svm_cid = VMADDR_CID_HOST;
+     361             : 
+     362             :     if (connect(sockfd, (struct sockaddr *)&remote, sizeof(remote)) == -1) {
+     363             :         if (dlt_user.connection_state != DLT_USER_RETRY_CONNECT) {
+     364             :             dlt_vlog(LOG_INFO, "VSOCK socket cannot be opened. Retrying later...\n");
+     365             :             dlt_user.connection_state = DLT_USER_RETRY_CONNECT;
+     366             :         }
+     367             : 
+     368             :         close(sockfd);
+     369             :         dlt_user.dlt_log_handle = -1;
+     370             :     }
+     371             :     else {
+     372             :         /* Set to non-blocking after connect() to avoid EINPROGRESS. DltUserConntextionState
+     373             :            needs "connecting" state if connect() should be non-blocking. */
+     374             :         if (dlt_socket_set_nonblock_and_linger(sockfd) != DLT_RETURN_OK) {
+     375             :             close(sockfd);
+     376             :             DLT_SEM_FREE();
+     377             :             return DLT_RETURN_ERROR;
+     378             :         }
+     379             : 
+     380             :         dlt_user.dlt_log_handle = sockfd;
+     381             :         dlt_user.connection_state = DLT_USER_CONNECTED;
+     382             : 
+     383             :         if (dlt_receiver_init(&(dlt_user.receiver),
+     384             :                               sockfd,
+     385             :                               DLT_RECEIVE_SOCKET,
+     386             :                               DLT_USER_RCVBUF_MAX_SIZE) == DLT_RETURN_ERROR) {
+     387             :             dlt_user_init_state = INIT_UNITIALIZED;
+     388             :             close(sockfd);
+     389             :             DLT_SEM_FREE();
+     390             :             return DLT_RETURN_ERROR;
+     391             :         }
+     392             :     }
+     393             : 
+     394             :     DLT_SEM_FREE();
+     395             : 
+     396             :     return DLT_RETURN_OK;
+     397             : }
+     398             : #else /* DLT_LIB_USE_FIFO_IPC */
+     399       16786 : static DltReturnValue dlt_initialize_fifo_connection(void)
+     400             : {
+     401             :     char filename[DLT_PATH_MAX];
+     402             :     int ret;
+     403             : 
+     404             :     snprintf(dlt_user_dir, DLT_PATH_MAX, "%s/dltpipes", dltFifoBaseDir);
+     405             :     snprintf(dlt_daemon_fifo, DLT_PATH_MAX, "%s/dlt", dltFifoBaseDir);
+     406       16786 :     ret = mkdir(dlt_user_dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_ISVTX);
+     407             : 
+     408       16786 :     if ((ret == -1) && (errno != EEXIST)) {
+     409           0 :         dlt_vnlog(LOG_ERR, DLT_USER_BUFFER_LENGTH, "FIFO user dir %s cannot be created!\n", dlt_user_dir);
+     410           0 :         return DLT_RETURN_ERROR;
+     411             :     }
+     412             : 
+     413             :     /* if dlt pipes directory is created by the application also chmod the directory */
+     414       16786 :     if (ret == 0) {
+     415             :         /* S_ISGID cannot be set by mkdir, let's reassign right bits */
+     416           1 :         ret = chmod(dlt_user_dir,
+     417             :                     S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH | S_ISGID |
+     418             :                     S_ISVTX);
+     419             : 
+     420           1 :         if (ret == -1) {
+     421           0 :             dlt_vnlog(LOG_ERR, DLT_USER_BUFFER_LENGTH, "FIFO user dir %s cannot be chmoded!\n", dlt_user_dir);
+     422           0 :             return DLT_RETURN_ERROR;
+     423             :         }
+     424             :     }
+     425             : 
+     426             :     /* create and open DLT user FIFO */
+     427       16786 :     snprintf(filename, DLT_PATH_MAX, "%s/dlt%d", dlt_user_dir, getpid());
+     428             : 
+     429             :     /* Try to delete existing pipe, ignore result of unlink */
+     430       16786 :     unlink(filename);
+     431             : 
+     432       16786 :     ret = mkfifo(filename, S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP);
+     433             : 
+     434       16786 :     if (ret == -1)
+     435           0 :         dlt_vnlog(LOG_WARNING, DLT_USER_BUFFER_LENGTH, "Loging disabled, FIFO user %s cannot be created!\n", filename);
+     436             : 
+     437             :     /* S_IWGRP cannot be set by mkfifo (???), let's reassign right bits */
+     438       16786 :     ret = chmod(filename, S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP);
+     439             : 
+     440       16786 :     if (ret == -1) {
+     441           0 :         dlt_vnlog(LOG_WARNING, DLT_USER_BUFFER_LENGTH, "FIFO user %s cannot be chmoded!\n", dlt_user_dir);
+     442           0 :         return DLT_RETURN_ERROR;
+     443             :     }
+     444             : 
+     445       16786 :     dlt_user.dlt_user_handle = open(filename, O_RDWR | O_NONBLOCK | O_CLOEXEC);
+     446             : 
+     447       16786 :     if (dlt_user.dlt_user_handle == DLT_FD_INIT) {
+     448           0 :         dlt_vnlog(LOG_WARNING, DLT_USER_BUFFER_LENGTH, "Logging disabled, FIFO user %s cannot be opened!\n", filename);
+     449           0 :         unlink(filename);
+     450           0 :         return DLT_RETURN_OK;
+     451             :     }
+     452             : 
+     453             :     /* open DLT output FIFO */
+     454       16786 :     dlt_user.dlt_log_handle = open(dlt_daemon_fifo, O_WRONLY | O_NONBLOCK | O_CLOEXEC);
+     455             : 
+     456       16786 :     if (dlt_user.dlt_log_handle == -1)
+     457             :         /* This is a normal usecase. It is OK that the daemon (and thus the FIFO /tmp/dlt)
+     458             :          * starts later and some DLT users have already been started before.
+     459             :          * Thus it is OK if the FIFO can't be opened. */
+     460       16779 :         dlt_vnlog(LOG_INFO, DLT_USER_BUFFER_LENGTH, "FIFO %s cannot be opened. Retrying later...\n",
+     461             :                   dlt_daemon_fifo);
+     462             : 
+     463             :     return DLT_RETURN_OK;
+     464             : }
+     465             : #endif
+     466             : 
+     467    59636257 : DltReturnValue dlt_init(void)
+     468             : {
+     469             :     /* process is exiting. Do not allocate new resources. */
+     470    59636257 :     if (dlt_user_freeing != 0) {
+     471             : #ifndef DLT_UNIT_TESTS
+     472             :         dlt_vlog(LOG_INFO, "%s logging disabled, process is exiting\n", __func__);
+     473             : #endif
+     474             :         /* return negative value, to stop the current log */
+     475             :         return DLT_RETURN_LOGGING_DISABLED;
+     476             :     }
+     477             : 
+     478             :     /* Compare dlt_user_init_state to INIT_UNITIALIZED. If equal it will be set to INIT_IN_PROGRESS.
+     479             :      * Call returns DLT_RETURN_OK init state != INIT_UNITIALIZED
+     480             :      * That way it's no problem, if two threads enter this function, because only the very first one will
+     481             :      * pass fully. The other one will immediately return, because when it executes the atomic function
+     482             :      * dlt_user_init_state won't be INIT_UNITIALIZED anymore.
+     483             :      * This is not handled via a simple boolean to prevent issues with shutting down while the init is still running.
+     484             :      * Furthermore, this makes sure we enter some function only when dlt_init is fully done.
+     485             :      * */
+     486             :     enum InitState expectedInitState = INIT_UNITIALIZED;
+     487     8704037 :     if (!(atomic_compare_exchange_strong(&dlt_user_init_state, &expectedInitState, INIT_IN_PROGRESS))) {
+     488             :         return DLT_RETURN_OK;
+     489             :     }
+     490             : 
+     491             :     /* check environment variables */
+     492       16786 :     dlt_check_envvar();
+     493             : 
+     494             :     /* Check logging mode and internal log file is opened or not*/
+     495       16786 :     if (logging_mode == DLT_LOG_TO_FILE && logging_handle == NULL) {
+     496           0 :         dlt_log_init(logging_mode);
+     497             :     }
+     498             : 
+     499             :     /* Initialize common part of dlt_init()/dlt_init_file() */
+     500       16786 :     if (dlt_init_common() == DLT_RETURN_ERROR) {
+     501           0 :         dlt_user_init_state = INIT_ERROR;
+     502           0 :         dlt_free();
+     503           0 :         return DLT_RETURN_ERROR;
+     504             :     }
+     505             : 
+     506       16786 :     dlt_user.dlt_is_file = 0;
+     507       16786 :     dlt_user.filesize_max = UINT_MAX;
+     508       16786 :     dlt_user_file_reach_max = false;
+     509             : 
+     510       16786 :     dlt_user.overflow = 0;
+     511       16786 :     dlt_user.overflow_counter = 0;
+     512             : #ifdef DLT_SHM_ENABLE
+     513             :     memset(&(dlt_user.dlt_shm), 0, sizeof(DltShm));
+     514             : 
+     515             :     /* init shared memory */
+     516             :     if (dlt_shm_init_client(&(dlt_user.dlt_shm), dltShmName) < DLT_RETURN_OK)
+     517             :         dlt_vnlog(LOG_WARNING, DLT_USER_BUFFER_LENGTH, "Logging disabled,"
+     518             :                   " Shared memory %s cannot be created!\n", dltShmName);
+     519             : 
+     520             : #endif
+     521             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+     522             :     pthread_rwlock_wrlock(&trace_load_rw_lock);
+     523             : 
+     524             :     trace_load_settings = malloc(sizeof(DltTraceLoadSettings));
+     525             :     if (trace_load_settings == NULL) {
+     526             :         dlt_vlog(LOG_ERR, "Failed to allocate memory for trace load settings\n");
+     527             :         dlt_user_init_state = INIT_UNITIALIZED;
+     528             :         return DLT_RETURN_ERROR;
+     529             :     }
+     530             :     memset(trace_load_settings, 0, sizeof(DltTraceLoadSettings));
+     531             :     trace_load_settings[0].soft_limit = DLT_TRACE_LOAD_CLIENT_SOFT_LIMIT_DEFAULT;
+     532             :     trace_load_settings[0].hard_limit = DLT_TRACE_LOAD_CLIENT_HARD_LIMIT_DEFAULT;
+     533             :     strncpy(trace_load_settings[0].apid, dlt_user.appID, DLT_ID_SIZE);
+     534             :     trace_load_settings_count = 1;
+     535             : 
+     536             :     pthread_rwlock_unlock(&trace_load_rw_lock);
+     537             : 
+     538             : #endif
+     539             : #ifdef DLT_LIB_USE_UNIX_SOCKET_IPC
+     540             : 
+     541             :     if (dlt_initialize_socket_connection() != DLT_RETURN_OK) {
+     542             :         /* We could connect to the pipe, but not to the socket, which is normally */
+     543             :         /* open before by the DLT daemon => bad failure => return error code */
+     544             :         /* in case application is started before daemon, it is expected behaviour */
+     545             :         dlt_user_init_state = INIT_ERROR;
+     546             :         dlt_free();
+     547             :         return DLT_RETURN_ERROR;
+     548             :     }
+     549             : 
+     550             : #elif defined DLT_LIB_USE_VSOCK_IPC
+     551             : 
+     552             :     if (dlt_initialize_vsock_connection() != DLT_RETURN_OK) {
+     553             :         dlt_user_init_state = INIT_ERROR;
+     554             :         dlt_free();
+     555             :         return DLT_RETURN_ERROR;
+     556             :     }
+     557             : 
+     558             : #else /* DLT_LIB_USE_FIFO_IPC */
+     559             : 
+     560       16786 :     if (dlt_initialize_fifo_connection() != DLT_RETURN_OK) {
+     561           0 :         dlt_user_init_state = INIT_ERROR;
+     562           0 :         dlt_free();
+     563           0 :         return DLT_RETURN_ERROR;
+     564             :     }
+     565             : 
+     566       16786 :     if (dlt_receiver_init(&(dlt_user.receiver),
+     567             :                           dlt_user.dlt_user_handle,
+     568             :                           DLT_RECEIVE_FD,
+     569             :                           DLT_USER_RCVBUF_MAX_SIZE) == DLT_RETURN_ERROR) {
+     570           0 :         dlt_user_init_state = INIT_ERROR;
+     571           0 :         dlt_free();
+     572           0 :         return DLT_RETURN_ERROR;
+     573             :     }
+     574             : 
+     575             : #endif
+     576             : 
+     577             : #ifdef DLT_NETWORK_TRACE_ENABLE
+     578             :     /* These will be lazy initialized only when needed */
+     579       16786 :     dlt_user.dlt_segmented_queue_read_handle = -1;
+     580       16786 :     dlt_user.dlt_segmented_queue_write_handle = -1;
+     581             : 
+     582       16786 :     pthread_cond_init(&mq_init_condition, NULL);
+     583             : #endif
+     584             : 
+     585       16786 :     if (dlt_start_threads() < 0) {
+     586           0 :         dlt_user_init_state = INIT_ERROR;
+     587           0 :         dlt_free();
+     588           0 :         return DLT_RETURN_ERROR;
+     589             :     }
+     590             : 
+     591             :     /* prepare for fork() call */
+     592       16786 :     pthread_atfork(NULL, NULL, &dlt_fork_child_fork_handler);
+     593             : 
+     594       16786 :     dlt_user_init_state = INIT_DONE;
+     595             : 
+     596       16786 :     return DLT_RETURN_OK;
+     597             : }
+     598             : 
+     599           0 : DltReturnValue dlt_get_appid(char *appid)
+     600             : {
+     601           0 :     if (appid != NULL) {
+     602             :         strncpy(appid, dlt_user.appID, 4);
+     603           0 :         return DLT_RETURN_OK;
+     604             :     } else {
+     605           0 :         dlt_log(LOG_ERR, "Invalid parameter.\n");
+     606           0 :         return DLT_RETURN_WRONG_PARAMETER;
+     607             :     }
+     608             : }
+     609             : 
+     610           0 : DltReturnValue dlt_init_file(const char *name)
+     611             : {
+     612             :     /* check null pointer */
+     613           0 :     if (!name)
+     614             :         return DLT_RETURN_WRONG_PARAMETER;
+     615             : 
+     616             :     /* Compare dlt_user_init_state to INIT_UNITIALIZED. If equal it will be set to INIT_IN_PROGRESS.
+     617             :      * Call returns DLT_RETURN_OK init state != INIT_UNITIALIZED
+     618             :      * That way it's no problem, if two threads enter this function, because only the very first one will
+     619             :      * pass fully. The other one will immediately return, because when it executes the atomic function
+     620             :      * dlt_user_init_state won't be INIT_UNITIALIZED anymore.
+     621             :      * This is not handled via a simple boolean to prevent issues with shutting down while the init is still running.
+     622             :      * Furthermore, this makes sure we enter some function only when dlt_init is fully done.
+     623             :      * */
+     624             :     enum InitState expectedInitState = INIT_UNITIALIZED;
+     625           0 :     if (!(atomic_compare_exchange_strong(&dlt_user_init_state, &expectedInitState, INIT_IN_PROGRESS)))
+     626             :         return DLT_RETURN_OK;
+     627             : 
+     628             :     /* Initialize common part of dlt_init()/dlt_init_file() */
+     629           0 :     if (dlt_init_common() == DLT_RETURN_ERROR) {
+     630             :         expectedInitState = INIT_UNITIALIZED;
+     631             :         return DLT_RETURN_ERROR;
+     632             :     }
+     633             : 
+     634           0 :     dlt_user.dlt_is_file = 1;
+     635             : 
+     636             :     /* open DLT output file */
+     637           0 :     dlt_user.dlt_log_handle = open(name, O_WRONLY | O_CREAT,
+     638             :                                    S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* mode: wb */
+     639             : 
+     640           0 :     if (dlt_user.dlt_log_handle == -1) {
+     641           0 :         dlt_vnlog(LOG_ERR, DLT_USER_BUFFER_LENGTH, "Log file %s cannot be opened!\n", name);
+     642           0 :         dlt_user.dlt_is_file = 0;
+     643           0 :         return DLT_RETURN_ERROR;
+     644             :     }
+     645             : 
+     646             :     return DLT_RETURN_OK;
+     647             : }
+     648             : 
+     649           0 : DltReturnValue dlt_set_filesize_max(unsigned int filesize)
+     650             : {
+     651           0 :     if (dlt_user.dlt_is_file == 0)
+     652             :     {
+     653           0 :         dlt_vlog(LOG_ERR, "%s: Library is not configured to log to file\n",
+     654             :                  __func__);
+     655           0 :         return DLT_RETURN_ERROR;
+     656             :     }
+     657             : 
+     658           0 :     if (filesize == 0) {
+     659           0 :         dlt_user.filesize_max = UINT_MAX;
+     660             :     }
+     661             :     else {
+     662           0 :         dlt_user.filesize_max = filesize;
+     663             :     }
+     664           0 :     dlt_vlog(LOG_DEBUG, "%s: Defined filesize_max is [%d]\n", __func__,
+     665             :              dlt_user.filesize_max);
+     666             : 
+     667           0 :     return DLT_RETURN_OK;
+     668             : }
+     669             : 
+     670             : #ifdef DLT_NETWORK_TRACE_ENABLE
+     671           0 : DltReturnValue dlt_init_message_queue(void)
+     672             : {
+     673           0 :     dlt_lock_mutex(&mq_mutex);
+     674             : 
+     675           0 :     if ((dlt_user.dlt_segmented_queue_read_handle >= 0) &&
+     676           0 :         (dlt_user.dlt_segmented_queue_write_handle >= 0)) {
+     677             :         /* Already intialized */
+     678           0 :         dlt_unlock_mutex(&mq_mutex);
+     679           0 :         return DLT_RETURN_OK;
+     680             :     }
+     681             : 
+     682             :     /* Generate per process name for queue */
+     683             :     char queue_name[NAME_MAX];
+     684           0 :     snprintf(queue_name, NAME_MAX, "%s.%d", DLT_MESSAGE_QUEUE_NAME, getpid());
+     685             : 
+     686             :     /* Maximum queue size is 10, limit to size of pointers */
+     687             :     struct mq_attr mqatr;
+     688           0 :     mqatr.mq_flags = 0;
+     689           0 :     mqatr.mq_maxmsg = 10;
+     690           0 :     mqatr.mq_msgsize = sizeof(s_segmented_data *);
+     691           0 :     mqatr.mq_curmsgs = 0;
+     692             : 
+     693             :     /**
+     694             :      * Create the message queue. It must be newly created
+     695             :      * if old one was left by a crashing process.
+     696             :      * */
+     697           0 :     dlt_user.dlt_segmented_queue_read_handle = mq_open(queue_name, O_CREAT | O_RDONLY | O_EXCL,
+     698             :                                                        S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH,
+     699             :                                                        &mqatr);
+     700             : 
+     701           0 :     if (dlt_user.dlt_segmented_queue_read_handle < 0) {
+     702           0 :         if (errno == EEXIST) {
+     703           0 :             dlt_log(LOG_WARNING, "Old message queue exists, trying to delete.\n");
+     704             : 
+     705           0 :             if (mq_unlink(queue_name) < 0)
+     706           0 :                 dlt_vnlog(LOG_CRIT, 256, "Could not delete existing message queue!: %s \n", strerror(errno));
+     707             :             else /* Retry */
+     708             : 
+     709           0 :                 dlt_user.dlt_segmented_queue_read_handle = mq_open(queue_name,
+     710             :                                                                    O_CREAT | O_RDONLY | O_EXCL,
+     711             :                                                                    S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH,
+     712             :                                                                    &mqatr);
+     713             :         }
+     714             : 
+     715           0 :         if (dlt_user.dlt_segmented_queue_read_handle < 0) {
+     716           0 :             dlt_vnlog(LOG_CRIT, 256, "Can't create message queue read handle!: %s \n", strerror(errno));
+     717           0 :             dlt_unlock_mutex(&mq_mutex);
+     718           0 :             return DLT_RETURN_ERROR;
+     719             :         }
+     720             :     }
+     721             : 
+     722           0 :     dlt_user.dlt_segmented_queue_write_handle = mq_open(queue_name, O_WRONLY | O_NONBLOCK);
+     723             : 
+     724           0 :     if (dlt_user.dlt_segmented_queue_write_handle < 0) {
+     725             : 
+     726           0 :         dlt_vnlog(LOG_CRIT, 256, "Can't open message queue write handle!: %s \n", strerror(errno));
+     727           0 :         dlt_unlock_mutex(&mq_mutex);
+     728           0 :         return DLT_RETURN_ERROR;
+     729             :     }
+     730             : 
+     731           0 :     pthread_cond_signal(&mq_init_condition);
+     732           0 :     dlt_unlock_mutex(&mq_mutex);
+     733           0 :     return DLT_RETURN_OK;
+     734             : }
+     735             : #endif /* DLT_NETWORK_TRACE_ENABLE */
+     736             : 
+     737             : /* Return true if verbose mode is to be used for this DltContextData */
+     738             : static inline bool is_verbose_mode(int8_t dltuser_verbose_mode, const DltContextData* log)
+     739             : {
+     740       11776 :     return (dltuser_verbose_mode == 1) || (log != NULL && log->verbose_mode);
+     741             : }
+     742             : 
+     743       16787 : DltReturnValue dlt_init_common(void)
+     744             : {
+     745             :     char *env_local_print;
+     746             :     char *env_initial_log_level;
+     747             :     char *env_buffer_min;
+     748             :     uint32_t buffer_min = DLT_USER_RINGBUFFER_MIN_SIZE;
+     749             :     char *env_buffer_max;
+     750             :     uint32_t buffer_max = DLT_USER_RINGBUFFER_MAX_SIZE;
+     751             :     char *env_buffer_step;
+     752             :     uint32_t buffer_step = DLT_USER_RINGBUFFER_STEP_SIZE;
+     753             :     char *env_disable_extended_header_for_nonverbose;
+     754             :     char *env_log_buffer_len;
+     755             :     uint32_t buffer_max_configured = 0;
+     756             :     uint32_t header_size = 0;
+     757             : 
+     758             :     // already initialized, nothing to do
+     759       16787 :     if (DLT_USER_INITALIZED) {
+     760             :         return DLT_RETURN_OK;
+     761             :     }
+     762             : 
+     763             :     /* Binary semaphore for threads */
+     764       33572 :     if ((pthread_attr_init(&dlt_mutex_attr) != 0) ||
+     765       33572 :         (pthread_mutexattr_settype(&dlt_mutex_attr, PTHREAD_MUTEX_ERRORCHECK) != 0) ||
+     766       16786 :         (pthread_mutex_init(&dlt_mutex, &dlt_mutex_attr) != 0)) {
+     767           0 :         dlt_user_init_state = INIT_UNITIALIZED;
+     768           0 :         return DLT_RETURN_ERROR;
+     769             :     }
+     770             : 
+     771             :     /* set to unknown state of connected client */
+     772       16786 :     dlt_user.log_state = -1;
+     773             : 
+     774       16786 :     dlt_user.dlt_log_handle = -1;
+     775       16786 :     dlt_user.dlt_user_handle = DLT_FD_INIT;
+     776             : 
+     777       16786 :     dlt_set_id(dlt_user.ecuID, DLT_USER_DEFAULT_ECU_ID);
+     778       16786 :     dlt_set_id(dlt_user.appID, "");
+     779             : 
+     780       16786 :     dlt_user.application_description = NULL;
+     781             : 
+     782             :     /* Verbose mode is enabled by default */
+     783       16786 :     dlt_user.verbose_mode = 1;
+     784             : 
+     785             :     /* header_size is used for resend buffer
+     786             :      * so it won't include DltStorageHeader
+     787             :      */
+     788             :     header_size = sizeof(DltUserHeader) + sizeof(DltStandardHeader) +
+     789             :                 sizeof(DltStandardHeaderExtra);
+     790             : 
+     791             :     /* Use extended header for non verbose is enabled by default */
+     792       16786 :     dlt_user.use_extended_header_for_non_verbose =
+     793             :             DLT_USER_USE_EXTENDED_HEADER_FOR_NONVERBOSE;
+     794             : 
+     795             :     /* Use extended header for non verbose is modified as per environment variable */
+     796             :     env_disable_extended_header_for_nonverbose =
+     797       16786 :             getenv(DLT_USER_ENV_DISABLE_EXTENDED_HEADER_FOR_NONVERBOSE);
+     798             : 
+     799       16786 :     if (env_disable_extended_header_for_nonverbose) {
+     800           0 :         if (strcmp(env_disable_extended_header_for_nonverbose, "1") == 0)
+     801           0 :             dlt_user.use_extended_header_for_non_verbose =
+     802             :                     DLT_USER_NO_USE_EXTENDED_HEADER_FOR_NONVERBOSE;
+     803             :     }
+     804             : 
+     805       16786 :     if (dlt_user.use_extended_header_for_non_verbose ==
+     806             :             DLT_USER_USE_EXTENDED_HEADER_FOR_NONVERBOSE)
+     807             :         header_size += (uint32_t) sizeof(DltExtendedHeader);
+     808             : 
+     809             :     /* With session id is enabled by default */
+     810       16786 :     dlt_user.with_session_id = DLT_USER_WITH_SESSION_ID;
+     811             : 
+     812             :     /* With timestamp is enabled by default */
+     813       16786 :     dlt_user.with_timestamp = DLT_USER_WITH_TIMESTAMP;
+     814             : 
+     815             :     /* With timestamp is enabled by default */
+     816       16786 :     dlt_user.with_ecu_id = DLT_USER_WITH_ECU_ID;
+     817             : 
+     818             :     /* Local print is disabled by default */
+     819       16786 :     dlt_user.enable_local_print = 0;
+     820             : 
+     821       16786 :     dlt_user.local_print_mode = DLT_PM_UNSET;
+     822             : 
+     823       16786 :     dlt_user.timeout_at_exit_handler = DLT_USER_ATEXIT_RESEND_BUFFER_EXIT_TIMEOUT;
+     824             : 
+     825       16786 :     env_local_print = getenv(DLT_USER_ENV_LOCAL_PRINT_MODE);
+     826             : 
+     827       16786 :     if (env_local_print) {
+     828           0 :         if (strcmp(env_local_print, "AUTOMATIC") == 0)
+     829           0 :             dlt_user.local_print_mode = DLT_PM_AUTOMATIC;
+     830           0 :         else if (strcmp(env_local_print, "FORCE_ON") == 0)
+     831           0 :             dlt_user.local_print_mode = DLT_PM_FORCE_ON;
+     832           0 :         else if (strcmp(env_local_print, "FORCE_OFF") == 0)
+     833           0 :             dlt_user.local_print_mode = DLT_PM_FORCE_OFF;
+     834             :     }
+     835             : 
+     836       16786 :     env_initial_log_level = getenv("DLT_INITIAL_LOG_LEVEL");
+     837             : 
+     838       16786 :     if (env_initial_log_level != NULL) {
+     839           0 :         if (dlt_env_extract_ll_set(&env_initial_log_level, &dlt_user.initial_ll_set) != 0)
+     840           0 :             dlt_vlog(LOG_WARNING,
+     841             :                      "Unable to parse initial set of log-levels from environment! Env:\n%s\n",
+     842             :                      getenv("DLT_INITIAL_LOG_LEVEL"));
+     843             :     }
+     844             : 
+     845             :     /* Initialize LogLevel/TraceStatus field */
+     846       16786 :     DLT_SEM_LOCK();
+     847       16786 :     dlt_user.dlt_ll_ts = NULL;
+     848       16786 :     dlt_user.dlt_ll_ts_max_num_entries = 0;
+     849       16786 :     dlt_user.dlt_ll_ts_num_entries = 0;
+     850             : 
+     851             : 
+     852       16786 :     env_buffer_min = getenv(DLT_USER_ENV_BUFFER_MIN_SIZE);
+     853       16786 :     env_buffer_max = getenv(DLT_USER_ENV_BUFFER_MAX_SIZE);
+     854       16786 :     env_buffer_step = getenv(DLT_USER_ENV_BUFFER_STEP_SIZE);
+     855             : 
+     856       16786 :     if (env_buffer_min != NULL) {
+     857           0 :         buffer_min = (uint32_t)strtol(env_buffer_min, NULL, 10);
+     858             : 
+     859           0 :         if ((errno == EINVAL) || (errno == ERANGE)) {
+     860           0 :             dlt_vlog(LOG_ERR,
+     861             :                      "Wrong value specified for %s. Using default\n",
+     862             :                      DLT_USER_ENV_BUFFER_MIN_SIZE);
+     863             :             buffer_min = DLT_USER_RINGBUFFER_MIN_SIZE;
+     864             :         }
+     865             :     }
+     866             : 
+     867       16786 :     if (env_buffer_max != NULL) {
+     868           0 :         buffer_max = (uint32_t)strtol(env_buffer_max, NULL, 10);
+     869             : 
+     870           0 :         if ((errno == EINVAL) || (errno == ERANGE)) {
+     871           0 :             dlt_vlog(LOG_ERR,
+     872             :                      "Wrong value specified for %s. Using default\n",
+     873             :                      DLT_USER_ENV_BUFFER_MAX_SIZE);
+     874             :             buffer_max = DLT_USER_RINGBUFFER_MAX_SIZE;
+     875             :         }
+     876             :     }
+     877             : 
+     878       16786 :     if (env_buffer_step != NULL) {
+     879           0 :         buffer_step = (uint32_t)strtol(env_buffer_step, NULL, 10);
+     880             : 
+     881           0 :         if ((errno == EINVAL) || (errno == ERANGE)) {
+     882           0 :             dlt_vlog(LOG_ERR,
+     883             :                      "Wrong value specified for %s. Using default\n",
+     884             :                      DLT_USER_ENV_BUFFER_STEP_SIZE);
+     885             :             buffer_step = DLT_USER_RINGBUFFER_STEP_SIZE;
+     886             :         }
+     887             :     }
+     888             : 
+     889             :     /* init log buffer size */
+     890       16786 :     dlt_user.log_buf_len = DLT_USER_BUF_MAX_SIZE;
+     891       16786 :     env_log_buffer_len = getenv(DLT_USER_ENV_LOG_MSG_BUF_LEN);
+     892             : 
+     893       16786 :     if (env_log_buffer_len != NULL) {
+     894           7 :         buffer_max_configured = (uint32_t)strtol(env_log_buffer_len, NULL, 10);
+     895             : 
+     896           7 :         if (buffer_max_configured > DLT_LOG_MSG_BUF_MAX_SIZE) {
+     897           0 :             dlt_user.log_buf_len = DLT_LOG_MSG_BUF_MAX_SIZE;
+     898           0 :             dlt_vlog(LOG_WARNING,
+     899             :                      "Configured size exceeds maximum allowed size,restricting to max [65535 bytes]\n");
+     900             :         }
+     901             :         else {
+     902           7 :             dlt_user.log_buf_len = (uint16_t) buffer_max_configured;
+     903           7 :             dlt_vlog(LOG_INFO,
+     904             :                      "Configured buffer size to [%u bytes]\n",
+     905             :                      buffer_max_configured);
+     906             :         }
+     907             :     }
+     908             : 
+     909       16786 :     if (dlt_user.resend_buffer == NULL) {
+     910       16786 :         dlt_user.resend_buffer = calloc(sizeof(unsigned char),
+     911       16786 :                                         (dlt_user.log_buf_len + header_size));
+     912             : 
+     913       16786 :         if (dlt_user.resend_buffer == NULL) {
+     914           0 :             dlt_user_init_state = INIT_UNITIALIZED;
+     915           0 :             DLT_SEM_FREE();
+     916           0 :             dlt_vlog(LOG_ERR, "cannot allocate memory for resend buffer\n");
+     917           0 :             return DLT_RETURN_ERROR;
+     918             :         }
+     919             :     }
+     920             : 
+     921       16786 :     dlt_user.disable_injection_msg = 0;
+     922       16786 :     if (getenv(DLT_USER_ENV_DISABLE_INJECTION_MSG)) {
+     923           0 :         dlt_log(LOG_WARNING, "Injection message is disabled\n");
+     924           0 :         dlt_user.disable_injection_msg = 1;
+     925             :     }
+     926             : 
+     927       16786 :     if (dlt_buffer_init_dynamic(&(dlt_user.startup_buffer),
+     928             :                                 buffer_min,
+     929             :                                 buffer_max,
+     930             :                                 buffer_step) == DLT_RETURN_ERROR) {
+     931           0 :         dlt_user_init_state = INIT_UNITIALIZED;
+     932           0 :         DLT_SEM_FREE();
+     933           0 :         return DLT_RETURN_ERROR;
+     934             :     }
+     935             : 
+     936       16786 :     DLT_SEM_FREE();
+     937             : 
+     938       16786 :     signal(SIGPIPE, SIG_IGN);                  /* ignore pipe signals */
+     939             : 
+     940       16786 :     if (atexit_registered == 0) {
+     941           8 :         atexit_registered = 1;
+     942           8 :         atexit(dlt_user_atexit_handler);
+     943             :     }
+     944             : 
+     945             : #ifdef DLT_TEST_ENABLE
+     946             :     dlt_user.corrupt_user_header = 0;
+     947             :     dlt_user.corrupt_message_size = 0;
+     948             :     dlt_user.corrupt_message_size_size = 0;
+     949             : #endif
+     950             : 
+     951             :     return DLT_RETURN_OK;
+     952             : }
+     953             : 
+     954           8 : void dlt_user_atexit_handler(void)
+     955             : {
+     956             :     /* parent will do clean-up */
+     957           8 :     if (g_dlt_is_child)
+     958             :         return;
+     959             : 
+     960           8 :     if (!DLT_USER_INITALIZED) {
+     961           1 :         dlt_vlog(LOG_WARNING, "%s dlt_user_init_state=%i (expected INIT_DONE), dlt_user_freeing=%i\n", __FUNCTION__, dlt_user_init_state, dlt_user_freeing);
+     962             :         /* close file */
+     963           1 :         dlt_log_free();
+     964           1 :         return;
+     965             :     }
+     966             : 
+     967             :     /* Try to resend potential log messages in the user buffer */
+     968           7 :     int count = dlt_user_atexit_blow_out_user_buffer();
+     969             : 
+     970           7 :     if (count != 0)
+     971           1 :         dlt_vnlog(LOG_WARNING, 128, "Lost log messages in user buffer when exiting: %i\n", count);
+     972             : 
+     973             :     /* Unregister app (this also unregisters all contexts in daemon) */
+     974             :     /* Ignore return value */
+     975           7 :     dlt_unregister_app_util(false);
+     976             : 
+     977             :     /* Cleanup */
+     978             :     /* Ignore return value */
+     979           7 :     dlt_free();
+     980             : 
+     981             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+     982             :     pthread_rwlock_destroy(&trace_load_rw_lock);
+     983             : #endif
+     984             : }
+     985             : 
+     986           7 : int dlt_user_atexit_blow_out_user_buffer(void)
+     987             : {
+     988             : 
+     989             :     int count, ret;
+     990             :     struct timespec ts;
+     991             : 
+     992           7 :     uint32_t exitTime = dlt_uptime() + dlt_user.timeout_at_exit_handler;
+     993             : 
+     994             :     /* Send content of ringbuffer */
+     995           7 :     DLT_SEM_LOCK();
+     996           7 :     count = dlt_buffer_get_message_count(&(dlt_user.startup_buffer));
+     997           7 :     DLT_SEM_FREE();
+     998             : 
+     999           7 :     if (count > 0) {
+    1000         101 :         while (dlt_uptime() < exitTime) {
+    1001         100 :             if (dlt_user.dlt_log_handle == -1) {
+    1002             :                 /* Reattach to daemon if neccesary */
+    1003         100 :                 dlt_user_log_reattach_to_daemon();
+    1004             : 
+    1005         100 :                 if ((dlt_user.dlt_log_handle != -1) && (dlt_user.overflow_counter)) {
+    1006           0 :                     if (dlt_user_log_send_overflow() == 0) {
+    1007           0 :                         dlt_vnlog(LOG_WARNING,
+    1008             :                                   DLT_USER_BUFFER_LENGTH,
+    1009             :                                   "%u messages discarded!\n",
+    1010             :                                   dlt_user.overflow_counter);
+    1011           0 :                         dlt_user.overflow_counter = 0;
+    1012             :                     }
+    1013             :                 }
+    1014             :             }
+    1015             : 
+    1016         100 :             if (dlt_user.dlt_log_handle != -1) {
+    1017           0 :                 ret = dlt_user_log_resend_buffer();
+    1018             : 
+    1019           0 :                 if (ret == 0) {
+    1020           0 :                     DLT_SEM_LOCK();
+    1021           0 :                     count = dlt_buffer_get_message_count(&(dlt_user.startup_buffer));
+    1022           0 :                     DLT_SEM_FREE();
+    1023             : 
+    1024           0 :                     return count;
+    1025             :                 }
+    1026             :             }
+    1027             : 
+    1028         100 :             ts.tv_sec = 0;
+    1029         100 :             ts.tv_nsec = DLT_USER_ATEXIT_RESEND_BUFFER_SLEEP;
+    1030         100 :             nanosleep(&ts, NULL);
+    1031             :         }
+    1032             : 
+    1033           1 :         DLT_SEM_LOCK();
+    1034           1 :         count = dlt_buffer_get_message_count(&(dlt_user.startup_buffer));
+    1035           1 :         DLT_SEM_FREE();
+    1036             :     }
+    1037             : 
+    1038             :     return count;
+    1039             : }
+    1040             : 
+    1041             : static void dlt_user_free_buffer(unsigned char **buffer)
+    1042             : {
+    1043       22796 :     if (*buffer) {
+    1044           2 :         free(*buffer);
+    1045       22785 :         *buffer = NULL;
+    1046             :     }
+    1047             : }
+    1048             : 
+    1049       72878 : DltReturnValue dlt_free(void)
+    1050             : {
+    1051             :     uint32_t i;
+    1052             :     int ret = 0;
+    1053             :     int expected = 0;
+    1054             : #ifdef DLT_LIB_USE_FIFO_IPC
+    1055             :     char filename[DLT_PATH_MAX];
+    1056             : #endif
+    1057             : 
+    1058             :     /* library is freeing its resources. Avoid to allocate it in dlt_init() */
+    1059       72878 :     if (!(atomic_compare_exchange_strong(&dlt_user_freeing, &expected, 1))) {
+    1060             :         /* resources are already being freed. Do nothing and return. */
+    1061             :         return DLT_RETURN_ERROR;
+    1062             :     }
+    1063             : 
+    1064             :     // no need to free when not initialized and no error occurred.
+    1065             :     // on error some resources might have been allocated, so free them.
+    1066       72878 :     if (!DLT_USER_INITALIZED && !DLT_USER_INIT_ERROR) {
+    1067       56092 :         dlt_user_freeing = 0;
+    1068       56092 :         return DLT_RETURN_ERROR;
+    1069             :     }
+    1070             : 
+    1071       16786 :     DLT_SEM_LOCK();
+    1072             : 
+    1073       16786 :     dlt_stop_threads();
+    1074             : 
+    1075       16786 :     dlt_user_init_state = INIT_UNITIALIZED;
+    1076             : 
+    1077             : #ifdef DLT_LIB_USE_FIFO_IPC
+    1078             : 
+    1079       16786 :     if (dlt_user.dlt_user_handle != DLT_FD_INIT) {
+    1080       16786 :         close(dlt_user.dlt_user_handle);
+    1081       16786 :         dlt_user.dlt_user_handle = DLT_FD_INIT;
+    1082       16786 :         snprintf(filename, DLT_PATH_MAX, "%s/dlt%d", dlt_user_dir, getpid());
+    1083       16786 :         unlink(filename);
+    1084             :     }
+    1085             : 
+    1086             : #endif
+    1087             : 
+    1088             : #ifdef DLT_SHM_ENABLE
+    1089             :     /* free shared memory */
+    1090             :     dlt_shm_free_client(&dlt_user.dlt_shm);
+    1091             : #endif
+    1092             : 
+    1093       16786 :     if (dlt_user.dlt_log_handle != -1) {
+    1094             :         /* close log file/output fifo to daemon */
+    1095             : #if defined DLT_LIB_USE_UNIX_SOCKET_IPC || defined DLT_LIB_USE_VSOCK_IPC
+    1096             :         ret = shutdown(dlt_user.dlt_log_handle, SHUT_WR);
+    1097             : 
+    1098             :         if (ret < 0) {
+    1099             :             dlt_vlog(LOG_WARNING, "%s: shutdown failed: %s\n", __func__, strerror(errno));
+    1100             :         }
+    1101             :         else {
+    1102             :             ssize_t bytes_read = 0;
+    1103             :             int prev_errno = 0;
+    1104             :             struct pollfd nfd[1];
+    1105             :             nfd[0].events = POLLIN;
+    1106             :             nfd[0].fd = dlt_user.dlt_log_handle;
+    1107             : 
+    1108             :             while (1) {
+    1109             :                 ret = poll(nfd, 1, DLT_USER_RECEIVE_MDELAY);
+    1110             : 
+    1111             :                 /* In case failure of polling or reaching timeout,
+    1112             :                  * continue to close socket anyway.
+    1113             :                  * */
+    1114             :                 if (ret < 0) {
+    1115             :                     dlt_vlog(LOG_WARNING, "[%s] Failed to poll with error [%s]\n",
+    1116             :                             __func__, strerror(errno));
+    1117             :                     break;
+    1118             :                 }
+    1119             :                 else if (ret == 0) {
+    1120             :                     dlt_vlog(LOG_DEBUG, "[%s] Polling timeout\n", __func__);
+    1121             :                     break;
+    1122             :                 }
+    1123             :                 else {
+    1124             :                     /* It could take some time to get the socket is shutdown
+    1125             :                      * So it means there could be some data available to read.
+    1126             :                      * Try to consume the data and poll the socket again.
+    1127             :                      * If read fails, time to close the socket then.
+    1128             :                      */
+    1129             :                     dlt_vlog(LOG_DEBUG, "[%s] polling returns [%d] with revent [0x%x]."
+    1130             :                             "There are something to read\n", __func__, ret, (unsigned int)nfd[0].revents);
+    1131             : 
+    1132             :                     bytes_read = read(dlt_user.dlt_log_handle, dlt_user.resend_buffer, dlt_user.log_buf_len);
+    1133             :                     prev_errno = errno;
+    1134             : 
+    1135             :                     if (bytes_read < 0) {
+    1136             :                         dlt_vlog(LOG_WARNING, "[%s] Failed to read with error [%s]\n",
+    1137             :                                 __func__, strerror(prev_errno));
+    1138             : 
+    1139             :                         if ((prev_errno == EAGAIN) || (EWOULDBLOCK != EAGAIN && prev_errno == EWOULDBLOCK))
+    1140             :                             continue;
+    1141             :                         else
+    1142             :                             break;
+    1143             :                     }
+    1144             :                     if (bytes_read >= 0) {
+    1145             :                         dlt_vlog(LOG_DEBUG, "%s - %d: %d bytes read from resend buffer\n",
+    1146             :                                 __func__, __LINE__, (int)bytes_read);
+    1147             :                         if (!bytes_read)
+    1148             :                             break;
+    1149             :                         dlt_vlog(LOG_NOTICE, "[%s] data is still readable... [%zd] bytes read\n",
+    1150             :                                 __func__, bytes_read);
+    1151             :                     }
+    1152             :                 }
+    1153             :             }
+    1154             :         }
+    1155             : 
+    1156             : #endif
+    1157           6 :         ret = close(dlt_user.dlt_log_handle);
+    1158             : 
+    1159           6 :         if (ret < 0)
+    1160           0 :             dlt_vlog(LOG_WARNING, "%s: close failed: %s\n", __func__, strerror(errno));
+    1161             : 
+    1162           6 :         dlt_user.dlt_log_handle = -1;
+    1163             :     }
+    1164             : 
+    1165       16786 :     dlt_receiver_free(&(dlt_user.receiver));
+    1166             : 
+    1167             :     dlt_user_free_buffer(&(dlt_user.resend_buffer));
+    1168       16786 :     dlt_buffer_free_dynamic(&(dlt_user.startup_buffer));
+    1169             : 
+    1170             :     /* Clear and free local stored application information */
+    1171       16786 :     if (dlt_user.application_description != NULL)
+    1172           0 :         free(dlt_user.application_description);
+    1173       16786 :     dlt_user.application_description = NULL;
+    1174             : 
+    1175       16786 :     if (dlt_user.dlt_ll_ts) {
+    1176       10521 :         for (i = 0; i < dlt_user.dlt_ll_ts_max_num_entries; i++) {
+    1177       10500 :             if (dlt_user.dlt_ll_ts[i].context_description != NULL) {
+    1178           1 :                 free (dlt_user.dlt_ll_ts[i].context_description);
+    1179           1 :                 dlt_user.dlt_ll_ts[i].context_description = NULL;
+    1180             :             }
+    1181             : 
+    1182       10500 :             if (dlt_user.dlt_ll_ts[i].log_level_ptr != NULL) {
+    1183           1 :                 free(dlt_user.dlt_ll_ts[i].log_level_ptr);
+    1184           1 :                 dlt_user.dlt_ll_ts[i].log_level_ptr = NULL;
+    1185             :             }
+    1186             : 
+    1187       10500 :             if (dlt_user.dlt_ll_ts[i].trace_status_ptr != NULL) {
+    1188           1 :                 free(dlt_user.dlt_ll_ts[i].trace_status_ptr);
+    1189           1 :                 dlt_user.dlt_ll_ts[i].trace_status_ptr = NULL;
+    1190             :             }
+    1191             : 
+    1192       10500 :             if (dlt_user.dlt_ll_ts[i].injection_table != NULL) {
+    1193           0 :                 free(dlt_user.dlt_ll_ts[i].injection_table);
+    1194           0 :                 dlt_user.dlt_ll_ts[i].injection_table = NULL;
+    1195             :             }
+    1196             : 
+    1197       10500 :             dlt_user.dlt_ll_ts[i].nrcallbacks = 0;
+    1198       10500 :             dlt_user.dlt_ll_ts[i].log_level_changed_callback = 0;
+    1199             :         }
+    1200             : 
+    1201          21 :         free(dlt_user.dlt_ll_ts);
+    1202          21 :         dlt_user.dlt_ll_ts = NULL;
+    1203          21 :         dlt_user.dlt_ll_ts_max_num_entries = 0;
+    1204          21 :         dlt_user.dlt_ll_ts_num_entries = 0;
+    1205             :     }
+    1206             : 
+    1207       16786 :     dlt_env_free_ll_set(&dlt_user.initial_ll_set);
+    1208             : 
+    1209             : #ifdef DLT_NETWORK_TRACE_ENABLE
+    1210             :     char queue_name[NAME_MAX];
+    1211       16786 :     snprintf(queue_name, NAME_MAX, "%s.%d", DLT_MESSAGE_QUEUE_NAME, getpid());
+    1212             : 
+    1213             :     /**
+    1214             :      * Ignore errors from these, to not to spam user if dlt_free
+    1215             :      * is accidentally called multiple times.
+    1216             :      */
+    1217       16786 :     if (dlt_user.dlt_segmented_queue_write_handle > 0)
+    1218           0 :         mq_close(dlt_user.dlt_segmented_queue_write_handle);
+    1219             : 
+    1220       16786 :     if (dlt_user.dlt_segmented_queue_read_handle > 0)
+    1221           0 :         mq_close(dlt_user.dlt_segmented_queue_read_handle);
+    1222             : 
+    1223       16786 :     if ((dlt_user.dlt_segmented_queue_write_handle > 0) ||
+    1224       16786 :         (dlt_user.dlt_segmented_queue_read_handle > 0))
+    1225           0 :         mq_unlink(queue_name);
+    1226             : 
+    1227       16786 :     dlt_user.dlt_segmented_queue_write_handle = DLT_FD_INIT;
+    1228       16786 :     dlt_user.dlt_segmented_queue_read_handle = DLT_FD_INIT;
+    1229             : 
+    1230       16786 :     pthread_cond_destroy(&mq_init_condition);
+    1231             : #endif /* DLT_NETWORK_TRACE_ENABLE */
+    1232             : 
+    1233             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+    1234             :     if (trace_load_settings != NULL) {
+    1235             :         free(trace_load_settings);
+    1236             :         trace_load_settings = NULL;
+    1237             :     }
+    1238             :     trace_load_settings_count = 0;
+    1239             : #endif
+    1240             : 
+    1241       16786 :     DLT_SEM_FREE();
+    1242       16786 :     pthread_mutex_destroy(&dlt_mutex);
+    1243             : 
+    1244             :     /* allow the user app to do dlt_init() again. */
+    1245             :     /* The flag is unset only to keep almost the same behaviour as before, on EntryNav */
+    1246             :     /* This should be removed for other projects (see documentation of dlt_free() */
+    1247       16786 :     dlt_user_freeing = 0;
+    1248             : 
+    1249       16786 :     return DLT_RETURN_OK;
+    1250             : }
+    1251             : 
+    1252           7 : DltReturnValue dlt_check_library_version(const char *user_major_version, const char *user_minor_version)
+    1253             : {
+    1254           7 :     return dlt_user_check_library_version(user_major_version, user_minor_version);
+    1255             : }
+    1256             : 
+    1257         176 : DltReturnValue dlt_register_app(const char *apid, const char *description)
+    1258             : {
+    1259             :     DltReturnValue ret = DLT_RETURN_OK;
+    1260             : 
+    1261             :     /* forbid dlt usage in child after fork */
+    1262         176 :     if (g_dlt_is_child)
+    1263             :         return DLT_RETURN_ERROR;
+    1264             : 
+    1265         176 :     if (!DLT_USER_INITALIZED) {
+    1266           8 :         if (dlt_init() < 0) {
+    1267           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    1268           0 :             return DLT_RETURN_ERROR;
+    1269             :         }
+    1270             :     }
+    1271             : 
+    1272         176 :     if ((apid == NULL) || (apid[0] == '\0'))
+    1273             :         return DLT_RETURN_WRONG_PARAMETER;
+    1274             : 
+    1275             :     /* check if application already registered */
+    1276             :     /* if yes do not register again */
+    1277         172 :     if (apid[1] == 0) {
+    1278           2 :         if (apid[0] == dlt_user.appID[0])
+    1279             :             return DLT_RETURN_OK;
+    1280             :     }
+    1281         170 :     else if (apid[2] == 0)
+    1282             :     {
+    1283           2 :         if ((apid[0] == dlt_user.appID[0]) &&
+    1284           0 :             (apid[1] == dlt_user.appID[1]))
+    1285             :             return DLT_RETURN_OK;
+    1286             :     }
+    1287         168 :     else if (apid[3] == 0)
+    1288             :     {
+    1289           2 :         if ((apid[0] == dlt_user.appID[0]) &&
+    1290           0 :             (apid[1] == dlt_user.appID[1]) &&
+    1291           0 :             (apid[2] == dlt_user.appID[2]))
+    1292             :             return DLT_RETURN_OK;
+    1293             :     }
+    1294         166 :     else if ((apid[0] == dlt_user.appID[0]) &&
+    1295           1 :              (apid[1] == dlt_user.appID[1]) &&
+    1296           1 :              (apid[2] == dlt_user.appID[2]) &&
+    1297           1 :              (apid[3] == dlt_user.appID[3]))
+    1298             :     {
+    1299             :         return DLT_RETURN_OK;
+    1300             :     }
+    1301             : 
+    1302         171 :     DLT_SEM_LOCK();
+    1303             : 
+    1304             :     /* Store locally application id and application description */
+    1305         171 :     dlt_set_id(dlt_user.appID, apid);
+    1306             : 
+    1307         171 :     if (dlt_user.application_description != NULL)
+    1308           0 :         free(dlt_user.application_description);
+    1309             : 
+    1310         171 :     dlt_user.application_description = NULL;
+    1311             : 
+    1312         171 :     if (description != NULL) {
+    1313         171 :         size_t desc_len = strlen(description);
+    1314         171 :         dlt_user.application_description = malloc(desc_len + 1);
+    1315             : 
+    1316         171 :         if (dlt_user.application_description) {
+    1317             :             strncpy(dlt_user.application_description, description, desc_len + 1);
+    1318             :         } else {
+    1319           0 :             DLT_SEM_FREE();
+    1320           0 :             return DLT_RETURN_ERROR;
+    1321             :         }
+    1322             :     }
+    1323             : 
+    1324         171 :     DLT_SEM_FREE();
+    1325             : 
+    1326             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+    1327             :     strncpy(trace_load_settings[0].apid, dlt_user.appID, DLT_ID_SIZE);
+    1328             : #endif
+    1329             : 
+    1330         171 :     ret = dlt_user_log_send_register_application();
+    1331             : 
+    1332         171 :     if ((ret == DLT_RETURN_OK) && (dlt_user.dlt_log_handle != -1))
+    1333           7 :         ret = dlt_user_log_resend_buffer();
+    1334             : 
+    1335             :     return ret;
+    1336             : }
+    1337             : 
+    1338         203 : DltReturnValue dlt_register_context(DltContext *handle, const char *contextid, const char *description)
+    1339             : {
+    1340             :     /* check nullpointer */
+    1341         203 :     if (handle == NULL)
+    1342             :         return DLT_RETURN_WRONG_PARAMETER;
+    1343             : 
+    1344             :     /* forbid dlt usage in child after fork */
+    1345         197 :     if (g_dlt_is_child)
+    1346             :         return DLT_RETURN_ERROR;
+    1347             : 
+    1348         197 :     if (!DLT_USER_INITALIZED) {
+    1349           0 :         if (dlt_init() < 0) {
+    1350           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    1351           0 :             return DLT_RETURN_ERROR;
+    1352             :         }
+    1353             :     }
+    1354             : 
+    1355         197 :     if ((contextid == NULL) || (contextid[0] == '\0'))
+    1356             :         return DLT_RETURN_WRONG_PARAMETER;
+    1357             : 
+    1358         189 :     return dlt_register_context_ll_ts(handle,
+    1359             :                                       contextid,
+    1360             :                                       description,
+    1361             :                                       DLT_USER_LOG_LEVEL_NOT_SET,
+    1362             :                                       DLT_USER_TRACE_STATUS_NOT_SET);
+    1363             : }
+    1364             : 
+    1365         216 : DltReturnValue dlt_register_context_ll_ts_llccb(DltContext *handle,
+    1366             :                                                 const char *contextid,
+    1367             :                                                 const char *description,
+    1368             :                                                 int loglevel,
+    1369             :                                                 int tracestatus,
+    1370             :                                                 void (*dlt_log_level_changed_callback)(char context_id[DLT_ID_SIZE],
+    1371             :                                                                                        uint8_t log_level,
+    1372             :                                                                                        uint8_t trace_status))
+    1373             : {
+    1374             :     DltContextData log;
+    1375             :     uint32_t i;
+    1376             :     int envLogLevel = DLT_USER_LOG_LEVEL_NOT_SET;
+    1377             : 
+    1378             :     /*check nullpointer */
+    1379         216 :     if ((handle == NULL) || (contextid == NULL) || (contextid[0] == '\0'))
+    1380             :         return DLT_RETURN_WRONG_PARAMETER;
+    1381             : 
+    1382             :     /* forbid dlt usage in child after fork */
+    1383         209 :     if (g_dlt_is_child)
+    1384             :         return DLT_RETURN_ERROR;
+    1385             : 
+    1386         209 :     if ((loglevel < DLT_USER_LOG_LEVEL_NOT_SET) || (loglevel >= DLT_LOG_MAX)) {
+    1387           2 :         dlt_vlog(LOG_ERR, "Loglevel %d is outside valid range", loglevel);
+    1388           2 :         return DLT_RETURN_WRONG_PARAMETER;
+    1389             :     }
+    1390             : 
+    1391         207 :     if ((tracestatus < DLT_USER_TRACE_STATUS_NOT_SET) || (tracestatus >= DLT_TRACE_STATUS_MAX)) {
+    1392           2 :         dlt_vlog(LOG_ERR, "Tracestatus %d is outside valid range", tracestatus);
+    1393           2 :         return DLT_RETURN_WRONG_PARAMETER;
+    1394             :     }
+    1395             : 
+    1396         205 :     if (dlt_user_log_init(handle, &log) < DLT_RETURN_OK)
+    1397             :         return DLT_RETURN_ERROR;
+    1398             : 
+    1399             :     /* Reset message counter */
+    1400         205 :     handle->mcnt = 0;
+    1401             : 
+    1402             :     /* Store context id in log level/trace status field */
+    1403             : 
+    1404             :     /* Check if already registered, else register context */
+    1405         205 :     DLT_SEM_LOCK();
+    1406             : 
+    1407             :     /* Check of double context registration removed */
+    1408             :     /* Double registration is already checked by daemon */
+    1409             : 
+    1410             :     /* Allocate or expand context array */
+    1411         205 :     if (dlt_user.dlt_ll_ts == NULL) {
+    1412          21 :         dlt_user.dlt_ll_ts = (dlt_ll_ts_type *)malloc(sizeof(dlt_ll_ts_type) * DLT_USER_CONTEXT_ALLOC_SIZE);
+    1413             : 
+    1414          21 :         if (dlt_user.dlt_ll_ts == NULL) {
+    1415           0 :             DLT_SEM_FREE();
+    1416           0 :             return DLT_RETURN_ERROR;
+    1417             :         }
+    1418             : 
+    1419          21 :         dlt_user.dlt_ll_ts_max_num_entries = DLT_USER_CONTEXT_ALLOC_SIZE;
+    1420             : 
+    1421             :         /* Initialize new entries */
+    1422       10521 :         for (i = 0; i < dlt_user.dlt_ll_ts_max_num_entries; i++) {
+    1423       10500 :             dlt_set_id(dlt_user.dlt_ll_ts[i].contextID, "");
+    1424             : 
+    1425             :             /* At startup, logging and tracing is locally enabled */
+    1426             :             /* the correct log level/status is set after received from daemon */
+    1427       10500 :             dlt_user.dlt_ll_ts[i].log_level = DLT_USER_INITIAL_LOG_LEVEL;
+    1428       10500 :             dlt_user.dlt_ll_ts[i].trace_status = DLT_USER_INITIAL_TRACE_STATUS;
+    1429             : 
+    1430       10500 :             dlt_user.dlt_ll_ts[i].log_level_ptr = 0;
+    1431       10500 :             dlt_user.dlt_ll_ts[i].trace_status_ptr = 0;
+    1432             : 
+    1433       10500 :             dlt_user.dlt_ll_ts[i].context_description = 0;
+    1434             : 
+    1435       10500 :             dlt_user.dlt_ll_ts[i].injection_table = 0;
+    1436       10500 :             dlt_user.dlt_ll_ts[i].nrcallbacks = 0;
+    1437       10500 :             dlt_user.dlt_ll_ts[i].log_level_changed_callback = 0;
+    1438             :         }
+    1439             :     }
+    1440         184 :     else if ((dlt_user.dlt_ll_ts_num_entries % DLT_USER_CONTEXT_ALLOC_SIZE) == 0)
+    1441             :     {
+    1442             :         /* allocate memory in steps of DLT_USER_CONTEXT_ALLOC_SIZE, e.g. 500 */
+    1443             :         dlt_ll_ts_type *old_ll_ts;
+    1444             :         uint32_t old_max_entries;
+    1445             : 
+    1446             :         old_ll_ts = dlt_user.dlt_ll_ts;
+    1447           0 :         old_max_entries = dlt_user.dlt_ll_ts_max_num_entries;
+    1448             : 
+    1449           0 :         dlt_user.dlt_ll_ts_max_num_entries = ((dlt_user.dlt_ll_ts_num_entries
+    1450           0 :                                                / DLT_USER_CONTEXT_ALLOC_SIZE) + 1)
+    1451           0 :             * DLT_USER_CONTEXT_ALLOC_SIZE;
+    1452           0 :         dlt_user.dlt_ll_ts = (dlt_ll_ts_type *)malloc(sizeof(dlt_ll_ts_type) *
+    1453           0 :                                                       dlt_user.dlt_ll_ts_max_num_entries);
+    1454             : 
+    1455           0 :         if (dlt_user.dlt_ll_ts == NULL) {
+    1456           0 :             dlt_user.dlt_ll_ts = old_ll_ts;
+    1457           0 :             dlt_user.dlt_ll_ts_max_num_entries = old_max_entries;
+    1458           0 :             DLT_SEM_FREE();
+    1459           0 :             return DLT_RETURN_ERROR;
+    1460             :         }
+    1461             : 
+    1462           0 :         memcpy(dlt_user.dlt_ll_ts, old_ll_ts, sizeof(dlt_ll_ts_type) * dlt_user.dlt_ll_ts_num_entries);
+    1463           0 :         free(old_ll_ts);
+    1464             : 
+    1465             :         /* Initialize new entries */
+    1466           0 :         for (i = dlt_user.dlt_ll_ts_num_entries; i < dlt_user.dlt_ll_ts_max_num_entries; i++) {
+    1467           0 :             dlt_set_id(dlt_user.dlt_ll_ts[i].contextID, "");
+    1468             : 
+    1469             :             /* At startup, logging and tracing is locally enabled */
+    1470             :             /* the correct log level/status is set after received from daemon */
+    1471           0 :             dlt_user.dlt_ll_ts[i].log_level = DLT_USER_INITIAL_LOG_LEVEL;
+    1472           0 :             dlt_user.dlt_ll_ts[i].trace_status = DLT_USER_INITIAL_TRACE_STATUS;
+    1473             : 
+    1474           0 :             dlt_user.dlt_ll_ts[i].log_level_ptr = 0;
+    1475           0 :             dlt_user.dlt_ll_ts[i].trace_status_ptr = 0;
+    1476             : 
+    1477           0 :             dlt_user.dlt_ll_ts[i].context_description = 0;
+    1478             : 
+    1479           0 :             dlt_user.dlt_ll_ts[i].injection_table = 0;
+    1480           0 :             dlt_user.dlt_ll_ts[i].nrcallbacks = 0;
+    1481           0 :             dlt_user.dlt_ll_ts[i].log_level_changed_callback = 0;
+    1482             :         }
+    1483             :     }
+    1484             : 
+    1485             :     /* New context entry to be initialized */
+    1486             :     dlt_ll_ts_type *ctx_entry;
+    1487         205 :     ctx_entry = &dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries];
+    1488             : 
+    1489             :     /* Store locally context id and context description */
+    1490         205 :     dlt_set_id(ctx_entry->contextID, contextid);
+    1491             : 
+    1492         205 :     if (ctx_entry->context_description != 0)
+    1493           0 :         free(ctx_entry->context_description);
+    1494             : 
+    1495         205 :     ctx_entry->context_description = 0;
+    1496             : 
+    1497         205 :     if (description != 0) {
+    1498         205 :         size_t desc_len = strlen(description);
+    1499         205 :         ctx_entry->context_description = malloc(desc_len + 1);
+    1500             : 
+    1501         205 :         if (ctx_entry->context_description == 0) {
+    1502           0 :             DLT_SEM_FREE();
+    1503           0 :             return DLT_RETURN_ERROR;
+    1504             :         }
+    1505             : 
+    1506             :         strncpy(ctx_entry->context_description, description, desc_len + 1);
+    1507             :     }
+    1508             : 
+    1509         205 :     if (ctx_entry->log_level_ptr == 0) {
+    1510         205 :         ctx_entry->log_level_ptr = malloc(sizeof(int8_t));
+    1511             : 
+    1512         205 :         if (ctx_entry->log_level_ptr == 0) {
+    1513           0 :             DLT_SEM_FREE();
+    1514           0 :             return DLT_RETURN_ERROR;
+    1515             :         }
+    1516             :     }
+    1517             : 
+    1518         205 :     if (ctx_entry->trace_status_ptr == 0) {
+    1519         205 :         ctx_entry->trace_status_ptr = malloc(sizeof(int8_t));
+    1520             : 
+    1521         205 :         if (ctx_entry->trace_status_ptr == 0) {
+    1522           0 :             DLT_SEM_FREE();
+    1523           0 :             return DLT_RETURN_ERROR;
+    1524             :         }
+    1525             :     }
+    1526             : 
+    1527             :     /* check if the log level is set in the environement */
+    1528         205 :     envLogLevel = dlt_env_adjust_ll_from_env(&dlt_user.initial_ll_set,
+    1529             :                                              dlt_user.appID,
+    1530             :                                              contextid,
+    1531             :                                              DLT_USER_LOG_LEVEL_NOT_SET);
+    1532             : 
+    1533         205 :     if (envLogLevel != DLT_USER_LOG_LEVEL_NOT_SET) {
+    1534           0 :         ctx_entry->log_level = (int8_t) envLogLevel;
+    1535             :         loglevel = envLogLevel;
+    1536             :     }
+    1537         205 :     else if (loglevel != DLT_USER_LOG_LEVEL_NOT_SET)
+    1538             :     {
+    1539          16 :         ctx_entry->log_level = (int8_t) loglevel;
+    1540             :     }
+    1541             : 
+    1542         205 :     if (tracestatus != DLT_USER_TRACE_STATUS_NOT_SET)
+    1543          15 :         ctx_entry->trace_status = (int8_t) tracestatus;
+    1544             : 
+    1545             :     /* Prepare transfer struct */
+    1546         205 :     dlt_set_id(handle->contextID, contextid);
+    1547         205 :     handle->log_level_pos = (int32_t) dlt_user.dlt_ll_ts_num_entries;
+    1548             : 
+    1549         205 :     handle->log_level_ptr = ctx_entry->log_level_ptr;
+    1550         205 :     handle->trace_status_ptr = ctx_entry->trace_status_ptr;
+    1551             : 
+    1552         205 :     log.context_description = ctx_entry->context_description;
+    1553             : 
+    1554         205 :     *(ctx_entry->log_level_ptr) = ctx_entry->log_level;
+    1555         205 :     *(ctx_entry->trace_status_ptr) = ctx_entry->trace_status = (int8_t) tracestatus;
+    1556         205 :     ctx_entry->log_level_changed_callback = dlt_log_level_changed_callback;
+    1557             : 
+    1558         205 :     log.log_level = loglevel;
+    1559         205 :     log.trace_status = tracestatus;
+    1560             : 
+    1561         205 :     dlt_user.dlt_ll_ts_num_entries++;
+    1562             : 
+    1563         205 :     DLT_SEM_FREE();
+    1564             : 
+    1565         205 :     return dlt_user_log_send_register_context(&log);
+    1566             : }
+    1567             : 
+    1568         216 : DltReturnValue dlt_register_context_ll_ts(DltContext *handle,
+    1569             :                                           const char *contextid,
+    1570             :                                           const char *description,
+    1571             :                                           int loglevel,
+    1572             :                                           int tracestatus)
+    1573             : {
+    1574         216 :     return dlt_register_context_ll_ts_llccb(handle,
+    1575             :                                             contextid,
+    1576             :                                             description,
+    1577             :                                             loglevel,
+    1578             :                                             tracestatus,
+    1579             :                                             NULL);
+    1580             : 
+    1581             : }
+    1582             : 
+    1583           0 : DltReturnValue dlt_register_context_llccb(DltContext *handle,
+    1584             :                                           const char *contextid,
+    1585             :                                           const char *description,
+    1586             :                                           void (*dlt_log_level_changed_callback)(char context_id[DLT_ID_SIZE],
+    1587             :                                                                                  uint8_t log_level,
+    1588             :                                                                                  uint8_t trace_status))
+    1589             : {
+    1590           0 :     if ((handle == NULL) || (contextid == NULL) || (contextid[0] == '\0'))
+    1591             :         return DLT_RETURN_WRONG_PARAMETER;
+    1592             : 
+    1593             :     /* forbid dlt usage in child after fork */
+    1594           0 :     if (g_dlt_is_child)
+    1595             :         return DLT_RETURN_ERROR;
+    1596             : 
+    1597           0 :     if (!DLT_USER_INITALIZED) {
+    1598           0 :         if (dlt_init() < 0) {
+    1599           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    1600           0 :             return DLT_RETURN_ERROR;
+    1601             :         }
+    1602             :     }
+    1603             : 
+    1604           0 :     return dlt_register_context_ll_ts_llccb(handle,
+    1605             :                                             contextid,
+    1606             :                                             description,
+    1607             :                                             DLT_USER_LOG_LEVEL_NOT_SET,
+    1608             :                                             DLT_USER_TRACE_STATUS_NOT_SET,
+    1609             :                                             dlt_log_level_changed_callback);
+    1610             : }
+    1611             : 
+    1612             : /* If force_sending_messages is set to true, do not clean appIDs when there are
+    1613             :  * still data in startup_buffer. atexit_handler will free the appIDs */
+    1614         181 : DltReturnValue dlt_unregister_app_util(bool force_sending_messages)
+    1615             : {
+    1616             :     DltReturnValue ret = DLT_RETURN_OK;
+    1617             : 
+    1618             :     /* forbid dlt usage in child after fork */
+    1619         181 :     if (g_dlt_is_child) {
+    1620             :         return DLT_RETURN_ERROR;
+    1621             :     }
+    1622             : 
+    1623         181 :     if (!DLT_USER_INITALIZED) {
+    1624           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_init_state=%i (expected INIT_DONE), dlt_user_freeing=%i\n", __FUNCTION__, dlt_user_init_state, dlt_user_freeing);
+    1625           0 :         return DLT_RETURN_ERROR;
+    1626             :     }
+    1627             : 
+    1628             :     /* Inform daemon to unregister application and all of its contexts */
+    1629         181 :     ret = dlt_user_log_send_unregister_application();
+    1630             : 
+    1631         181 :     DLT_SEM_LOCK();
+    1632             : 
+    1633         181 :     int count = dlt_buffer_get_message_count(&(dlt_user.startup_buffer));
+    1634             : 
+    1635         181 :     if (!force_sending_messages ||
+    1636           7 :         (force_sending_messages && (count == 0))) {
+    1637             :         /* Clear and free local stored application information */
+    1638         180 :         dlt_set_id(dlt_user.appID, "");
+    1639             : 
+    1640         180 :         if (dlt_user.application_description != NULL) {
+    1641         171 :             free(dlt_user.application_description);
+    1642             :         }
+    1643             : 
+    1644         180 :         dlt_user.application_description = NULL;
+    1645             :     }
+    1646             : 
+    1647         181 :     DLT_SEM_FREE();
+    1648             : 
+    1649         181 :     return ret;
+    1650             : }
+    1651             : 
+    1652         167 : DltReturnValue dlt_unregister_app(void)
+    1653             : {
+    1654         167 :     return dlt_unregister_app_util(false);
+    1655             : }
+    1656             : 
+    1657           7 : DltReturnValue dlt_unregister_app_flush_buffered_logs(void)
+    1658             : {
+    1659             :     DltReturnValue ret = DLT_RETURN_OK;
+    1660             : 
+    1661             :     /* forbid dlt usage in child after fork */
+    1662           7 :     if (g_dlt_is_child)
+    1663             :         return DLT_RETURN_ERROR;
+    1664             : 
+    1665           7 :     if (!DLT_USER_INITALIZED) {
+    1666           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_init_state=%i (expected INIT_DONE), dlt_user_freeing=%i\n", __FUNCTION__, dlt_user_init_state, dlt_user_freeing);
+    1667           0 :         return DLT_RETURN_ERROR;
+    1668             :     }
+    1669             : 
+    1670           7 :     if (dlt_user.dlt_log_handle != -1) {
+    1671             :         do
+    1672           6 :             ret = dlt_user_log_resend_buffer();
+    1673           6 :         while ((ret != DLT_RETURN_OK) && (dlt_user.dlt_log_handle != -1));
+    1674             :     }
+    1675             : 
+    1676           7 :     return dlt_unregister_app_util(true);
+    1677             : }
+    1678             : 
+    1679         204 : DltReturnValue dlt_unregister_context(DltContext *handle)
+    1680             : {
+    1681             :     DltContextData log;
+    1682             :     DltReturnValue ret = DLT_RETURN_OK;
+    1683             : 
+    1684             :     /* forbid dlt usage in child after fork */
+    1685         204 :     if (g_dlt_is_child) {
+    1686             :         return DLT_RETURN_ERROR;
+    1687             :     }
+    1688             : 
+    1689         204 :     log.handle = NULL;
+    1690         204 :     log.context_description = NULL;
+    1691             : 
+    1692         204 :     if (dlt_user_log_init(handle, &log) <= DLT_RETURN_ERROR) {
+    1693             :         return DLT_RETURN_ERROR;
+    1694             :     }
+    1695             : 
+    1696         204 :     DLT_SEM_LOCK();
+    1697             : 
+    1698         204 :     handle->log_level_ptr = NULL;
+    1699         204 :     handle->trace_status_ptr = NULL;
+    1700             : 
+    1701         204 :     if (dlt_user.dlt_ll_ts != NULL) {
+    1702             :         /* Clear and free local stored context information */
+    1703         204 :         dlt_set_id(dlt_user.dlt_ll_ts[handle->log_level_pos].contextID, "");
+    1704             : 
+    1705         204 :         dlt_user.dlt_ll_ts[handle->log_level_pos].log_level = DLT_USER_INITIAL_LOG_LEVEL;
+    1706         204 :         dlt_user.dlt_ll_ts[handle->log_level_pos].trace_status = DLT_USER_INITIAL_TRACE_STATUS;
+    1707             : 
+    1708         204 :         if (dlt_user.dlt_ll_ts[handle->log_level_pos].context_description != NULL) {
+    1709         204 :             free(dlt_user.dlt_ll_ts[handle->log_level_pos].context_description);
+    1710             :         }
+    1711             : 
+    1712         204 :         if (dlt_user.dlt_ll_ts[handle->log_level_pos].log_level_ptr != NULL) {
+    1713         204 :             free(dlt_user.dlt_ll_ts[handle->log_level_pos].log_level_ptr);
+    1714         204 :             dlt_user.dlt_ll_ts[handle->log_level_pos].log_level_ptr = NULL;
+    1715             :         }
+    1716             : 
+    1717         204 :         if (dlt_user.dlt_ll_ts[handle->log_level_pos].trace_status_ptr != NULL) {
+    1718         204 :             free(dlt_user.dlt_ll_ts[handle->log_level_pos].trace_status_ptr);
+    1719         204 :             dlt_user.dlt_ll_ts[handle->log_level_pos].trace_status_ptr = NULL;
+    1720             :         }
+    1721             : 
+    1722         204 :         dlt_user.dlt_ll_ts[handle->log_level_pos].context_description = NULL;
+    1723             : 
+    1724         204 :         if (dlt_user.dlt_ll_ts[handle->log_level_pos].injection_table != NULL) {
+    1725           0 :             free(dlt_user.dlt_ll_ts[handle->log_level_pos].injection_table);
+    1726           0 :             dlt_user.dlt_ll_ts[handle->log_level_pos].injection_table = NULL;
+    1727             :         }
+    1728             : 
+    1729         204 :         dlt_user.dlt_ll_ts[handle->log_level_pos].nrcallbacks = 0;
+    1730         204 :         dlt_user.dlt_ll_ts[handle->log_level_pos].log_level_changed_callback = 0;
+    1731             :     }
+    1732             : 
+    1733         204 :     DLT_SEM_FREE();
+    1734             : 
+    1735             :     /* Inform daemon to unregister context */
+    1736         204 :     ret = dlt_user_log_send_unregister_context(&log);
+    1737             : 
+    1738         204 :     return ret;
+    1739             : }
+    1740             : 
+    1741           0 : DltReturnValue dlt_set_application_ll_ts_limit(DltLogLevelType loglevel, DltTraceStatusType tracestatus)
+    1742             : {
+    1743             :     uint32_t i;
+    1744             : 
+    1745             :     /* forbid dlt usage in child after fork */
+    1746           0 :     if (g_dlt_is_child)
+    1747             :         return DLT_RETURN_ERROR;
+    1748             : 
+    1749           0 :     if ((loglevel < DLT_USER_LOG_LEVEL_NOT_SET) || (loglevel >= DLT_LOG_MAX)) {
+    1750           0 :         dlt_vlog(LOG_ERR, "Loglevel %d is outside valid range", loglevel);
+    1751           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    1752             :     }
+    1753             : 
+    1754           0 :     if ((tracestatus < DLT_USER_TRACE_STATUS_NOT_SET) || (tracestatus >= DLT_TRACE_STATUS_MAX)) {
+    1755           0 :         dlt_vlog(LOG_ERR, "Tracestatus %d is outside valid range", tracestatus);
+    1756           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    1757             :     }
+    1758             : 
+    1759           0 :     if (!DLT_USER_INITALIZED) {
+    1760           0 :         if (dlt_init() < 0) {
+    1761           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    1762           0 :             return DLT_RETURN_ERROR;
+    1763             :         }
+    1764             :     }
+    1765             : 
+    1766           0 :     DLT_SEM_LOCK();
+    1767             : 
+    1768           0 :     if (dlt_user.dlt_ll_ts == NULL) {
+    1769           0 :         DLT_SEM_FREE();
+    1770           0 :         return DLT_RETURN_ERROR;
+    1771             :     }
+    1772             : 
+    1773             :     /* Update local structures */
+    1774           0 :     for (i = 0; i < dlt_user.dlt_ll_ts_num_entries; i++) {
+    1775           0 :         dlt_user.dlt_ll_ts[i].log_level = loglevel;
+    1776           0 :         dlt_user.dlt_ll_ts[i].trace_status = tracestatus;
+    1777             : 
+    1778           0 :         if (dlt_user.dlt_ll_ts[i].log_level_ptr)
+    1779           0 :             *(dlt_user.dlt_ll_ts[i].log_level_ptr) = loglevel;
+    1780             : 
+    1781           0 :         if (dlt_user.dlt_ll_ts[i].trace_status_ptr)
+    1782           0 :             *(dlt_user.dlt_ll_ts[i].trace_status_ptr) = tracestatus;
+    1783             :     }
+    1784             : 
+    1785           0 :     DLT_SEM_FREE();
+    1786             : 
+    1787             :     /* Inform DLT server about update */
+    1788           0 :     return dlt_send_app_ll_ts_limit(dlt_user.appID, loglevel, tracestatus);
+    1789             : }
+    1790             : 
+    1791           1 : int dlt_get_log_state()
+    1792             : {
+    1793           1 :     return dlt_user.log_state;
+    1794             : }
+    1795             : 
+    1796           4 : DltReturnValue dlt_set_log_mode(DltUserLogMode mode)
+    1797             : {
+    1798             :     DLT_UNUSED(mode);
+    1799             : 
+    1800             :     /* forbid dlt usage in child after fork */
+    1801           4 :     if (g_dlt_is_child)
+    1802             :         return DLT_RETURN_ERROR;
+    1803             : 
+    1804           4 :     if ((mode < DLT_USER_MODE_UNDEFINED) || (mode >= DLT_USER_MODE_MAX)) {
+    1805           0 :         dlt_vlog(LOG_ERR, "User log mode %d is outside valid range", mode);
+    1806           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    1807             :     }
+    1808             : 
+    1809           4 :     if (!DLT_USER_INITALIZED) {
+    1810           0 :         if (dlt_init() < 0) {
+    1811           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    1812           0 :             return DLT_RETURN_ERROR;
+    1813             :         }
+    1814             :     }
+    1815             : 
+    1816           4 :     return dlt_user_log_send_log_mode(mode);
+    1817             : }
+    1818             : 
+    1819           0 : int dlt_set_resend_timeout_atexit(uint32_t timeout_in_milliseconds)
+    1820             : {
+    1821             :     /* forbid dlt usage in child after fork */
+    1822           0 :     if (g_dlt_is_child)
+    1823             :         return DLT_RETURN_ERROR;
+    1824             : 
+    1825           0 :     if (DLT_USER_INITALIZED == 0)
+    1826           0 :         if (dlt_init() < 0)
+    1827             :             return -1;
+    1828             : 
+    1829           0 :     dlt_user.timeout_at_exit_handler = timeout_in_milliseconds * 10;
+    1830           0 :     return 0;
+    1831             : }
+    1832             : 
+    1833             : /* ********************************************************************************************* */
+    1834             : 
+    1835        6001 : DltReturnValue dlt_user_log_write_start_init(DltContext *handle,
+    1836             :                                                     DltContextData *log,
+    1837             :                                                     DltLogLevelType loglevel,
+    1838             :                                                     bool is_verbose)
+    1839             : {
+    1840             :     DLT_LOG_FATAL_RESET_TRAP(loglevel);
+    1841             : 
+    1842             :     /* initialize values */
+    1843        6001 :     if ((dlt_user_log_init(handle, log) < DLT_RETURN_OK) || (dlt_user.dlt_ll_ts == NULL))
+    1844             :         return DLT_RETURN_ERROR;
+    1845             : 
+    1846        6001 :     log->args_num = 0;
+    1847        6001 :     log->log_level = loglevel;
+    1848        6001 :     log->size = 0;
+    1849        6001 :     log->use_timestamp = DLT_AUTO_TIMESTAMP;
+    1850        6001 :     log->verbose_mode = is_verbose;
+    1851             : 
+    1852        6001 :     return DLT_RETURN_TRUE;
+    1853             : }
+    1854             : 
+    1855             : static DltReturnValue dlt_user_log_write_start_internal(DltContext *handle,
+    1856             :                                                         DltContextData *log,
+    1857             :                                                         DltLogLevelType loglevel,
+    1858             :                                                         uint32_t messageid,
+    1859             :                                                         bool is_verbose);
+    1860             : 
+    1861        5926 : inline DltReturnValue dlt_user_log_write_start(DltContext *handle, DltContextData *log, DltLogLevelType loglevel)
+    1862             : {
+    1863        6036 :     return dlt_user_log_write_start_internal(handle, log, loglevel, DLT_USER_DEFAULT_MSGID, true);
+    1864             : }
+    1865             : 
+    1866          23 : DltReturnValue dlt_user_log_write_start_id(DltContext *handle,
+    1867             :                                            DltContextData *log,
+    1868             :                                            DltLogLevelType loglevel,
+    1869             :                                            uint32_t messageid)
+    1870             : {
+    1871          23 :     return dlt_user_log_write_start_internal(handle, log, loglevel, messageid, false);
+    1872             : }
+    1873             : 
+    1874        6059 : DltReturnValue dlt_user_log_write_start_internal(DltContext *handle,
+    1875             :                                            DltContextData *log,
+    1876             :                                            DltLogLevelType loglevel,
+    1877             :                                            uint32_t messageid,
+    1878             :                                            bool is_verbose)
+    1879             : {
+    1880             :     int ret = DLT_RETURN_TRUE;
+    1881             : 
+    1882             :     /* check nullpointer */
+    1883        6059 :     if ((handle == NULL) || (log == NULL))
+    1884             :         return DLT_RETURN_WRONG_PARAMETER;
+    1885             : 
+    1886             :     /* forbid dlt usage in child after fork */
+    1887        6053 :     if (g_dlt_is_child)
+    1888             :         return DLT_RETURN_ERROR;
+    1889             : 
+    1890             :     /* check log levels */
+    1891             :     ret = dlt_user_is_logLevel_enabled(handle, loglevel);
+    1892             : 
+    1893             :     if (ret == DLT_RETURN_WRONG_PARAMETER) {
+    1894             :         return DLT_RETURN_WRONG_PARAMETER;
+    1895        6040 :     } else if (ret == DLT_RETURN_LOGGING_DISABLED) {
+    1896          39 :         log->handle = NULL;
+    1897          39 :         return DLT_RETURN_OK;
+    1898             :     }
+    1899             : 
+    1900        6001 :     ret = dlt_user_log_write_start_init(handle, log, loglevel, is_verbose);
+    1901        6001 :     if (ret == DLT_RETURN_TRUE) {
+    1902             :         /* initialize values */
+    1903        6001 :         if ((NULL != log->buffer))
+    1904             :         {
+    1905           0 :             free(log->buffer);
+    1906           0 :             log->buffer = NULL;
+    1907             :         }
+    1908             :         else
+    1909             :         {
+    1910        6001 :             log->buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
+    1911             :         }
+    1912             : 
+    1913        6001 :         if (log->buffer == NULL) {
+    1914           0 :             dlt_vlog(LOG_ERR, "Cannot allocate buffer for DLT Log message\n");
+    1915           0 :             return DLT_RETURN_ERROR;
+    1916             :         }
+    1917             :         else
+    1918             :         {
+    1919             :             /* In non-verbose mode, insert message id */
+    1920        6011 :             if (!is_verbose_mode(dlt_user.verbose_mode, log)) {
+    1921           3 :                 if ((sizeof(uint32_t)) > dlt_user.log_buf_len)
+    1922             :                     return DLT_RETURN_USER_BUFFER_FULL;
+    1923             : 
+    1924             :                 /* Write message id */
+    1925             :                 memcpy(log->buffer, &(messageid), sizeof(uint32_t));
+    1926           3 :                 log->size = sizeof(uint32_t);
+    1927             : 
+    1928             :                 /* as the message id is part of each message in non-verbose mode,
+    1929             :                 * it doesn't increment the argument counter in extended header (if used) */
+    1930             :             }
+    1931             :         }
+    1932             :     }
+    1933             : 
+    1934             :     return ret;
+    1935             : }
+    1936             : 
+    1937           0 : DltReturnValue dlt_user_log_write_start_w_given_buffer(DltContext *handle,
+    1938             :                                                        DltContextData *log,
+    1939             :                                                        DltLogLevelType loglevel,
+    1940             :                                                        char *buffer,
+    1941             :                                                        size_t size,
+    1942             :                                                        int32_t args_num)
+    1943             : {
+    1944             :     int ret = DLT_RETURN_TRUE;
+    1945             : 
+    1946             :     /* check nullpointer */
+    1947           0 :     if ((handle == NULL) || (log == NULL) || (buffer == NULL))
+    1948             :         return DLT_RETURN_WRONG_PARAMETER;
+    1949             : 
+    1950             :     /* discard unexpected parameters */
+    1951           0 :     if ((size <= 0) || (size > dlt_user.log_buf_len) || (args_num <= 0))
+    1952             :         return DLT_RETURN_WRONG_PARAMETER;
+    1953             : 
+    1954             :     /* forbid dlt usage in child after fork */
+    1955           0 :     if (g_dlt_is_child)
+    1956             :         return DLT_RETURN_ERROR;
+    1957             : 
+    1958             :     /* discard non-verbose mode */
+    1959           0 :     if (dlt_user.verbose_mode == 0)
+    1960             :         return DLT_RETURN_ERROR;
+    1961             : 
+    1962           0 :     ret = dlt_user_log_write_start_init(handle, log, loglevel, true);
+    1963           0 :     if (ret == DLT_RETURN_TRUE) {
+    1964           0 :         log->buffer = (unsigned char *)buffer;
+    1965           0 :         log->size = size;
+    1966           0 :         log->args_num = args_num;
+    1967             :     }
+    1968             : 
+    1969             :     return ret;
+    1970             :  }
+    1971             : 
+    1972        6008 : DltReturnValue dlt_user_log_write_finish(DltContextData *log)
+    1973             : {
+    1974             :     int ret = DLT_RETURN_ERROR;
+    1975             : 
+    1976        6008 :     if (log == NULL)
+    1977             :         return DLT_RETURN_WRONG_PARAMETER;
+    1978             : 
+    1979        6008 :     ret = dlt_user_log_send_log(log, DLT_TYPE_LOG, NULL);
+    1980             : 
+    1981             :     dlt_user_free_buffer(&(log->buffer));
+    1982             : 
+    1983             :     return ret;
+    1984             : }
+    1985             : 
+    1986           0 : DltReturnValue dlt_user_log_write_finish_w_given_buffer(DltContextData *log)
+    1987             : {
+    1988             :     int ret = DLT_RETURN_ERROR;
+    1989             : 
+    1990           0 :     if (log == NULL)
+    1991             :         return DLT_RETURN_WRONG_PARAMETER;
+    1992             : 
+    1993           0 :     ret = dlt_user_log_send_log(log, DLT_TYPE_LOG, NULL);
+    1994             : 
+    1995           0 :     return ret;
+    1996             : }
+    1997             : 
+    1998          38 : static DltReturnValue dlt_user_log_write_raw_internal(DltContextData *log, const void *data, uint16_t length, DltFormatType type, const char *name, bool with_var_info)
+    1999             : {
+    2000             :     /* check nullpointer */
+    2001          38 :     if ((log == NULL) || ((data == NULL) && (length != 0)))
+    2002             :         return DLT_RETURN_WRONG_PARAMETER;
+    2003             : 
+    2004             :     /* Have to cast type to signed type because some compilers assume that DltFormatType is unsigned and issue a warning */
+    2005          31 :     if (((int16_t)type < DLT_FORMAT_DEFAULT) || (type >= DLT_FORMAT_MAX)) {
+    2006           0 :         dlt_vlog(LOG_ERR, "Format type %u is outside valid range", type);
+    2007           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    2008             :     }
+    2009             : 
+    2010          31 :     if (!DLT_USER_INITALIZED) {
+    2011           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_init_state=%i (expected INIT_DONE), dlt_user_freeing=%i\n", __FUNCTION__, dlt_user_init_state, dlt_user_freeing);
+    2012           0 :         return DLT_RETURN_ERROR;
+    2013             :     }
+    2014             : 
+    2015          31 :     const uint16_t name_size = (name != NULL) ? strlen(name)+1 : 0;
+    2016             : 
+    2017          31 :     size_t needed_size = length + sizeof(uint16_t);
+    2018          31 :     if ((log->size + needed_size) > dlt_user.log_buf_len)
+    2019             :         return DLT_RETURN_USER_BUFFER_FULL;
+    2020             : 
+    2021          29 :     if (is_verbose_mode(dlt_user.verbose_mode, log)) {
+    2022          29 :         uint32_t type_info = DLT_TYPE_INFO_RAWD;
+    2023             : 
+    2024          29 :         needed_size += sizeof(uint32_t);  // Type Info field
+    2025          29 :         if (with_var_info) {
+    2026           6 :             needed_size += sizeof(uint16_t);  // length of name
+    2027           6 :             needed_size += name_size;  // the name itself
+    2028             : 
+    2029           6 :             type_info |= DLT_TYPE_INFO_VARI;
+    2030             :         }
+    2031          29 :         if ((log->size + needed_size) > dlt_user.log_buf_len)
+    2032           0 :             return DLT_RETURN_USER_BUFFER_FULL;
+    2033             : 
+    2034             :         // Genivi extension: put formatting hints into the unused (for RAWD) TYLE + SCOD fields.
+    2035             :         // The SCOD field holds the base (hex or bin); the TYLE field holds the column width (8bit..64bit).
+    2036          29 :         if ((type >= DLT_FORMAT_HEX8) && (type <= DLT_FORMAT_HEX64)) {
+    2037           8 :             type_info |= DLT_SCOD_HEX;
+    2038           8 :             type_info += type;
+    2039             :         }
+    2040          21 :         else if ((type >= DLT_FORMAT_BIN8) && (type <= DLT_FORMAT_BIN16))
+    2041             :         {
+    2042           4 :             type_info |= DLT_SCOD_BIN;
+    2043           4 :             type_info += type - DLT_FORMAT_BIN8 + 1;
+    2044             :         }
+    2045             : 
+    2046          29 :         memcpy(log->buffer + log->size, &type_info, sizeof(uint32_t));
+    2047          29 :         log->size += sizeof(uint32_t);
+    2048             :     }
+    2049             : 
+    2050          29 :     memcpy(log->buffer + log->size, &length, sizeof(uint16_t));
+    2051          29 :     log->size += sizeof(uint16_t);
+    2052             : 
+    2053          29 :     if (is_verbose_mode(dlt_user.verbose_mode, log)) {
+    2054          29 :         if (with_var_info) {
+    2055             :             // Write length of "name" attribute.
+    2056             :             // We assume that the protocol allows zero-sized strings here (which this code will create
+    2057             :             // when the input pointer is NULL).
+    2058           6 :             memcpy(log->buffer + log->size, &name_size, sizeof(uint16_t));
+    2059           6 :             log->size += sizeof(uint16_t);
+    2060             : 
+    2061             :             // Write name string itself.
+    2062             :             // Must not use NULL as source pointer for memcpy. This check assures that.
+    2063           6 :             if (name_size != 0) {
+    2064           4 :                 memcpy(log->buffer + log->size, name, name_size);
+    2065           4 :                 log->size += name_size;
+    2066             :             }
+    2067             :         }
+    2068             :     }
+    2069             : 
+    2070          29 :     if (data != NULL) {
+    2071          27 :         memcpy(log->buffer + log->size, data, length);
+    2072          27 :         log->size += length;
+    2073          27 :         log->args_num++;
+    2074             :     }
+    2075             : 
+    2076             :     return DLT_RETURN_OK;
+    2077             : }
+    2078             : 
+    2079          13 : DltReturnValue dlt_user_log_write_raw(DltContextData *log, void *data, uint16_t length)
+    2080             : {
+    2081          13 :     return dlt_user_log_write_raw_internal(log, data, length, DLT_FORMAT_DEFAULT, NULL, false);
+    2082             : }
+    2083             : 
+    2084          19 : DltReturnValue dlt_user_log_write_raw_formatted(DltContextData *log, void *data, uint16_t length, DltFormatType type)
+    2085             : {
+    2086          19 :     return dlt_user_log_write_raw_internal(log, data, length, type, NULL, false);
+    2087             : }
+    2088             : 
+    2089           3 : DltReturnValue dlt_user_log_write_raw_attr(DltContextData *log, const void *data, uint16_t length, const char *name)
+    2090             : {
+    2091           3 :     return dlt_user_log_write_raw_internal(log, data, length, DLT_FORMAT_DEFAULT, name, true);
+    2092             : }
+    2093             : 
+    2094           3 : DltReturnValue dlt_user_log_write_raw_formatted_attr(DltContextData *log, const void *data, uint16_t length, DltFormatType type, const char *name)
+    2095             : {
+    2096           3 :     return dlt_user_log_write_raw_internal(log, data, length, type, name, true);
+    2097             : }
+    2098             : 
+    2099             : // Generic implementation for all "simple" types, possibly with attributes
+    2100       11760 : static DltReturnValue dlt_user_log_write_generic_attr(DltContextData *log, const void *datap, size_t datalen, uint32_t type_info, const VarInfo *varinfo)
+    2101             : {
+    2102       11760 :     if (log == NULL)
+    2103             :         return DLT_RETURN_WRONG_PARAMETER;
+    2104             : 
+    2105       11749 :     if (!DLT_USER_INITALIZED_NOT_FREEING) {
+    2106           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_init_state=%i (expected INIT_DONE), dlt_user_freeing=%i\n", __FUNCTION__, dlt_user_init_state, dlt_user_freeing);
+    2107           0 :         return DLT_RETURN_ERROR;
+    2108             :     }
+    2109             : 
+    2110             :     size_t needed_size = datalen;
+    2111       11749 :     if ((log->size + needed_size) > dlt_user.log_buf_len)
+    2112             :         return DLT_RETURN_USER_BUFFER_FULL;
+    2113             : 
+    2114       11751 :     if (is_verbose_mode(dlt_user.verbose_mode, log)) {
+    2115             :         bool with_var_info = (varinfo != NULL);
+    2116             : 
+    2117             :         uint16_t name_size;
+    2118             :         uint16_t unit_size;
+    2119             : 
+    2120       11745 :         needed_size += sizeof(uint32_t);  // Type Info field
+    2121       11745 :         if (with_var_info) {
+    2122          89 :             name_size = (varinfo->name != NULL) ? strlen(varinfo->name)+1 : 0;
+    2123          89 :             unit_size = (varinfo->unit != NULL) ? strlen(varinfo->unit)+1 : 0;
+    2124             : 
+    2125          89 :             needed_size += sizeof(uint16_t);      // length of name
+    2126          89 :             needed_size += name_size;             // the name itself
+    2127          89 :             if (varinfo->with_unit) {
+    2128          86 :                 needed_size += sizeof(uint16_t);  // length of unit
+    2129          86 :                 needed_size += unit_size;         // the unit itself
+    2130             :             }
+    2131             : 
+    2132          89 :             type_info |= DLT_TYPE_INFO_VARI;
+    2133             :         }
+    2134       11745 :         if ((log->size + needed_size) > dlt_user.log_buf_len)
+    2135           0 :             return DLT_RETURN_USER_BUFFER_FULL;
+    2136             : 
+    2137       11745 :         memcpy(log->buffer + log->size, &type_info, sizeof(uint32_t));
+    2138       11745 :         log->size += sizeof(uint32_t);
+    2139             : 
+    2140       11745 :         if (with_var_info) {
+    2141             :             // Write lengths of name/unit strings
+    2142             :             // We assume here that the protocol allows zero-sized strings here (which occur
+    2143             :             // when the input pointers are NULL).
+    2144          89 :             memcpy(log->buffer + log->size, &name_size, sizeof(uint16_t));
+    2145          89 :             log->size += sizeof(uint16_t);
+    2146          89 :             if (varinfo->with_unit) {
+    2147          86 :                 memcpy(log->buffer + log->size, &unit_size, sizeof(uint16_t));
+    2148          86 :                 log->size += sizeof(uint16_t);
+    2149             :             }
+    2150             : 
+    2151             :             // Write name/unit strings themselves
+    2152             :             // Must not use NULL as source pointer for memcpy.
+    2153          89 :             if (name_size != 0) {
+    2154          64 :                 memcpy(log->buffer + log->size, varinfo->name, name_size);
+    2155          64 :                 log->size += name_size;
+    2156             :             }
+    2157          89 :             if (unit_size != 0) {
+    2158          62 :                 memcpy(log->buffer + log->size, varinfo->unit, unit_size);
+    2159          62 :                 log->size += unit_size;
+    2160             :             }
+    2161             :         }
+    2162             :     }
+    2163             : 
+    2164       11747 :     memcpy(log->buffer + log->size, datap, datalen);
+    2165       11747 :     log->size += datalen;
+    2166             : 
+    2167       11747 :     log->args_num++;
+    2168             : 
+    2169       11747 :     return DLT_RETURN_OK;
+    2170             : }
+    2171             : 
+    2172             : // Generic implementation for all "simple" types
+    2173         112 : static DltReturnValue dlt_user_log_write_generic_formatted(DltContextData *log, const void *datap, size_t datalen, uint32_t type_info, DltFormatType type)
+    2174             : {
+    2175         112 :     if (log == NULL)
+    2176             :         return DLT_RETURN_WRONG_PARAMETER;
+    2177             : 
+    2178             :     /* Have to cast type to signed type because some compilers assume that DltFormatType is unsigned and issue a warning */
+    2179          84 :     if (((int16_t)type < DLT_FORMAT_DEFAULT) || (type >= DLT_FORMAT_MAX)) {
+    2180           0 :         dlt_vlog(LOG_ERR, "Format type %d is outside valid range", type);
+    2181           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    2182             :     }
+    2183             : 
+    2184          84 :     if (!DLT_USER_INITALIZED) {
+    2185           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_init_state=%i (expected INIT_DONE), dlt_user_freeing=%i\n", __FUNCTION__, dlt_user_init_state, dlt_user_freeing);
+    2186           0 :         return DLT_RETURN_ERROR;
+    2187             :     }
+    2188             : 
+    2189             :     size_t needed_size = datalen;
+    2190          84 :     if ((log->size + needed_size) > dlt_user.log_buf_len)
+    2191             :         return DLT_RETURN_USER_BUFFER_FULL;
+    2192             : 
+    2193          84 :     if (is_verbose_mode(dlt_user.verbose_mode, log)) {
+    2194          84 :         needed_size += sizeof(uint32_t);  // Type Info field
+    2195          84 :         if ((log->size + needed_size) > dlt_user.log_buf_len)
+    2196             :             return DLT_RETURN_USER_BUFFER_FULL;
+    2197             : 
+    2198             :         // Genivi extension: put formatting hints into the unused (for SINT/UINT/FLOA) SCOD field.
+    2199          84 :         if ((type >= DLT_FORMAT_HEX8) && (type <= DLT_FORMAT_HEX64))
+    2200          48 :             type_info |= DLT_SCOD_HEX;
+    2201             : 
+    2202          36 :         else if ((type >= DLT_FORMAT_BIN8) && (type <= DLT_FORMAT_BIN16))
+    2203          24 :             type_info |= DLT_SCOD_BIN;
+    2204             : 
+    2205          84 :         memcpy(log->buffer + log->size, &type_info, sizeof(uint32_t));
+    2206          84 :         log->size += sizeof(uint32_t);
+    2207             :     }
+    2208             : 
+    2209          84 :     memcpy(log->buffer + log->size, datap, datalen);
+    2210          84 :     log->size += datalen;
+    2211             : 
+    2212          84 :     log->args_num++;
+    2213             : 
+    2214          84 :     return DLT_RETURN_OK;
+    2215             : }
+    2216             : 
+    2217           7 : DltReturnValue dlt_user_log_write_float32(DltContextData *log, float32_t data)
+    2218             : {
+    2219             :     if (sizeof(float32_t) != 4)
+    2220             :         return DLT_RETURN_ERROR;
+    2221             : 
+    2222             :     uint32_t type_info = DLT_TYPE_INFO_FLOA | DLT_TYLE_32BIT;
+    2223           7 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(float32_t), type_info, NULL);
+    2224             : }
+    2225             : 
+    2226           7 : DltReturnValue dlt_user_log_write_float64(DltContextData *log, float64_t data)
+    2227             : {
+    2228             :     if (sizeof(float64_t) != 8)
+    2229             :         return DLT_RETURN_ERROR;
+    2230             : 
+    2231             :     uint32_t type_info = DLT_TYPE_INFO_FLOA | DLT_TYLE_64BIT;
+    2232           7 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(float64_t), type_info, NULL);
+    2233             : }
+    2234             : 
+    2235           7 : DltReturnValue dlt_user_log_write_float32_attr(DltContextData *log, float32_t data, const char *name, const char *unit)
+    2236             : {
+    2237             :     if (sizeof(float32_t) != 4)
+    2238             :         return DLT_RETURN_ERROR;
+    2239             : 
+    2240             :     uint32_t type_info = DLT_TYPE_INFO_FLOA | DLT_TYLE_32BIT;
+    2241           7 :     const VarInfo var_info = { name, unit, true };
+    2242           7 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(float32_t), type_info, &var_info);
+    2243             : }
+    2244             : 
+    2245           7 : DltReturnValue dlt_user_log_write_float64_attr(DltContextData *log, float64_t data, const char *name, const char *unit)
+    2246             : {
+    2247             :     if (sizeof(float64_t) != 8)
+    2248             :         return DLT_RETURN_ERROR;
+    2249             : 
+    2250             :     uint32_t type_info = DLT_TYPE_INFO_FLOA | DLT_TYLE_64BIT;
+    2251           7 :     const VarInfo var_info = { name, unit, true };
+    2252           7 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(float64_t), type_info, &var_info);
+    2253             : }
+    2254             : 
+    2255          35 : DltReturnValue dlt_user_log_write_uint(DltContextData *log, unsigned int data)
+    2256             : {
+    2257          35 :     if (log == NULL)
+    2258             :         return DLT_RETURN_WRONG_PARAMETER;
+    2259             : 
+    2260          34 :     if (!DLT_USER_INITALIZED_NOT_FREEING) {
+    2261           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_init_state=%i (expected INIT_DONE), dlt_user_freeing=%i\n", __FUNCTION__, dlt_user_init_state, dlt_user_freeing);
+    2262           0 :         return DLT_RETURN_ERROR;
+    2263             :     }
+    2264             : 
+    2265             :     switch (sizeof(unsigned int)) {
+    2266             :     case 1:
+    2267             :     {
+    2268             :         return dlt_user_log_write_uint8(log, (uint8_t)data);
+    2269             :         break;
+    2270             :     }
+    2271             :     case 2:
+    2272             :     {
+    2273             :         return dlt_user_log_write_uint16(log, (uint16_t)data);
+    2274             :         break;
+    2275             :     }
+    2276          34 :     case 4:
+    2277             :     {
+    2278          34 :         return dlt_user_log_write_uint32(log, (uint32_t)data);
+    2279             :         break;
+    2280             :     }
+    2281             :     case 8:
+    2282             :     {
+    2283             :         return dlt_user_log_write_uint64(log, (uint64_t)data);
+    2284             :         break;
+    2285             :     }
+    2286             :     default:
+    2287             :     {
+    2288             :         return DLT_RETURN_ERROR;
+    2289             :         break;
+    2290             :     }
+    2291             :     }
+    2292             : 
+    2293             :     return DLT_RETURN_OK;
+    2294             : }
+    2295             : 
+    2296           4 : DltReturnValue dlt_user_log_write_uint8(DltContextData *log, uint8_t data)
+    2297             : {
+    2298             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_8BIT;
+    2299           4 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(uint8_t), type_info, NULL);
+    2300             : }
+    2301             : 
+    2302           4 : DltReturnValue dlt_user_log_write_uint16(DltContextData *log, uint16_t data)
+    2303             : {
+    2304             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_16BIT;
+    2305           4 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(uint16_t), type_info, NULL);
+    2306             : }
+    2307             : 
+    2308       11580 : DltReturnValue dlt_user_log_write_uint32(DltContextData *log, uint32_t data)
+    2309             : {
+    2310             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_32BIT;
+    2311       11580 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(uint32_t), type_info, NULL);
+    2312             : }
+    2313             : 
+    2314           4 : DltReturnValue dlt_user_log_write_uint64(DltContextData *log, uint64_t data)
+    2315             : {
+    2316             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_64BIT;
+    2317           4 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(uint64_t), type_info, NULL);
+    2318             : }
+    2319             : 
+    2320           7 : DltReturnValue dlt_user_log_write_uint_attr(DltContextData *log, unsigned int data, const char *name, const char *unit)
+    2321             : {
+    2322           7 :     if (log == NULL)
+    2323             :         return DLT_RETURN_WRONG_PARAMETER;
+    2324             : 
+    2325           7 :     if (!DLT_USER_INITALIZED_NOT_FREEING) {
+    2326           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
+    2327           0 :         return DLT_RETURN_ERROR;
+    2328             :     }
+    2329             : 
+    2330             :     switch (sizeof(unsigned int)) {
+    2331             :     case 1:
+    2332             :     {
+    2333             :         return dlt_user_log_write_uint8_attr(log, (uint8_t)data, name, unit);
+    2334             :         break;
+    2335             :     }
+    2336             :     case 2:
+    2337             :     {
+    2338             :         return dlt_user_log_write_uint16_attr(log, (uint16_t)data, name, unit);
+    2339             :         break;
+    2340             :     }
+    2341           7 :     case 4:
+    2342             :     {
+    2343           7 :         return dlt_user_log_write_uint32_attr(log, (uint32_t)data, name, unit);
+    2344             :         break;
+    2345             :     }
+    2346             :     case 8:
+    2347             :     {
+    2348             :         return dlt_user_log_write_uint64_attr(log, (uint64_t)data, name, unit);
+    2349             :         break;
+    2350             :     }
+    2351             :     default:
+    2352             :     {
+    2353             :         return DLT_RETURN_ERROR;
+    2354             :         break;
+    2355             :     }
+    2356             :     }
+    2357             : 
+    2358             :     return DLT_RETURN_OK;
+    2359             : }
+    2360             : 
+    2361           7 : DltReturnValue dlt_user_log_write_uint8_attr(DltContextData *log, uint8_t data, const char *name, const char *unit)
+    2362             : {
+    2363             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_8BIT;
+    2364           7 :     const VarInfo var_info = { name, unit, true };
+    2365           7 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(uint8_t), type_info, &var_info);
+    2366             : }
+    2367             : 
+    2368           7 : DltReturnValue dlt_user_log_write_uint16_attr(DltContextData *log, uint16_t data, const char *name, const char *unit)
+    2369             : {
+    2370             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_16BIT;
+    2371           7 :     const VarInfo var_info = { name, unit, true };
+    2372           7 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(uint16_t), type_info, &var_info);
+    2373             : }
+    2374             : 
+    2375          18 : DltReturnValue dlt_user_log_write_uint32_attr(DltContextData *log, uint32_t data, const char *name, const char *unit)
+    2376             : {
+    2377             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_32BIT;
+    2378          18 :     const VarInfo var_info = { name, unit, true };
+    2379          18 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(uint32_t), type_info, &var_info);
+    2380             : }
+    2381             : 
+    2382           7 : DltReturnValue dlt_user_log_write_uint64_attr(DltContextData *log, uint64_t data, const char *name, const char *unit)
+    2383             : {
+    2384             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_64BIT;
+    2385           7 :     const VarInfo var_info = { name, unit, true };
+    2386           7 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(uint64_t), type_info, &var_info);
+    2387             : }
+    2388             : 
+    2389          28 : DltReturnValue dlt_user_log_write_uint8_formatted(DltContextData *log, uint8_t data, DltFormatType type)
+    2390             : {
+    2391             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_8BIT;
+    2392          28 :     return dlt_user_log_write_generic_formatted(log, &data, sizeof(uint8_t), type_info, type);
+    2393             : }
+    2394             : 
+    2395          28 : DltReturnValue dlt_user_log_write_uint16_formatted(DltContextData *log, uint16_t data, DltFormatType type)
+    2396             : {
+    2397             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_16BIT;
+    2398          28 :     return dlt_user_log_write_generic_formatted(log, &data, sizeof(uint16_t), type_info, type);
+    2399             : }
+    2400             : 
+    2401          28 : DltReturnValue dlt_user_log_write_uint32_formatted(DltContextData *log, uint32_t data, DltFormatType type)
+    2402             : {
+    2403             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_32BIT;
+    2404          28 :     return dlt_user_log_write_generic_formatted(log, &data, sizeof(uint32_t), type_info, type);
+    2405             : }
+    2406             : 
+    2407          28 : DltReturnValue dlt_user_log_write_uint64_formatted(DltContextData *log, uint64_t data, DltFormatType type)
+    2408             : {
+    2409             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_64BIT;
+    2410          28 :     return dlt_user_log_write_generic_formatted(log, &data, sizeof(uint64_t), type_info, type);
+    2411             : }
+    2412             : 
+    2413           0 : DltReturnValue dlt_user_log_write_ptr(DltContextData *log, void *data)
+    2414             : {
+    2415           0 :     if (log == NULL)
+    2416             :         return DLT_RETURN_WRONG_PARAMETER;
+    2417             : 
+    2418           0 :     if (!DLT_USER_INITALIZED_NOT_FREEING) {
+    2419           0 :         dlt_vlog(LOG_WARNING, "%s user_initialised false\n", __FUNCTION__);
+    2420           0 :         return DLT_RETURN_ERROR;
+    2421             :     }
+    2422             : 
+    2423             :     switch (sizeof(void *)) {
+    2424             :     case 4:
+    2425             :         return dlt_user_log_write_uint32_formatted(log,
+    2426             :                                                    (uintptr_t) data,
+    2427             :                                                    DLT_FORMAT_HEX32);
+    2428             :         break;
+    2429           0 :     case 8:
+    2430           0 :         return dlt_user_log_write_uint64_formatted(log,
+    2431             :                                                    (uintptr_t) data,
+    2432             :                                                    DLT_FORMAT_HEX64);
+    2433             :         break;
+    2434             :     default:
+    2435             :         ;     /* skip */
+    2436             :     }
+    2437             : 
+    2438             :     return DLT_RETURN_OK;
+    2439             : }
+    2440             : 
+    2441          37 : DltReturnValue dlt_user_log_write_int(DltContextData *log, int data)
+    2442             : {
+    2443          37 :     if (log == NULL)
+    2444             :         return DLT_RETURN_WRONG_PARAMETER;
+    2445             : 
+    2446          36 :     if (!DLT_USER_INITALIZED_NOT_FREEING) {
+    2447           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_init_state=%i (expected INIT_DONE), dlt_user_freeing=%i\n", __FUNCTION__, dlt_user_init_state, dlt_user_freeing);
+    2448           0 :         return DLT_RETURN_ERROR;
+    2449             :     }
+    2450             : 
+    2451             :     switch (sizeof(int)) {
+    2452             :     case 1:
+    2453             :     {
+    2454             :         return dlt_user_log_write_int8(log, (int8_t)data);
+    2455             :         break;
+    2456             :     }
+    2457             :     case 2:
+    2458             :     {
+    2459             :         return dlt_user_log_write_int16(log, (int16_t)data);
+    2460             :         break;
+    2461             :     }
+    2462          36 :     case 4:
+    2463             :     {
+    2464          36 :         return dlt_user_log_write_int32(log, (int32_t)data);
+    2465             :         break;
+    2466             :     }
+    2467             :     case 8:
+    2468             :     {
+    2469             :         return dlt_user_log_write_int64(log, (int64_t)data);
+    2470             :         break;
+    2471             :     }
+    2472             :     default:
+    2473             :     {
+    2474             :         return DLT_RETURN_ERROR;
+    2475             :         break;
+    2476             :     }
+    2477             :     }
+    2478             : 
+    2479             :     return DLT_RETURN_OK;
+    2480             : }
+    2481             : 
+    2482           6 : DltReturnValue dlt_user_log_write_int8(DltContextData *log, int8_t data)
+    2483             : {
+    2484             :     uint32_t type_info = DLT_TYPE_INFO_SINT | DLT_TYLE_8BIT;
+    2485           6 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(int8_t), type_info, NULL);
+    2486             : }
+    2487             : 
+    2488           6 : DltReturnValue dlt_user_log_write_int16(DltContextData *log, int16_t data)
+    2489             : {
+    2490             :     uint32_t type_info = DLT_TYPE_INFO_SINT | DLT_TYLE_16BIT;
+    2491           6 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(int16_t), type_info, NULL);
+    2492             : }
+    2493             : 
+    2494          42 : DltReturnValue dlt_user_log_write_int32(DltContextData *log, int32_t data)
+    2495             : {
+    2496             :     uint32_t type_info = DLT_TYPE_INFO_SINT | DLT_TYLE_32BIT;
+    2497          42 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(int32_t), type_info, NULL);
+    2498             : }
+    2499             : 
+    2500           6 : DltReturnValue dlt_user_log_write_int64(DltContextData *log, int64_t data)
+    2501             : {
+    2502             :     uint32_t type_info = DLT_TYPE_INFO_SINT | DLT_TYLE_64BIT;
+    2503           6 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(int64_t), type_info, NULL);
+    2504             : }
+    2505             : 
+    2506           7 : DltReturnValue dlt_user_log_write_int_attr(DltContextData *log, int data, const char *name, const char *unit)
+    2507             : {
+    2508           7 :     if (log == NULL)
+    2509             :         return DLT_RETURN_WRONG_PARAMETER;
+    2510             : 
+    2511           7 :     if (!DLT_USER_INITALIZED_NOT_FREEING) {
+    2512           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
+    2513           0 :         return DLT_RETURN_ERROR;
+    2514             :     }
+    2515             : 
+    2516             :     switch (sizeof(int)) {
+    2517             :     case 1:
+    2518             :     {
+    2519             :         return dlt_user_log_write_int8_attr(log, (int8_t)data, name, unit);
+    2520             :         break;
+    2521             :     }
+    2522             :     case 2:
+    2523             :     {
+    2524             :         return dlt_user_log_write_int16_attr(log, (int16_t)data, name, unit);
+    2525             :         break;
+    2526             :     }
+    2527           7 :     case 4:
+    2528             :     {
+    2529           7 :         return dlt_user_log_write_int32_attr(log, (int32_t)data, name, unit);
+    2530             :         break;
+    2531             :     }
+    2532             :     case 8:
+    2533             :     {
+    2534             :         return dlt_user_log_write_int64_attr(log, (int64_t)data, name, unit);
+    2535             :         break;
+    2536             :     }
+    2537             :     default:
+    2538             :     {
+    2539             :         return DLT_RETURN_ERROR;
+    2540             :         break;
+    2541             :     }
+    2542             :     }
+    2543             : 
+    2544             :     return DLT_RETURN_OK;
+    2545             : }
+    2546             : 
+    2547           7 : DltReturnValue dlt_user_log_write_int8_attr(DltContextData *log, int8_t data, const char *name, const char *unit)
+    2548             : {
+    2549             :     uint32_t type_info = DLT_TYPE_INFO_SINT | DLT_TYLE_8BIT;
+    2550           7 :     const VarInfo var_info = { name, unit, true };
+    2551           7 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(int8_t), type_info, &var_info);
+    2552             : }
+    2553             : 
+    2554           7 : DltReturnValue dlt_user_log_write_int16_attr(DltContextData *log, int16_t data, const char *name, const char *unit)
+    2555             : {
+    2556             :     uint32_t type_info = DLT_TYPE_INFO_SINT | DLT_TYLE_16BIT;
+    2557           7 :     const VarInfo var_info = { name, unit, true };
+    2558           7 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(int16_t), type_info, &var_info);
+    2559             : }
+    2560             : 
+    2561          14 : DltReturnValue dlt_user_log_write_int32_attr(DltContextData *log, int32_t data, const char *name, const char *unit)
+    2562             : {
+    2563             :     uint32_t type_info = DLT_TYPE_INFO_SINT | DLT_TYLE_32BIT;
+    2564          14 :     const VarInfo var_info = { name, unit, true };
+    2565          14 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(int32_t), type_info, &var_info);
+    2566             : }
+    2567             : 
+    2568           7 : DltReturnValue dlt_user_log_write_int64_attr(DltContextData *log, int64_t data, const char *name, const char *unit)
+    2569             : {
+    2570             :     uint32_t type_info = DLT_TYPE_INFO_SINT | DLT_TYLE_64BIT;
+    2571           7 :     const VarInfo var_info = { name, unit, true };
+    2572           7 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(int64_t), type_info, &var_info);
+    2573             : }
+    2574             : 
+    2575           3 : DltReturnValue dlt_user_log_write_bool(DltContextData *log, uint8_t data)
+    2576             : {
+    2577             :     uint32_t type_info = DLT_TYPE_INFO_BOOL | DLT_TYLE_8BIT;
+    2578           3 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(uint8_t), type_info, NULL);
+    2579             : }
+    2580             : 
+    2581           3 : DltReturnValue dlt_user_log_write_bool_attr(DltContextData *log, uint8_t data, const char *name)
+    2582             : {
+    2583             :     uint32_t type_info = DLT_TYPE_INFO_BOOL | DLT_TYLE_8BIT;
+    2584           3 :     const VarInfo var_info = { name, NULL, false };
+    2585           3 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(uint8_t), type_info, &var_info);
+    2586             : }
+    2587             : 
+    2588       11686 : DltReturnValue dlt_user_log_write_string(DltContextData *log, const char *text)
+    2589             : {
+    2590       11686 :     return dlt_user_log_write_string_utils_attr(log, text, ASCII_STRING, NULL, false);
+    2591             : }
+    2592             : 
+    2593           7 : DltReturnValue dlt_user_log_write_string_attr(DltContextData *log, const char *text, const char *name)
+    2594             : {
+    2595           7 :     return dlt_user_log_write_string_utils_attr(log, text, ASCII_STRING, name, true);
+    2596             : }
+    2597             : 
+    2598           2 : DltReturnValue dlt_user_log_write_sized_string(DltContextData *log, const char *text, uint16_t length)
+    2599             : {
+    2600           2 :     return dlt_user_log_write_sized_string_utils_attr(log, text, length, ASCII_STRING, NULL, false);
+    2601             : }
+    2602             : 
+    2603           6 : DltReturnValue dlt_user_log_write_sized_string_attr(DltContextData *log, const char *text, uint16_t length, const char *name)
+    2604             : {
+    2605           6 :     return dlt_user_log_write_sized_string_utils_attr(log, text, length, ASCII_STRING, name, true);
+    2606             : }
+    2607             : 
+    2608           7 : DltReturnValue dlt_user_log_write_constant_string(DltContextData *log, const char *text)
+    2609             : {
+    2610             :     /* Send parameter only in verbose mode */
+    2611           8 :     return is_verbose_mode(dlt_user.verbose_mode, log) ? dlt_user_log_write_string(log, text) : DLT_RETURN_OK;
+    2612             : }
+    2613             : 
+    2614           5 : DltReturnValue dlt_user_log_write_constant_string_attr(DltContextData *log, const char *text, const char *name)
+    2615             : {
+    2616             :     /* Send parameter only in verbose mode */
+    2617           7 :     return is_verbose_mode(dlt_user.verbose_mode, log) ? dlt_user_log_write_string_attr(log, text, name) : DLT_RETURN_OK;
+    2618             : }
+    2619             : 
+    2620           1 : DltReturnValue dlt_user_log_write_sized_constant_string(DltContextData *log, const char *text, uint16_t length)
+    2621             : {
+    2622             :     /* Send parameter only in verbose mode */
+    2623           1 :     return is_verbose_mode(dlt_user.verbose_mode, log) ? dlt_user_log_write_sized_string(log, text, length) : DLT_RETURN_OK;
+    2624             : }
+    2625             : 
+    2626           3 : DltReturnValue dlt_user_log_write_sized_constant_string_attr(DltContextData *log, const char *text, uint16_t length, const char *name)
+    2627             : {
+    2628             :     /* Send parameter only in verbose mode */
+    2629           3 :     return is_verbose_mode(dlt_user.verbose_mode, log) ? dlt_user_log_write_sized_string_attr(log, text, length, name) : DLT_RETURN_OK;
+    2630             : }
+    2631             : 
+    2632          21 : DltReturnValue dlt_user_log_write_utf8_string(DltContextData *log, const char *text)
+    2633             : {
+    2634          21 :     return dlt_user_log_write_string_utils_attr(log, text, UTF8_STRING, NULL, false);
+    2635             : }
+    2636             : 
+    2637           7 : DltReturnValue dlt_user_log_write_utf8_string_attr(DltContextData *log, const char *text, const char *name)
+    2638             : {
+    2639           7 :     return dlt_user_log_write_string_utils_attr(log, text, UTF8_STRING, name, true);
+    2640             : }
+    2641             : 
+    2642           8 : DltReturnValue dlt_user_log_write_sized_utf8_string(DltContextData *log, const char *text, uint16_t length)
+    2643             : {
+    2644           8 :     return dlt_user_log_write_sized_string_utils_attr(log, text, length, UTF8_STRING, NULL, false);
+    2645             : }
+    2646             : 
+    2647           7 : DltReturnValue dlt_user_log_write_sized_utf8_string_attr(DltContextData *log, const char *text, uint16_t length, const char *name)
+    2648             : {
+    2649           7 :     return dlt_user_log_write_sized_string_utils_attr(log, text, length, UTF8_STRING, name, true);
+    2650             : }
+    2651             : 
+    2652           5 : DltReturnValue dlt_user_log_write_constant_utf8_string(DltContextData *log, const char *text)
+    2653             : {
+    2654             :     /* Send parameter only in verbose mode */
+    2655           6 :     return is_verbose_mode(dlt_user.verbose_mode, log) ? dlt_user_log_write_utf8_string(log, text) : DLT_RETURN_OK;
+    2656             : }
+    2657             : 
+    2658           4 : DltReturnValue dlt_user_log_write_constant_utf8_string_attr(DltContextData *log, const char *text, const char *name)
+    2659             : {
+    2660             :     /* Send parameter only in verbose mode */
+    2661           4 :     return is_verbose_mode(dlt_user.verbose_mode, log) ? dlt_user_log_write_utf8_string_attr(log, text, name) : DLT_RETURN_OK;
+    2662             : }
+    2663             : 
+    2664           5 : DltReturnValue dlt_user_log_write_sized_constant_utf8_string(DltContextData *log, const char *text, uint16_t length)
+    2665             : {
+    2666             :     /* Send parameter only in verbose mode */
+    2667           6 :     return is_verbose_mode(dlt_user.verbose_mode, log) ? dlt_user_log_write_sized_utf8_string(log, text, length) : DLT_RETURN_OK;
+    2668             : }
+    2669             : 
+    2670           4 : DltReturnValue dlt_user_log_write_sized_constant_utf8_string_attr(DltContextData *log, const char *text, uint16_t length, const char *name)
+    2671             : {
+    2672             :     /* Send parameter only in verbose mode */
+    2673           4 :     return is_verbose_mode(dlt_user.verbose_mode, log) ? dlt_user_log_write_sized_utf8_string_attr(log, text, length, name) : DLT_RETURN_OK;
+    2674             : }
+    2675             : 
+    2676       11729 : static DltReturnValue dlt_user_log_write_sized_string_utils_attr(DltContextData *log, const char *text, size_t length, const enum StringType type, const char *name, bool with_var_info)
+    2677             : {
+    2678       11729 :     if ((log == NULL) || (text == NULL))
+    2679             :         return DLT_RETURN_WRONG_PARAMETER;
+    2680             : 
+    2681       11720 :     if (!DLT_USER_INITALIZED_NOT_FREEING) {
+    2682           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_init_state=%i (expected INIT_DONE), dlt_user_freeing=%i\n", __FUNCTION__, dlt_user_init_state, dlt_user_freeing);
+    2683           0 :         return DLT_RETURN_ERROR;
+    2684             :     }
+    2685             : 
+    2686       11720 :     const uint16_t name_size = (name != NULL) ? strlen(name)+1 : 0;
+    2687             : 
+    2688       11720 :     size_t arg_size = (size_t) (length + 1);
+    2689             : 
+    2690       11720 :     size_t new_log_size = log->size + arg_size + sizeof(uint16_t);
+    2691             : 
+    2692       11720 :     uint32_t type_info = 0;
+    2693             : 
+    2694       11727 :     if (is_verbose_mode(dlt_user.verbose_mode, log)) {
+    2695       11720 :         new_log_size += sizeof(uint32_t);
+    2696       11720 :         if (with_var_info) {
+    2697          21 :             new_log_size += sizeof(uint16_t);  // length of "name" attribute
+    2698          21 :             new_log_size += name_size;  // the "name" attribute itself
+    2699             : 
+    2700          21 :             type_info |= DLT_TYPE_INFO_VARI;
+    2701             :         }
+    2702             :     }
+    2703             : 
+    2704             :     size_t str_truncate_message_length = strlen(STR_TRUNCATED_MESSAGE) + 1;
+    2705             :     size_t max_payload_str_msg;
+    2706             :     DltReturnValue ret = DLT_RETURN_OK;
+    2707             : 
+    2708             :     /* Check log size condition */
+    2709       11720 :     if (new_log_size > dlt_user.log_buf_len) {
+    2710             :         ret = DLT_RETURN_USER_BUFFER_FULL;
+    2711             : 
+    2712             :         /* Re-calculate arg_size */
+    2713          21 :         arg_size = (size_t) (dlt_user.log_buf_len - log->size - sizeof(uint16_t));
+    2714             : 
+    2715          21 :         size_t min_payload_str_truncate_msg = log->size + str_truncate_message_length + sizeof(uint16_t);
+    2716             : 
+    2717          21 :         if (is_verbose_mode(dlt_user.verbose_mode, log)) {
+    2718          21 :             min_payload_str_truncate_msg += sizeof(uint32_t);
+    2719          21 :             arg_size -= (size_t) sizeof(uint32_t);
+    2720          21 :             if (with_var_info) {
+    2721           0 :                 min_payload_str_truncate_msg += sizeof(uint16_t) + name_size;
+    2722           0 :                 arg_size -= sizeof(uint16_t) + name_size;
+    2723             :             }
+    2724             :         }
+    2725             : 
+    2726             :         /* Return when dlt_user.log_buf_len does not have enough space for min_payload_str_truncate_msg */
+    2727          21 :         if (min_payload_str_truncate_msg > dlt_user.log_buf_len) {
+    2728           1 :             dlt_vlog(LOG_WARNING, "%s not enough minimum space to store data\n", __FUNCTION__);
+    2729           1 :             return ret;
+    2730             :         }
+    2731             : 
+    2732             :         /* Calculate the maximum size of string will be copied after truncate */
+    2733          20 :         max_payload_str_msg = dlt_user.log_buf_len - min_payload_str_truncate_msg;
+    2734             : 
+    2735          20 :         if (type == UTF8_STRING) {
+    2736             :             /**
+    2737             :              * Adjust the lengh to truncate one utf8 character corectly
+    2738             :              * refer: https://en.wikipedia.org/wiki/UTF-8
+    2739             :              * one utf8 character will have maximum 4 bytes then maximum bytes will be truncate additional is 3
+    2740             :              */
+    2741          12 :             const char *tmp = (text + max_payload_str_msg - 3);
+    2742             :             uint16_t reduce_size = 0;
+    2743             : 
+    2744          12 :             if (tmp[2] & 0x80) {
+    2745             :                 /* Is the last byte of truncated text is the first byte in multi-byte sequence (utf8 2 bytes) */
+    2746           9 :                 if (tmp[2] & 0x40)
+    2747             :                     reduce_size = 1;
+    2748             :                 /* Is the next to last byte of truncated text is the first byte in multi-byte sequence (utf8 3 bytes) */
+    2749           6 :                 else if ((tmp[1] & 0xe0) == 0xe0)
+    2750             :                     reduce_size = 2;
+    2751             :                 /* utf8 4 bytes */
+    2752           3 :                 else if ((tmp[0] & 0xf0) == 0xf0)
+    2753             :                     reduce_size = 3;
+    2754             :             }
+    2755             : 
+    2756          12 :             max_payload_str_msg -= reduce_size;
+    2757          12 :             arg_size -= (size_t) reduce_size;
+    2758             :         }
+    2759             :     }
+    2760             : 
+    2761       11719 :     if (is_verbose_mode(dlt_user.verbose_mode, log)) {
+    2762       11719 :         switch (type) {
+    2763       11694 :         case ASCII_STRING:
+    2764       11694 :             type_info |= DLT_TYPE_INFO_STRG | DLT_SCOD_ASCII;
+    2765       11694 :             break;
+    2766          25 :         case UTF8_STRING:
+    2767          25 :             type_info |= DLT_TYPE_INFO_STRG | DLT_SCOD_UTF8;
+    2768          25 :             break;
+    2769             :         default:
+    2770             :             /* Do nothing */
+    2771             :             break;
+    2772             :         }
+    2773             : 
+    2774       11719 :         memcpy(log->buffer + log->size, &type_info, sizeof(uint32_t));
+    2775       11719 :         log->size += sizeof(uint32_t);
+    2776             :     }
+    2777             : 
+    2778       11719 :     memcpy(log->buffer + log->size, &arg_size, sizeof(uint16_t));
+    2779       11719 :     log->size += sizeof(uint16_t);
+    2780             : 
+    2781       11726 :     if (is_verbose_mode(dlt_user.verbose_mode, log)) {
+    2782       11719 :         if (with_var_info) {
+    2783             :             // Write length of "name" attribute.
+    2784             :             // We assume that the protocol allows zero-sized strings here (which this code will create
+    2785             :             // when the input pointer is NULL).
+    2786          21 :             memcpy(log->buffer + log->size, &name_size, sizeof(uint16_t));
+    2787          21 :             log->size += sizeof(uint16_t);
+    2788             : 
+    2789             :             // Write name string itself.
+    2790             :             // Must not use NULL as source pointer for memcpy. This check assures that.
+    2791          21 :             if (name_size != 0) {
+    2792          15 :                 memcpy(log->buffer + log->size, name, name_size);
+    2793          15 :                 log->size += name_size;
+    2794             :             }
+    2795             :         }
+    2796             :     }
+    2797             : 
+    2798       11719 :     switch (ret) {
+    2799       11699 :     case DLT_RETURN_OK:
+    2800             :     {
+    2801             :         /* Whole string will be copied */
+    2802       11699 :         memcpy(log->buffer + log->size, text, length);
+    2803             :         /* The input string might not be null-terminated, so we're doing that by ourselves */
+    2804       11699 :         log->buffer[log->size + length] = '\0';
+    2805       11699 :         log->size += arg_size;
+    2806       11699 :         break;
+    2807             :     }
+    2808          20 :     case DLT_RETURN_USER_BUFFER_FULL:
+    2809             :     {
+    2810             :         /* Only copy partial string */
+    2811          20 :         memcpy(log->buffer + log->size, text, max_payload_str_msg);
+    2812          20 :         log->size += max_payload_str_msg;
+    2813             : 
+    2814             :         /* Append string truncate the input string */
+    2815          20 :         memcpy(log->buffer + log->size, STR_TRUNCATED_MESSAGE, str_truncate_message_length);
+    2816          20 :         log->size += str_truncate_message_length;
+    2817          20 :         break;
+    2818             :     }
+    2819             :     default:
+    2820             :     {
+    2821             :         /* Do nothing */
+    2822             :         break;
+    2823             :     }
+    2824             :     }
+    2825             : 
+    2826       11719 :     log->args_num++;
+    2827             : 
+    2828       11719 :     return ret;
+    2829             : }
+    2830             : 
+    2831       11721 : static DltReturnValue dlt_user_log_write_string_utils_attr(DltContextData *log, const char *text, const enum StringType type, const char *name, bool with_var_info)
+    2832             : {
+    2833       11721 :     if ((log == NULL) || (text == NULL))
+    2834             :         return DLT_RETURN_WRONG_PARAMETER;
+    2835             : 
+    2836       11706 :     size_t length = strlen(text);
+    2837       11706 :     return dlt_user_log_write_sized_string_utils_attr(log, text, length, type, name, with_var_info);
+    2838             : }
+    2839             : 
+    2840           0 : DltReturnValue dlt_register_injection_callback_with_id(DltContext *handle, uint32_t service_id,
+    2841             :                                                        dlt_injection_callback_id dlt_injection_cbk, void *priv)
+    2842             : {
+    2843             :     DltContextData log;
+    2844             :     uint32_t i, j, k;
+    2845             :     int found = 0;
+    2846             : 
+    2847             :     DltUserInjectionCallback *old;
+    2848             : 
+    2849           0 :     if (dlt_user_log_init(handle, &log) < DLT_RETURN_OK)
+    2850             :         return DLT_RETURN_ERROR;
+    2851             : 
+    2852           0 :     if (service_id < DLT_USER_INJECTION_MIN)
+    2853             :         return DLT_RETURN_WRONG_PARAMETER;
+    2854             : 
+    2855             :     /* This function doesn't make sense storing to local file is choosen;
+    2856             :      * so terminate this function */
+    2857           0 :     if (dlt_user.dlt_is_file)
+    2858             :         return DLT_RETURN_OK;
+    2859             : 
+    2860           0 :     DLT_SEM_LOCK();
+    2861             : 
+    2862           0 :     if (dlt_user.dlt_ll_ts == NULL) {
+    2863           0 :         DLT_SEM_FREE();
+    2864           0 :         return DLT_RETURN_OK;
+    2865             :     }
+    2866             : 
+    2867             :     /* Insert callback in corresponding table */
+    2868           0 :     i = (uint32_t) handle->log_level_pos;
+    2869             : 
+    2870             :     /* Insert each service_id only once */
+    2871           0 :     for (k = 0; k < dlt_user.dlt_ll_ts[i].nrcallbacks; k++)
+    2872           0 :         if ((dlt_user.dlt_ll_ts[i].injection_table) &&
+    2873           0 :             (dlt_user.dlt_ll_ts[i].injection_table[k].service_id == service_id)) {
+    2874             :             found = 1;
+    2875             :             break;
+    2876             :         }
+    2877             : 
+    2878           0 :     if (found) {
+    2879             :         j = k;
+    2880             :     }
+    2881             :     else {
+    2882             :         j = dlt_user.dlt_ll_ts[i].nrcallbacks;
+    2883             : 
+    2884             :         /* Allocate or expand injection table */
+    2885           0 :         if (dlt_user.dlt_ll_ts[i].injection_table == NULL) {
+    2886           0 :             dlt_user.dlt_ll_ts[i].injection_table =
+    2887           0 :                 (DltUserInjectionCallback *)malloc(sizeof(DltUserInjectionCallback));
+    2888             : 
+    2889           0 :             if (dlt_user.dlt_ll_ts[i].injection_table == NULL) {
+    2890           0 :                 DLT_SEM_FREE();
+    2891           0 :                 return DLT_RETURN_ERROR;
+    2892             :             }
+    2893             :         }
+    2894             :         else {
+    2895             :             old = dlt_user.dlt_ll_ts[i].injection_table;
+    2896           0 :             dlt_user.dlt_ll_ts[i].injection_table = (DltUserInjectionCallback *)malloc(
+    2897           0 :                 sizeof(DltUserInjectionCallback) * (j + 1));
+    2898             : 
+    2899           0 :             if (dlt_user.dlt_ll_ts[i].injection_table == NULL) {
+    2900           0 :                 dlt_user.dlt_ll_ts[i].injection_table = old;
+    2901           0 :                 DLT_SEM_FREE();
+    2902           0 :                 return DLT_RETURN_ERROR;
+    2903             :             }
+    2904             : 
+    2905           0 :             memcpy(dlt_user.dlt_ll_ts[i].injection_table, old, sizeof(DltUserInjectionCallback) * j);
+    2906           0 :             free(old);
+    2907             :         }
+    2908             : 
+    2909           0 :         dlt_user.dlt_ll_ts[i].nrcallbacks++;
+    2910             :     }
+    2911             : 
+    2912             :     /* Store service_id and corresponding function pointer for callback function */
+    2913           0 :     dlt_user.dlt_ll_ts[i].injection_table[j].service_id = service_id;
+    2914             : 
+    2915           0 :     if (priv == NULL) {
+    2916           0 :         dlt_user.dlt_ll_ts[i].injection_table[j].injection_callback = (dlt_injection_callback)(void*)dlt_injection_cbk;
+    2917           0 :         dlt_user.dlt_ll_ts[i].injection_table[j].injection_callback_with_id = NULL;
+    2918           0 :         dlt_user.dlt_ll_ts[i].injection_table[j].data = NULL;
+    2919             :     }
+    2920             :     else {
+    2921           0 :         dlt_user.dlt_ll_ts[i].injection_table[j].injection_callback = NULL;
+    2922           0 :         dlt_user.dlt_ll_ts[i].injection_table[j].injection_callback_with_id = dlt_injection_cbk;
+    2923           0 :         dlt_user.dlt_ll_ts[i].injection_table[j].data = priv;
+    2924             :     }
+    2925             : 
+    2926           0 :     DLT_SEM_FREE();
+    2927             : 
+    2928           0 :     return DLT_RETURN_OK;
+    2929             : }
+    2930             : 
+    2931           0 : DltReturnValue dlt_register_injection_callback(DltContext *handle, uint32_t service_id,
+    2932             :                                                int (*dlt_injection_callback)(uint32_t service_id,
+    2933             :                                                                              void *data,
+    2934             :                                                                              uint32_t length))
+    2935             : {
+    2936           0 :     return dlt_register_injection_callback_with_id(handle,
+    2937             :                                                    service_id,
+    2938             :                                                    (dlt_injection_callback_id)(void*)dlt_injection_callback,
+    2939             :                                                    NULL);
+    2940             : }
+    2941             : 
+    2942           1 : DltReturnValue dlt_register_log_level_changed_callback(DltContext *handle,
+    2943             :                                                        void (*dlt_log_level_changed_callback)(
+    2944             :                                                            char context_id[DLT_ID_SIZE],
+    2945             :                                                            uint8_t log_level,
+    2946             :                                                            uint8_t trace_status))
+    2947             : {
+    2948             :     DltContextData log;
+    2949             :     uint32_t i;
+    2950             : 
+    2951           1 :     if (dlt_user_log_init(handle, &log) < DLT_RETURN_OK)
+    2952             :         return DLT_RETURN_ERROR;
+    2953             : 
+    2954             :     /* This function doesn't make sense storing to local file is choosen;
+    2955             :      * so terminate this function */
+    2956           1 :     if (dlt_user.dlt_is_file)
+    2957             :         return DLT_RETURN_OK;
+    2958             : 
+    2959           1 :     DLT_SEM_LOCK();
+    2960             : 
+    2961           1 :     if (dlt_user.dlt_ll_ts == NULL) {
+    2962           0 :         DLT_SEM_FREE();
+    2963           0 :         return DLT_RETURN_OK;
+    2964             :     }
+    2965             : 
+    2966             :     /* Insert callback in corresponding table */
+    2967           1 :     i = (uint32_t) handle->log_level_pos;
+    2968             : 
+    2969             :     /* Store new callback function */
+    2970           1 :     dlt_user.dlt_ll_ts[i].log_level_changed_callback = dlt_log_level_changed_callback;
+    2971             : 
+    2972           1 :     DLT_SEM_FREE();
+    2973             : 
+    2974           1 :     return DLT_RETURN_OK;
+    2975             : }
+    2976             : 
+    2977             : /**
+    2978             :  * NW Trace related
+    2979             :  */
+    2980             : 
+    2981             : #ifdef DLT_NETWORK_TRACE_ENABLE
+    2982           0 : int check_buffer(void)
+    2983             : {
+    2984             :     int total_size, used_size;
+    2985           0 :     dlt_user_check_buffer(&total_size, &used_size);
+    2986             : 
+    2987           0 :     return (total_size - used_size < total_size / 2) ? -1 : 1;
+    2988             : }
+    2989             : 
+    2990             : /**
+    2991             :  * Send the start of a segment chain.
+    2992             :  * Returns DLT_RETURN_ERROR on failure
+    2993             :  */
+    2994           0 : DltReturnValue dlt_user_trace_network_segmented_start(uint32_t *id,
+    2995             :                                                       DltContext *handle,
+    2996             :                                                       DltNetworkTraceType nw_trace_type,
+    2997             :                                                       uint16_t header_len,
+    2998             :                                                       void *header,
+    2999             :                                                       uint16_t payload_len)
+    3000             : {
+    3001           0 :     DltContextData log = { 0 };
+    3002             :     struct timeval tv;
+    3003             :     int ret = DLT_RETURN_ERROR;
+    3004             : 
+    3005             :     /* check null pointer */
+    3006           0 :     if (id == NULL)
+    3007             :         return DLT_RETURN_WRONG_PARAMETER;
+    3008             : 
+    3009           0 :     if ((nw_trace_type < DLT_NW_TRACE_IPC) || (nw_trace_type >= DLT_NW_TRACE_MAX)) {
+    3010           0 :         dlt_vlog(LOG_ERR, "Network trace type %u is outside valid range", nw_trace_type);
+    3011           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    3012             :     }
+    3013             : 
+    3014           0 :     if (dlt_user.dlt_ll_ts == NULL)
+    3015             :         return DLT_RETURN_ERROR;
+    3016             : 
+    3017           0 :     if (handle->trace_status_ptr && (*(handle->trace_status_ptr) == DLT_TRACE_STATUS_ON)) {
+    3018             :         /* initialize values */
+    3019           0 :         if (dlt_user_log_init(handle, &log) < DLT_RETURN_OK)
+    3020             :             return DLT_RETURN_ERROR;
+    3021             : 
+    3022           0 :         if (log.buffer == NULL) {
+    3023           0 :             log.buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
+    3024             : 
+    3025           0 :             if (log.buffer == NULL) {
+    3026           0 :                 dlt_vlog(LOG_ERR, "Cannot allocate buffer for DLT Log message\n");
+    3027           0 :                 return DLT_RETURN_ERROR;
+    3028             :             }
+    3029             :         }
+    3030             : 
+    3031           0 :         log.args_num = 0;
+    3032           0 :         log.trace_status = nw_trace_type;
+    3033           0 :         log.size = 0;
+    3034             : 
+    3035           0 :         gettimeofday(&tv, NULL);
+    3036           0 :         *id = (uint32_t) tv.tv_usec;
+    3037             : 
+    3038             :         /* Write identifier */
+    3039           0 :         if (dlt_user_log_write_string(&log, DLT_TRACE_NW_START) < 0) {
+    3040             :             dlt_user_free_buffer(&(log.buffer));
+    3041           0 :             return DLT_RETURN_ERROR;
+    3042             :         }
+    3043             : 
+    3044             :         /* Write stream handle */
+    3045           0 :         if (dlt_user_log_write_uint32(&log, *id) < 0) {
+    3046             :             dlt_user_free_buffer(&(log.buffer));
+    3047           0 :             return DLT_RETURN_ERROR;
+    3048             :         }
+    3049             : 
+    3050             :         /* Write header */
+    3051           0 :         if (dlt_user_log_write_raw(&log, header, header_len) < 0) {
+    3052             :             dlt_user_free_buffer(&(log.buffer));
+    3053           0 :             return DLT_RETURN_ERROR;
+    3054             :         }
+    3055             : 
+    3056             :         /* Write size of payload */
+    3057           0 :         if (dlt_user_log_write_uint32(&log, payload_len) < 0) {
+    3058             :             dlt_user_free_buffer(&(log.buffer));
+    3059           0 :             return DLT_RETURN_ERROR;
+    3060             :         }
+    3061             : 
+    3062             :         /* Write expected segment count */
+    3063           0 :         uint16_t segment_count = (uint16_t) (payload_len / DLT_MAX_TRACE_SEGMENT_SIZE + 1);
+    3064             : 
+    3065             :         /* If segments align perfectly with segment size, avoid sending empty segment */
+    3066           0 :         if ((payload_len % DLT_MAX_TRACE_SEGMENT_SIZE) == 0)
+    3067             :             segment_count--;
+    3068             : 
+    3069           0 :         if (dlt_user_log_write_uint16(&log, segment_count) < 0) {
+    3070             :             dlt_user_free_buffer(&(log.buffer));
+    3071           0 :             return DLT_RETURN_ERROR;
+    3072             :         }
+    3073             : 
+    3074             :         /* Write length of one segment */
+    3075           0 :         if (dlt_user_log_write_uint16(&log, DLT_MAX_TRACE_SEGMENT_SIZE) < 0) {
+    3076             :             dlt_user_free_buffer(&(log.buffer));
+    3077           0 :             return DLT_RETURN_ERROR;
+    3078             :         }
+    3079             : 
+    3080             :         /* Send log */
+    3081           0 :         ret = dlt_user_log_send_log(&log, DLT_TYPE_NW_TRACE, NULL);
+    3082             : 
+    3083             :         dlt_user_free_buffer(&(log.buffer));
+    3084             : 
+    3085           0 :         return ret;
+    3086             :     }
+    3087             : 
+    3088             :     return DLT_RETURN_OK;
+    3089             : }
+    3090             : 
+    3091           0 : DltReturnValue dlt_user_trace_network_segmented_segment(uint32_t id,
+    3092             :                                                         DltContext *handle,
+    3093             :                                                         DltNetworkTraceType nw_trace_type,
+    3094             :                                                         int sequence,
+    3095             :                                                         uint16_t payload_len,
+    3096             :                                                         void *payload)
+    3097             : {
+    3098             :     int ret = DLT_RETURN_ERROR;
+    3099             :     struct timespec ts;
+    3100             : 
+    3101           0 :     if ((nw_trace_type < DLT_NW_TRACE_IPC) || (nw_trace_type >= DLT_NW_TRACE_MAX)) {
+    3102           0 :         dlt_vlog(LOG_ERR, "Network trace type %u is outside valid range", nw_trace_type);
+    3103           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    3104             :     }
+    3105             : 
+    3106           0 :     while (check_buffer() < 0) {
+    3107             :         /* Wait 50ms */
+    3108           0 :         ts.tv_sec = 0;
+    3109           0 :         ts.tv_nsec = 1000000 * 50;
+    3110           0 :         nanosleep(&ts, NULL);
+    3111           0 :         dlt_user_log_resend_buffer();
+    3112             :     }
+    3113             : 
+    3114           0 :     if (dlt_user.dlt_ll_ts == NULL)
+    3115             :         return DLT_RETURN_ERROR;
+    3116             : 
+    3117           0 :     if (handle->trace_status_ptr && (*(handle->trace_status_ptr) == DLT_TRACE_STATUS_ON)) {
+    3118           0 :         DltContextData log = { 0 };
+    3119             : 
+    3120           0 :         if (dlt_user_log_init(handle, &log) < DLT_RETURN_OK)
+    3121             :             return DLT_RETURN_ERROR;
+    3122             : 
+    3123             :         /* initialize values */
+    3124           0 :         if (log.buffer == NULL) {
+    3125           0 :             log.buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
+    3126             : 
+    3127           0 :             if (log.buffer == NULL) {
+    3128           0 :                 dlt_vlog(LOG_ERR, "Cannot allocate buffer for DLT Log message\n");
+    3129           0 :                 return DLT_RETURN_ERROR;
+    3130             :             }
+    3131             :         }
+    3132             : 
+    3133           0 :         log.args_num = 0;
+    3134           0 :         log.trace_status = nw_trace_type;
+    3135           0 :         log.size = 0;
+    3136             : 
+    3137             :         /* Write identifier */
+    3138           0 :         if (dlt_user_log_write_string(&log, DLT_TRACE_NW_SEGMENT) < DLT_RETURN_OK) {
+    3139             :             dlt_user_free_buffer(&(log.buffer));
+    3140           0 :             return DLT_RETURN_ERROR;
+    3141             :         }
+    3142             : 
+    3143             :         /* Write stream handle */
+    3144           0 :         if (dlt_user_log_write_uint32(&log, id) < DLT_RETURN_OK) {
+    3145             :             dlt_user_free_buffer(&(log.buffer));
+    3146           0 :             return DLT_RETURN_ERROR;
+    3147             :         }
+    3148             : 
+    3149             :         /* Write segment sequence number */
+    3150           0 :         if (dlt_user_log_write_uint16(&log, (uint16_t) sequence) < DLT_RETURN_OK) {
+    3151             :             dlt_user_free_buffer(&(log.buffer));
+    3152           0 :             return DLT_RETURN_ERROR;
+    3153             :         }
+    3154             : 
+    3155             :         /* Write data */
+    3156           0 :         if (dlt_user_log_write_raw(&log, payload, payload_len) < DLT_RETURN_OK) {
+    3157             :             dlt_user_free_buffer(&(log.buffer));
+    3158           0 :             return DLT_RETURN_ERROR;
+    3159             :         }
+    3160             : 
+    3161           0 :         ret = dlt_user_log_send_log(&log, DLT_TYPE_NW_TRACE, NULL);
+    3162             :         /* Send log */
+    3163             : 
+    3164             :         dlt_user_free_buffer(&(log.buffer));
+    3165             : 
+    3166           0 :         return ret;
+    3167             :     }
+    3168             : 
+    3169             :     /* Allow other threads to log between chunks */
+    3170           0 :     sched_yield();
+    3171           0 :     return DLT_RETURN_OK;
+    3172             : }
+    3173             : 
+    3174           0 : DltReturnValue dlt_user_trace_network_segmented_end(uint32_t id, DltContext *handle, DltNetworkTraceType nw_trace_type)
+    3175             : {
+    3176           0 :     DltContextData log = { 0 };
+    3177             :     int ret = DLT_RETURN_ERROR;
+    3178             : 
+    3179           0 :     if ((nw_trace_type < DLT_NW_TRACE_IPC) || (nw_trace_type >= DLT_NW_TRACE_MAX)) {
+    3180           0 :         dlt_vlog(LOG_ERR, "Network trace type %u is outside valid range", nw_trace_type);
+    3181           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    3182             :     }
+    3183             : 
+    3184           0 :     if (dlt_user.dlt_ll_ts == NULL)
+    3185             :         return DLT_RETURN_ERROR;
+    3186             : 
+    3187           0 :     if (handle->trace_status_ptr && (*(handle->trace_status_ptr) == DLT_TRACE_STATUS_ON)) {
+    3188             :         /* initialize values */
+    3189           0 :         if (dlt_user_log_init(handle, &log) < DLT_RETURN_OK)
+    3190             :             return DLT_RETURN_ERROR;
+    3191             : 
+    3192             :         /* initialize values */
+    3193           0 :         if (log.buffer == NULL) {
+    3194           0 :             log.buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
+    3195             : 
+    3196           0 :             if (log.buffer == NULL) {
+    3197           0 :                 dlt_vlog(LOG_ERR, "Cannot allocate buffer for DLT Log message\n");
+    3198           0 :                 return DLT_RETURN_ERROR;
+    3199             :             }
+    3200             :         }
+    3201             : 
+    3202           0 :         log.args_num = 0;
+    3203           0 :         log.trace_status = nw_trace_type;
+    3204           0 :         log.size = 0;
+    3205             : 
+    3206             :         /* Write identifier */
+    3207           0 :         if (dlt_user_log_write_string(&log, DLT_TRACE_NW_END) < DLT_RETURN_OK) {
+    3208             :             dlt_user_free_buffer(&(log.buffer));
+    3209           0 :             return DLT_RETURN_ERROR;
+    3210             :         }
+    3211             : 
+    3212             :         /* Write stream handle */
+    3213           0 :         if (dlt_user_log_write_uint32(&log, id) < DLT_RETURN_OK) {
+    3214             :             dlt_user_free_buffer(&(log.buffer));
+    3215           0 :             return DLT_RETURN_ERROR;
+    3216             :         }
+    3217             : 
+    3218           0 :         ret = dlt_user_log_send_log(&log, DLT_TYPE_NW_TRACE, NULL);
+    3219             :         /* Send log */
+    3220             : 
+    3221             :         dlt_user_free_buffer(&(log.buffer));
+    3222             : 
+    3223           0 :         return ret;
+    3224             : 
+    3225             :     }
+    3226             : 
+    3227             :     return DLT_RETURN_OK;
+    3228             : }
+    3229             : 
+    3230       16786 : void dlt_user_trace_network_segmented_thread(void *unused)
+    3231             : {
+    3232             :     /* Unused on purpose. */
+    3233             :     (void)unused;
+    3234             : #ifdef DLT_USE_PTHREAD_SETNAME_NP
+    3235       16786 :     if (pthread_setname_np(dlt_user.dlt_segmented_nwt_handle, "dlt_segmented"))
+    3236           0 :         dlt_log(LOG_WARNING, "Failed to rename segmented thread!\n");
+    3237             : #elif linux
+    3238             :     if (prctl(PR_SET_NAME, "dlt_segmented", 0, 0, 0) < 0)
+    3239             :         dlt_log(LOG_WARNING, "Failed to rename segmented thread!\n");
+    3240             : #endif
+    3241       33572 :     pthread_cleanup_push(dlt_user_cleanup_handler, NULL);
+    3242             : 
+    3243             :     s_segmented_data *data;
+    3244             : 
+    3245             :     while (1) {
+    3246             :         /* Wait until message queue is initialized */
+    3247       16786 :         dlt_lock_mutex(&mq_mutex);
+    3248             : 
+    3249       17033 :         while (dlt_user.dlt_segmented_queue_read_handle < 0)
+    3250             :         {
+    3251       17033 :             pthread_cond_wait(&mq_init_condition, &mq_mutex);
+    3252             :         }
+    3253             : 
+    3254           0 :         dlt_unlock_mutex(&mq_mutex);
+    3255             : 
+    3256           0 :         ssize_t read = mq_receive(dlt_user.dlt_segmented_queue_read_handle, (char *)&data,
+    3257             :                                   sizeof(s_segmented_data *), NULL);
+    3258             : 
+    3259           0 :         if (read < 0) {
+    3260           0 :             if (errno != EINTR) {
+    3261             :                 struct timespec req;
+    3262             :                 long sec = (DLT_USER_MQ_ERROR_RETRY_INTERVAL / 1000000);
+    3263           0 :                 dlt_vlog(LOG_WARNING, "NWTSegmented: Error while reading queue: %s\n", strerror(errno));
+    3264           0 :                 req.tv_sec = sec;
+    3265           0 :                 req.tv_nsec = (DLT_USER_MQ_ERROR_RETRY_INTERVAL - sec * 1000000) * 1000;
+    3266           0 :                 nanosleep(&req, NULL);
+    3267             :             }
+    3268             : 
+    3269           0 :             continue;
+    3270             :         }
+    3271             : 
+    3272           0 :         if (read != sizeof(s_segmented_data *)) {
+    3273             :             /* This case will not happen. */
+    3274             :             /* When this thread is interrupted by signal, mq_receive() will not return */
+    3275             :             /* partial read length and will return -1. And also no data is removed from mq. */
+    3276           0 :             dlt_vlog(LOG_WARNING, "NWTSegmented: Could not read data fully from queue: %zd\n", read);
+    3277           0 :             continue;
+    3278             :         }
+    3279             : 
+    3280           0 :         dlt_user_trace_network_segmented_thread_segmenter(data);
+    3281             : 
+    3282             :         /* Send the end message */
+    3283           0 :         DltReturnValue err = dlt_user_trace_network_segmented_end(data->id, data->handle, data->nw_trace_type);
+    3284             : 
+    3285           0 :         if ((err == DLT_RETURN_BUFFER_FULL) || (err == DLT_RETURN_ERROR))
+    3286           0 :             dlt_log(LOG_WARNING, "NWTSegmented: Could not send end segment.\n");
+    3287             : 
+    3288             :         /* Free resources */
+    3289           0 :         free(data->header);
+    3290           0 :         free(data->payload);
+    3291           0 :         free(data);
+    3292             :     }
+    3293             : 
+    3294             :     pthread_cleanup_pop(1);
+    3295             : }
+    3296             : 
+    3297           0 : void dlt_user_trace_network_segmented_thread_segmenter(s_segmented_data *data)
+    3298             : {
+    3299             :     /* Segment the data and send the chunks */
+    3300             :     void *ptr = NULL;
+    3301             :     uint32_t offset = 0;
+    3302             :     uint16_t sequence = 0;
+    3303             : 
+    3304             :     do {
+    3305             :         uint16_t len = 0;
+    3306             : 
+    3307           0 :         if (offset + DLT_MAX_TRACE_SEGMENT_SIZE > data->payload_len)
+    3308           0 :             len = (uint16_t) (data->payload_len - offset);
+    3309             :         else
+    3310             :             len = DLT_MAX_TRACE_SEGMENT_SIZE;
+    3311             : 
+    3312             :         /* If payload size aligns perfectly with segment size, avoid sending empty segment */
+    3313           0 :         if (len == 0)
+    3314             :             break;
+    3315             : 
+    3316           0 :         ptr = data->payload + offset;
+    3317           0 :         DltReturnValue err = dlt_user_trace_network_segmented_segment(data->id,
+    3318             :                                                                       data->handle,
+    3319             :                                                                       data->nw_trace_type,
+    3320           0 :                                                                       sequence++,
+    3321             :                                                                       len,
+    3322             :                                                                       ptr);
+    3323             : 
+    3324           0 :         if ((err == DLT_RETURN_BUFFER_FULL) || (err == DLT_RETURN_ERROR)) {
+    3325           0 :             dlt_log(LOG_ERR, "NWTSegmented: Could not send segment. Aborting.\n");
+    3326           0 :             break;             /* loop */
+    3327             :         }
+    3328             : 
+    3329           0 :         offset += len;
+    3330           0 :     } while (ptr < data->payload + data->payload_len);
+    3331           0 : }
+    3332             : 
+    3333             : 
+    3334           7 : DltReturnValue dlt_user_trace_network_segmented(DltContext *handle,
+    3335             :                                                 DltNetworkTraceType nw_trace_type,
+    3336             :                                                 uint16_t header_len,
+    3337             :                                                 void *header,
+    3338             :                                                 uint16_t payload_len,
+    3339             :                                                 void *payload)
+    3340             : {
+    3341             :     /* forbid dlt usage in child after fork */
+    3342           7 :     if (g_dlt_is_child)
+    3343             :         return DLT_RETURN_ERROR;
+    3344             : 
+    3345             :     /* Send as normal trace if possible */
+    3346           7 :     if (header_len + payload_len + sizeof(uint16_t) < dlt_user.log_buf_len)
+    3347           7 :         return dlt_user_trace_network(handle, nw_trace_type, header_len, header, payload_len, payload);
+    3348             : 
+    3349             :     /* Allocate Memory */
+    3350           0 :     s_segmented_data *thread_data = malloc(sizeof(s_segmented_data));
+    3351             : 
+    3352           0 :     if (thread_data == NULL)
+    3353             :         return DLT_RETURN_ERROR;
+    3354             : 
+    3355           0 :     thread_data->header = malloc(header_len);
+    3356             : 
+    3357           0 :     if (thread_data->header == NULL) {
+    3358           0 :         free(thread_data);
+    3359           0 :         return DLT_RETURN_ERROR;
+    3360             :     }
+    3361             : 
+    3362           0 :     thread_data->payload = malloc(payload_len);
+    3363             : 
+    3364           0 :     if (thread_data->payload == NULL) {
+    3365           0 :         free(thread_data->header);
+    3366           0 :         free(thread_data);
+    3367           0 :         return DLT_RETURN_ERROR;
+    3368             :     }
+    3369             : 
+    3370             :     /* Copy data */
+    3371           0 :     thread_data->handle = handle;
+    3372           0 :     thread_data->nw_trace_type = nw_trace_type;
+    3373           0 :     thread_data->header_len = header_len;
+    3374             :     memcpy(thread_data->header, header, header_len);
+    3375           0 :     thread_data->payload_len = payload_len;
+    3376             :     memcpy(thread_data->payload, payload, payload_len);
+    3377             : 
+    3378             :     /* Send start message */
+    3379           0 :     DltReturnValue err = dlt_user_trace_network_segmented_start(&(thread_data->id),
+    3380             :                                                                 thread_data->handle,
+    3381             :                                                                 thread_data->nw_trace_type,
+    3382             :                                                                 (uint16_t) thread_data->header_len,
+    3383             :                                                                 thread_data->header,
+    3384             :                                                                 (uint16_t) thread_data->payload_len);
+    3385             : 
+    3386           0 :     if ((err == DLT_RETURN_BUFFER_FULL) || (err == DLT_RETURN_ERROR)) {
+    3387           0 :         dlt_log(LOG_ERR, "NWTSegmented: Could not send start segment. Aborting.\n");
+    3388           0 :         free(thread_data->header);
+    3389           0 :         free(thread_data->payload);
+    3390           0 :         free(thread_data);
+    3391           0 :         return DLT_RETURN_ERROR;
+    3392             :     }
+    3393             : 
+    3394             :     /* Open queue if it is not open */
+    3395           0 :     if (dlt_init_message_queue() < 0) {
+    3396           0 :         dlt_log(LOG_ERR, "NWTSegmented: Could not open queue.\n");
+    3397           0 :         free(thread_data->header);
+    3398           0 :         free(thread_data->payload);
+    3399           0 :         free(thread_data);
+    3400             : 
+    3401           0 :         return DLT_RETURN_ERROR;
+    3402             :     }
+    3403             : 
+    3404             :     /* Add to queue */
+    3405           0 :     if (mq_send(dlt_user.dlt_segmented_queue_write_handle,
+    3406             :                 (char *)&thread_data, sizeof(s_segmented_data *), 1) < 0) {
+    3407           0 :         if (errno == EAGAIN)
+    3408           0 :             dlt_log(LOG_WARNING, "NWTSegmented: Queue full. Message discarded.\n");
+    3409             : 
+    3410           0 :         free(thread_data->header);
+    3411           0 :         free(thread_data->payload);
+    3412           0 :         free(thread_data);
+    3413           0 :         dlt_vnlog(LOG_WARNING, 256, "NWTSegmented: Could not write into queue: %s \n", strerror(errno));
+    3414           0 :         return DLT_RETURN_ERROR;
+    3415             :     }
+    3416             : 
+    3417             :     /*thread_data will be freed by the receiver function */
+    3418             :     /*coverity[leaked_storage] */
+    3419             :     return DLT_RETURN_OK;
+    3420             : }
+    3421             : 
+    3422          14 : DltReturnValue dlt_user_trace_network(DltContext *handle,
+    3423             :                                       DltNetworkTraceType nw_trace_type,
+    3424             :                                       uint16_t header_len,
+    3425             :                                       void *header,
+    3426             :                                       uint16_t payload_len,
+    3427             :                                       void *payload)
+    3428             : {
+    3429          14 :     return dlt_user_trace_network_truncated(handle, nw_trace_type, header_len, header, payload_len, payload, 1);
+    3430             : }
+    3431             : 
+    3432          21 : DltReturnValue dlt_user_trace_network_truncated(DltContext *handle,
+    3433             :                                                 DltNetworkTraceType nw_trace_type,
+    3434             :                                                 uint16_t header_len,
+    3435             :                                                 void *header,
+    3436             :                                                 uint16_t payload_len,
+    3437             :                                                 void *payload,
+    3438             :                                                 int allow_truncate)
+    3439             : {
+    3440             :     int ret = DLT_RETURN_ERROR;
+    3441          21 :     DltContextData log = { 0 };
+    3442             : 
+    3443          21 :     if ((payload == NULL) && (payload_len > 0))
+    3444             :         return DLT_RETURN_WRONG_PARAMETER;
+    3445             : 
+    3446          15 :     if ((nw_trace_type < DLT_NW_TRACE_IPC) || (nw_trace_type >= DLT_NW_TRACE_MAX)) {
+    3447           0 :         dlt_vlog(LOG_ERR, "Network trace type %u is outside valid range", nw_trace_type);
+    3448           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    3449             :     }
+    3450             : 
+    3451          15 :     if (dlt_user.dlt_ll_ts == NULL)
+    3452             :         return DLT_RETURN_ERROR;
+    3453             : 
+    3454          15 :     if (handle->trace_status_ptr && (*(handle->trace_status_ptr) == DLT_TRACE_STATUS_ON)) {
+    3455           0 :         if ((dlt_user_log_init(handle, &log) < DLT_RETURN_OK) || (dlt_user.dlt_ll_ts == NULL))
+    3456             :             return DLT_RETURN_ERROR;
+    3457             : 
+    3458             :         /* initialize values */
+    3459           0 :         if (log.buffer == NULL) {
+    3460           0 :             log.buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
+    3461             : 
+    3462           0 :             if (log.buffer == NULL) {
+    3463           0 :                 dlt_vlog(LOG_ERR, "Cannot allocate buffer for DLT Log message\n");
+    3464           0 :                 return DLT_RETURN_ERROR;
+    3465             :             }
+    3466             :         }
+    3467             : 
+    3468           0 :         log.args_num = 0;
+    3469           0 :         log.trace_status = nw_trace_type;
+    3470           0 :         log.size = 0;
+    3471             : 
+    3472           0 :         if (header == NULL)
+    3473             :             header_len = 0;
+    3474             : 
+    3475             :         /* If truncation is allowed, check if we must do it */
+    3476           0 :         if ((allow_truncate > 0) && ((header_len + payload_len + sizeof(uint16_t)) > dlt_user.log_buf_len)) {
+    3477             :             /* Identify as truncated */
+    3478           0 :             if (dlt_user_log_write_string(&log, DLT_TRACE_NW_TRUNCATED) < DLT_RETURN_OK) {
+    3479             :                 dlt_user_free_buffer(&(log.buffer));
+    3480           0 :                 return DLT_RETURN_ERROR;
+    3481             :             }
+    3482             : 
+    3483             :             /* Write header and its length */
+    3484           0 :             if (dlt_user_log_write_raw(&log, header, header_len) < DLT_RETURN_OK) {
+    3485             :                 dlt_user_free_buffer(&(log.buffer));
+    3486           0 :                 return DLT_RETURN_ERROR;
+    3487             :             }
+    3488             : 
+    3489             :             /* Write original size of payload */
+    3490           0 :             if (dlt_user_log_write_uint32(&log, payload_len) < DLT_RETURN_OK) {
+    3491             :                 dlt_user_free_buffer(&(log.buffer));
+    3492           0 :                 return DLT_RETURN_ERROR;
+    3493             :             }
+    3494             : 
+    3495             :             /**
+    3496             :              *  Calculate maximum available space in sending buffer after headers.
+    3497             :              */
+    3498             : 
+    3499           0 :             uint16_t truncated_payload_len = (uint16_t) (dlt_user.log_buf_len - log.size - sizeof(uint16_t) - sizeof(uint32_t));
+    3500             : 
+    3501             :             /* Write truncated payload */
+    3502           0 :             if (dlt_user_log_write_raw(&log, payload, truncated_payload_len) < DLT_RETURN_OK) {
+    3503             :                 dlt_user_free_buffer(&(log.buffer));
+    3504           0 :                 return DLT_RETURN_ERROR;
+    3505             :             }
+    3506             :         }
+    3507             :         else { /* Truncation not allowed or data short enough */
+    3508             : 
+    3509             :             /* Write header and its length */
+    3510           0 :             if (dlt_user_log_write_raw(&log, header, header_len) < DLT_RETURN_OK) {
+    3511             :                 dlt_user_free_buffer(&(log.buffer));
+    3512           0 :                 return DLT_RETURN_ERROR;
+    3513             :             }
+    3514             : 
+    3515           0 :             if (payload == NULL)
+    3516             :                 payload_len = 0;
+    3517             : 
+    3518             :             /* Write payload and its length */
+    3519           0 :             if (dlt_user_log_write_raw(&log, payload, payload_len) < DLT_RETURN_OK) {
+    3520             :                 dlt_user_free_buffer(&(log.buffer));
+    3521           0 :                 return DLT_RETURN_ERROR;
+    3522             :             }
+    3523             :         }
+    3524             : 
+    3525           0 :         ret = dlt_user_log_send_log(&log, DLT_TYPE_NW_TRACE, NULL);
+    3526             : 
+    3527             :         dlt_user_free_buffer(&(log.buffer));
+    3528             : 
+    3529             :         /* Send log */
+    3530           0 :         return ret;
+    3531             :     }
+    3532             : 
+    3533             :     return DLT_RETURN_OK;
+    3534             : }
+    3535             : #else  /* DLT_NETWORK_TRACE_ENABLE not set */
+    3536             : DltReturnValue dlt_user_trace_network_segmented(DltContext *handle,
+    3537             :                                                 DltNetworkTraceType nw_trace_type,
+    3538             :                                                 uint16_t header_len,
+    3539             :                                                 void *header,
+    3540             :                                                 uint16_t payload_len,
+    3541             :                                                 void *payload)
+    3542             : {
+    3543             :     /**
+    3544             :      *  vsomeip uses the DLT_TRACE_NETWORK_SEGMENTED macro that calls this function.
+    3545             :      *  It's not possible to rewrite this macro directly to a no-op,
+    3546             :      *  because the macro is used on vsomeip side and there our defines are not set.
+    3547             :      *  Add an empty function to the dlt-lib to avoid a broken build.
+    3548             :      */
+    3549             :     (void)handle;
+    3550             :     (void)nw_trace_type;
+    3551             :     (void)header_len;
+    3552             :     (void)header;
+    3553             :     (void)payload_len;
+    3554             :     (void)payload;
+    3555             :     return DLT_RETURN_LOGGING_DISABLED;
+    3556             : }
+    3557             : 
+    3558             : DltReturnValue dlt_user_trace_network_truncated(DltContext *handle,
+    3559             :                                                 DltNetworkTraceType nw_trace_type,
+    3560             :                                                 uint16_t header_len,
+    3561             :                                                 void *header,
+    3562             :                                                 uint16_t payload_len,
+    3563             :                                                 void *payload,
+    3564             :                                                 int allow_truncate)
+    3565             : {
+    3566             :     /**
+    3567             :      *  vsomeip uses the DLT_TRACE_NETWORK_TRUNCATED macro that calls this function.
+    3568             :      *  It's not possible to rewrite this macro directly to a no-op,
+    3569             :      *  because the macro is used on vsomeip side and there our defines are not set.
+    3570             :      *  Add an empty function to the dlt-lib to avoid a broken build.
+    3571             :      */
+    3572             :     (void)handle;
+    3573             :     (void)nw_trace_type;
+    3574             :     (void)header_len;
+    3575             :     (void)header;
+    3576             :     (void)payload_len;
+    3577             :     (void)payload;
+    3578             :     (void)allow_truncate;
+    3579             :     return DLT_RETURN_LOGGING_DISABLED;
+    3580             : }
+    3581             : 
+    3582             : #endif /* DLT_NETWORK_TRACE_ENABLE */
+    3583             : 
+    3584          18 : DltReturnValue dlt_log_string(DltContext *handle, DltLogLevelType loglevel, const char *text)
+    3585             : {
+    3586          18 :     if (!is_verbose_mode(dlt_user.verbose_mode, NULL))
+    3587             :         return DLT_RETURN_ERROR;
+    3588             : 
+    3589          18 :     if ((handle == NULL) || (text == NULL))
+    3590             :         return DLT_RETURN_WRONG_PARAMETER;
+    3591             : 
+    3592             :     DltReturnValue ret = DLT_RETURN_OK;
+    3593             :     DltContextData log;
+    3594             : 
+    3595          15 :     if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE) {
+    3596          11 :         ret = dlt_user_log_write_string(&log, text);
+    3597             : 
+    3598          11 :         if (dlt_user_log_write_finish(&log) < DLT_RETURN_OK)
+    3599             :             ret = DLT_RETURN_ERROR;
+    3600             :     }
+    3601             : 
+    3602             :     return ret;
+    3603             : }
+    3604             : 
+    3605          25 : DltReturnValue dlt_log_string_int(DltContext *handle, DltLogLevelType loglevel, const char *text, int data)
+    3606             : {
+    3607          25 :     if (!is_verbose_mode(dlt_user.verbose_mode, NULL))
+    3608             :         return DLT_RETURN_ERROR;
+    3609             : 
+    3610          25 :     if ((handle == NULL) || (text == NULL))
+    3611             :         return DLT_RETURN_WRONG_PARAMETER;
+    3612             : 
+    3613             :     DltReturnValue ret = DLT_RETURN_OK;
+    3614             :     DltContextData log;
+    3615             : 
+    3616          22 :     if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE) {
+    3617          16 :         ret = dlt_user_log_write_string(&log, text);
+    3618          16 :         dlt_user_log_write_int(&log, data);
+    3619             : 
+    3620          16 :         if (dlt_user_log_write_finish(&log) < DLT_RETURN_OK)
+    3621             :             ret = DLT_RETURN_ERROR;
+    3622             :     }
+    3623             : 
+    3624             :     return ret;
+    3625             : }
+    3626             : 
+    3627          25 : DltReturnValue dlt_log_string_uint(DltContext *handle, DltLogLevelType loglevel, const char *text, unsigned int data)
+    3628             : {
+    3629          25 :     if (!is_verbose_mode(dlt_user.verbose_mode, NULL))
+    3630             :         return DLT_RETURN_ERROR;
+    3631             : 
+    3632          25 :     if ((handle == NULL) || (text == NULL))
+    3633             :         return DLT_RETURN_WRONG_PARAMETER;
+    3634             : 
+    3635             :     DltReturnValue ret = DLT_RETURN_OK;
+    3636             :     DltContextData log;
+    3637             : 
+    3638          22 :     if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE) {
+    3639          16 :         ret = dlt_user_log_write_string(&log, text);
+    3640          16 :         dlt_user_log_write_uint(&log, data);
+    3641             : 
+    3642          16 :         if (dlt_user_log_write_finish(&log) < DLT_RETURN_OK)
+    3643             :             ret = DLT_RETURN_ERROR;
+    3644             :     }
+    3645             : 
+    3646             :     return ret;
+    3647             : }
+    3648             : 
+    3649          22 : DltReturnValue dlt_log_int(DltContext *handle, DltLogLevelType loglevel, int data)
+    3650             : {
+    3651          22 :     if (!is_verbose_mode(dlt_user.verbose_mode, NULL))
+    3652             :         return DLT_RETURN_ERROR;
+    3653             : 
+    3654          22 :     if (handle == NULL)
+    3655             :         return DLT_RETURN_ERROR;
+    3656             : 
+    3657             :     DltContextData log;
+    3658             : 
+    3659          21 :     if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE) {
+    3660          15 :         dlt_user_log_write_int(&log, data);
+    3661             : 
+    3662          15 :         if (dlt_user_log_write_finish(&log) < DLT_RETURN_OK)
+    3663           0 :             return DLT_RETURN_ERROR;
+    3664             :     }
+    3665             : 
+    3666             :     return DLT_RETURN_OK;
+    3667             : }
+    3668             : 
+    3669          22 : DltReturnValue dlt_log_uint(DltContext *handle, DltLogLevelType loglevel, unsigned int data)
+    3670             : {
+    3671          22 :     if (!is_verbose_mode(dlt_user.verbose_mode, NULL))
+    3672             :         return DLT_RETURN_ERROR;
+    3673             : 
+    3674          22 :     if (handle == NULL)
+    3675             :         return DLT_RETURN_WRONG_PARAMETER;
+    3676             : 
+    3677             :     DltContextData log;
+    3678             : 
+    3679          21 :     if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE) {
+    3680          15 :         dlt_user_log_write_uint(&log, data);
+    3681             : 
+    3682          15 :         if (dlt_user_log_write_finish(&log) < DLT_RETURN_OK)
+    3683           0 :             return DLT_RETURN_ERROR;
+    3684             :     }
+    3685             : 
+    3686             :     return DLT_RETURN_OK;
+    3687             : }
+    3688             : 
+    3689          11 : DltReturnValue dlt_log_raw(DltContext *handle, DltLogLevelType loglevel, void *data, uint16_t length)
+    3690             : {
+    3691          11 :     if (!is_verbose_mode(dlt_user.verbose_mode, NULL))
+    3692             :         return DLT_RETURN_ERROR;
+    3693             : 
+    3694          11 :     if (handle == NULL)
+    3695             :         return DLT_RETURN_WRONG_PARAMETER;
+    3696             : 
+    3697             :     DltContextData log;
+    3698             :     DltReturnValue ret = DLT_RETURN_OK;
+    3699             : 
+    3700           9 :     if (dlt_user_log_write_start(handle, &log, loglevel) > 0) {
+    3701           7 :         if ((ret = dlt_user_log_write_raw(&log, data, length)) < DLT_RETURN_OK) {
+    3702             :             dlt_user_free_buffer(&(log.buffer));
+    3703           2 :             return ret;
+    3704             :         }
+    3705             : 
+    3706           5 :         if (dlt_user_log_write_finish(&log) < DLT_RETURN_OK)
+    3707           0 :             return DLT_RETURN_ERROR;
+    3708             :     }
+    3709             : 
+    3710             :     return DLT_RETURN_OK;
+    3711             : }
+    3712             : 
+    3713           1 : DltReturnValue dlt_log_marker()
+    3714             : {
+    3715           1 :     if (!DLT_USER_INITALIZED) {
+    3716           0 :         if (dlt_init() < DLT_RETURN_OK) {
+    3717           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    3718           0 :             return DLT_RETURN_ERROR;
+    3719             :         }
+    3720             :     }
+    3721             : 
+    3722           1 :     return dlt_user_log_send_marker();
+    3723             : }
+    3724             : 
+    3725          10 : DltReturnValue dlt_verbose_mode(void)
+    3726             : {
+    3727          10 :     if (!DLT_USER_INITALIZED) {
+    3728           0 :         if (dlt_init() < DLT_RETURN_OK) {
+    3729           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    3730           0 :             return DLT_RETURN_ERROR;
+    3731             :         }
+    3732             :     }
+    3733             : 
+    3734             :     /* Switch to verbose mode */
+    3735          10 :     dlt_user.verbose_mode = 1;
+    3736             : 
+    3737          10 :     return DLT_RETURN_OK;
+    3738             : }
+    3739             : 
+    3740          10 : DltReturnValue dlt_nonverbose_mode(void)
+    3741             : {
+    3742          10 :     if (!DLT_USER_INITALIZED) {
+    3743           0 :         if (dlt_init() < DLT_RETURN_OK) {
+    3744           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    3745           0 :             return DLT_RETURN_ERROR;
+    3746             :         }
+    3747             :     }
+    3748             : 
+    3749             :     /* Switch to non-verbose mode */
+    3750          10 :     dlt_user.verbose_mode = 0;
+    3751             : 
+    3752          10 :     return DLT_RETURN_OK;
+    3753             : }
+    3754             : 
+    3755           2 : DltReturnValue dlt_use_extended_header_for_non_verbose(int8_t use_extended_header_for_non_verbose)
+    3756             : {
+    3757           2 :     if (!DLT_USER_INITALIZED) {
+    3758           0 :         if (dlt_init() < DLT_RETURN_OK) {
+    3759           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    3760           0 :             return DLT_RETURN_ERROR;
+    3761             :         }
+    3762             :     }
+    3763             : 
+    3764             :     /* Set use_extended_header_for_non_verbose */
+    3765           2 :     dlt_user.use_extended_header_for_non_verbose = use_extended_header_for_non_verbose;
+    3766             : 
+    3767           2 :     return DLT_RETURN_OK;
+    3768             : }
+    3769             : 
+    3770           0 : DltReturnValue dlt_with_session_id(int8_t with_session_id)
+    3771             : {
+    3772           0 :     if (!DLT_USER_INITALIZED) {
+    3773           0 :         if (dlt_init() < DLT_RETURN_OK) {
+    3774           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    3775           0 :             return DLT_RETURN_ERROR;
+    3776             :         }
+    3777             :     }
+    3778             : 
+    3779             :     /* Set use_extended_header_for_non_verbose */
+    3780           0 :     dlt_user.with_session_id = with_session_id;
+    3781             : 
+    3782           0 :     return DLT_RETURN_OK;
+    3783             : }
+    3784             : 
+    3785           0 : DltReturnValue dlt_with_timestamp(int8_t with_timestamp)
+    3786             : {
+    3787           0 :     if (!DLT_USER_INITALIZED) {
+    3788           0 :         if (dlt_init() < DLT_RETURN_OK) {
+    3789           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    3790           0 :             return DLT_RETURN_ERROR;
+    3791             :         }
+    3792             :     }
+    3793             : 
+    3794             :     /* Set with_timestamp */
+    3795           0 :     dlt_user.with_timestamp = with_timestamp;
+    3796             : 
+    3797           0 :     return DLT_RETURN_OK;
+    3798             : }
+    3799             : 
+    3800           0 : DltReturnValue dlt_with_ecu_id(int8_t with_ecu_id)
+    3801             : {
+    3802           0 :     if (!DLT_USER_INITALIZED) {
+    3803           0 :         if (dlt_init() < DLT_RETURN_OK) {
+    3804           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    3805           0 :             return DLT_RETURN_ERROR;
+    3806             :         }
+    3807             :     }
+    3808             : 
+    3809             :     /* Set with_timestamp */
+    3810           0 :     dlt_user.with_ecu_id = with_ecu_id;
+    3811             : 
+    3812           0 :     return DLT_RETURN_OK;
+    3813             : }
+    3814             : 
+    3815           0 : DltReturnValue dlt_enable_local_print(void)
+    3816             : {
+    3817           0 :     if (!DLT_USER_INITALIZED) {
+    3818           0 :         if (dlt_init() < DLT_RETURN_OK) {
+    3819           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    3820           0 :             return DLT_RETURN_ERROR;
+    3821             :         }
+    3822             :     }
+    3823             : 
+    3824           0 :     dlt_user.enable_local_print = 1;
+    3825             : 
+    3826           0 :     return DLT_RETURN_OK;
+    3827             : }
+    3828             : 
+    3829           0 : DltReturnValue dlt_disable_local_print(void)
+    3830             : {
+    3831           0 :     if (!DLT_USER_INITALIZED) {
+    3832           0 :         if (dlt_init() < DLT_RETURN_OK) {
+    3833           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    3834           0 :             return DLT_RETURN_ERROR;
+    3835             :         }
+    3836             :     }
+    3837             : 
+    3838           0 :     dlt_user.enable_local_print = 0;
+    3839             : 
+    3840           0 :     return DLT_RETURN_OK;
+    3841             : }
+    3842             : 
+    3843             : /* Cleanup on thread cancellation, thread may hold lock release it here */
+    3844       33569 : static void dlt_user_cleanup_handler(void *arg)
+    3845             : {
+    3846             :     DLT_UNUSED(arg); /* Satisfy compiler */
+    3847             : 
+    3848             : #ifdef DLT_NETWORK_TRACE_ENABLE
+    3849             :     /* unlock the message queue */
+    3850       33569 :     dlt_unlock_mutex(&mq_mutex);
+    3851             : #endif
+    3852             : 
+    3853             :     /* unlock DLT (dlt_mutex) */
+    3854       33571 :     DLT_SEM_FREE();
+    3855       33565 : }
+    3856             : 
+    3857       16786 : void dlt_user_housekeeperthread_function(void *ptr)
+    3858             : {
+    3859             :     struct timespec ts;
+    3860             :     bool in_loop = true;
+    3861             :     int signal_status = 0;
+    3862             :     atomic_bool* dlt_housekeeper_running = (atomic_bool*)ptr;
+    3863             : 
+    3864             : #ifdef __ANDROID_API__
+    3865             :     sigset_t set;
+    3866             :     sigset_t pset;
+    3867             :     /*
+    3868             :      * bionic is not supporting pthread_cancel so
+    3869             :      * use SIGUSR1 to kill thread properly.
+    3870             :      */
+    3871             :     sigemptyset(&set);
+    3872             :     sigaddset(&set, SIGUSR1);
+    3873             :     if (pthread_sigmask(SIG_BLOCK, &set, NULL) != 0) {
+    3874             :         dlt_vlog(LOG_ERR, "Failed to block signal with error [%s]\n",
+    3875             :                 strerror(errno));
+    3876             :         in_loop = false;
+    3877             :     }
+    3878             : #endif
+    3879             : 
+    3880             : #ifdef DLT_USE_PTHREAD_SETNAME_NP
+    3881       16786 :     if (pthread_setname_np(dlt_housekeeperthread_handle, "dlt_housekeeper"))
+    3882           0 :         dlt_log(LOG_WARNING, "Failed to rename housekeeper thread!\n");
+    3883             : #elif linux
+    3884             :     if (prctl(PR_SET_NAME, "dlt_housekeeper", 0, 0, 0) < 0)
+    3885             :         dlt_log(LOG_WARNING, "Failed to rename housekeeper thread!\n");
+    3886             : #endif
+    3887             : 
+    3888       33572 :     pthread_cleanup_push(dlt_user_cleanup_handler, NULL);
+    3889             : 
+    3890             : 
+    3891       16786 :     pthread_mutex_lock(&dlt_housekeeper_running_mutex);
+    3892             : 
+    3893             :     // signal dlt thread to be running
+    3894       16786 :     *dlt_housekeeper_running = true;
+    3895       16786 :     signal_status = pthread_cond_signal(&dlt_housekeeper_running_cond);
+    3896       16786 :     if (signal_status != 0) {
+    3897           0 :         dlt_log(LOG_CRIT, "Housekeeper thread failed to signal running state\n");
+    3898             :     }
+    3899             : 
+    3900       16786 :     pthread_mutex_unlock(&dlt_housekeeper_running_mutex);
+    3901             : 
+    3902             :     while (in_loop) {
+    3903             :         /* Check for new messages from DLT daemon */
+    3904       16802 :         if (!dlt_user.disable_injection_msg)
+    3905       16802 :             if (dlt_user_log_check_user_message() < DLT_RETURN_OK)
+    3906             :                 /* Critical error */
+    3907           0 :                 dlt_log(LOG_CRIT, "Housekeeper thread encountered error condition\n");
+    3908             : 
+    3909             :         /* Reattach to daemon if neccesary */
+    3910          21 :         dlt_user_log_reattach_to_daemon();
+    3911             : 
+    3912             :         /* flush buffer to DLT daemon if possible */
+    3913          21 :         if (dlt_user.dlt_log_handle != DLT_FD_INIT)
+    3914          10 :             dlt_user_log_resend_buffer();
+    3915             : 
+    3916             : #ifdef __ANDROID_API__
+    3917             :         if (sigpending(&pset)) {
+    3918             :             dlt_vlog(LOG_ERR, "sigpending failed with error [%s]!\n", strerror(errno));
+    3919             :             break;
+    3920             :         }
+    3921             : 
+    3922             :         if (sigismember(&pset, SIGUSR1)) {
+    3923             :             dlt_log(LOG_NOTICE, "Received SIGUSR1! Stop thread\n");
+    3924             :             break;
+    3925             :         }
+    3926             : #endif
+    3927             : 
+    3928             :         /* delay */
+    3929          21 :         ts.tv_sec = 0;
+    3930          21 :         ts.tv_nsec = DLT_USER_RECEIVE_NDELAY;
+    3931          21 :         nanosleep(&ts, NULL);
+    3932             :     }
+    3933             : 
+    3934             :     pthread_cleanup_pop(1);
+    3935             : }
+    3936             : 
+    3937             : /* Private functions of user library */
+    3938             : 
+    3939        6411 : DltReturnValue dlt_user_log_init(DltContext *handle, DltContextData *log)
+    3940             : {
+    3941             :     int ret = DLT_RETURN_OK;
+    3942             : 
+    3943        6411 :     if ((handle == NULL) || (log == NULL))
+    3944             :         return DLT_RETURN_WRONG_PARAMETER;
+    3945             : 
+    3946        6411 :     if (!DLT_USER_INITALIZED) {
+    3947           0 :         ret = dlt_init();
+    3948             : 
+    3949           0 :         if (ret < DLT_RETURN_OK) {
+    3950           0 :             if (ret != DLT_RETURN_LOGGING_DISABLED)
+    3951           0 :                 dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    3952             : 
+    3953           0 :             return ret;
+    3954             :         }
+    3955             :     }
+    3956             : 
+    3957        6411 :     log->handle = handle;
+    3958        6411 :     log->buffer = NULL;
+    3959        6411 :     return ret;
+    3960             : }
+    3961             : 
+    3962        6008 : DltReturnValue dlt_user_log_send_log(DltContextData *log, const int mtype, int *const sent_size)
+    3963             : {
+    3964             :     DltMessage msg;
+    3965             :     DltUserHeader userheader;
+    3966             :     int32_t len;
+    3967             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+    3968             :     uint32_t time_stamp;
+    3969             : #else
+    3970             :     // shut up warning
+    3971             :     (void)sent_size;
+    3972             : #endif
+    3973             : 
+    3974             :     DltReturnValue ret = DLT_RETURN_OK;
+    3975             : 
+    3976        6008 :     if (!DLT_USER_INITALIZED_NOT_FREEING) {
+    3977           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_init_state=%i (expected INIT_DONE), dlt_user_freeing=%i\n", __FUNCTION__, dlt_user_init_state, dlt_user_freeing);
+    3978           0 :         return DLT_RETURN_ERROR;
+    3979             :     }
+    3980             : 
+    3981        6008 :     if ((log == NULL) ||
+    3982        6008 :         (log->handle == NULL) ||
+    3983        5999 :         (log->handle->contextID[0] == '\0') ||
+    3984        5999 :         (mtype < DLT_TYPE_LOG) || (mtype > DLT_TYPE_CONTROL)
+    3985             :         )
+    3986             :         return DLT_RETURN_WRONG_PARAMETER;
+    3987             : 
+    3988             :     /* also for Trace messages */
+    3989        5999 :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_LOG) < DLT_RETURN_OK)
+    3990             :         return DLT_RETURN_ERROR;
+    3991             : 
+    3992        5999 :     if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+    3993             :         return DLT_RETURN_ERROR;
+    3994             : 
+    3995        5999 :     msg.storageheader = (DltStorageHeader *)msg.headerbuffer;
+    3996             : 
+    3997        5999 :     if (dlt_set_storageheader(msg.storageheader, dlt_user.ecuID) == DLT_RETURN_ERROR)
+    3998             :         return DLT_RETURN_ERROR;
+    3999             : 
+    4000        5999 :     msg.standardheader = (DltStandardHeader *)(msg.headerbuffer + sizeof(DltStorageHeader));
+    4001        5999 :     msg.standardheader->htyp = DLT_HTYP_PROTOCOL_VERSION1;
+    4002             : 
+    4003             :     /* send ecu id */
+    4004        5999 :     if (dlt_user.with_ecu_id)
+    4005        5999 :         msg.standardheader->htyp |= DLT_HTYP_WEID;
+    4006             : 
+    4007             :     /* send timestamp */
+    4008        5999 :     if (dlt_user.with_timestamp)
+    4009        5999 :         msg.standardheader->htyp |= DLT_HTYP_WTMS;
+    4010             : 
+    4011             :     /* send session id */
+    4012        5999 :     if (dlt_user.with_session_id) {
+    4013        5999 :         msg.standardheader->htyp |= DLT_HTYP_WSID;
+    4014        5999 :         msg.headerextra.seid = (uint32_t) getpid();
+    4015             :     }
+    4016             : 
+    4017        6009 :     if (is_verbose_mode(dlt_user.verbose_mode, log))
+    4018             :         /* In verbose mode, send extended header */
+    4019        5996 :         msg.standardheader->htyp = (msg.standardheader->htyp | DLT_HTYP_UEH);
+    4020             :     else
+    4021             :         /* In non-verbose, send extended header if desired */
+    4022           3 :         if (dlt_user.use_extended_header_for_non_verbose)
+    4023           2 :             msg.standardheader->htyp = (msg.standardheader->htyp | DLT_HTYP_UEH);
+    4024             : 
+    4025             : #if (BYTE_ORDER == BIG_ENDIAN)
+    4026             :     msg.standardheader->htyp = (msg.standardheader->htyp | DLT_HTYP_MSBF);
+    4027             : #endif
+    4028             : 
+    4029        5999 :     msg.standardheader->mcnt = log->handle->mcnt++;
+    4030             : 
+    4031             :     /* Set header extra parameters */
+    4032        5999 :     dlt_set_id(msg.headerextra.ecu, dlt_user.ecuID);
+    4033             : 
+    4034             :     /*msg.headerextra.seid = 0; */
+    4035        5999 :     if (log->use_timestamp == DLT_AUTO_TIMESTAMP) {
+    4036        5998 :         msg.headerextra.tmsp = dlt_uptime();
+    4037             :     }
+    4038             :     else {
+    4039           1 :         msg.headerextra.tmsp = log->user_timestamp;
+    4040             :     }
+    4041             : 
+    4042             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+    4043             :     time_stamp = msg.headerextra.tmsp;
+    4044             : #endif
+    4045             : 
+    4046        5999 :     if (dlt_message_set_extraparameters(&msg, 0) == DLT_RETURN_ERROR)
+    4047             :         return DLT_RETURN_ERROR;
+    4048             : 
+    4049             :     /* Fill out extended header, if extended header should be provided */
+    4050        5999 :     if (DLT_IS_HTYP_UEH(msg.standardheader->htyp)) {
+    4051             :         /* with extended header */
+    4052        5998 :         msg.extendedheader =
+    4053        5998 :             (DltExtendedHeader *)(msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+    4054        5998 :                                   DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp));
+    4055             : 
+    4056        5998 :         switch (mtype) {
+    4057        5998 :         case DLT_TYPE_LOG:
+    4058             :         {
+    4059        5998 :             msg.extendedheader->msin = (uint8_t) (DLT_TYPE_LOG << DLT_MSIN_MSTP_SHIFT |
+    4060        5998 :                 ((log->log_level << DLT_MSIN_MTIN_SHIFT) & DLT_MSIN_MTIN));
+    4061        5998 :             break;
+    4062             :         }
+    4063           0 :         case DLT_TYPE_NW_TRACE:
+    4064             :         {
+    4065           0 :             msg.extendedheader->msin = (uint8_t) (DLT_TYPE_NW_TRACE << DLT_MSIN_MSTP_SHIFT |
+    4066           0 :                 ((log->trace_status << DLT_MSIN_MTIN_SHIFT) & DLT_MSIN_MTIN));
+    4067           0 :             break;
+    4068             :         }
+    4069             :         default:
+    4070             :         {
+    4071             :             /* This case should not occur */
+    4072             :             return DLT_RETURN_ERROR;
+    4073             :             break;
+    4074             :         }
+    4075             :         }
+    4076             : 
+    4077             :         /* If in verbose mode, set flag in header for verbose mode */
+    4078        6007 :         if (is_verbose_mode(dlt_user.verbose_mode, log))
+    4079        5996 :             msg.extendedheader->msin |= DLT_MSIN_VERB;
+    4080             : 
+    4081        5998 :         msg.extendedheader->noar = (uint8_t) log->args_num;              /* number of arguments */
+    4082        5998 :         dlt_set_id(msg.extendedheader->apid, dlt_user.appID);       /* application id */
+    4083        5998 :         dlt_set_id(msg.extendedheader->ctid, log->handle->contextID);   /* context id */
+    4084             : 
+    4085        5998 :         msg.headersize = (uint32_t) (sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) +
+    4086        5998 :             DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp));
+    4087             :     }
+    4088             :     else {
+    4089             :         /* without extended header */
+    4090           1 :         msg.headersize = (uint32_t) (sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + DLT_STANDARD_HEADER_EXTRA_SIZE(
+    4091             :             msg.standardheader->htyp));
+    4092             :     }
+    4093             : 
+    4094        5999 :     len = (int32_t) (msg.headersize - sizeof(DltStorageHeader) + log->size);
+    4095             : 
+    4096        5999 :     if (len > UINT16_MAX) {
+    4097           0 :         dlt_log(LOG_WARNING, "Huge message discarded!\n");
+    4098           0 :         return DLT_RETURN_ERROR;
+    4099             :     }
+    4100             : 
+    4101        5999 :     msg.standardheader->len = DLT_HTOBE_16(len);
+    4102             : 
+    4103             :     /* print to std out, if enabled */
+    4104        5999 :     if ((dlt_user.local_print_mode != DLT_PM_FORCE_OFF) &&
+    4105             :         (dlt_user.local_print_mode != DLT_PM_AUTOMATIC)) {
+    4106        5999 :         if ((dlt_user.enable_local_print) || (dlt_user.local_print_mode == DLT_PM_FORCE_ON))
+    4107           0 :             if (dlt_user_print_msg(&msg, log) == DLT_RETURN_ERROR)
+    4108             :                 return DLT_RETURN_ERROR;
+    4109             :     }
+    4110             : 
+    4111        5999 :     if (dlt_user.dlt_is_file) {
+    4112           0 :         if (dlt_user_file_reach_max) {
+    4113             :             return DLT_RETURN_FILESZERR;
+    4114             :         }
+    4115             :         else {
+    4116             :             /* Get file size */
+    4117             :             struct stat st;
+    4118           0 :             if(fstat(dlt_user.dlt_log_handle, &st) != 0) {
+    4119           0 :                 dlt_vlog(LOG_WARNING,
+    4120           0 :                      "%s: Cannot get file information (errno=%d)\n", __func__, errno);
+    4121           0 :                 return DLT_RETURN_ERROR;
+    4122             :             }
+    4123             : 
+    4124           0 :             dlt_vlog(LOG_DEBUG, "%s: Current file size=[%ld]\n", __func__,
+    4125             :                      st.st_size);
+    4126             :             /* Check filesize */
+    4127             :             /* Return error if the file size has reached to maximum */
+    4128           0 :             unsigned int msg_size = st.st_size + (unsigned int) msg.headersize +
+    4129           0 :                                     (unsigned int) log->size;
+    4130           0 :             if (msg_size > dlt_user.filesize_max) {
+    4131           0 :                 dlt_user_file_reach_max = true;
+    4132           0 :                 dlt_vlog(LOG_ERR,
+    4133             :                          "%s: File size (%ld bytes) reached to defined maximum size (%d bytes)\n",
+    4134             :                          __func__, st.st_size, dlt_user.filesize_max);
+    4135           0 :                 return DLT_RETURN_FILESZERR;
+    4136             :             }
+    4137             :             else {
+    4138             :                 /* log to file */
+    4139           0 :                 ret = dlt_user_log_out2(dlt_user.dlt_log_handle,
+    4140             :                                         msg.headerbuffer, msg.headersize,
+    4141           0 :                                         log->buffer, log->size);
+    4142           0 :                 return ret;
+    4143             :             }
+    4144             :         }
+    4145             :     } else {
+    4146        5999 :         if (dlt_user.overflow_counter) {
+    4147           0 :             if (dlt_user_log_send_overflow() == DLT_RETURN_OK) {
+    4148           0 :                 dlt_vnlog(LOG_WARNING, DLT_USER_BUFFER_LENGTH, "%u messages discarded!\n", dlt_user.overflow_counter);
+    4149           0 :                 dlt_user.overflow_counter = 0;
+    4150             :             }
+    4151             :         }
+    4152             : 
+    4153             :         /* try to resent old data first */
+    4154             :         ret = DLT_RETURN_OK;
+    4155             : 
+    4156        5999 :         if ((dlt_user.dlt_log_handle != -1) && (dlt_user.appID[0] != '\0'))
+    4157        5811 :             ret = dlt_user_log_resend_buffer();
+    4158             : 
+    4159        5999 :         if ((ret == DLT_RETURN_OK) && (dlt_user.appID[0] != '\0')) {
+    4160             :             /* resend ok or nothing to resent */
+    4161             : #ifdef DLT_SHM_ENABLE
+    4162             : 
+    4163             :             if (dlt_user.dlt_log_handle != -1)
+    4164             :                 dlt_shm_push(&dlt_user.dlt_shm, msg.headerbuffer + sizeof(DltStorageHeader),
+    4165             :                              msg.headersize - sizeof(DltStorageHeader),
+    4166             :                              log->buffer, log->size, 0, 0);
+    4167             : 
+    4168             :             ret = dlt_user_log_out3(dlt_user.dlt_log_handle,
+    4169             :                                     &(userheader), sizeof(DltUserHeader),
+    4170             :                                     0, 0,
+    4171             :                                     0, 0);
+    4172             : #else
+    4173             : #   ifdef DLT_TEST_ENABLE
+    4174             : 
+    4175             :             if (dlt_user.corrupt_user_header) {
+    4176             :                 userheader.pattern[0] = (char) 0xff;
+    4177             :                 userheader.pattern[1] = (char) 0xff;
+    4178             :                 userheader.pattern[2] = (char) 0xff;
+    4179             :                 userheader.pattern[3] = (char) 0xff;
+    4180             :             }
+    4181             : 
+    4182             :             if (dlt_user.corrupt_message_size)
+    4183             :                 msg.standardheader->len = DLT_HTOBE_16(dlt_user.corrupt_message_size_size);
+    4184             : 
+    4185             : #   endif
+    4186             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+    4187             :             /* check trace load before output */
+    4188             :             if (!sent_size)
+    4189             :             {
+    4190             :                 pthread_rwlock_wrlock(&trace_load_rw_lock);
+    4191             :                 DltTraceLoadSettings* settings =
+    4192             :                     dlt_find_runtime_trace_load_settings(
+    4193             :                         trace_load_settings, trace_load_settings_count, dlt_user.appID, log->handle->contextID);
+    4194             :                 const bool trace_load_in_limits = dlt_check_trace_load(
+    4195             :                         settings,
+    4196             :                         log->log_level, time_stamp,
+    4197             :                         sizeof(DltUserHeader)
+    4198             :                             + msg.headersize - sizeof(DltStorageHeader)
+    4199             :                             + log->size,
+    4200             :                         dlt_user_output_internal_msg,
+    4201             :                         NULL);
+    4202             :                 pthread_rwlock_unlock(&trace_load_rw_lock);
+    4203             :                 if (!trace_load_in_limits){
+    4204             :                     return DLT_RETURN_LOAD_EXCEEDED;
+    4205             :                 }
+    4206             :             }
+    4207             :             else
+    4208             :             {
+    4209             :                 *sent_size = (sizeof(DltUserHeader) + msg.headersize - sizeof(DltStorageHeader) + log->size);
+    4210             :             }
+    4211             : #endif
+    4212             : 
+    4213        5998 :             ret = dlt_user_log_out3(dlt_user.dlt_log_handle,
+    4214             :                                     &(userheader), sizeof(DltUserHeader),
+    4215             :                                     msg.headerbuffer + sizeof(DltStorageHeader),
+    4216        5998 :                                     msg.headersize - sizeof(DltStorageHeader),
+    4217        5998 :                                     log->buffer, log->size);
+    4218             : #endif
+    4219             :         }
+    4220             : 
+    4221             :         DltReturnValue process_error_ret = DLT_RETURN_OK;
+    4222             :         /* store message in ringbuffer, if an error has occurred */
+    4223             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+    4224             :         if (((ret!=DLT_RETURN_OK) || (dlt_user.appID[0] == '\0')) && !sent_size)
+    4225             : #else
+    4226        5999 :         if ((ret != DLT_RETURN_OK) || (dlt_user.appID[0] == '\0'))
+    4227             : #endif
+    4228         190 :             process_error_ret = dlt_user_log_out_error_handling(&(userheader),
+    4229             :                                                   sizeof(DltUserHeader),
+    4230             :                                                   msg.headerbuffer + sizeof(DltStorageHeader),
+    4231         190 :                                                   msg.headersize - sizeof(DltStorageHeader),
+    4232         190 :                                                   log->buffer,
+    4233         190 :                                                   log->size);
+    4234             : 
+    4235         190 :         if (process_error_ret == DLT_RETURN_OK)
+    4236        5999 :             return DLT_RETURN_OK;
+    4237           0 :         if (process_error_ret == DLT_RETURN_BUFFER_FULL) {
+    4238             :             /* Buffer full */
+    4239           0 :             dlt_user.overflow_counter += 1;
+    4240           0 :             return DLT_RETURN_BUFFER_FULL;
+    4241             :         }
+    4242             : 
+    4243             :         /* handle return value of function dlt_user_log_out3() when process_error_ret < 0*/
+    4244           0 :         switch (ret) {
+    4245             :             case DLT_RETURN_PIPE_FULL:
+    4246             :             {
+    4247             :                 /* data could not be written */
+    4248             :                 return DLT_RETURN_PIPE_FULL;
+    4249             :             }
+    4250           0 :             case DLT_RETURN_PIPE_ERROR:
+    4251             :             {
+    4252             :                 /* handle not open or pipe error */
+    4253           0 :                 close(dlt_user.dlt_log_handle);
+    4254           0 :                 dlt_user.dlt_log_handle = -1;
+    4255             : #if defined DLT_LIB_USE_UNIX_SOCKET_IPC || defined DLT_LIB_USE_VSOCK_IPC
+    4256             :             dlt_user.connection_state = DLT_USER_RETRY_CONNECT;
+    4257             : #endif
+    4258             : 
+    4259             :     #ifdef DLT_SHM_ENABLE
+    4260             :             /* free shared memory */
+    4261             :             dlt_shm_free_client(&dlt_user.dlt_shm);
+    4262             :     #endif
+    4263             : 
+    4264           0 :             if (dlt_user.local_print_mode == DLT_PM_AUTOMATIC)
+    4265           0 :                 dlt_user_print_msg(&msg, log);
+    4266             : 
+    4267           0 :             return DLT_RETURN_PIPE_ERROR;
+    4268             :         }
+    4269           0 :         case DLT_RETURN_ERROR:
+    4270             :         {
+    4271             :             /* other error condition */
+    4272           0 :             return DLT_RETURN_ERROR;
+    4273             :         }
+    4274           0 :         case DLT_RETURN_OK:
+    4275             :         {
+    4276           0 :             return DLT_RETURN_OK;
+    4277             :         }
+    4278           0 :         default:
+    4279             :         {
+    4280             :             /* This case should never occur. */
+    4281           0 :             return DLT_RETURN_ERROR;
+    4282             :         }
+    4283             :         }
+    4284             :     }
+    4285             : 
+    4286             :     return DLT_RETURN_OK;
+    4287             : }
+    4288             : 
+    4289         171 : DltReturnValue dlt_user_log_send_register_application(void)
+    4290             : {
+    4291             :     DltUserHeader userheader;
+    4292             :     DltUserControlMsgRegisterApplication usercontext;
+    4293             : 
+    4294             :     DltReturnValue ret;
+    4295             : 
+    4296         171 :     if (dlt_user.appID[0] == '\0')
+    4297             :         return DLT_RETURN_ERROR;
+    4298             : 
+    4299             :     /* set userheader */
+    4300         171 :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_REGISTER_APPLICATION) < DLT_RETURN_OK)
+    4301             :         return DLT_RETURN_ERROR;
+    4302             : 
+    4303             :     /* set usercontext */
+    4304         171 :     dlt_set_id(usercontext.apid, dlt_user.appID);       /* application id */
+    4305         171 :     usercontext.pid = getpid();
+    4306             : 
+    4307         171 :     if (dlt_user.application_description != NULL)
+    4308         171 :         usercontext.description_length = (uint32_t) strlen(dlt_user.application_description);
+    4309             :     else
+    4310           0 :         usercontext.description_length = 0;
+    4311             : 
+    4312         171 :     if (dlt_user.dlt_is_file)
+    4313             :         return DLT_RETURN_OK;
+    4314             : 
+    4315         171 :     ret = dlt_user_log_out3(dlt_user.dlt_log_handle,
+    4316             :                             &(userheader), sizeof(DltUserHeader),
+    4317             :                             &(usercontext), sizeof(DltUserControlMsgRegisterApplication),
+    4318         171 :                             dlt_user.application_description, usercontext.description_length);
+    4319             : 
+    4320             :     /* store message in ringbuffer, if an error has occured */
+    4321         171 :     if (ret < DLT_RETURN_OK)
+    4322         164 :         return dlt_user_log_out_error_handling(&(userheader),
+    4323             :                                                sizeof(DltUserHeader),
+    4324             :                                                &(usercontext),
+    4325             :                                                sizeof(DltUserControlMsgRegisterApplication),
+    4326         164 :                                                dlt_user.application_description,
+    4327         164 :                                                usercontext.description_length);
+    4328             : 
+    4329             :     return DLT_RETURN_OK;
+    4330             : }
+    4331             : 
+    4332         181 : DltReturnValue dlt_user_log_send_unregister_application(void)
+    4333             : {
+    4334             :     DltUserHeader userheader;
+    4335             :     DltUserControlMsgUnregisterApplication usercontext;
+    4336             :     DltReturnValue ret = DLT_RETURN_OK;
+    4337             : 
+    4338         181 :     if (dlt_user.appID[0] == '\0')
+    4339             :         return DLT_RETURN_ERROR;
+    4340             : 
+    4341             :     /* set userheader */
+    4342         172 :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_UNREGISTER_APPLICATION) < DLT_RETURN_OK)
+    4343             :         return DLT_RETURN_ERROR;
+    4344             : 
+    4345             :     /* set usercontext */
+    4346         172 :     dlt_set_id(usercontext.apid, dlt_user.appID);       /* application id */
+    4347         172 :     usercontext.pid = getpid();
+    4348             : 
+    4349         172 :     if (dlt_user.dlt_is_file)
+    4350             :         return DLT_RETURN_OK;
+    4351             : 
+    4352         172 :     ret = dlt_user_log_out2(dlt_user.dlt_log_handle,
+    4353             :                             &(userheader), sizeof(DltUserHeader),
+    4354             :                             &(usercontext), sizeof(DltUserControlMsgUnregisterApplication));
+    4355             : 
+    4356             :     /* store message in ringbuffer, if an error has occured */
+    4357         172 :     if (ret < DLT_RETURN_OK)
+    4358         166 :         return dlt_user_log_out_error_handling(&(userheader),
+    4359             :                                                sizeof(DltUserHeader),
+    4360             :                                                &(usercontext),
+    4361             :                                                sizeof(DltUserControlMsgUnregisterApplication),
+    4362             :                                                NULL,
+    4363             :                                                0);
+    4364             : 
+    4365             :     return DLT_RETURN_OK;
+    4366             : }
+    4367             : 
+    4368         205 : DltReturnValue dlt_user_log_send_register_context(DltContextData *log)
+    4369             : {
+    4370             :     DltUserHeader userheader;
+    4371             :     DltUserControlMsgRegisterContext usercontext;
+    4372             :     DltReturnValue ret = DLT_RETURN_ERROR;
+    4373             : 
+    4374         205 :     if (log == NULL)
+    4375             :         return DLT_RETURN_WRONG_PARAMETER;
+    4376             : 
+    4377         205 :     if (log->handle == NULL)
+    4378             :         return DLT_RETURN_ERROR;
+    4379             : 
+    4380         205 :     if (log->handle->contextID[0] == '\0')
+    4381             :         return DLT_RETURN_ERROR;
+    4382             : 
+    4383             :     /* set userheader */
+    4384         205 :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_REGISTER_CONTEXT) < DLT_RETURN_OK)
+    4385             :         return DLT_RETURN_ERROR;
+    4386             : 
+    4387             :     /* set usercontext */
+    4388         205 :     dlt_set_id(usercontext.apid, dlt_user.appID);       /* application id */
+    4389         205 :     dlt_set_id(usercontext.ctid, log->handle->contextID);       /* context id */
+    4390         205 :     usercontext.log_level_pos = log->handle->log_level_pos;
+    4391         205 :     usercontext.pid = getpid();
+    4392             : 
+    4393         205 :     usercontext.log_level = (int8_t) log->log_level;
+    4394         205 :     usercontext.trace_status = (int8_t) log->trace_status;
+    4395             : 
+    4396         205 :     if (log->context_description != NULL)
+    4397         205 :         usercontext.description_length = (uint32_t) strlen(log->context_description);
+    4398             :     else
+    4399           0 :         usercontext.description_length = 0;
+    4400             : 
+    4401         205 :     if (dlt_user.dlt_is_file)
+    4402             :         return DLT_RETURN_OK;
+    4403             : 
+    4404         205 :     if (dlt_user.appID[0] != '\0')
+    4405             :         ret =
+    4406         205 :             dlt_user_log_out3(dlt_user.dlt_log_handle,
+    4407             :                               &(userheader),
+    4408             :                               sizeof(DltUserHeader),
+    4409             :                               &(usercontext),
+    4410             :                               sizeof(DltUserControlMsgRegisterContext),
+    4411             :                               log->context_description,
+    4412         205 :                               usercontext.description_length);
+    4413             : 
+    4414             :     /* store message in ringbuffer, if an error has occured */
+    4415         205 :     if ((ret != DLT_RETURN_OK) || (dlt_user.appID[0] == '\0'))
+    4416         167 :         return dlt_user_log_out_error_handling(&(userheader),
+    4417             :                                                sizeof(DltUserHeader),
+    4418             :                                                &(usercontext),
+    4419             :                                                sizeof(DltUserControlMsgRegisterContext),
+    4420         167 :                                                log->context_description,
+    4421         167 :                                                usercontext.description_length);
+    4422             : 
+    4423             :     return DLT_RETURN_OK;
+    4424             : 
+    4425             : }
+    4426             : 
+    4427         204 : DltReturnValue dlt_user_log_send_unregister_context(DltContextData *log)
+    4428             : {
+    4429             :     DltUserHeader userheader;
+    4430             :     DltUserControlMsgUnregisterContext usercontext;
+    4431             :     DltReturnValue ret;
+    4432             : 
+    4433         204 :     if (log == NULL)
+    4434             :         return DLT_RETURN_WRONG_PARAMETER;
+    4435             : 
+    4436         204 :     if (log->handle == NULL)
+    4437             :         return DLT_RETURN_WRONG_PARAMETER;
+    4438             : 
+    4439         204 :     if (log->handle->contextID[0] == '\0')
+    4440             :         return DLT_RETURN_ERROR;
+    4441             : 
+    4442             :     /* set userheader */
+    4443         204 :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_UNREGISTER_CONTEXT) < DLT_RETURN_OK)
+    4444             :         return DLT_RETURN_ERROR;
+    4445             : 
+    4446             :     /* set usercontext */
+    4447         204 :     dlt_set_id(usercontext.apid, dlt_user.appID);       /* application id */
+    4448         204 :     dlt_set_id(usercontext.ctid, log->handle->contextID);       /* context id */
+    4449         204 :     usercontext.pid = getpid();
+    4450             : 
+    4451         204 :     if (dlt_user.dlt_is_file)
+    4452             :         return DLT_RETURN_OK;
+    4453             : 
+    4454         204 :     ret = dlt_user_log_out2(dlt_user.dlt_log_handle,
+    4455             :                             &(userheader),
+    4456             :                             sizeof(DltUserHeader),
+    4457             :                             &(usercontext),
+    4458             :                             sizeof(DltUserControlMsgUnregisterContext));
+    4459             : 
+    4460             :     /* store message in ringbuffer, if an error has occured */
+    4461         204 :     if (ret < DLT_RETURN_OK)
+    4462         167 :         return dlt_user_log_out_error_handling(&(userheader),
+    4463             :                                                sizeof(DltUserHeader),
+    4464             :                                                &(usercontext),
+    4465             :                                                sizeof(DltUserControlMsgUnregisterContext),
+    4466             :                                                NULL,
+    4467             :                                                0);
+    4468             : 
+    4469             :     return DLT_RETURN_OK;
+    4470             : }
+    4471             : 
+    4472           0 : DltReturnValue dlt_send_app_ll_ts_limit(const char *apid, DltLogLevelType loglevel, DltTraceStatusType tracestatus)
+    4473             : {
+    4474             :     DltUserHeader userheader;
+    4475             :     DltUserControlMsgAppLogLevelTraceStatus usercontext;
+    4476             :     DltReturnValue ret;
+    4477             : 
+    4478           0 :     if ((loglevel < DLT_USER_LOG_LEVEL_NOT_SET) || (loglevel >= DLT_LOG_MAX)) {
+    4479           0 :         dlt_vlog(LOG_ERR, "Loglevel %d is outside valid range", loglevel);
+    4480           0 :         return DLT_RETURN_ERROR;
+    4481             :     }
+    4482             : 
+    4483           0 :     if ((tracestatus < DLT_USER_TRACE_STATUS_NOT_SET) || (tracestatus >= DLT_TRACE_STATUS_MAX)) {
+    4484           0 :         dlt_vlog(LOG_ERR, "Tracestatus %d is outside valid range", tracestatus);
+    4485           0 :         return DLT_RETURN_ERROR;
+    4486             :     }
+    4487             : 
+    4488           0 :     if ((apid == NULL) || (apid[0] == '\0'))
+    4489             :         return DLT_RETURN_ERROR;
+    4490             : 
+    4491             :     /* set userheader */
+    4492           0 :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_APP_LL_TS) < DLT_RETURN_OK)
+    4493             :         return DLT_RETURN_ERROR;
+    4494             : 
+    4495             :     /* set usercontext */
+    4496           0 :     dlt_set_id(usercontext.apid, apid);       /* application id */
+    4497           0 :     usercontext.log_level = loglevel;
+    4498           0 :     usercontext.trace_status = tracestatus;
+    4499             : 
+    4500           0 :     if (dlt_user.dlt_is_file)
+    4501             :         return DLT_RETURN_OK;
+    4502             : 
+    4503           0 :     ret = dlt_user_log_out2(dlt_user.dlt_log_handle,
+    4504             :                             &(userheader), sizeof(DltUserHeader),
+    4505             :                             &(usercontext), sizeof(DltUserControlMsgAppLogLevelTraceStatus));
+    4506             : 
+    4507             :     /* store message in ringbuffer, if an error has occured */
+    4508           0 :     if (ret < DLT_RETURN_OK)
+    4509           0 :         return dlt_user_log_out_error_handling(&(userheader),
+    4510             :                                                sizeof(DltUserHeader),
+    4511             :                                                &(usercontext),
+    4512             :                                                sizeof(DltUserControlMsgAppLogLevelTraceStatus),
+    4513             :                                                NULL,
+    4514             :                                                0);
+    4515             : 
+    4516             :     return DLT_RETURN_OK;
+    4517             : }
+    4518             : 
+    4519           4 : DltReturnValue dlt_user_log_send_log_mode(DltUserLogMode mode)
+    4520             : {
+    4521             :     DltUserHeader userheader;
+    4522             :     DltUserControlMsgLogMode logmode;
+    4523             :     DltReturnValue ret;
+    4524             : 
+    4525           4 :     if ((mode < DLT_USER_MODE_UNDEFINED) || (mode >= DLT_USER_MODE_MAX)) {
+    4526           0 :         dlt_vlog(LOG_ERR, "User log mode %d is outside valid range", mode);
+    4527           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    4528             :     }
+    4529             : 
+    4530             :     /* set userheader */
+    4531           4 :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_LOG_MODE) < DLT_RETURN_OK)
+    4532             :         return DLT_RETURN_ERROR;
+    4533             : 
+    4534             :     /* set data */
+    4535           4 :     logmode.log_mode = (unsigned char)mode;
+    4536             : 
+    4537           4 :     if (dlt_user.dlt_is_file)
+    4538             :         return DLT_RETURN_OK;
+    4539             : 
+    4540           4 :     ret = dlt_user_log_out2(dlt_user.dlt_log_handle,
+    4541             :                             &(userheader), sizeof(DltUserHeader),
+    4542             :                             &(logmode), sizeof(DltUserControlMsgLogMode));
+    4543             : 
+    4544             :     /* store message in ringbuffer, if an error has occured */
+    4545           4 :     if (ret < DLT_RETURN_OK)
+    4546           4 :         return dlt_user_log_out_error_handling(&(userheader),
+    4547             :                                                sizeof(DltUserHeader),
+    4548             :                                                &(logmode),
+    4549             :                                                sizeof(DltUserControlMsgLogMode),
+    4550             :                                                NULL,
+    4551             :                                                0);
+    4552             : 
+    4553             :     return DLT_RETURN_OK;
+    4554             : }
+    4555             : 
+    4556           1 : DltReturnValue dlt_user_log_send_marker()
+    4557             : {
+    4558             :     DltUserHeader userheader;
+    4559             :     DltReturnValue ret;
+    4560             : 
+    4561             :     /* set userheader */
+    4562           1 :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_MARKER) < DLT_RETURN_OK)
+    4563             :         return DLT_RETURN_ERROR;
+    4564             : 
+    4565           1 :     if (dlt_user.dlt_is_file)
+    4566             :         return DLT_RETURN_OK;
+    4567             : 
+    4568             :     /* log to FIFO */
+    4569           1 :     ret = dlt_user_log_out2(dlt_user.dlt_log_handle,
+    4570             :                             &(userheader), sizeof(DltUserHeader), 0, 0);
+    4571             : 
+    4572             :     /* store message in ringbuffer, if an error has occured */
+    4573           1 :     if (ret < DLT_RETURN_OK)
+    4574           1 :         return dlt_user_log_out_error_handling(&(userheader),
+    4575             :                                                sizeof(DltUserHeader),
+    4576             :                                                NULL,
+    4577             :                                                0,
+    4578             :                                                NULL,
+    4579             :                                                0);
+    4580             : 
+    4581             :     return DLT_RETURN_OK;
+    4582             : }
+    4583             : 
+    4584           0 : DltReturnValue dlt_user_print_msg(DltMessage *msg, DltContextData *log)
+    4585             : {
+    4586             :     uint8_t *databuffer_tmp;
+    4587             :     uint32_t datasize_tmp;
+    4588             :     uint32_t databuffersize_tmp;
+    4589             :     static char text[DLT_USER_TEXT_LENGTH];
+    4590             : 
+    4591           0 :     if ((msg == NULL) || (log == NULL))
+    4592             :         return DLT_RETURN_WRONG_PARAMETER;
+    4593             : 
+    4594             :     /* Save variables before print */
+    4595           0 :     databuffer_tmp = msg->databuffer;
+    4596           0 :     datasize_tmp = msg->datasize;
+    4597           0 :     databuffersize_tmp = msg->databuffersize;
+    4598             : 
+    4599             :     /* Act like a receiver, convert header back to host format */
+    4600           0 :     msg->standardheader->len = DLT_BETOH_16(msg->standardheader->len);
+    4601           0 :     dlt_message_get_extraparameters(msg, 0);
+    4602             : 
+    4603           0 :     msg->databuffer = log->buffer;
+    4604           0 :     msg->datasize = (uint32_t) log->size;
+    4605           0 :     msg->databuffersize = (uint32_t) log->size;
+    4606             : 
+    4607             :     /* Print message as ASCII */
+    4608           0 :     if (dlt_message_print_ascii(msg, text, DLT_USER_TEXT_LENGTH, 0) == DLT_RETURN_ERROR)
+    4609             :         return DLT_RETURN_ERROR;
+    4610             : 
+    4611             :     /* Restore variables and set len to BE*/
+    4612           0 :     msg->databuffer = databuffer_tmp;
+    4613           0 :     msg->databuffersize = databuffersize_tmp;
+    4614           0 :     msg->datasize = datasize_tmp;
+    4615             : 
+    4616           0 :     msg->standardheader->len = DLT_HTOBE_16(msg->standardheader->len);
+    4617             : 
+    4618           0 :     return DLT_RETURN_OK;
+    4619             : }
+    4620             : 
+    4621       16802 : DltReturnValue dlt_user_log_check_user_message(void)
+    4622             : {
+    4623             :     int offset = 0;
+    4624             :     int leave_while = 0;
+    4625             :     int ret = 0;
+    4626             : 
+    4627             :     uint32_t i;
+    4628             :     int fd;
+    4629             :     struct pollfd nfd[1];
+    4630             : 
+    4631             :     DltUserHeader *userheader;
+    4632             :     DltReceiver *receiver = &(dlt_user.receiver);
+    4633             : 
+    4634             :     DltUserControlMsgLogLevel *usercontextll;
+    4635             :     DltUserControlMsgInjection *usercontextinj;
+    4636             :     DltUserControlMsgLogState *userlogstate;
+    4637             :     unsigned char *userbuffer;
+    4638             : 
+    4639             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+    4640             :     DltUserControlMsgTraceSettingMsg *trace_load_settings_user_messages;
+    4641             :     uint32_t trace_load_settings_user_messages_count = 0;
+    4642             :     uint32_t trace_load_settings_user_message_bytes_required = 0;
+    4643             :     unsigned long trace_load_settings_alloc_size = 0;
+    4644             : #endif
+    4645             : 
+    4646             :     /* For delayed calling of injection callback, to avoid deadlock */
+    4647             :     DltUserInjectionCallback delayed_injection_callback;
+    4648             :     DltUserLogLevelChangedCallback delayed_log_level_changed_callback;
+    4649             :     unsigned char *delayed_inject_buffer = 0;
+    4650             :     uint32_t delayed_inject_data_length = 0;
+    4651             : 
+    4652             :     /* Ensure that callback is null before searching for it */
+    4653             :     delayed_injection_callback.injection_callback = 0;
+    4654             :     delayed_injection_callback.injection_callback_with_id = 0;
+    4655             :     delayed_injection_callback.service_id = 0;
+    4656       16802 :     delayed_log_level_changed_callback.log_level_changed_callback = 0;
+    4657             :     delayed_injection_callback.data = 0;
+    4658             : 
+    4659             : #if defined DLT_LIB_USE_UNIX_SOCKET_IPC || defined DLT_LIB_USE_VSOCK_IPC
+    4660             :     fd = dlt_user.dlt_log_handle;
+    4661             : #else /* DLT_LIB_USE_FIFO_IPC */
+    4662       16802 :     fd = dlt_user.dlt_user_handle;
+    4663             : #endif
+    4664       16802 :     nfd[0].events = POLLIN;
+    4665       16802 :     nfd[0].fd = fd;
+    4666             : 
+    4667       16802 :     if (fd >= 0) {
+    4668             :         ret = poll(nfd, 1, DLT_USER_RECEIVE_MDELAY);
+    4669          21 :         if (ret) {
+    4670           9 :             if (nfd[0].revents & (POLLHUP | POLLNVAL | POLLERR)) {
+    4671           0 :                 dlt_user.dlt_log_handle = DLT_FD_INIT;
+    4672           0 :                 return DLT_RETURN_ERROR;
+    4673             :             }
+    4674             : 
+    4675           9 :             if (dlt_receiver_receive(receiver) <= 0)
+    4676             :                 /* No new message available */
+    4677             :                 return DLT_RETURN_OK;
+    4678             : 
+    4679             :             /* look through buffer as long as data is in there */
+    4680             :             while (1) {
+    4681          21 :                 if (receiver->bytesRcvd < (int32_t) sizeof(DltUserHeader))
+    4682             :                     break;
+    4683             : 
+    4684             :                 /* resync if necessary */
+    4685             :                 offset = 0;
+    4686             : 
+    4687             :                 do {
+    4688          12 :                     userheader = (DltUserHeader *)(receiver->buf + offset);
+    4689             : 
+    4690             :                     /* Check for user header pattern */
+    4691          12 :                     if (dlt_user_check_userheader(userheader))
+    4692             :                         break;
+    4693             : 
+    4694           0 :                     offset++;
+    4695             : 
+    4696           0 :                 } while (((int32_t) (sizeof(DltUserHeader)) + offset) <= receiver->bytesRcvd);
+    4697             : 
+    4698             :                 /* Check for user header pattern */
+    4699          24 :                 if ((dlt_user_check_userheader(userheader) < 0) ||
+    4700          12 :                     (dlt_user_check_userheader(userheader) == 0))
+    4701             :                     break;
+    4702             : 
+    4703             :                 /* Set new start offset */
+    4704          12 :                 if (offset > 0) {
+    4705           0 :                     receiver->buf += offset;
+    4706           0 :                     receiver->bytesRcvd -= offset;
+    4707             :                 }
+    4708             : 
+    4709          12 :                 switch (userheader->message) {
+    4710           5 :                 case DLT_USER_MESSAGE_LOG_LEVEL:
+    4711             :                 {
+    4712           5 :                     if (receiver->bytesRcvd < (int32_t) (sizeof(DltUserHeader) + sizeof(DltUserControlMsgLogLevel))) {
+    4713             :                         leave_while = 1;
+    4714             :                         break;
+    4715             :                     }
+    4716             : 
+    4717           5 :                     usercontextll = (DltUserControlMsgLogLevel *)(receiver->buf + sizeof(DltUserHeader));
+    4718             : 
+    4719             :                     /* Update log level and trace status */
+    4720             :                     if (usercontextll != NULL) {
+    4721           5 :                         DLT_SEM_LOCK();
+    4722             : 
+    4723           5 :                         if ((usercontextll->log_level_pos >= 0) &&
+    4724           5 :                             (usercontextll->log_level_pos < (int32_t)dlt_user.dlt_ll_ts_num_entries)) {
+    4725           5 :                             if (dlt_user.dlt_ll_ts) {
+    4726           5 :                                 dlt_user.dlt_ll_ts[usercontextll->log_level_pos].log_level = (int8_t) usercontextll->log_level;
+    4727           5 :                                 dlt_user.dlt_ll_ts[usercontextll->log_level_pos].trace_status =
+    4728           5 :                                     (int8_t) usercontextll->trace_status;
+    4729             : 
+    4730           5 :                                 if (dlt_user.dlt_ll_ts[usercontextll->log_level_pos].log_level_ptr)
+    4731           0 :                                     *(dlt_user.dlt_ll_ts[usercontextll->log_level_pos].log_level_ptr) =
+    4732             :                                         (int8_t) usercontextll->log_level;
+    4733             : 
+    4734           5 :                                 if (dlt_user.dlt_ll_ts[usercontextll->log_level_pos].trace_status_ptr)
+    4735           0 :                                     *(dlt_user.dlt_ll_ts[usercontextll->log_level_pos].trace_status_ptr) =
+    4736           0 :                                         (int8_t) usercontextll->trace_status;
+    4737             : 
+    4738           5 :                                 delayed_log_level_changed_callback.log_level_changed_callback =
+    4739           5 :                                     dlt_user.dlt_ll_ts[usercontextll->log_level_pos].log_level_changed_callback;
+    4740             :                                 memcpy(delayed_log_level_changed_callback.contextID,
+    4741             :                                        dlt_user.dlt_ll_ts[usercontextll->log_level_pos].contextID, DLT_ID_SIZE);
+    4742           5 :                                 delayed_log_level_changed_callback.log_level = (int8_t) usercontextll->log_level;
+    4743           5 :                                 delayed_log_level_changed_callback.trace_status = (int8_t) usercontextll->trace_status;
+    4744             :                             }
+    4745             :                         }
+    4746             : 
+    4747           5 :                         DLT_SEM_FREE();
+    4748             :                     }
+    4749             : 
+    4750             :                     /* call callback outside of semaphore */
+    4751           5 :                     if (delayed_log_level_changed_callback.log_level_changed_callback != 0)
+    4752           0 :                         delayed_log_level_changed_callback.log_level_changed_callback(
+    4753             :                             delayed_log_level_changed_callback.contextID,
+    4754           0 :                             (uint8_t) delayed_log_level_changed_callback.log_level,
+    4755           0 :                             (uint8_t) delayed_log_level_changed_callback.trace_status);
+    4756             : 
+    4757             :                     /* keep not read data in buffer */
+    4758           5 :                     if (dlt_receiver_remove(receiver,
+    4759             :                                             sizeof(DltUserHeader) + sizeof(DltUserControlMsgLogLevel)) ==
+    4760             :                         DLT_RETURN_ERROR)
+    4761             :                         return DLT_RETURN_ERROR;
+    4762             :                 }
+    4763             :                 break;
+    4764           0 :                 case DLT_USER_MESSAGE_INJECTION:
+    4765             :                 {
+    4766             :                     /* At least, user header, user context, and service id and data_length of injected message is available */
+    4767           0 :                     if (receiver->bytesRcvd < (int32_t) (sizeof(DltUserHeader) + sizeof(DltUserControlMsgInjection))) {
+    4768             :                         leave_while = 1;
+    4769             :                         break;
+    4770             :                     }
+    4771             : 
+    4772           0 :                     usercontextinj = (DltUserControlMsgInjection *)(receiver->buf + sizeof(DltUserHeader));
+    4773           0 :                     userbuffer =
+    4774             :                         (unsigned char *)(receiver->buf + sizeof(DltUserHeader) + sizeof(DltUserControlMsgInjection));
+    4775             : 
+    4776             :                     if (userbuffer != NULL) {
+    4777             : 
+    4778           0 :                         if (receiver->bytesRcvd <
+    4779           0 :                             (int32_t) (sizeof(DltUserHeader) + sizeof(DltUserControlMsgInjection) +
+    4780           0 :                                       usercontextinj->data_length_inject)) {
+    4781             :                             leave_while = 1;
+    4782             :                             break;
+    4783             :                         }
+    4784             : 
+    4785           0 :                         DLT_SEM_LOCK();
+    4786             : 
+    4787           0 :                         if ((usercontextinj->data_length_inject > 0) && (dlt_user.dlt_ll_ts))
+    4788             :                             /* Check if injection callback is registered for this context */
+    4789           0 :                             for (i = 0; i < dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].nrcallbacks; i++)
+    4790           0 :                                 if ((dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table) &&
+    4791           0 :                                     (dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].service_id ==
+    4792           0 :                                      usercontextinj->service_id)) {
+    4793             :                                     /* Prepare delayed injection callback call */
+    4794           0 :                                     if (dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].
+    4795             :                                         injection_callback != NULL) {
+    4796             :                                         delayed_injection_callback.injection_callback =
+    4797             :                                             dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].
+    4798             :                                             injection_callback;
+    4799             :                                     }
+    4800           0 :                                     else if (dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].
+    4801             :                                              injection_callback_with_id != NULL)
+    4802             :                                     {
+    4803             :                                         delayed_injection_callback.injection_callback_with_id =
+    4804             :                                             dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].
+    4805             :                                             injection_callback_with_id;
+    4806             :                                         delayed_injection_callback.data =
+    4807           0 :                                             dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].data;
+    4808             :                                     }
+    4809             : 
+    4810             :                                     delayed_injection_callback.service_id = usercontextinj->service_id;
+    4811             :                                     delayed_inject_data_length = usercontextinj->data_length_inject;
+    4812           0 :                                     delayed_inject_buffer = malloc(delayed_inject_data_length);
+    4813             : 
+    4814           0 :                                     if (delayed_inject_buffer != NULL) {
+    4815             :                                         memcpy(delayed_inject_buffer, userbuffer, delayed_inject_data_length);
+    4816             :                                     }
+    4817             :                                     else {
+    4818           0 :                                         DLT_SEM_FREE();
+    4819           0 :                                         dlt_log(LOG_WARNING, "malloc failed!\n");
+    4820           0 :                                         return DLT_RETURN_ERROR;
+    4821             :                                     }
+    4822             : 
+    4823             :                                     break;
+    4824             :                                 }
+    4825             : 
+    4826           0 :                         DLT_SEM_FREE();
+    4827             : 
+    4828             :                         /* Delayed injection callback call */
+    4829           0 :                         if ((delayed_inject_buffer != NULL) &&
+    4830             :                             (delayed_injection_callback.injection_callback != NULL)) {
+    4831           0 :                             delayed_injection_callback.injection_callback(delayed_injection_callback.service_id,
+    4832             :                                                                           delayed_inject_buffer,
+    4833             :                                                                           delayed_inject_data_length);
+    4834           0 :                             delayed_injection_callback.injection_callback = NULL;
+    4835             :                         }
+    4836           0 :                         else if ((delayed_inject_buffer != NULL) &&
+    4837             :                                  (delayed_injection_callback.injection_callback_with_id != NULL))
+    4838             :                         {
+    4839           0 :                             delayed_injection_callback.injection_callback_with_id(delayed_injection_callback.service_id,
+    4840             :                                                                                   delayed_inject_buffer,
+    4841             :                                                                                   delayed_inject_data_length,
+    4842             :                                                                                   delayed_injection_callback.data);
+    4843             :                             delayed_injection_callback.injection_callback_with_id = NULL;
+    4844             :                         }
+    4845             : 
+    4846           0 :                         free(delayed_inject_buffer);
+    4847             :                         delayed_inject_buffer = NULL;
+    4848             : 
+    4849             :                         /* keep not read data in buffer */
+    4850           0 :                         if (dlt_receiver_remove(receiver,
+    4851             :                                                 (int) (sizeof(DltUserHeader) +
+    4852           0 :                                                  sizeof(DltUserControlMsgInjection) +
+    4853           0 :                                                  usercontextinj->data_length_inject)) != DLT_RETURN_OK)
+    4854             :                             return DLT_RETURN_ERROR;
+    4855             :                     }
+    4856             :                 }
+    4857             :                 break;
+    4858           7 :                 case DLT_USER_MESSAGE_LOG_STATE:
+    4859             :                 {
+    4860             :                     /* At least, user header, user context, and service id and data_length of injected message is available */
+    4861           7 :                     if (receiver->bytesRcvd < (int32_t) (sizeof(DltUserHeader) + sizeof(DltUserControlMsgLogState))) {
+    4862             :                         leave_while = 1;
+    4863             :                         break;
+    4864             :                     }
+    4865             : 
+    4866           7 :                     userlogstate = (DltUserControlMsgLogState *)(receiver->buf + sizeof(DltUserHeader));
+    4867           7 :                     dlt_user.log_state = userlogstate->log_state;
+    4868             : 
+    4869             :                     /* keep not read data in buffer */
+    4870           7 :                     if (dlt_receiver_remove(receiver,
+    4871             :                                             (sizeof(DltUserHeader) + sizeof(DltUserControlMsgLogState))) ==
+    4872             :                         DLT_RETURN_ERROR)
+    4873             :                         return DLT_RETURN_ERROR;
+    4874             :                 }
+    4875             :                 break;
+    4876             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+    4877             :                 case DLT_USER_MESSAGE_TRACE_LOAD:
+    4878             :                 {
+    4879             :                     /*
+    4880             :                      * at least user header and message length is available
+    4881             :                      */
+    4882             :                     trace_load_settings_user_message_bytes_required =
+    4883             :                         (int32_t) (sizeof(DltUserHeader) + sizeof(uint32_t ));
+    4884             :                     if (receiver->bytesRcvd < (int32_t)trace_load_settings_user_message_bytes_required) {
+    4885             :                         // Not enough data to read the message length
+    4886             :                         leave_while = 1;
+    4887             :                         break;
+    4888             :                     }
+    4889             : 
+    4890             :                     // Read trace settings count from buffer.
+    4891             :                     trace_load_settings_user_messages_count = (uint32_t)(*(receiver->buf + sizeof(DltUserHeader)));
+    4892             :                     trace_load_settings_user_message_bytes_required +=
+    4893             :                         trace_load_settings_user_messages_count * sizeof(DltUserControlMsgTraceSettingMsg);
+    4894             :                     if (receiver->bytesRcvd < (int32_t)trace_load_settings_user_message_bytes_required) {
+    4895             :                         // Not enough data to read trace settings
+    4896             :                         leave_while = 1;
+    4897             :                         break;
+    4898             :                     }
+    4899             : 
+    4900             :                     trace_load_settings_user_messages =
+    4901             :                         (DltUserControlMsgTraceSettingMsg *)(receiver->buf + sizeof(DltUserHeader) + sizeof(uint32_t));
+    4902             : 
+    4903             :                     pthread_rwlock_wrlock(&trace_load_rw_lock);
+    4904             : 
+    4905             :                     // Remove the default created at startup
+    4906             :                     if (trace_load_settings != NULL) {
+    4907             :                         free(trace_load_settings);
+    4908             :                     }
+    4909             : 
+    4910             :                     char msg[255];
+    4911             :                     trace_load_settings_alloc_size = sizeof(DltTraceLoadSettings) * trace_load_settings_user_messages_count;
+    4912             :                     trace_load_settings = malloc(trace_load_settings_alloc_size);
+    4913             :                     if (trace_load_settings == NULL) {
+    4914             :                         pthread_rwlock_unlock(&trace_load_rw_lock);
+    4915             :                         dlt_log(LOG_ERR, "Failed to allocate memory for trace load settings\n");
+    4916             :                         return DLT_RETURN_ERROR;
+    4917             :                     }
+    4918             :                     memset(trace_load_settings, 0, trace_load_settings_alloc_size);
+    4919             :                     for (i = 0; i < trace_load_settings_user_messages_count; i++) {
+    4920             :                         strncpy(trace_load_settings[i].apid, dlt_user.appID, DLT_ID_SIZE);
+    4921             :                         strncpy(trace_load_settings[i].ctid, trace_load_settings_user_messages[i].ctid, DLT_ID_SIZE);
+    4922             :                         trace_load_settings[i].soft_limit = trace_load_settings_user_messages[i].soft_limit;
+    4923             :                         trace_load_settings[i].hard_limit = trace_load_settings_user_messages[i].hard_limit;
+    4924             :                     }
+    4925             :                     trace_load_settings_count = trace_load_settings_user_messages_count;
+    4926             :                     pthread_rwlock_unlock(&trace_load_rw_lock);
+    4927             : 
+    4928             :                     // must be sent with unlocked trace_load_rw_lock
+    4929             :                     for (i = 0; i < trace_load_settings_user_messages_count; i++) {
+    4930             :                         if (trace_load_settings[i].ctid[0] == '\0') {
+    4931             :                             snprintf(
+    4932             :                                 msg, sizeof(msg),
+    4933             :                                 "Received trace load settings: apid=%.4s, soft_limit=%u, hard_limit=%u\n",
+    4934             :                                 trace_load_settings[i].apid,
+    4935             :                                 trace_load_settings[i].soft_limit,
+    4936             :                                 trace_load_settings[i].hard_limit);
+    4937             :                         } else {
+    4938             :                             snprintf(
+    4939             :                                 msg, sizeof(msg),
+    4940             :                                 "Received trace load settings: apid=%.4s, ctid=%.4s, soft_limit=%u, hard_limit=%u\n",
+    4941             :                                 trace_load_settings[i].apid,
+    4942             :                                 trace_load_settings[i].ctid,
+    4943             :                                 trace_load_settings[i].soft_limit,
+    4944             :                                 trace_load_settings[i].hard_limit);
+    4945             :                         }
+    4946             :                         dlt_user_output_internal_msg(DLT_LOG_INFO, msg, NULL);
+    4947             :                     }
+    4948             : 
+    4949             :                     /* keep not read data in buffer */
+    4950             :                     if (dlt_receiver_remove(receiver, trace_load_settings_user_message_bytes_required)
+    4951             :                         == DLT_RETURN_ERROR) {
+    4952             :                         return DLT_RETURN_ERROR;
+    4953             :                     }
+    4954             :                 }
+    4955             : #endif
+    4956           0 :                 default:
+    4957             :                 {
+    4958           0 :                     dlt_log(LOG_WARNING, "Invalid user message type received!\n");
+    4959             :                     /* Ignore result */
+    4960           0 :                     if (dlt_receiver_remove(receiver, sizeof(DltUserHeader)) == -1)
+    4961           0 :                         dlt_log(LOG_WARNING, "Can't remove bytes from receiver\n");
+    4962             :                     /* In next invocation of while loop, a resync will be triggered if additional data was received */
+    4963             :                 }
+    4964             :                 break;
+    4965             :                 } /* switch() */
+    4966             : 
+    4967             :                 if (leave_while == 1) {
+    4968             :                     leave_while = 0;
+    4969             :                     break;
+    4970             :                 }
+    4971             :             } /* while buffer*/
+    4972             : 
+    4973           9 :             if (dlt_receiver_move_to_begin(receiver) == DLT_RETURN_ERROR)
+    4974           0 :                 return DLT_RETURN_ERROR;
+    4975             :         } /* while receive */
+    4976             : 
+    4977             :     } /* if */
+    4978             : 
+    4979             :     return DLT_RETURN_OK;
+    4980             : }
+    4981             : 
+    4982        5834 : DltReturnValue dlt_user_log_resend_buffer(void)
+    4983             : {
+    4984             :     int num, count;
+    4985             :     int size;
+    4986             :     DltReturnValue ret;
+    4987             : 
+    4988        5834 :     DLT_SEM_LOCK();
+    4989             : 
+    4990        5834 :     if (dlt_user.appID[0] == '\0') {
+    4991           4 :         DLT_SEM_FREE();
+    4992           4 :         return 0;
+    4993             :     }
+    4994             : 
+    4995             :     /* Send content of ringbuffer */
+    4996        5830 :     count = dlt_buffer_get_message_count(&(dlt_user.startup_buffer));
+    4997        5830 :     DLT_SEM_FREE();
+    4998             : 
+    4999        5830 :     for (num = 0; num < count; num++) {
+    5000             : 
+    5001           1 :         DLT_SEM_LOCK();
+    5002           1 :         size = dlt_buffer_copy(&(dlt_user.startup_buffer), dlt_user.resend_buffer, dlt_user.log_buf_len);
+    5003             : 
+    5004           1 :         if (size > 0) {
+    5005           1 :             DltUserHeader *userheader = (DltUserHeader *)(dlt_user.resend_buffer);
+    5006             : 
+    5007             :             /* Add application id to the messages of needed*/
+    5008           1 :             if (dlt_user_check_userheader(userheader)) {
+    5009           1 :                 switch (userheader->message) {
+    5010           0 :                 case DLT_USER_MESSAGE_REGISTER_CONTEXT:
+    5011             :                 {
+    5012             :                     DltUserControlMsgRegisterContext *usercontext =
+    5013           0 :                         (DltUserControlMsgRegisterContext *)(dlt_user.resend_buffer + sizeof(DltUserHeader));
+    5014             : 
+    5015           0 :                     if ((usercontext != 0) && (usercontext->apid[0] == '\0'))
+    5016           0 :                         dlt_set_id(usercontext->apid, dlt_user.appID);
+    5017             : 
+    5018             :                     break;
+    5019             :                 }
+    5020           1 :                 case DLT_USER_MESSAGE_LOG:
+    5021             :                 {
+    5022             :                     DltExtendedHeader *extendedHeader =
+    5023           1 :                         (DltExtendedHeader *)(dlt_user.resend_buffer + sizeof(DltUserHeader) +
+    5024             :                                               sizeof(DltStandardHeader) +
+    5025             :                                               sizeof(DltStandardHeaderExtra));
+    5026             : 
+    5027           1 :                     if (((extendedHeader) != 0) && (extendedHeader->apid[0] == '\0')) /* if application id is empty, add it */
+    5028           0 :                         dlt_set_id(extendedHeader->apid, dlt_user.appID);
+    5029             : 
+    5030             :                     break;
+    5031             :                 }
+    5032             :                 default:
+    5033             :                 {
+    5034             :                     break;
+    5035             :                 }
+    5036             :                 }
+    5037             :             }
+    5038             : 
+    5039             : #ifdef DLT_SHM_ENABLE
+    5040             :             dlt_shm_push(&dlt_user.dlt_shm,
+    5041             :                          dlt_user.resend_buffer + sizeof(DltUserHeader),
+    5042             :                          size - sizeof(DltUserHeader),
+    5043             :                          0,
+    5044             :                          0,
+    5045             :                          0,
+    5046             :                          0);
+    5047             : 
+    5048             :             ret = dlt_user_log_out3(dlt_user.dlt_log_handle, dlt_user.resend_buffer, sizeof(DltUserHeader), 0, 0, 0, 0);
+    5049             : #else
+    5050           1 :             ret = dlt_user_log_out3(dlt_user.dlt_log_handle, dlt_user.resend_buffer, (size_t) size, 0, 0, 0, 0);
+    5051             : #endif
+    5052             : 
+    5053             :             /* in case of error, keep message in ringbuffer */
+    5054           1 :             if (ret == DLT_RETURN_OK) {
+    5055           0 :                 dlt_buffer_remove(&(dlt_user.startup_buffer));
+    5056             :             }
+    5057             :             else {
+    5058           1 :                 if (ret == DLT_RETURN_PIPE_ERROR) {
+    5059             :                     /* handle not open or pipe error */
+    5060           1 :                     close(dlt_user.dlt_log_handle);
+    5061           1 :                     dlt_user.dlt_log_handle = -1;
+    5062             :                 }
+    5063             : 
+    5064             :                 /* keep message in ringbuffer */
+    5065           1 :                 DLT_SEM_FREE();
+    5066           1 :                 return ret;
+    5067             :             }
+    5068             :         }
+    5069             : 
+    5070           0 :         DLT_SEM_FREE();
+    5071             :     }
+    5072             : 
+    5073             :     return DLT_RETURN_OK;
+    5074             : }
+    5075             : 
+    5076         121 : void dlt_user_log_reattach_to_daemon(void)
+    5077             : {
+    5078             :     uint32_t num;
+    5079             :     DltContext handle;
+    5080             :     DltContextData log_new;
+    5081             : 
+    5082         121 :     if (!DLT_USER_INITALIZED_NOT_FREEING) {
+    5083         111 :         return;
+    5084             :     }
+    5085             : 
+    5086             : 
+    5087         121 :     if (dlt_user.dlt_log_handle < 0) {
+    5088         111 :         dlt_user.dlt_log_handle = DLT_FD_INIT;
+    5089             : 
+    5090             : #ifdef DLT_LIB_USE_UNIX_SOCKET_IPC
+    5091             :         /* try to open connection to dlt daemon */
+    5092             :         dlt_initialize_socket_connection();
+    5093             : 
+    5094             :         if (dlt_user.connection_state != DLT_USER_CONNECTED)
+    5095             :             /* return if not connected */
+    5096             :             return;
+    5097             : 
+    5098             : #elif defined DLT_LIB_USE_VSOCK_IPC
+    5099             :         dlt_initialize_vsock_connection();
+    5100             : 
+    5101             :         if (dlt_user.connection_state != DLT_USER_CONNECTED)
+    5102             :             return;
+    5103             : 
+    5104             : #else /* DLT_LIB_USE_FIFO_IPC */
+    5105             :         /* try to open pipe to dlt daemon */
+    5106             :         int fd = open(dlt_daemon_fifo, O_WRONLY | O_NONBLOCK);
+    5107             : 
+    5108         111 :         if (fd < 0)
+    5109             :             return;
+    5110             : 
+    5111           0 :         dlt_user.dlt_log_handle = fd;
+    5112             : #endif
+    5113             : 
+    5114           0 :         if (dlt_user_log_init(&handle, &log_new) < DLT_RETURN_OK)
+    5115             :             return;
+    5116             : 
+    5117             : #ifdef DLT_SHM_ENABLE
+    5118             : 
+    5119             :         /* init shared memory */
+    5120             :         if (dlt_shm_init_client(&dlt_user.dlt_shm, dltShmName) < DLT_RETURN_OK)
+    5121             :             dlt_vnlog(LOG_WARNING, DLT_USER_BUFFER_LENGTH, "Logging disabled,"
+    5122             :                       " Shared memory %s cannot be created!\n", dltShmName);
+    5123             : 
+    5124             : #endif
+    5125             : 
+    5126           0 :         dlt_log(LOG_NOTICE, "Logging (re-)enabled!\n");
+    5127             : 
+    5128             :         /* Re-register application */
+    5129           0 :         if (dlt_user_log_send_register_application() < DLT_RETURN_ERROR)
+    5130             :             return;
+    5131             : 
+    5132           0 :         DLT_SEM_LOCK();
+    5133             : 
+    5134             :         /* Re-register all stored contexts */
+    5135           0 :         for (num = 0; num < dlt_user.dlt_ll_ts_num_entries; num++)
+    5136             :             /* Re-register stored context */
+    5137           0 :             if ((dlt_user.appID[0] != '\0') && (dlt_user.dlt_ll_ts) && (dlt_user.dlt_ll_ts[num].contextID[0] != '\0')) {
+    5138             :                 /*dlt_set_id(log_new.appID, dlt_user.appID); */
+    5139           0 :                 dlt_set_id(handle.contextID, dlt_user.dlt_ll_ts[num].contextID);
+    5140           0 :                 handle.log_level_pos = (int32_t) num;
+    5141           0 :                 log_new.context_description = dlt_user.dlt_ll_ts[num].context_description;
+    5142             : 
+    5143             :                 /* Release the mutex for sending context registration: */
+    5144             :                 /* function  dlt_user_log_send_register_context() can take the mutex to write to the DLT buffer. => dead lock */
+    5145           0 :                 DLT_SEM_FREE();
+    5146             : 
+    5147           0 :                 log_new.log_level = DLT_USER_LOG_LEVEL_NOT_SET;
+    5148           0 :                 log_new.trace_status = DLT_USER_TRACE_STATUS_NOT_SET;
+    5149             : 
+    5150           0 :                 if (dlt_user_log_send_register_context(&log_new) < DLT_RETURN_ERROR)
+    5151             :                     return;
+    5152             : 
+    5153             :                 /* Lock again the mutex */
+    5154             :                 /* it is necessary in the for(;;) test, in order to have coherent dlt_user data all over the critical section. */
+    5155           0 :                 DLT_SEM_LOCK();
+    5156             :             }
+    5157           0 :         DLT_SEM_FREE();
+    5158             :     }
+    5159             : }
+    5160             : 
+    5161           0 : DltReturnValue dlt_user_log_send_overflow(void)
+    5162             : {
+    5163             :     DltUserHeader userheader;
+    5164             :     DltUserControlMsgBufferOverflow userpayload;
+    5165             : 
+    5166             :     /* set userheader */
+    5167           0 :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_OVERFLOW) < DLT_RETURN_OK)
+    5168             :         return DLT_RETURN_ERROR;
+    5169             : 
+    5170           0 :     if (dlt_user.dlt_is_file)
+    5171             :         return DLT_RETURN_OK;
+    5172             : 
+    5173             :     /* set user message parameters */
+    5174           0 :     userpayload.overflow_counter = dlt_user.overflow_counter;
+    5175           0 :     dlt_set_id(userpayload.apid, dlt_user.appID);
+    5176             : 
+    5177           0 :     return dlt_user_log_out2(dlt_user.dlt_log_handle,
+    5178             :                              &(userheader), sizeof(DltUserHeader),
+    5179             :                              &(userpayload), sizeof(DltUserControlMsgBufferOverflow));
+    5180             : }
+    5181             : 
+    5182           0 : DltReturnValue dlt_user_check_buffer(int *total_size, int *used_size)
+    5183             : {
+    5184           0 :     if ((total_size == NULL) || (used_size == NULL))
+    5185             :         return DLT_RETURN_WRONG_PARAMETER;
+    5186             : 
+    5187           0 :     DLT_SEM_LOCK();
+    5188             : 
+    5189             : #ifdef DLT_SHM_ENABLE
+    5190             :     *total_size = dlt_shm_get_total_size(&(dlt_user.dlt_shm));
+    5191             :     *used_size = dlt_shm_get_used_size(&(dlt_user.dlt_shm));
+    5192             : #else
+    5193           0 :     *total_size = (int) dlt_buffer_get_total_size(&(dlt_user.startup_buffer));
+    5194           0 :     *used_size = dlt_buffer_get_used_size(&(dlt_user.startup_buffer));
+    5195             : #endif
+    5196             : 
+    5197           0 :     DLT_SEM_FREE();
+    5198           0 :     return DLT_RETURN_OK; /* ok */
+    5199             : }
+    5200             : 
+    5201             : #ifdef DLT_TEST_ENABLE
+    5202             : void dlt_user_test_corrupt_user_header(int enable)
+    5203             : {
+    5204             :     dlt_user.corrupt_user_header = enable;
+    5205             : }
+    5206             : void dlt_user_test_corrupt_message_size(int enable, int16_t size)
+    5207             : {
+    5208             :     dlt_user.corrupt_message_size = enable;
+    5209             :     dlt_user.corrupt_message_size_size = size;
+    5210             : }
+    5211             : #endif
+    5212             : 
+    5213             : 
+    5214       16786 : int dlt_start_threads()
+    5215             : {
+    5216             :     struct timespec time_to_wait, single_wait;
+    5217             :     struct timespec now;
+    5218             :     int signal_status = 1;
+    5219       16786 :     atomic_bool dlt_housekeeper_running = false;
+    5220             : 
+    5221             :     /*
+    5222             :     * Configure the condition varibale to use CLOCK_MONOTONIC.
+    5223             :     * This makes sure we're protected against changes in the system clock
+    5224             :      */
+    5225             :     pthread_condattr_t attr;
+    5226       16786 :     pthread_condattr_init(&attr);
+    5227       16786 :     pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
+    5228       16786 :     pthread_cond_init(&dlt_housekeeper_running_cond, &attr);
+    5229             : 
+    5230       16786 :     if (pthread_create(&(dlt_housekeeperthread_handle),
+    5231             :                        0,
+    5232             :                        (void *)&dlt_user_housekeeperthread_function,
+    5233             :                        &dlt_housekeeper_running) != 0) {
+    5234           0 :         dlt_log(LOG_CRIT, "Can't create housekeeper thread!\n");
+    5235           0 :         return -1;
+    5236             :     }
+    5237             : 
+    5238       16786 :     clock_gettime(CLOCK_MONOTONIC, &now);
+    5239             :     /* wait at most 10s */
+    5240       16786 :     time_to_wait.tv_sec = now.tv_sec + 10;
+    5241             :     time_to_wait.tv_nsec = now.tv_nsec;
+    5242             : 
+    5243             :     /*
+    5244             :     * wait until the house keeper is up and running
+    5245             :     * Even though the condition variable and the while are
+    5246             :     * using the same time out the while loop is not a no op.
+    5247             :     * This is due to the fact that the pthread_cond_timedwait
+    5248             :     * can be woken before time is up and dlt_housekeeper_running is not true yet.
+    5249             :     * (spurious wakeup)
+    5250             :     * To protect against this, a while loop with a timeout is added
+    5251             :     * */
+    5252             : 
+    5253             :     // pthread_cond_timedwait has to be called on a locked mutex
+    5254       16786 :     pthread_mutex_lock(&dlt_housekeeper_running_mutex);
+    5255             : 
+    5256       16786 :     while (!dlt_housekeeper_running
+    5257       16786 :            && now.tv_sec <= time_to_wait.tv_sec) {
+    5258             : 
+    5259             :         /*
+    5260             :         * wait 500ms at a time
+    5261             :         * this makes sure we don't block too long
+    5262             :         * even if we missed the signal
+    5263             :          */
+    5264       16767 :         clock_gettime(CLOCK_MONOTONIC, &now);
+    5265       16767 :         if (now.tv_nsec >= 500000000) {
+    5266        8535 :             single_wait.tv_sec = now.tv_sec + 1;
+    5267        8535 :             single_wait.tv_nsec = now.tv_nsec - 500000000;
+    5268             :         } else {
+    5269        8232 :             single_wait.tv_sec = now.tv_sec;
+    5270        8232 :             single_wait.tv_nsec = now.tv_nsec + 500000000;
+    5271             :         }
+    5272             : 
+    5273       16767 :         signal_status = pthread_cond_timedwait(
+    5274             :             &dlt_housekeeper_running_cond,
+    5275             :             &dlt_housekeeper_running_mutex,
+    5276             :             &single_wait);
+    5277             : 
+    5278             :         /* otherwise it might be a spurious wakeup, try again until the time is over */
+    5279       16767 :         if (signal_status == 0) {
+    5280             :             break;
+    5281             :         }
+    5282             :      }
+    5283             : 
+    5284       16786 :     pthread_mutex_unlock(&dlt_housekeeper_running_mutex);
+    5285             : 
+    5286       16786 :      if (signal_status != 0 && !dlt_housekeeper_running) {
+    5287           0 :          dlt_log(LOG_CRIT, "Failed to wait for house keeper thread!\n");
+    5288           0 :          dlt_stop_threads();
+    5289           0 :          return -1;
+    5290             :      }
+    5291             : 
+    5292             : #ifdef DLT_NETWORK_TRACE_ENABLE
+    5293             :     /* Start the segmented thread */
+    5294       16786 :     if (pthread_create(&(dlt_user.dlt_segmented_nwt_handle), NULL,
+    5295             :                        (void *)dlt_user_trace_network_segmented_thread, NULL)) {
+    5296           0 :         dlt_log(LOG_CRIT, "Can't start segmented thread!\n");
+    5297           0 :         return -1;
+    5298             :     }
+    5299             : #endif
+    5300             :     return 0;
+    5301             : }
+    5302             : 
+    5303       16786 : void dlt_stop_threads()
+    5304             : {
+    5305             :     int dlt_housekeeperthread_result = 0;
+    5306             :     int joined = 0;
+    5307             : 
+    5308       16786 :     if (dlt_housekeeperthread_handle) {
+    5309             :         /* do not ignore return value */
+    5310             : #ifndef __ANDROID_API__
+    5311       16786 :         dlt_housekeeperthread_result = pthread_cancel(dlt_housekeeperthread_handle);
+    5312             : #else
+    5313             : 
+    5314             : #ifdef DLT_NETWORK_TRACE_ENABLE
+    5315             :         dlt_lock_mutex(&mq_mutex);
+    5316             : #endif /* DLT_NETWORK_TRACE_ENABLE */
+    5317             :         dlt_housekeeperthread_result = pthread_kill(dlt_housekeeperthread_handle, SIGUSR1);
+    5318             :         dlt_user_cleanup_handler(NULL);
+    5319             : #endif
+    5320             : 
+    5321             : 
+    5322       16786 :         if (dlt_housekeeperthread_result != 0)
+    5323           0 :             dlt_vlog(LOG_ERR,
+    5324             :                      "ERROR %s(dlt_housekeeperthread_handle): %s\n",
+    5325             : #ifndef __ANDROID_API__
+    5326             :                      "pthread_cancel",
+    5327             : #else
+    5328             :                      "pthread_kill",
+    5329             : #endif
+    5330             :                      strerror(dlt_housekeeperthread_result));
+    5331             :     }
+    5332             : 
+    5333             : #ifdef DLT_NETWORK_TRACE_ENABLE
+    5334             :     int dlt_segmented_nwt_result = 0;
+    5335             : 
+    5336       16786 :     if (dlt_user.dlt_segmented_nwt_handle) {
+    5337       16786 :         dlt_lock_mutex(&mq_mutex);
+    5338       16786 :         pthread_cond_signal(&mq_init_condition);
+    5339       16786 :         dlt_unlock_mutex(&mq_mutex);
+    5340             : 
+    5341       16786 :         dlt_segmented_nwt_result = pthread_cancel(dlt_user.dlt_segmented_nwt_handle);
+    5342             : 
+    5343       16786 :         if (dlt_segmented_nwt_result != 0)
+    5344           0 :             dlt_vlog(LOG_ERR,
+    5345             :                      "ERROR pthread_cancel(dlt_user.dlt_segmented_nwt_handle): %s\n",
+    5346             :                      strerror(dlt_segmented_nwt_result));
+    5347             :     }
+    5348             : #endif /* DLT_NETWORK_TRACE_ENABLE */
+    5349             :     /* make sure that the threads really finished working */
+    5350       16786 :     if ((dlt_housekeeperthread_result == 0) && dlt_housekeeperthread_handle) {
+    5351       16786 :         joined = pthread_join(dlt_housekeeperthread_handle, NULL);
+    5352             : 
+    5353       16786 :         if (joined != 0)
+    5354           0 :             dlt_vlog(LOG_ERR,
+    5355             :                      "ERROR pthread_join(dlt_housekeeperthread_handle, NULL): %s\n",
+    5356             :                      strerror(joined));
+    5357             : 
+    5358       16786 :         dlt_housekeeperthread_handle = 0; /* set to invalid */
+    5359             :     }
+    5360             : 
+    5361             : #ifdef DLT_NETWORK_TRACE_ENABLE
+    5362       16786 :     if ((dlt_segmented_nwt_result == 0) && dlt_user.dlt_segmented_nwt_handle) {
+    5363       16786 :         joined = pthread_join(dlt_user.dlt_segmented_nwt_handle, NULL);
+    5364             : 
+    5365       16786 :         if (joined != 0)
+    5366           0 :             dlt_vlog(LOG_ERR,
+    5367             :                      "ERROR pthread_join(dlt_user.dlt_segmented_nwt_handle, NULL): %s\n",
+    5368             :                      strerror(joined));
+    5369             : 
+    5370       16786 :         dlt_user.dlt_segmented_nwt_handle = 0; /* set to invalid */
+    5371             :     }
+    5372             : #endif /* DLT_NETWORK_TRACE_ENABLE */
+    5373       16786 : }
+    5374             : 
+    5375           0 : static void dlt_fork_child_fork_handler()
+    5376             : {
+    5377           0 :     g_dlt_is_child = 1;
+    5378           0 :     dlt_user_init_state = INIT_UNITIALIZED;
+    5379           0 :     dlt_user.dlt_log_handle = -1;
+    5380             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+    5381             :     pthread_rwlock_unlock(&trace_load_rw_lock);
+    5382             : #endif
+    5383           0 : }
+    5384             : 
+    5385             : 
+    5386             : #if defined(DLT_TRACE_LOAD_CTRL_ENABLE)
+    5387             : static DltReturnValue dlt_user_output_internal_msg(
+    5388             :     const DltLogLevelType loglevel, const char *const text, void* const params)
+    5389             : {
+    5390             :     (void)params; // parameter is not needed
+    5391             :     static DltContext handle;
+    5392             :     DltContextData log;
+    5393             :     int ret;
+    5394             :     int sent_size = 0;
+    5395             : 
+    5396             :     if (!handle.contextID[0])
+    5397             :     {
+    5398             :         // Register Special Context ID for output DLT library internal message
+    5399             :         ret = dlt_register_context(&handle, DLT_TRACE_LOAD_CONTEXT_ID, "DLT user library internal context");
+    5400             :         if (ret < DLT_RETURN_OK)
+    5401             :         {
+    5402             :             return ret;
+    5403             :         }
+    5404             :     }
+    5405             : 
+    5406             :     if (dlt_user.verbose_mode == 0)
+    5407             :     {
+    5408             :         return DLT_RETURN_ERROR;
+    5409             :     }
+    5410             : 
+    5411             :     if (loglevel < DLT_USER_LOG_LEVEL_NOT_SET || loglevel >= DLT_LOG_MAX)
+    5412             :     {
+    5413             :         dlt_vlog(LOG_ERR, "Loglevel %d is outside valid range", loglevel);
+    5414             :         return DLT_RETURN_WRONG_PARAMETER;
+    5415             :     }
+    5416             : 
+    5417             :     if (text == NULL)
+    5418             :     {
+    5419             :         return DLT_RETURN_WRONG_PARAMETER;
+    5420             :     }
+    5421             : 
+    5422             :     ret = dlt_user_log_write_start(&handle, &log, loglevel);
+    5423             : 
+    5424             :     // Ok means below threshold
+    5425             :     // see src/dlt-qnx-system/dlt-qnx-slogger2-adapter.cpp::sloggerinfo_callback for reference
+    5426             :     if (ret == DLT_RETURN_OK)
+    5427             :     {
+    5428             :         return ret;
+    5429             :     }
+    5430             : 
+    5431             :     if (ret != DLT_RETURN_TRUE)
+    5432             :     {
+    5433             :         dlt_vlog(LOG_ERR, "Loglevel %d is disabled", loglevel);
+    5434             :     }
+    5435             : 
+    5436             : 
+    5437             :     if (log.buffer == NULL)
+    5438             :     {
+    5439             :         return DLT_RETURN_LOGGING_DISABLED;
+    5440             :     }
+    5441             : 
+    5442             :     ret = dlt_user_log_write_string(&log, text);
+    5443             :     if (ret < DLT_RETURN_OK)
+    5444             :     {
+    5445             :         return ret;
+    5446             :     }
+    5447             : 
+    5448             :     ret = dlt_user_log_send_log(&log, DLT_TYPE_LOG, &sent_size);
+    5449             : 
+    5450             :     /* Return number of bytes if message was successfully sent */
+    5451             :     return (ret == DLT_RETURN_OK) ? sent_size : ret;
+    5452             : }
+    5453             : #endif
+    5454             : 
+    5455         859 : DltReturnValue dlt_user_log_out_error_handling(void *ptr1, size_t len1, void *ptr2, size_t len2, void *ptr3,
+    5456             :                                                size_t len3)
+    5457             : {
+    5458             :     DltReturnValue ret = DLT_RETURN_ERROR;
+    5459         859 :     size_t msg_size = len1 + len2 + len3;
+    5460             : 
+    5461         859 :     DLT_SEM_LOCK();
+    5462         859 :     ret = dlt_buffer_check_size(&(dlt_user.startup_buffer), (int)msg_size);
+    5463         859 :     DLT_SEM_FREE();
+    5464             : 
+    5465         859 :     DLT_SEM_LOCK();
+    5466             : 
+    5467         859 :     if (dlt_buffer_push3(&(dlt_user.startup_buffer),
+    5468             :                          ptr1, (unsigned int)len1,
+    5469             :                          ptr2, (unsigned int)len2,
+    5470             :                          ptr3, (unsigned int)len3) == DLT_RETURN_ERROR) {
+    5471           0 :         if (dlt_user.overflow_counter == 0)
+    5472           0 :             dlt_log(LOG_WARNING, "Buffer full! Messages will be discarded.\n");
+    5473             : 
+    5474             :         ret = DLT_RETURN_BUFFER_FULL;
+    5475             :     }
+    5476             : 
+    5477         859 :     DLT_SEM_FREE();
+    5478             : 
+    5479         859 :     return ret;
+    5480             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/lib/index-sort-f.html b/dlt_lcov_report/lib/index-sort-f.html new file mode 100644 index 000000000..e0123f234 --- /dev/null +++ b/dlt_lcov_report/lib/index-sort-f.html @@ -0,0 +1,123 @@ + + + + + + + LCOV - dlt_final_coverage.info - lib + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - libHitTotalCoverage
Test:dlt_final_coverage.infoLines:1262262248.1 %
Date:2024-12-05 09:07:13Functions:12819964.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_filetransfer.c +
0.0%
+
0.0 %0 / 1990.0 %0 / 18
dlt_env_ll.c +
6.1%6.1%
+
6.1 %8 / 13216.7 %2 / 12
dlt_client.c +
44.9%44.9%
+
44.9 %240 / 53448.4 %15 / 31
dlt_user.c +
57.7%57.7%
+
57.7 %1014 / 175780.4 %111 / 138
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/lib/index-sort-l.html b/dlt_lcov_report/lib/index-sort-l.html new file mode 100644 index 000000000..57fa0c792 --- /dev/null +++ b/dlt_lcov_report/lib/index-sort-l.html @@ -0,0 +1,123 @@ + + + + + + + LCOV - dlt_final_coverage.info - lib + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - libHitTotalCoverage
Test:dlt_final_coverage.infoLines:1262262248.1 %
Date:2024-12-05 09:07:13Functions:12819964.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_filetransfer.c +
0.0%
+
0.0 %0 / 1990.0 %0 / 18
dlt_env_ll.c +
6.1%6.1%
+
6.1 %8 / 13216.7 %2 / 12
dlt_client.c +
44.9%44.9%
+
44.9 %240 / 53448.4 %15 / 31
dlt_user.c +
57.7%57.7%
+
57.7 %1014 / 175780.4 %111 / 138
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/lib/index.html b/dlt_lcov_report/lib/index.html new file mode 100644 index 000000000..3448213dc --- /dev/null +++ b/dlt_lcov_report/lib/index.html @@ -0,0 +1,123 @@ + + + + + + + LCOV - dlt_final_coverage.info - lib + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - libHitTotalCoverage
Test:dlt_final_coverage.infoLines:1262262248.1 %
Date:2024-12-05 09:07:13Functions:12819964.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_client.c +
44.9%44.9%
+
44.9 %240 / 53448.4 %15 / 31
dlt_env_ll.c +
6.1%6.1%
+
6.1 %8 / 13216.7 %2 / 12
dlt_filetransfer.c +
0.0%
+
0.0 %0 / 1990.0 %0 / 18
dlt_user.c +
57.7%57.7%
+
57.7 %1014 / 175780.4 %111 / 138
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage.c.func-sort-c.html b/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage.c.func-sort-c.html new file mode 100644 index 000000000..ac57cc6a7 --- /dev/null +++ b/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage.c.func-sort-c.html @@ -0,0 +1,288 @@ + + + + + + + LCOV - dlt_final_coverage.info - offlinelogstorage/dlt_offline_logstorage.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - offlinelogstorage - dlt_offline_logstorage.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:59884470.9 %
Date:2024-12-05 09:07:13Functions:465485.2 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_setup_general_properties0
dlt_logstorage_check_general_param0
dlt_logstorage_check_gzip_compression0
dlt_logstorage_check_maintain_logstorage_loglevel0
dlt_logstorage_check_reset_loglevel0
dlt_logstorage_create_keys_only_ctid0
dlt_logstorage_create_keys_only_ecu0
dlt_logstorage_set_sync_strategy0
dlt_logstorage_check_disable_network1
dlt_logstorage_store_config_excluded_apids2
dlt_logstorage_store_config_excluded_ctids2
dlt_logstorage_check_specificsize4
dlt_logstorage_create_keys_only_apid4
dlt_logstorage_sync_caches4
dlt_logstorage_set_loglevel5
dlt_logstorage_free7
dlt_logstorage_device_disconnected8
dlt_logstorage_device_connected9
dlt_logstorage_load_config10
dlt_logstorage_store_filters11
dlt_logstorage_set_number12
dlt_logstorage_filter_set_strategy13
dlt_logstorage_list_destroy13
dlt_logstorage_count_ids19
dlt_logstorage_check_excluded_ids24
dlt_logstorage_check_param26
dlt_logstorage_check_sync_strategy27
dlt_logstorage_check_overwrite_strategy30
dlt_logstorage_check_ecuid34
dlt_logstorage_create_keys_multi34
dlt_daemon_offline_setup_filter_properties36
dlt_logstorage_setup_table36
dlt_logstorage_get_loglevel_by_key37
dlt_logstorage_check_apids38
dlt_logstorage_check_ctids38
dlt_logstorage_check_loglevel38
dlt_logstorage_check_nofiles38
dlt_logstorage_create_keys38
dlt_logstorage_prepare_table38
dlt_logstorage_validate_filter_name38
dlt_logstorage_check_filename39
dlt_logstorage_check_filesize39
dlt_logstorage_filter_config_free75
dlt_logstorage_get_keys_list76
dlt_logstorage_list_add76
dlt_logstorage_list_add_config77
dlt_logstorage_read_list_of_names78
dlt_logstorage_read_number81
dlt_logstorage_get_filter_section_value540
dlt_logstorage_get_filter_value540
dlt_logstorage_write5842
dlt_logstorage_filter5849
dlt_logstorage_get_config5884
dlt_logstorage_list_find40315
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage.c.func.html b/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage.c.func.html new file mode 100644 index 000000000..017b2f45c --- /dev/null +++ b/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage.c.func.html @@ -0,0 +1,288 @@ + + + + + + + LCOV - dlt_final_coverage.info - offlinelogstorage/dlt_offline_logstorage.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - offlinelogstorage - dlt_offline_logstorage.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:59884470.9 %
Date:2024-12-05 09:07:13Functions:465485.2 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_offline_setup_filter_properties36
dlt_daemon_setup_general_properties0
dlt_logstorage_check_apids38
dlt_logstorage_check_ctids38
dlt_logstorage_check_disable_network1
dlt_logstorage_check_ecuid34
dlt_logstorage_check_excluded_ids24
dlt_logstorage_check_filename39
dlt_logstorage_check_filesize39
dlt_logstorage_check_general_param0
dlt_logstorage_check_gzip_compression0
dlt_logstorage_check_loglevel38
dlt_logstorage_check_maintain_logstorage_loglevel0
dlt_logstorage_check_nofiles38
dlt_logstorage_check_overwrite_strategy30
dlt_logstorage_check_param26
dlt_logstorage_check_reset_loglevel0
dlt_logstorage_check_specificsize4
dlt_logstorage_check_sync_strategy27
dlt_logstorage_count_ids19
dlt_logstorage_create_keys38
dlt_logstorage_create_keys_multi34
dlt_logstorage_create_keys_only_apid4
dlt_logstorage_create_keys_only_ctid0
dlt_logstorage_create_keys_only_ecu0
dlt_logstorage_device_connected9
dlt_logstorage_device_disconnected8
dlt_logstorage_filter5849
dlt_logstorage_filter_config_free75
dlt_logstorage_filter_set_strategy13
dlt_logstorage_free7
dlt_logstorage_get_config5884
dlt_logstorage_get_filter_section_value540
dlt_logstorage_get_filter_value540
dlt_logstorage_get_keys_list76
dlt_logstorage_get_loglevel_by_key37
dlt_logstorage_list_add76
dlt_logstorage_list_add_config77
dlt_logstorage_list_destroy13
dlt_logstorage_list_find40315
dlt_logstorage_load_config10
dlt_logstorage_prepare_table38
dlt_logstorage_read_list_of_names78
dlt_logstorage_read_number81
dlt_logstorage_set_loglevel5
dlt_logstorage_set_number12
dlt_logstorage_set_sync_strategy0
dlt_logstorage_setup_table36
dlt_logstorage_store_config_excluded_apids2
dlt_logstorage_store_config_excluded_ctids2
dlt_logstorage_store_filters11
dlt_logstorage_sync_caches4
dlt_logstorage_validate_filter_name38
dlt_logstorage_write5842
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage.c.gcov.html b/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage.c.gcov.html new file mode 100644 index 000000000..c1c1b83f3 --- /dev/null +++ b/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage.c.gcov.html @@ -0,0 +1,2883 @@ + + + + + + + LCOV - dlt_final_coverage.info - offlinelogstorage/dlt_offline_logstorage.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - offlinelogstorage - dlt_offline_logstorage.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:59884470.9 %
Date:2024-12-05 09:07:13Functions:465485.2 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /**
+       2             :  * Copyright (C) 2013 - 2015  Advanced Driver Information Technology.
+       3             :  * This code is developed by Advanced Driver Information Technology.
+       4             :  * Copyright of Advanced Driver Information Technology, Bosch and DENSO.
+       5             :  *
+       6             :  * DLT offline log storage functionality source file.
+       7             :  *
+       8             :  * \copyright
+       9             :  * This Source Code Form is subject to the terms of the
+      10             :  * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
+      11             :  * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+      12             :  *
+      13             :  *
+      14             :  * \author Syed Hameed <shameed@jp.adit-jv.com> ADIT 2013 - 2015
+      15             :  * \author Christoph Lipka <clipka@jp.adit-jv.com> ADIT 2015
+      16             :  *
+      17             :  * \file: dlt_offline_logstorage.c
+      18             :  * For further information see http://www.covesa.org/.
+      19             :  */
+      20             : #include <stdio.h>
+      21             : #include <string.h>
+      22             : #include <stdlib.h>
+      23             : #include <limits.h>
+      24             : #include <ctype.h>
+      25             : #include <syslog.h>
+      26             : #include <sys/stat.h>
+      27             : #include <sys/stat.h>
+      28             : #include <unistd.h>
+      29             : #include <dirent.h>
+      30             : #include <time.h>
+      31             : 
+      32             : #include "dlt_offline_logstorage.h"
+      33             : #include "dlt_offline_logstorage_internal.h"
+      34             : #include "dlt_offline_logstorage_behavior.h"
+      35             : #include "dlt_config_file_parser.h"
+      36             : 
+      37             : #define DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR 1
+      38             : #define DLT_OFFLINE_LOGSTORAGE_STORE_FILTER_ERROR 2
+      39             : #define DLT_OFFLINE_LOGSTORAGE_FILTER_CONTINUE 3
+      40             : 
+      41             : #define GENERAL_BASE_NAME "General"
+      42             : 
+      43          75 : DLT_STATIC void dlt_logstorage_filter_config_free(DltLogStorageFilterConfig *data)
+      44             : {
+      45             :     DltLogStorageFileList *n = NULL;
+      46             :     DltLogStorageFileList *n1 = NULL;
+      47             : 
+      48          75 :     if (data->apids) {
+      49          72 :         free(data->apids);
+      50          72 :         data->apids = NULL;
+      51             :     }
+      52             : 
+      53          75 :     if (data->ctids) {
+      54          72 :         free(data->ctids);
+      55          72 :         data->ctids = NULL;
+      56             :     }
+      57             : 
+      58          75 :     if (data->excluded_apids) {
+      59           0 :         free(data->excluded_apids);
+      60           0 :         data->excluded_apids = NULL;
+      61             :     }
+      62             : 
+      63          75 :     if (data->excluded_ctids) {
+      64           0 :         free(data->excluded_ctids);
+      65           0 :         data->excluded_ctids = NULL;
+      66             :     }
+      67             : 
+      68          75 :     if (data->file_name) {
+      69          70 :         free(data->file_name);
+      70          70 :         data->file_name = NULL;
+      71             :     }
+      72             : 
+      73          75 :     if (data->working_file_name) {
+      74          27 :         free(data->working_file_name);
+      75          27 :         data->working_file_name = NULL;
+      76             :     }
+      77             : 
+      78          75 :     if (data->ecuid != NULL) {
+      79          64 :         free(data->ecuid);
+      80          64 :         data->ecuid = NULL;
+      81             :     }
+      82             : 
+      83          75 :     if (data->log != NULL)
+      84           3 :         fclose(data->log);
+      85             : 
+      86             : #ifdef DLT_LOGSTORAGE_USE_GZIP
+      87             :     if (data->gzlog != NULL)
+      88             :         gzclose(data->gzlog);
+      89             : #endif
+      90             : 
+      91          75 :     if (data->cache != NULL) {
+      92          23 :         free(data->cache);
+      93          23 :         data->cache = NULL;
+      94             :     }
+      95             : 
+      96          75 :     n = data->records;
+      97             : 
+      98         114 :     while (n) {
+      99             :         n1 = n;
+     100          39 :         n = n->next;
+     101          39 :         if (n1->name) {
+     102          39 :             free(n1->name);
+     103             :             n1->name = NULL;
+     104             :         }
+     105             : 
+     106          39 :         free(n1);
+     107             :         n1 = NULL;
+     108             :     }
+     109          75 : }
+     110             : 
+     111             : /**
+     112             :  * dlt_logstorage_list_destroy
+     113             :  *
+     114             :  * Destroy Filter configurations list.
+     115             :  *
+     116             :  * @param list List of the filter configurations will be destroyed.
+     117             :  * @param uconfig User configurations for log file
+     118             :  * @param dev_path Path to the device
+     119             :  * @param reason Reason for the destroying of Filter configurations list
+     120             :  * @return 0 on success, -1 on error
+     121             :  */
+     122          13 : DLT_STATIC int dlt_logstorage_list_destroy(DltLogStorageFilterList **list,
+     123             :                                            DltLogStorageUserConfig *uconfig,
+     124             :                                            char *dev_path,
+     125             :                                            int reason)
+     126             : {
+     127             :     DltLogStorageFilterList *tmp = NULL;
+     128             : 
+     129          52 :     while (*(list) != NULL) {
+     130             :         tmp = *list;
+     131          39 :         *list = (*list)->next;
+     132          39 :         if (tmp->key_list != NULL)
+     133             :         {
+     134          39 :             free(tmp->key_list);
+     135          39 :             tmp->key_list = NULL;
+     136             :         }
+     137             : 
+     138          39 :         if (tmp->data != NULL) {
+     139             :             /* sync data if necessary */
+     140             :             /* ignore return value */
+     141          39 :             tmp->data->dlt_logstorage_sync(tmp->data,
+     142             :                                            uconfig,
+     143             :                                            dev_path,
+     144             :                                            reason);
+     145             : 
+     146          39 :             dlt_logstorage_filter_config_free(tmp->data);
+     147             : 
+     148          39 :             free(tmp->data);
+     149             :             tmp->data = NULL;
+     150             :         }
+     151             : 
+     152          39 :         free(tmp);
+     153             :         tmp = NULL;
+     154             :     }
+     155             : 
+     156          13 :     return 0;
+     157             : }
+     158             : 
+     159          77 : DLT_STATIC int dlt_logstorage_list_add_config(DltLogStorageFilterConfig *data,
+     160             :                                               DltLogStorageFilterConfig **listdata)
+     161             : {
+     162          77 :     if (*(listdata) == NULL)
+     163             :         return -1;
+     164             : 
+     165             :     /* copy the data to list */
+     166             :     memcpy(*listdata, data, sizeof(DltLogStorageFilterConfig));
+     167             : 
+     168          77 :     if (data->apids != NULL)
+     169          72 :         (*listdata)->apids = strdup(data->apids);
+     170             : 
+     171          77 :     if (data->ctids != NULL)
+     172          72 :         (*listdata)->ctids = strdup(data->ctids);
+     173             : 
+     174          77 :     if (data->excluded_apids != NULL)
+     175          12 :         (*listdata)->excluded_apids = strdup(data->excluded_apids);
+     176             : 
+     177          77 :     if (data->excluded_ctids != NULL)
+     178          12 :         (*listdata)->excluded_ctids = strdup(data->excluded_ctids);
+     179             : 
+     180          77 :     if (data->file_name != NULL)
+     181          70 :         (*listdata)->file_name = strdup(data->file_name);
+     182             : 
+     183          77 :     if (data->ecuid != NULL)
+     184          66 :         (*listdata)->ecuid = strdup(data->ecuid);
+     185             : 
+     186             :     return 0;
+     187             : }
+     188             : 
+     189             : /**
+     190             :  * dlt_logstorage_list_add
+     191             :  *
+     192             :  * Add Filter configurations to the list.
+     193             :  *
+     194             :  * @param keys Keys will be added to the list.
+     195             :  * @param num_keys Number of keys
+     196             :  * @param data Filter configurations data will be added to the list.
+     197             :  * @param list List of the filter configurations
+     198             :  * @return 0 on success, -1 on error
+     199             :  */
+     200          76 : DLT_STATIC int dlt_logstorage_list_add(char *keys,
+     201             :                                        int num_keys,
+     202             :                                        DltLogStorageFilterConfig *data,
+     203             :                                        DltLogStorageFilterList **list)
+     204             : {
+     205             :     DltLogStorageFilterList *tmp = NULL;
+     206             : 
+     207         245 :     while (*(list) != NULL) {
+     208         169 :         list = &(*list)->next;
+     209             :     }
+     210             : 
+     211          76 :     tmp = calloc(1, sizeof(DltLogStorageFilterList));
+     212             : 
+     213          76 :     if (tmp == NULL)
+     214             :         return -1;
+     215             : 
+     216          76 :     tmp->key_list = (char *)calloc(
+     217          76 :                 (num_keys * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN), sizeof(char));
+     218          76 :     if (tmp->key_list == NULL)
+     219             :     {
+     220           0 :         free(tmp);
+     221             :         tmp = NULL;
+     222           0 :         return -1;
+     223             :     }
+     224             : 
+     225             :     memcpy(tmp->key_list, keys, num_keys * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN);
+     226          76 :     tmp->num_keys = num_keys;
+     227          76 :     tmp->next = NULL;
+     228          76 :     tmp->data = calloc(1, sizeof(DltLogStorageFilterConfig));
+     229             : 
+     230          76 :     if (tmp->data == NULL) {
+     231           0 :         free(tmp->key_list);
+     232             :         tmp->key_list = NULL;
+     233           0 :         free(tmp);
+     234             :         tmp = NULL;
+     235           0 :         return -1;
+     236             :     }
+     237             : 
+     238          76 :     if (dlt_logstorage_list_add_config(data, &(tmp->data)) != 0) {
+     239           0 :         free(tmp->key_list);
+     240             :         tmp->key_list = NULL;
+     241           0 :         free(tmp->data);
+     242             :         tmp->data = NULL;
+     243           0 :         free(tmp);
+     244             :         tmp = NULL;
+     245           0 :         return -1;
+     246             :     }
+     247             : 
+     248          76 :     *list = tmp;
+     249             : 
+     250          76 :     return 0;
+     251             : }
+     252             : 
+     253             : /**
+     254             :  * dlt_logstorage_list_find
+     255             :  *
+     256             :  * Find all Filter configurations corresponding with key provided.
+     257             :  *
+     258             :  * @param key Key to find the filter configurations
+     259             :  * @param list List of the filter configurations
+     260             :  * @param config Filter configurations corresponding with the key.
+     261             :  * @return Number of the filter configuration found.
+     262             :  */
+     263       40315 : DLT_STATIC int dlt_logstorage_list_find(char *key,
+     264             :                                         DltLogStorageFilterList **list,
+     265             :                                         DltLogStorageFilterConfig **config)
+     266             : {
+     267             :     int i = 0;
+     268             :     int num = 0;
+     269             : 
+     270      460056 :     while (*(list) != NULL) {
+     271      833774 :         for (i = 0; i < (*list)->num_keys; i++)
+     272             :         {
+     273      419741 :             if (strncmp(((*list)->key_list
+     274      419741 :                         + (i * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN)),
+     275             :                         key, DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN) == 0)
+     276             :             {
+     277        5708 :                 config[num] = (*list)->data;
+     278        5708 :                 num++;
+     279        5708 :                 break;
+     280             :             }
+     281             :         }
+     282      419741 :         list = &(*list)->next;
+     283             :     }
+     284             : 
+     285       40315 :     return num;
+     286             : }
+     287             : 
+     288             : /* Configuration file parsing helper functions */
+     289             : 
+     290          19 : DLT_STATIC int dlt_logstorage_count_ids(const char *str)
+     291             : {
+     292             : 
+     293          19 :     if (str == NULL)
+     294             :         return -1;
+     295             : 
+     296             :     /* delimiter is: "," */
+     297             :     const char *p = str;
+     298             :     int i = 0;
+     299             :     int num = 1;
+     300             : 
+     301         400 :     while (p[i] != 0) {
+     302         322 :         if (p[i] == ',')
+     303          18 :             num++;
+     304             : 
+     305         322 :         i++;
+     306             :     }
+     307             : 
+     308             :     return num;
+     309             : }
+     310             : 
+     311             : /**
+     312             :  * dlt_logstorage_free
+     313             :  *
+     314             :  * Free all allocated memory used in log storage handle
+     315             :  *
+     316             :  * @param handle         DLT Logstorage handle
+     317             :  * @param reason         Reason for freeing the device
+     318             :  *
+     319             :  */
+     320           7 : void dlt_logstorage_free(DltLogStorage *handle, int reason)
+     321             : {
+     322           7 :     if (handle == NULL) {
+     323           0 :         dlt_vlog(LOG_ERR, "%s failed: handle is NULL\n", __func__);
+     324           0 :         return;
+     325             :     }
+     326             : 
+     327           7 :     dlt_logstorage_list_destroy(&(handle->config_list), &handle->uconfig,
+     328           7 :                                 handle->device_mount_point, reason);
+     329             : }
+     330             : 
+     331             : 
+     332             : /**
+     333             :  * dlt_logstorage_read_list_of_names
+     334             :  *
+     335             :  * Evaluate app and ctx names given in config file and create a list of names
+     336             :  * acceptable by DLT Daemon. When using SET_APPLICATION_NAME and SET_CONTEXT_NAME
+     337             :  * there is no constraint that these names have max 4 characters. Internally,
+     338             :  * these names are cutted down to max 4 chars. To have create valid keys, the
+     339             :  * internal representation of these names has to be considered.
+     340             :  * Therefore, a given configuration of "AppLogName = App1,Application2,A3" will
+     341             :  * be stored as "App1,Appl,A3".
+     342             :  *
+     343             :  * @param names        to store the list of names
+     344             :  * @param value        string given in config file
+     345             :  * @return             0 on success, -1 on error
+     346             :  */
+     347          78 : DLT_STATIC int dlt_logstorage_read_list_of_names(char **names, const char *value)
+     348             : {
+     349             :     int i = 0;
+     350             :     int y = 0;
+     351             :     int len = 0;
+     352             :     char *tok;
+     353             :     int num = 1;
+     354             : 
+     355          78 :     if ((names == NULL) || (value == NULL)) {
+     356           1 :         dlt_vlog(LOG_ERR, "%s: Arguments are set to NULL\n", __func__);
+     357           1 :         return -1;
+     358             :     }
+     359             : 
+     360             :     /* free, alloce'd memory to store new apid/ctid */
+     361          77 :     if (*names != NULL) {
+     362           5 :         free(*names);
+     363           5 :         *names = NULL;
+     364             :     }
+     365             : 
+     366          77 :     len = strlen(value);
+     367             : 
+     368          77 :     if (len == 0) {
+     369           0 :         dlt_vlog(LOG_ERR, "%s: Length of string given in config file is 0\n",
+     370             :                  __func__);
+     371           0 :         return -1;
+     372             :     }
+     373             : 
+     374             :     /* count number of delimiters to get actual number off names */
+     375          13 :     num = dlt_logstorage_count_ids(value);
+     376             : 
+     377             :     /* need to alloc space for 5 chars, 4 for the name and "," and "\0" */
+     378          77 :     *names = (char *)calloc(num * 5, sizeof(char));
+     379             : 
+     380          77 :     if (*names == NULL) {
+     381           0 :         dlt_vlog(LOG_ERR, "%s: Cannot allocate memory\n", __func__);
+     382           0 :         return -1;
+     383             :     }
+     384             : 
+     385          77 :     tok = strdup(value);
+     386          77 :     tok = strtok(tok, ",");
+     387             : 
+     388             :     i = 1;
+     389             : 
+     390         169 :     while (tok != NULL) {
+     391          92 :         len = strlen(tok);
+     392          92 :         len = DLT_OFFLINE_LOGSTORAGE_MIN(len, 4);
+     393             : 
+     394          92 :         strncpy((*names + y), tok, len);
+     395             : 
+     396          92 :         if ((num > 1) && (i < num))
+     397          15 :             strncpy((*names + y + len), ",", 2);
+     398             : 
+     399          92 :         y += len + 1;
+     400             : 
+     401          92 :         i++;
+     402          92 :         tok = strtok(NULL, ",");
+     403             :     }
+     404             : 
+     405             :     free(tok);
+     406             : 
+     407             :     return 0;
+     408             : }
+     409             : 
+     410          12 : DLT_STATIC int dlt_logstorage_set_number(unsigned int *number, unsigned int value)
+     411             : {
+     412          12 :     if (value == 0) {
+     413           0 :         dlt_log(LOG_ERR, "Invalid value of 0\n");
+     414           0 :         return -1;
+     415             :     }
+     416             : 
+     417          80 :     *number = value;
+     418             : 
+     419          80 :     return 0;
+     420             : }
+     421             : 
+     422             : /**
+     423             :  * dlt_logstorage_read_number
+     424             :  *
+     425             :  * Evaluate file size and number of files given in config file and set file size
+     426             :  * The file number is checked by converting a string to an unsigned integer
+     427             :  * width 0 > result < UINT_MAX (excludes 0!)
+     428             :  * Non-digit characters including spaces and out of boundary will lead to an
+     429             :  * error -1.
+     430             :  *
+     431             :  * @param number       Number to be read
+     432             :  * @param value        string given in config file
+     433             :  * @return             0 on success, -1 on error
+     434             :  */
+     435          81 : DLT_STATIC int dlt_logstorage_read_number(unsigned int *number, char *value)
+     436             : {
+     437             :     int i = 0;
+     438             :     int len = 0;
+     439             :     unsigned long size = 0;
+     440             : 
+     441          81 :     if (value == NULL)
+     442             :         return -1;
+     443             : 
+     444          80 :     *number = 0;
+     445          80 :     len = strlen(value);
+     446             : 
+     447             :     /* check if string consists of digits only */
+     448         308 :     for (i = 0; i < len; i++)
+     449         228 :         if (!isdigit(value[i])) {
+     450           0 :             dlt_log(LOG_ERR, "Invalid, is not a number \n");
+     451           0 :             return -1;
+     452             :         }
+     453             : 
+     454          80 :     size = strtoul(value, NULL, 10);
+     455             : 
+     456          80 :     return dlt_logstorage_set_number(number, size);
+     457             : }
+     458             : 
+     459             : /**
+     460             :  * dlt_logstorage_get_keys_list
+     461             :  *
+     462             :  * Obtain key list and number of keys for id list passed
+     463             :  * after splitting it between seperator (,)
+     464             :  *
+     465             :  * @param ids            ID's
+     466             :  * @param sep            Seperator
+     467             :  * @param list           Prepared key list is stored here
+     468             :  * @param numids         Number of keys in the list is stored here
+     469             :  * @return: 0 on success, error on failure*
+     470             :  */
+     471          76 : DLT_STATIC int dlt_logstorage_get_keys_list(char *ids, char *sep, char **list,
+     472             :                                             int *numids)
+     473             : {
+     474             :     char *token = NULL;
+     475          76 :     char *tmp_token = NULL;
+     476             :     char *ids_local = NULL;
+     477             : 
+     478          76 :     *numids = 0;
+     479             : 
+     480             :     /* Duplicate the ids passed for using in strtok_r() */
+     481          76 :     ids_local = strdup(ids);
+     482             : 
+     483          76 :     if (ids_local == NULL)
+     484             :         return -1;
+     485             : 
+     486          76 :     token = strtok_r(ids_local, sep, &tmp_token);
+     487             : 
+     488          76 :     if (token == NULL) {
+     489           0 :         free(ids_local);
+     490           0 :         return -1;
+     491             :     }
+     492             : 
+     493          76 :     *list = (char *)calloc(DLT_OFFLINE_LOGSTORAGE_MAXIDS * (DLT_ID_SIZE + 1),
+     494             :                            sizeof(char));
+     495             : 
+     496          76 :     if (*(list) == NULL) {
+     497           0 :         free(ids_local);
+     498           0 :         return -1;
+     499             :     }
+     500             : 
+     501         152 :     while (token != NULL) {
+     502             :         /* If it reached the max then other ids are ignored */
+     503          76 :         if (*numids >= DLT_OFFLINE_LOGSTORAGE_MAXIDS) {
+     504           0 :             free(ids_local);
+     505           0 :             return 0;
+     506             :         }
+     507             : 
+     508          76 :         strncpy(((*list) + ((*numids) * (DLT_ID_SIZE + 1))), token,
+     509             :                 DLT_ID_SIZE);
+     510          76 :         *numids = *numids + 1;
+     511          76 :         token = strtok_r(NULL, sep, &tmp_token);
+     512             :     }
+     513             : 
+     514          76 :     free(ids_local);
+     515             : 
+     516          76 :     return 0;
+     517             : }
+     518             : 
+     519          24 : DLT_STATIC bool dlt_logstorage_check_excluded_ids(char *id, char *delim, char *excluded_ids)
+     520             : {
+     521             :     char *token = NULL;
+     522          24 :     char *tmp_token = NULL;
+     523             :     char *ids_local = NULL;
+     524             : 
+     525          24 :     if ((id == NULL) || (delim == NULL) || (excluded_ids == NULL)) {
+     526           1 :         dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
+     527           1 :         return false;
+     528             :     }
+     529             : 
+     530          23 :     ids_local = strdup(excluded_ids);
+     531             : 
+     532          23 :     if (ids_local == NULL) {
+     533           0 :         dlt_vlog(LOG_ERR, "%s: Cannot duplicate string.\n", __func__);
+     534           0 :         return false;
+     535             :     }
+     536             : 
+     537          23 :     token = strtok_r(ids_local, delim, &tmp_token);
+     538             : 
+     539          23 :     if (token == NULL) {
+     540           0 :         dlt_vlog(LOG_ERR, "%s: %s could not be parsed.\n", __func__, ids_local);
+     541           0 :         free(ids_local);
+     542           0 :         return false;
+     543             :     }
+     544             : 
+     545          39 :     while (token != NULL) {
+     546          29 :         if(strncmp(id, token, DLT_ID_SIZE) == 0) {
+     547          13 :             free(ids_local);
+     548          13 :             return true;
+     549             :         }
+     550             : 
+     551          16 :         token = strtok_r(NULL, delim, &tmp_token);
+     552             :     }
+     553             : 
+     554          10 :     free(ids_local);
+     555          10 :     return false;
+     556             : }
+     557             : 
+     558             : /**
+     559             :  * dlt_logstorage_create_keys_only_ctid
+     560             :  *
+     561             :  * Prepares keys with context ID alone, will use ecuid if provided
+     562             :  * (ecuid\:\:ctid) or (\:\:ctid)
+     563             :  *
+     564             :  * @param ecuid          ECU ID
+     565             :  * @param ctid           Context ID
+     566             :  * @param key            Prepared key stored here
+     567             :  * @return               None
+     568             :  */
+     569           0 : DLT_STATIC void dlt_logstorage_create_keys_only_ctid(char *ecuid, char *ctid,
+     570             :                                                      char *key)
+     571             : {
+     572           0 :     char curr_str[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = { 0 };
+     573             :     int curr_len = 0;
+     574             :     const char *delimiter = "::";
+     575             : 
+     576           0 :     if (ecuid != NULL) {
+     577             :         strncpy(curr_str, ecuid, DLT_ID_SIZE);
+     578             :         strncat(curr_str, delimiter, strlen(delimiter));
+     579             :     }
+     580             :     else {
+     581             :         strncpy(curr_str, delimiter, strlen(delimiter));
+     582             :     }
+     583             : 
+     584           0 :     if (ctid != NULL) {
+     585           0 :         curr_len = strlen(ctid);
+     586           0 :         strncat(curr_str, ctid, curr_len);
+     587             :     }
+     588             : 
+     589           0 :     curr_len = strlen(curr_str);
+     590           0 :     strncpy(key, curr_str, curr_len);
+     591           0 : }
+     592             : 
+     593             : /**
+     594             :  * dlt_logstorage_create_keys_only_apid
+     595             :  *
+     596             :  * Prepares keys with application ID alone, will use ecuid if provided
+     597             :  * (ecuid:apid::) or (:apid::)
+     598             :  *
+     599             :  * @param ecuid          ECU ID
+     600             :  * @param apid           Application ID
+     601             :  * @param key            Prepared key stored here
+     602             :  * @return               None
+     603             :  */
+     604           4 : DLT_STATIC void dlt_logstorage_create_keys_only_apid(char *ecuid, char *apid,
+     605             :                                                      char *key)
+     606             : {
+     607           4 :     char curr_str[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = { 0 };
+     608             :     int curr_len = 0;
+     609             :     const char *colon = ":";
+     610             : 
+     611           4 :     if (ecuid != NULL) {
+     612             :         strncpy(curr_str, ecuid, DLT_ID_SIZE);
+     613             :         strncat(curr_str, colon, strlen(colon));
+     614             :     }
+     615             :     else {
+     616             :         strncat(curr_str, colon, strlen(colon));
+     617             :     }
+     618             : 
+     619           4 :     if (apid != NULL) {
+     620           4 :         curr_len = strlen(apid);
+     621           4 :         strncat(curr_str, apid, curr_len);
+     622             :     }
+     623             : 
+     624             :     strncat(curr_str, colon, strlen(colon));
+     625           4 :     curr_len = strlen(curr_str);
+     626           4 :     strncpy(key, curr_str, curr_len);
+     627           4 : }
+     628             : 
+     629             : /**
+     630             :  * dlt_logstorage_create_keys_multi
+     631             :  *
+     632             :  * Prepares keys with apid, ctid (ecuid:apid:ctid), will use ecuid if is provided
+     633             :  * (ecuid:apid:ctid) or (:apid:ctid)
+     634             :  *
+     635             :  * @param ecuid          ECU ID
+     636             :  * @param apid           Application ID
+     637             :  * @param ctid           Context ID
+     638             :  * @param key            Prepared key stored here
+     639             :  * @return               None
+     640             :  */
+     641          34 : DLT_STATIC void dlt_logstorage_create_keys_multi(char *ecuid, char *apid,
+     642             :                                                  char *ctid, char *key)
+     643             : {
+     644          34 :     char curr_str[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = { 0 };
+     645             :     int curr_len = 0;
+     646             :     const char *colon = ":";
+     647             : 
+     648          34 :     if (ecuid != NULL) {
+     649             :         strncpy(curr_str, ecuid, DLT_ID_SIZE);
+     650             :         strncat(curr_str, colon, strlen(colon));
+     651             :     }
+     652             :     else {
+     653             :         strncat(curr_str, colon, strlen(colon));
+     654             :     }
+     655             : 
+     656          34 :     if (apid != NULL) {
+     657          34 :         curr_len = strlen(apid);
+     658          34 :         strncat(curr_str, apid, curr_len);
+     659             :     }
+     660             : 
+     661             :     strncat(curr_str, colon, strlen(colon));
+     662             : 
+     663          34 :     if (ctid != NULL) {
+     664          34 :         curr_len = strlen(ctid);
+     665          34 :         strncat(curr_str, ctid, curr_len);
+     666             :     }
+     667             : 
+     668          34 :     curr_len = strlen(curr_str);
+     669          34 :     strncpy(key, curr_str, curr_len);
+     670          34 : }
+     671             : 
+     672             : /**
+     673             :  * dlt_logstorage_create_keys_only_ecu
+     674             :  *
+     675             :  * Prepares keys with only ecuid (ecuid::)
+     676             :  *
+     677             :  * @param ecuid          ECU ID
+     678             :  * @param key            Prepared key stored here
+     679             :  * @return               None
+     680             :  */
+     681           0 : DLT_STATIC void dlt_logstorage_create_keys_only_ecu(char *ecuid, char *key)
+     682             : {
+     683           0 :     char curr_str[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = { 0 };
+     684             : 
+     685             :     strncpy(curr_str, ecuid, DLT_ID_SIZE);
+     686             :     strncat(curr_str, "::", 2);
+     687             : 
+     688           0 :     strncpy(key, curr_str, strlen(curr_str));
+     689           0 : }
+     690             : 
+     691             : /**
+     692             :  * dlt_logstorage_create_keys
+     693             :  *
+     694             :  * Create keys for hash table
+     695             :  *
+     696             :  * From each section [filter] in offline logstorage configuration file, we
+     697             :  * receive application and context id strings.
+     698             :  * Application and context id can consist of
+     699             :  * - a 4char long name
+     700             :  * - a comma separated list of ids
+     701             :  * - a wildcard: .*
+     702             :  *
+     703             :  * If both application and context id are set to wildcard, this will be treated
+     704             :  * in the same way of the case application and context id are not present:
+     705             :  * - EcuID must be specified
+     706             :  *
+     707             :  * If lists given for application and/or context id, all possible combinations
+     708             :  * are returned as keys in a form "[apid][ctid], e.g. "APP1\:CTX1".
+     709             :  * If wildcards are used, the non-wildcard value becomes the key, e.g. "APP1\:"
+     710             :  * or "\:CTX2".
+     711             :  *
+     712             :  * @param[in] apids string given from filter configuration
+     713             :  * @param[in] ctids string given from filter configuration
+     714             :  * @param[in] ecuid string given from filter configuration
+     715             :  * @param[out] keys keys to fill into hash table
+     716             :  * @param[out] num_keys number of keys
+     717             :  * @return: 0 on success, error on failure*
+     718             :  */
+     719          38 : DLT_STATIC int dlt_logstorage_create_keys(char *apids,
+     720             :                                           char *ctids,
+     721             :                                           char *ecuid,
+     722             :                                           char **keys,
+     723             :                                           int *num_keys)
+     724             : {
+     725             :     int i, j;
+     726          38 :     int num_apids = 0;
+     727          38 :     int num_ctids = 0;
+     728          38 :     char *apid_list = NULL;
+     729          38 :     char *ctid_list = NULL;
+     730             :     char *curr_apid = NULL;
+     731             :     char *curr_ctid = NULL;
+     732          38 :     char curr_key[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = { 0 };
+     733             :     int num_currkey = 0;
+     734             : 
+     735             :     /* Handle ecuid alone case here */
+     736          38 :     if (((apids == NULL) && (ctids == NULL) && (ecuid != NULL)) ||
+     737          38 :         ((apids != NULL) && (strncmp(apids, ".*", 2) == 0) &&
+     738           0 :          (ctids != NULL) && (strncmp(ctids, ".*", 2) == 0) && (ecuid != NULL)) ) {
+     739           0 :         dlt_logstorage_create_keys_only_ecu(ecuid, curr_key);
+     740           0 :         *(num_keys) = 1;
+     741           0 :         *(keys) = (char *)calloc(*num_keys * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN,
+     742             :                                  sizeof(char));
+     743             : 
+     744           0 :         if (*(keys) == NULL)
+     745             :             return -1;
+     746             : 
+     747           0 :         strncpy(*keys, curr_key, strlen(curr_key));
+     748           0 :         return 0;
+     749             :     }
+     750             : 
+     751          38 :     if ((apids == NULL) || (ctids == NULL)) {
+     752           0 :         dlt_log(LOG_ERR, "Required inputs (apid and ctid) are NULL\n");
+     753           0 :         return -1;
+     754             :     }
+     755             : 
+     756             :     /* obtain key list and number of keys for application ids */
+     757          38 :     if (dlt_logstorage_get_keys_list(apids, ",", &apid_list, &num_apids) != 0) {
+     758           0 :         dlt_log(LOG_ERR, "Failed to obtain apid, check configuration file \n");
+     759           0 :         return -1;
+     760             :     }
+     761             : 
+     762             :     /* obtain key list and number of keys for context ids */
+     763          38 :     if (dlt_logstorage_get_keys_list(ctids, ",", &ctid_list, &num_ctids) != 0) {
+     764           0 :         dlt_log(LOG_ERR, "Failed to obtain ctid, check configuration file \n");
+     765           0 :         free(apid_list);
+     766           0 :         return -1;
+     767             :     }
+     768             : 
+     769          38 :     *(num_keys) = num_apids * num_ctids;
+     770             : 
+     771             :     /* allocate memory for needed number of keys */
+     772          38 :     *(keys) = (char *)calloc(*num_keys * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN,
+     773             :                              sizeof(char));
+     774             : 
+     775          38 :     if (*(keys) == NULL) {
+     776           0 :         free(apid_list);
+     777           0 :         free(ctid_list);
+     778           0 :         return -1;
+     779             :     }
+     780             : 
+     781             :     /* store all combinations of apid ctid in keys */
+     782          76 :     for (i = 0; i < num_apids; i++) {
+     783          38 :         curr_apid = apid_list + (i * (DLT_ID_SIZE + 1));
+     784             : 
+     785          76 :         for (j = 0; j < num_ctids; j++) {
+     786          38 :             curr_ctid = ctid_list + (j * (DLT_ID_SIZE + 1));
+     787             : 
+     788          38 :             if (strncmp(curr_apid, ".*", 2) == 0) /* only context id matters */
+     789           0 :                 dlt_logstorage_create_keys_only_ctid(ecuid, curr_ctid, curr_key);
+     790          38 :             else if (strncmp(curr_ctid, ".*", 2) == 0) /* only app id matters*/
+     791           4 :                 dlt_logstorage_create_keys_only_apid(ecuid, curr_apid, curr_key);
+     792             :             else /* key is combination of all */
+     793          34 :                 dlt_logstorage_create_keys_multi(ecuid, curr_apid, curr_ctid, curr_key);
+     794             : 
+     795          38 :             strncpy((*keys + (num_currkey * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN)),
+     796             :                     curr_key, strlen(curr_key));
+     797          38 :             num_currkey += 1;
+     798             :             memset(&curr_key[0], 0, sizeof(curr_key));
+     799             :         }
+     800             :     }
+     801             : 
+     802          38 :     free(apid_list);
+     803          38 :     free(ctid_list);
+     804             : 
+     805          38 :     return 0;
+     806             : }
+     807             : 
+     808             : /**
+     809             :  * dlt_logstorage_prepare_table
+     810             :  *
+     811             :  * Prepares hash table with keys and data
+     812             :  *
+     813             :  * @param handle         DLT Logstorage handle
+     814             :  * @param data           Holds all other configuration values
+     815             :  * @return               0 on success, -1 on error
+     816             :  */
+     817          38 : DLT_STATIC int dlt_logstorage_prepare_table(DltLogStorage *handle,
+     818             :                                             DltLogStorageFilterConfig *data)
+     819             : {
+     820             :     int ret = 0;
+     821          38 :     int num_keys = 0;
+     822             :     int found = 0;
+     823          38 :     char *keys = NULL;
+     824             :     DltNewestFileName *tmp = NULL;
+     825             :     DltNewestFileName *prev_tmp = NULL;
+     826             :     DltNewestFileName *new_tmp = NULL;
+     827             : 
+     828          38 :     if ((handle == NULL) || (data == NULL)) {
+     829           1 :         dlt_vlog(LOG_ERR, "Invalid parameters in %s\n", __func__);
+     830           1 :         return -1;
+     831             :     }
+     832             : 
+     833          37 :     ret = dlt_logstorage_create_keys(data->apids,
+     834             :                                      data->ctids,
+     835             :                                      data->ecuid,
+     836             :                                      &keys,
+     837             :                                      &num_keys);
+     838             : 
+     839          37 :     if (ret != 0) {
+     840           0 :         dlt_log(LOG_ERR, "Not able to create keys for hash table\n");
+     841           0 :         return -1;
+     842             :     }
+     843             : 
+     844             :     /* hash_add */
+     845          37 :     if (dlt_logstorage_list_add(keys,
+     846             :                                 num_keys,
+     847             :                                 data,
+     848             :                                 &(handle->config_list)) != 0)
+     849             :     {
+     850           0 :         dlt_log(LOG_ERR, "Adding to hash table failed, returning failure\n");
+     851           0 :         dlt_logstorage_free(handle, DLT_LOGSTORAGE_SYNC_ON_ERROR);
+     852           0 :         free(keys);
+     853             :         keys = NULL;
+     854           0 :         return -1;
+     855             :     }
+     856             : 
+     857          37 :     if (data->file_name) {
+     858          36 :         if (handle->newest_file_list != NULL) {
+     859             :             tmp = handle->newest_file_list;
+     860         165 :             while (tmp) {
+     861         139 :                 if (strcmp(tmp->file_name, data->file_name) == 0) {
+     862             :                     found = 1;
+     863             :                     break;
+     864             :                 }
+     865             :                 else {
+     866             :                     prev_tmp = tmp;
+     867         139 :                     tmp = tmp->next;
+     868             :                 }
+     869             :             }
+     870             :         }
+     871             : 
+     872          26 :         if (!found) {
+     873          36 :             new_tmp = calloc(1, sizeof(DltNewestFileName));
+     874          36 :             if (new_tmp == NULL) {
+     875             :                 /* In this case, the existing list does not need to be freed.*/
+     876           0 :                 dlt_vlog(LOG_ERR,
+     877             :                         "Failed to allocate memory for new file name [%s]\n",
+     878             :                         data->file_name);
+     879           0 :                 free(keys);
+     880             :                 keys = NULL;
+     881           0 :                 return -1;
+     882             :             }
+     883          36 :             new_tmp->file_name = strdup(data->file_name);
+     884          36 :             new_tmp->newest_file = NULL;
+     885          36 :             new_tmp->next = NULL;
+     886             : 
+     887          36 :             if (handle->newest_file_list == NULL)
+     888          10 :                 handle->newest_file_list = new_tmp;
+     889             :             else
+     890          26 :                 prev_tmp->next = new_tmp;
+     891             :         }
+     892             :     }
+     893             : 
+     894          37 :     free(keys);
+     895             :     keys = NULL;
+     896          37 :     return 0;
+     897             : }
+     898             : 
+     899             : /**
+     900             :  * dlt_logstorage_validate_filter_name
+     901             :  *
+     902             :  * Validates if the provided filter name is as required [FILTER<number>]
+     903             :  *
+     904             :  * @param name           Filter name
+     905             :  * @return               0 on success, -1 on error
+     906             :  *
+     907             :  */
+     908          38 : DLT_STATIC int dlt_logstorage_validate_filter_name(char *name)
+     909             : {
+     910             :     int len = 0;
+     911             :     int idx = 0;
+     912             :     int config_sec_len = strlen(DLT_OFFLINE_LOGSTORAGE_CONFIG_SECTION);
+     913             :     int storage_sec_len = strlen(DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_STORAGE_SECTION);
+     914             :     int control_sec_len = strlen(DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_CONTROL_SECTION);
+     915             : 
+     916          38 :     if (name == NULL)
+     917             :         return -1;
+     918             : 
+     919          37 :     len = strlen(name);
+     920             : 
+     921             :     /* Check if section header is of format "FILTER" followed by a number */
+     922          37 :     if (strncmp(name,
+     923             :                 DLT_OFFLINE_LOGSTORAGE_CONFIG_SECTION,
+     924             :                 config_sec_len) == 0) {
+     925          45 :         for (idx = config_sec_len; idx < len - 1; idx++)
+     926           8 :             if (!isdigit(name[idx]))
+     927             :                 return -1;
+     928             : 
+     929             :         return 0;
+     930             :     }
+     931             :     /* Check if section header is of format "FILTER" followed by a number */
+     932           0 :     else if (strncmp(name,
+     933             :                      DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_STORAGE_SECTION,
+     934             :                      storage_sec_len) == 0)
+     935             :     {
+     936           0 :         for (idx = storage_sec_len; idx < len - 1; idx++)
+     937           0 :             if (!isdigit(name[idx]))
+     938             :                 return -1;
+     939             : 
+     940             :         return 0;
+     941             :     }
+     942             :     /* Check if section header is of format "FILTER" followed by a number */
+     943           0 :     else if (strncmp(name,
+     944             :                      DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_CONTROL_SECTION,
+     945             :                      control_sec_len) == 0)
+     946             :     {
+     947           0 :         for (idx = control_sec_len; idx < len - 1; idx++)
+     948           0 :             if (!isdigit(name[idx]))
+     949             :                 return -1;
+     950             : 
+     951             :         return 0;
+     952             :     }
+     953             :     else {
+     954             :         return -1;
+     955             :     }
+     956             : }
+     957             : 
+     958          13 : DLT_STATIC void dlt_logstorage_filter_set_strategy(DltLogStorageFilterConfig *config,
+     959             :                                                    int strategy)
+     960             : {
+     961          13 :     if (config == NULL)
+     962             :         return;
+     963             : 
+     964             :     /* file based */
+     965          13 :     if ((strategy == DLT_LOGSTORAGE_SYNC_ON_MSG) ||
+     966             :         (strategy == DLT_LOGSTORAGE_SYNC_UNSET)) {
+     967          20 :         config->dlt_logstorage_prepare = &dlt_logstorage_prepare_on_msg;
+     968          20 :         config->dlt_logstorage_write = &dlt_logstorage_write_on_msg;
+     969          20 :         config->dlt_logstorage_sync = &dlt_logstorage_sync_on_msg;
+     970             :     }
+     971             :     else { /* cache based */
+     972          25 :         config->dlt_logstorage_prepare = &dlt_logstorage_prepare_msg_cache;
+     973          25 :         config->dlt_logstorage_write = &dlt_logstorage_write_msg_cache;
+     974          25 :         config->dlt_logstorage_sync = &dlt_logstorage_sync_msg_cache;
+     975             :     }
+     976             : }
+     977             : 
+     978          38 : DLT_STATIC int dlt_logstorage_check_apids(DltLogStorageFilterConfig *config,
+     979             :                                           char *value)
+     980             : {
+     981          38 :     if ((config == NULL) || (value == NULL)) {
+     982           1 :         dlt_log(LOG_ERR, "Not able to create keys for hash table\n");
+     983           1 :         return -1;
+     984             :     }
+     985             : 
+     986          37 :     return dlt_logstorage_read_list_of_names(&config->apids, value);
+     987             : }
+     988             : 
+     989          38 : DLT_STATIC int dlt_logstorage_check_ctids(DltLogStorageFilterConfig *config,
+     990             :                                           char *value)
+     991             : {
+     992          38 :     if ((config == NULL) || (value == NULL))
+     993             :         return -1;
+     994             : 
+     995          37 :     return dlt_logstorage_read_list_of_names(&config->ctids, (const char*)value);
+     996             : }
+     997             : 
+     998           2 : DLT_STATIC int dlt_logstorage_store_config_excluded_apids(DltLogStorageFilterConfig *config,
+     999             :                                           char *value)
+    1000             : {
+    1001           2 :     if ((config == NULL) || (value == NULL)) {
+    1002           1 :         dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
+    1003           1 :         return -1;
+    1004             :     }
+    1005             : 
+    1006           1 :     return dlt_logstorage_read_list_of_names(&config->excluded_apids, value);
+    1007             : }
+    1008             : 
+    1009           2 : DLT_STATIC int dlt_logstorage_store_config_excluded_ctids(DltLogStorageFilterConfig *config,
+    1010             :                                           char *value)
+    1011             : {
+    1012           2 :     if ((config == NULL) || (value == NULL)) {
+    1013           1 :         dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
+    1014           1 :         return -1;
+    1015             :     }
+    1016             : 
+    1017           1 :     return dlt_logstorage_read_list_of_names(&config->excluded_ctids, (const char*)value);
+    1018             : }
+    1019             : 
+    1020           5 : DLT_STATIC int dlt_logstorage_set_loglevel(int *log_level,
+    1021             :                                            int value)
+    1022             : {
+    1023          37 :     *log_level = value;
+    1024          37 :     if ((value <= DLT_LOG_DEFAULT) || (value >= DLT_LOG_MAX)) {
+    1025           0 :         *log_level = -1;
+    1026           0 :         dlt_log(LOG_ERR, "Invalid log level \n");
+    1027           0 :         return -1;
+    1028             :     }
+    1029             :     return 0;
+    1030             : }
+    1031             : 
+    1032          38 : DLT_STATIC int dlt_logstorage_check_loglevel(DltLogStorageFilterConfig *config,
+    1033             :                                              char *value)
+    1034             : {
+    1035             :     int ll = -1;
+    1036             : 
+    1037          38 :     if ((config == NULL) || (value == NULL)) {
+    1038           1 :         if (config != NULL)
+    1039           0 :             config->log_level = 0;
+    1040           1 :         dlt_vlog(LOG_ERR, "Invalid parameters in %s\n", __func__);
+    1041           1 :         return -1;
+    1042             :     }
+    1043             : 
+    1044          37 :     if (strcmp(value, "DLT_LOG_FATAL") == 0) {
+    1045             :         ll = 1;
+    1046             :     }
+    1047          36 :     else if (strcmp(value, "DLT_LOG_ERROR") == 0)
+    1048             :     {
+    1049             :         ll = 2;
+    1050             :     }
+    1051          32 :     else if (strcmp(value, "DLT_LOG_WARN") == 0)
+    1052             :     {
+    1053             :         ll = 3;
+    1054             :     }
+    1055          32 :     else if (strcmp(value, "DLT_LOG_INFO") == 0)
+    1056             :     {
+    1057             :         ll = 4;
+    1058             :     }
+    1059           0 :     else if (strcmp(value, "DLT_LOG_DEBUG") == 0)
+    1060             :     {
+    1061             :         ll = 5;
+    1062             :     }
+    1063           0 :     else if (strcmp(value, "DLT_LOG_VERBOSE") == 0)
+    1064             :     {
+    1065             :         ll = 6;
+    1066             :     }
+    1067             : 
+    1068           5 :     return dlt_logstorage_set_loglevel(&config->log_level, ll);
+    1069             : }
+    1070             : 
+    1071           0 : DLT_STATIC int dlt_logstorage_check_reset_loglevel(DltLogStorageFilterConfig *config,
+    1072             :                                                    char *value)
+    1073             : {
+    1074           0 :     if (config == NULL)
+    1075             :         return -1;
+    1076             : 
+    1077           0 :     if (value == NULL) {
+    1078           0 :         config->reset_log_level = 0;
+    1079           0 :         return -1;
+    1080             :     }
+    1081             : 
+    1082           0 :     if (strcmp(value, "DLT_LOG_OFF") == 0) {
+    1083           0 :         config->reset_log_level = DLT_LOG_OFF;
+    1084             :     }
+    1085           0 :     else if (strcmp(value, "DLT_LOG_FATAL") == 0)
+    1086             :     {
+    1087           0 :         config->reset_log_level = DLT_LOG_FATAL;
+    1088             :     }
+    1089           0 :     else if (strcmp(value, "DLT_LOG_ERROR") == 0)
+    1090             :     {
+    1091           0 :         config->reset_log_level = DLT_LOG_ERROR;
+    1092             :     }
+    1093           0 :     else if (strcmp(value, "DLT_LOG_WARN") == 0)
+    1094             :     {
+    1095           0 :         config->reset_log_level = DLT_LOG_WARN;
+    1096             :     }
+    1097           0 :     else if (strcmp(value, "DLT_LOG_INFO") == 0)
+    1098             :     {
+    1099           0 :         config->reset_log_level = DLT_LOG_INFO;
+    1100             :     }
+    1101           0 :     else if (strcmp(value, "DLT_LOG_DEBUG") == 0)
+    1102             :     {
+    1103           0 :         config->reset_log_level = DLT_LOG_DEBUG;
+    1104             :     }
+    1105           0 :     else if (strcmp(value, "DLT_LOG_VERBOSE") == 0)
+    1106             :     {
+    1107           0 :         config->reset_log_level = DLT_LOG_VERBOSE;
+    1108             :     }
+    1109             :     else {
+    1110           0 :         config->reset_log_level = -1;
+    1111           0 :         dlt_log(LOG_ERR, "Invalid log level \n");
+    1112           0 :         return -1;
+    1113             :     }
+    1114             : 
+    1115             :     return 0;
+    1116             : }
+    1117             : 
+    1118          39 : DLT_STATIC int dlt_logstorage_check_filename(DltLogStorageFilterConfig *config,
+    1119             :                                              char *value)
+    1120             : {
+    1121             :     int len;
+    1122             : 
+    1123          39 :     if ((value == NULL) || (strcmp(value, "") == 0)) {
+    1124           1 :         dlt_vlog(LOG_ERR, "%s: Arguments are set to NULL\n", __func__);
+    1125           1 :         return -1;
+    1126             :     }
+    1127             : 
+    1128          38 :     if (config->file_name != NULL) {
+    1129           2 :         free(config->file_name);
+    1130           2 :         config->file_name = NULL;
+    1131             :     }
+    1132             : 
+    1133          38 :     len = strlen(value);
+    1134             : 
+    1135          38 :     if (len == 0) {
+    1136           0 :         dlt_vlog(LOG_ERR, "%s: Length of string given in config file is 0\n",
+    1137             :                  __func__);
+    1138           0 :         return -1;
+    1139             :     }
+    1140             : 
+    1141             :     /* do not allow the user to change directory by adding a relative path */
+    1142          38 :     if (strstr(value, "..") == NULL) {
+    1143          37 :         config->file_name = calloc((len + 1), sizeof(char));
+    1144             : 
+    1145          37 :         if (config->file_name == NULL) {
+    1146           0 :             dlt_log(LOG_ERR,
+    1147             :                     "Cannot allocate memory for filename\n");
+    1148           0 :             return -1;
+    1149             :         }
+    1150             : 
+    1151          37 :         strncpy(config->file_name, value, len);
+    1152             :     }
+    1153             :     else {
+    1154           1 :         dlt_log(LOG_ERR,
+    1155             :                 "Invalid filename, paths not accepted due to security issues\n");
+    1156           1 :         return -1;
+    1157             :     }
+    1158             : 
+    1159          37 :     return 0;
+    1160             : }
+    1161             : 
+    1162          39 : DLT_STATIC int dlt_logstorage_check_filesize(DltLogStorageFilterConfig *config,
+    1163             :                                              char *value)
+    1164             : {
+    1165          39 :     if ((config == NULL) || (value == NULL))
+    1166             :         return -1;
+    1167             : 
+    1168          38 :     return dlt_logstorage_read_number(&config->file_size, value);
+    1169             : }
+    1170             : 
+    1171          38 : DLT_STATIC int dlt_logstorage_check_nofiles(DltLogStorageFilterConfig *config,
+    1172             :                                             char *value)
+    1173             : {
+    1174          38 :     if ((config == NULL) || (value == NULL))
+    1175             :         return -1;
+    1176             : 
+    1177          37 :     return dlt_logstorage_read_number(&config->num_files, value);
+    1178             : }
+    1179             : 
+    1180           4 : DLT_STATIC int dlt_logstorage_check_specificsize(DltLogStorageFilterConfig *config,
+    1181             :                                                  char *value)
+    1182             : {
+    1183           4 :     if ((config == NULL) || (value == NULL))
+    1184             :         return -1;
+    1185             : 
+    1186           4 :     return dlt_logstorage_read_number(&config->specific_size, value);
+    1187             : }
+    1188             : 
+    1189           0 : DLT_STATIC int dlt_logstorage_set_sync_strategy(int *sync,
+    1190             :                                                 int value)
+    1191             : {
+    1192           0 :     *sync = value;
+    1193             : 
+    1194           0 :     if (value == 0)
+    1195             :     {
+    1196           0 :         dlt_log(LOG_WARNING,
+    1197             :                 "Unknown sync strategies. Set default ON_MSG\n");
+    1198           0 :         *sync = DLT_LOGSTORAGE_SYNC_ON_MSG;
+    1199           0 :         return 1;
+    1200             :     }
+    1201             : 
+    1202             :     return 0;
+    1203             : }
+    1204             : 
+    1205             : /**
+    1206             :  * dlt_logstorage_check_sync_strategy
+    1207             :  *
+    1208             :  * Evaluate sync strategy. The sync strategy is an optional filter
+    1209             :  * configuration parameter.
+    1210             :  * If the given value cannot be associated with a sync strategy, the default
+    1211             :  * sync strategy will be assigned.
+    1212             :  *
+    1213             :  * @param config       DltLogStorageFilterConfig
+    1214             :  * @param value        string given in config file
+    1215             :  * @return             0 on success, -1 on error
+    1216             :  */
+    1217          27 : DLT_STATIC int dlt_logstorage_check_sync_strategy(DltLogStorageFilterConfig *config,
+    1218             :                                                   char *value)
+    1219             : {
+    1220          27 :     if ((config == NULL) || (value == NULL))
+    1221             :         return -1;
+    1222             : 
+    1223          26 :     if (strcasestr(value, "ON_MSG") != NULL) {
+    1224           1 :         config->sync = DLT_LOGSTORAGE_SYNC_ON_MSG;
+    1225           1 :         dlt_log(LOG_DEBUG, "ON_MSG found, ignore other if added\n");
+    1226             :     }
+    1227             :     else { /* ON_MSG not set, combination of cache based strategies possible */
+    1228             : 
+    1229          25 :         if (strcasestr(value, "ON_DAEMON_EXIT") != NULL)
+    1230           8 :             config->sync |= DLT_LOGSTORAGE_SYNC_ON_DAEMON_EXIT;
+    1231             : 
+    1232          25 :         if (strcasestr(value, "ON_DEMAND") != NULL)
+    1233           4 :             config->sync |= DLT_LOGSTORAGE_SYNC_ON_DEMAND;
+    1234             : 
+    1235          25 :         if (strcasestr(value, "ON_DEVICE_DISCONNECT") != NULL)
+    1236           0 :             config->sync |= DLT_LOGSTORAGE_SYNC_ON_DEVICE_DISCONNECT;
+    1237             : 
+    1238          25 :         if (strcasestr(value, "ON_SPECIFIC_SIZE") != NULL)
+    1239           4 :             config->sync |= DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE;
+    1240             : 
+    1241          25 :         if (strcasestr(value, "ON_FILE_SIZE") != NULL)
+    1242          12 :             config->sync |= DLT_LOGSTORAGE_SYNC_ON_FILE_SIZE;
+    1243             : 
+    1244          25 :         if (config->sync == 0) {
+    1245           1 :             dlt_log(LOG_WARNING,
+    1246             :                     "Unknown sync strategies. Set default ON_MSG\n");
+    1247           1 :             config->sync = DLT_LOGSTORAGE_SYNC_ON_MSG;
+    1248           1 :             return 1;
+    1249             :         }
+    1250             :     }
+    1251             : 
+    1252             :     return 0;
+    1253             : }
+    1254             : 
+    1255             : /**
+    1256             :  * dlt_logstorage_check_overwrite_strategy
+    1257             :  *
+    1258             :  * Evaluate overwrite strategy. The sync strategy is an optional filter
+    1259             :  * configuration parameter.
+    1260             :  * If the given value cannot be associated with a strategy, the default
+    1261             :  * strategy will be assigned.
+    1262             :  *
+    1263             :  * @param[in] config    DltLogStorageFilterConfig
+    1264             :  * @param[in] value     string given in config file
+    1265             :  * @return              0 on success, 1 on unknown value, -1 on error
+    1266             :  */
+    1267          30 : DLT_STATIC int dlt_logstorage_check_overwrite_strategy(DltLogStorageFilterConfig *config,
+    1268             :                                                   char *value)
+    1269             : {
+    1270          30 :     if ((config == NULL) || (value == NULL))
+    1271             :         return -1;
+    1272             : 
+    1273          30 :     if (strcasestr(value, "DISCARD_OLD") != NULL) {
+    1274          12 :         config->overwrite = DLT_LOGSTORAGE_OVERWRITE_DISCARD_OLD;
+    1275          18 :     } else if (strcasestr(value, "DISCARD_NEW") != NULL) {
+    1276          18 :         config->overwrite = DLT_LOGSTORAGE_OVERWRITE_DISCARD_NEW;
+    1277             :     } else {
+    1278           0 :         dlt_log(LOG_WARNING,
+    1279             :                 "Unknown overwrite strategy. Set default DISCARD_OLD\n");
+    1280           0 :         config->overwrite = DLT_LOGSTORAGE_OVERWRITE_DISCARD_OLD;
+    1281           0 :         return 1;
+    1282             :     }
+    1283             : 
+    1284             :     return 0;
+    1285             : }
+    1286             : 
+    1287             : /**
+    1288             :  * dlt_logstorage_check_disable_network
+    1289             :  *
+    1290             :  * Evaluate disable network. The disable network is an optional filter
+    1291             :  * configuration parameter.
+    1292             :  * If the given value cannot be associated with a flag, the default
+    1293             :  * flag will be assigned.
+    1294             :  *
+    1295             :  * @param[in] config    DltLogStorageFilterConfig
+    1296             :  * @param[in] value     string given in config file
+    1297             :  * @return              0 on success, 1 on unknown value, -1 on error
+    1298             :  */
+    1299           1 : DLT_STATIC int dlt_logstorage_check_disable_network(DltLogStorageFilterConfig *config,
+    1300             :                                                   char *value)
+    1301             : {
+    1302           1 :     if ((config == NULL) || (value == NULL))
+    1303             :         return -1;
+    1304             : 
+    1305           1 :     if (strcasestr(value, "ON") != NULL) {
+    1306           1 :         config->disable_network_routing = DLT_LOGSTORAGE_DISABLE_NW_ON;
+    1307           0 :     } else if (strcasestr(value, "OFF") != NULL) {
+    1308           0 :         config->disable_network_routing = DLT_LOGSTORAGE_DISABLE_NW_OFF;
+    1309             :     } else {
+    1310           0 :         dlt_log(LOG_WARNING,
+    1311             :                 "Unknown disable network flag. Set default OFF\n");
+    1312           0 :         config->disable_network_routing = DLT_LOGSTORAGE_DISABLE_NW_OFF;
+    1313           0 :         return 1;
+    1314             :     }
+    1315             : 
+    1316             :     return 0;
+    1317             : }
+    1318             : 
+    1319             : /**
+    1320             :  * dlt_logstorage_check_gzip_compression
+    1321             :  *
+    1322             :  * Evaluate gzip compression. The gzip compression is an optional filter
+    1323             :  * configuration parameter.
+    1324             :  * If the given value cannot be associated with a flag, the default
+    1325             :  * flag will be assigned.
+    1326             :  *
+    1327             :  * @param[in] config    DltLogStorageFilterConfig
+    1328             :  * @param[in] value     string given in config file
+    1329             :  * @return              0 on success, 1 on unknown value, -1 on error
+    1330             :  */
+    1331           0 : DLT_STATIC int dlt_logstorage_check_gzip_compression(DltLogStorageFilterConfig *config,
+    1332             :                                                      char *value)
+    1333             : {
+    1334             : #ifdef DLT_LOGSTORAGE_USE_GZIP
+    1335             :     if ((config == NULL) || (value == NULL))
+    1336             :         return -1;
+    1337             : 
+    1338             :     if (strcasestr(value, "ON") != NULL) {
+    1339             :         config->gzip_compression = DLT_LOGSTORAGE_GZIP_ON;
+    1340             :     } else if (strcasestr(value, "OFF") != NULL) {
+    1341             :         config->gzip_compression = DLT_LOGSTORAGE_GZIP_OFF;
+    1342             :     } else {
+    1343             :         dlt_log(LOG_WARNING,
+    1344             :                 "Unknown gzip compression flag. Set default OFF\n");
+    1345             :         config->gzip_compression = DLT_LOGSTORAGE_GZIP_OFF;
+    1346             :         return 1;
+    1347             :     }
+    1348             : #else
+    1349           0 :     dlt_log(LOG_WARNING, "dlt-daemon not compiled with logstorage gzip support\n");
+    1350           0 :     config->gzip_compression = 0;
+    1351             : #endif
+    1352           0 :     return 0;
+    1353             : }
+    1354             : 
+    1355             : /**
+    1356             :  * dlt_logstorage_check_ecuid
+    1357             :  *
+    1358             :  * Evaluate if ECU idenfifier given in config file
+    1359             :  *
+    1360             :  * @param config       DltLogStorageFilterConfig
+    1361             :  * @param value        string given in config file
+    1362             :  * @return             0 on success, -1 on error
+    1363             :  */
+    1364          34 : DLT_STATIC int dlt_logstorage_check_ecuid(DltLogStorageFilterConfig *config,
+    1365             :                                           char *value)
+    1366             : {
+    1367             :     int len;
+    1368             : 
+    1369          34 :     if ((config == NULL) || (value == NULL) || (value[0] == '\0'))
+    1370             :         return -1;
+    1371             : 
+    1372          33 :     if (config->ecuid != NULL) {
+    1373           1 :         free(config->ecuid);
+    1374           1 :         config->ecuid = NULL;
+    1375             :     }
+    1376             : 
+    1377          33 :     len = strlen(value);
+    1378          33 :     config->ecuid = calloc((len + 1), sizeof(char));
+    1379             : 
+    1380          33 :     if (config->ecuid == NULL)
+    1381             :         return -1;
+    1382             : 
+    1383          33 :     strncpy(config->ecuid, value, len);
+    1384             : 
+    1385          33 :     return 0;
+    1386             : }
+    1387             : 
+    1388             : DLT_STATIC DltLogstorageFilterConf
+    1389             :     filter_cfg_entries[DLT_LOGSTORAGE_FILTER_CONF_COUNT] = {
+    1390             :     [DLT_LOGSTORAGE_FILTER_CONF_LOGAPPNAME] = {
+    1391             :         .key = "LogAppName",
+    1392             :         .func = dlt_logstorage_check_apids,
+    1393             :         .is_opt = 1
+    1394             :     },
+    1395             :     [DLT_LOGSTORAGE_FILTER_CONF_CONTEXTNAME] = {
+    1396             :         .key = "ContextName",
+    1397             :         .func = dlt_logstorage_check_ctids,
+    1398             :         .is_opt = 1
+    1399             :     },
+    1400             :     [DLT_LOGSTORAGE_FILTER_CONF_EXCLUDED_LOGAPPNAME] = {
+    1401             :         .key = "ExcludedLogAppName",
+    1402             :         .func = dlt_logstorage_store_config_excluded_apids,
+    1403             :         .is_opt = 1
+    1404             :     },
+    1405             :     [DLT_LOGSTORAGE_FILTER_CONF_EXCLUDED_CONTEXTNAME] = {
+    1406             :         .key = "ExcludedContextName",
+    1407             :         .func = dlt_logstorage_store_config_excluded_ctids,
+    1408             :         .is_opt = 1
+    1409             :     },
+    1410             :     [DLT_LOGSTORAGE_FILTER_CONF_LOGLEVEL] = {
+    1411             :         .key = "LogLevel",
+    1412             :         .func = dlt_logstorage_check_loglevel,
+    1413             :         .is_opt = 0
+    1414             :     },
+    1415             :     [DLT_LOGSTORAGE_FILTER_CONF_RESET_LOGLEVEL] = {
+    1416             :         .key = NULL,
+    1417             :         .func = dlt_logstorage_check_reset_loglevel,
+    1418             :         .is_opt = 0
+    1419             :     },
+    1420             :     [DLT_LOGSTORAGE_FILTER_CONF_FILE] = {
+    1421             :         .key = "File",
+    1422             :         .func = dlt_logstorage_check_filename,
+    1423             :         .is_opt = 0
+    1424             :     },
+    1425             :     [DLT_LOGSTORAGE_FILTER_CONF_FILESIZE] = {
+    1426             :         .key = "FileSize",
+    1427             :         .func = dlt_logstorage_check_filesize,
+    1428             :         .is_opt = 0
+    1429             :     },
+    1430             :     [DLT_LOGSTORAGE_FILTER_CONF_NOFILES] = {
+    1431             :         .key = "NOFiles",
+    1432             :         .func = dlt_logstorage_check_nofiles,
+    1433             :         .is_opt = 0
+    1434             :     },
+    1435             :     [DLT_LOGSTORAGE_FILTER_CONF_SYNCBEHAVIOR] = {
+    1436             :         .key = "SyncBehavior",
+    1437             :         .func = dlt_logstorage_check_sync_strategy,
+    1438             :         .is_opt = 1
+    1439             :     },
+    1440             :     [DLT_LOGSTORAGE_FILTER_CONF_OVERWRITEBEHAVIOR] = {
+    1441             :         .key = "OverwriteBehavior",
+    1442             :         .func = dlt_logstorage_check_overwrite_strategy,
+    1443             :         .is_opt = 1
+    1444             :     },
+    1445             :     [DLT_LOGSTORAGE_FILTER_CONF_ECUID] = {
+    1446             :         .key = "EcuID",
+    1447             :         .func = dlt_logstorage_check_ecuid,
+    1448             :         .is_opt = 1
+    1449             :     },
+    1450             :     [DLT_LOGSTORAGE_FILTER_CONF_SPECIFIC_SIZE] = {
+    1451             :         .key = "SpecificSize",
+    1452             :         .func = dlt_logstorage_check_specificsize,
+    1453             :         .is_opt = 1
+    1454             :     },
+    1455             :     [DLT_LOGSTORAGE_FILTER_CONF_GZIP_COMPRESSION] = {
+    1456             :         .key = "GzipCompression",
+    1457             :         .func = dlt_logstorage_check_gzip_compression,
+    1458             :         .is_opt = 1
+    1459             :     },
+    1460             :     [DLT_LOGSTORAGE_FILTER_CONF_DISABLE_NETWORK] = {
+    1461             :         .key = "DisableNetwork",
+    1462             :         .func = dlt_logstorage_check_disable_network,
+    1463             :         .is_opt = 1
+    1464             :     }
+    1465             : };
+    1466             : 
+    1467             : /* */
+    1468             : DLT_STATIC DltLogstorageFilterConf
+    1469             :     filter_nonverbose_storage_entries[DLT_LOGSTORAGE_FILTER_CONF_COUNT] = {
+    1470             :     [DLT_LOGSTORAGE_FILTER_CONF_LOGAPPNAME] = {
+    1471             :         .key = NULL,
+    1472             :         .func = dlt_logstorage_check_apids,
+    1473             :         .is_opt = 0
+    1474             :     },
+    1475             :     [DLT_LOGSTORAGE_FILTER_CONF_CONTEXTNAME] = {
+    1476             :         .key = NULL,
+    1477             :         .func = dlt_logstorage_check_ctids,
+    1478             :         .is_opt = 0
+    1479             :     },
+    1480             :     [DLT_LOGSTORAGE_FILTER_CONF_EXCLUDED_LOGAPPNAME] = {
+    1481             :         .key = NULL,
+    1482             :         .func = dlt_logstorage_store_config_excluded_apids,
+    1483             :         .is_opt = 1
+    1484             :     },
+    1485             :     [DLT_LOGSTORAGE_FILTER_CONF_EXCLUDED_CONTEXTNAME] = {
+    1486             :         .key = NULL,
+    1487             :         .func = dlt_logstorage_store_config_excluded_ctids,
+    1488             :         .is_opt = 1
+    1489             :     },
+    1490             :     [DLT_LOGSTORAGE_FILTER_CONF_LOGLEVEL] = {
+    1491             :         .key = NULL,
+    1492             :         .func = dlt_logstorage_check_loglevel,
+    1493             :         .is_opt = 0
+    1494             :     },
+    1495             :     [DLT_LOGSTORAGE_FILTER_CONF_RESET_LOGLEVEL] = {
+    1496             :         .key = NULL,
+    1497             :         .func = NULL,
+    1498             :         .is_opt = 0
+    1499             :     },
+    1500             :     [DLT_LOGSTORAGE_FILTER_CONF_FILE] = {
+    1501             :         .key = "File",
+    1502             :         .func = dlt_logstorage_check_filename,
+    1503             :         .is_opt = 0
+    1504             :     },
+    1505             :     [DLT_LOGSTORAGE_FILTER_CONF_FILESIZE] = {
+    1506             :         .key = "FileSize",
+    1507             :         .func = dlt_logstorage_check_filesize,
+    1508             :         .is_opt = 0
+    1509             :     },
+    1510             :     [DLT_LOGSTORAGE_FILTER_CONF_NOFILES] = {
+    1511             :         .key = "NOFiles",
+    1512             :         .func = dlt_logstorage_check_nofiles,
+    1513             :         .is_opt = 0
+    1514             :     },
+    1515             :     [DLT_LOGSTORAGE_FILTER_CONF_SYNCBEHAVIOR] = {
+    1516             :         .key = NULL,
+    1517             :         .func = dlt_logstorage_check_sync_strategy,
+    1518             :         .is_opt = 1
+    1519             :     },
+    1520             :     [DLT_LOGSTORAGE_FILTER_CONF_OVERWRITEBEHAVIOR] = {
+    1521             :         .key = NULL,
+    1522             :         .func = dlt_logstorage_check_overwrite_strategy,
+    1523             :         .is_opt = 1
+    1524             :     },
+    1525             :     [DLT_LOGSTORAGE_FILTER_CONF_ECUID] = {
+    1526             :         .key = "EcuID",
+    1527             :         .func = dlt_logstorage_check_ecuid,
+    1528             :         .is_opt = 0
+    1529             :     },
+    1530             :     [DLT_LOGSTORAGE_FILTER_CONF_SPECIFIC_SIZE] = {
+    1531             :         .key = NULL,
+    1532             :         .func = dlt_logstorage_check_specificsize,
+    1533             :         .is_opt = 1
+    1534             :     },
+    1535             :     [DLT_LOGSTORAGE_FILTER_CONF_GZIP_COMPRESSION] = {
+    1536             :         .key = "GzipCompression",
+    1537             :         .func = dlt_logstorage_check_gzip_compression,
+    1538             :         .is_opt = 1
+    1539             :     },
+    1540             :     [DLT_LOGSTORAGE_FILTER_CONF_DISABLE_NETWORK] = {
+    1541             :         .key = NULL,
+    1542             :         .func = dlt_logstorage_check_disable_network,
+    1543             :         .is_opt = 1
+    1544             :     }
+    1545             : };
+    1546             : 
+    1547             : DLT_STATIC DltLogstorageFilterConf
+    1548             :     filter_nonverbose_control_entries[DLT_LOGSTORAGE_FILTER_CONF_COUNT] = {
+    1549             :     [DLT_LOGSTORAGE_FILTER_CONF_LOGAPPNAME] = {
+    1550             :         .key = "LogAppName",
+    1551             :         .func = dlt_logstorage_check_apids,
+    1552             :         .is_opt = 0
+    1553             :     },
+    1554             :     [DLT_LOGSTORAGE_FILTER_CONF_CONTEXTNAME] = {
+    1555             :         .key = "ContextName",
+    1556             :         .func = dlt_logstorage_check_ctids,
+    1557             :         .is_opt = 0
+    1558             :     },
+    1559             :     [DLT_LOGSTORAGE_FILTER_CONF_EXCLUDED_LOGAPPNAME] = {
+    1560             :         .key = NULL,
+    1561             :         .func = dlt_logstorage_store_config_excluded_apids,
+    1562             :         .is_opt = 1
+    1563             :     },
+    1564             :     [DLT_LOGSTORAGE_FILTER_CONF_EXCLUDED_CONTEXTNAME] = {
+    1565             :         .key = NULL,
+    1566             :         .func = dlt_logstorage_store_config_excluded_ctids,
+    1567             :         .is_opt = 1
+    1568             :     },
+    1569             :     [DLT_LOGSTORAGE_FILTER_CONF_LOGLEVEL] = {
+    1570             :         .key = "LogLevel",
+    1571             :         .func = dlt_logstorage_check_loglevel,
+    1572             :         .is_opt = 0
+    1573             :     },
+    1574             :     [DLT_LOGSTORAGE_FILTER_CONF_RESET_LOGLEVEL] = {
+    1575             :         .key = "ResetLogLevel",
+    1576             :         .func = dlt_logstorage_check_reset_loglevel,
+    1577             :         .is_opt = 1
+    1578             :     },
+    1579             :     [DLT_LOGSTORAGE_FILTER_CONF_FILE] = {
+    1580             :         .key = NULL,
+    1581             :         .func = dlt_logstorage_check_filename,
+    1582             :         .is_opt = 0
+    1583             :     },
+    1584             :     [DLT_LOGSTORAGE_FILTER_CONF_FILESIZE] = {
+    1585             :         .key = NULL,
+    1586             :         .func = dlt_logstorage_check_filesize,
+    1587             :         .is_opt = 0
+    1588             :     },
+    1589             :     [DLT_LOGSTORAGE_FILTER_CONF_NOFILES] = {
+    1590             :         .key = NULL,
+    1591             :         .func = dlt_logstorage_check_nofiles,
+    1592             :         .is_opt = 0
+    1593             :     },
+    1594             :     [DLT_LOGSTORAGE_FILTER_CONF_SYNCBEHAVIOR] = {
+    1595             :         .key = NULL,
+    1596             :         .func = dlt_logstorage_check_sync_strategy,
+    1597             :         .is_opt = 1
+    1598             :     },
+    1599             :     [DLT_LOGSTORAGE_FILTER_CONF_OVERWRITEBEHAVIOR] = {
+    1600             :         .key = NULL,
+    1601             :         .func = dlt_logstorage_check_overwrite_strategy,
+    1602             :         .is_opt = 1
+    1603             :     },
+    1604             :     [DLT_LOGSTORAGE_FILTER_CONF_ECUID] = {
+    1605             :         .key = "EcuID",
+    1606             :         .func = dlt_logstorage_check_ecuid,
+    1607             :         .is_opt = 0
+    1608             :     },
+    1609             :     [DLT_LOGSTORAGE_FILTER_CONF_SPECIFIC_SIZE] = {
+    1610             :         .key = NULL,
+    1611             :         .func = dlt_logstorage_check_specificsize,
+    1612             :         .is_opt = 1
+    1613             :     },
+    1614             :     [DLT_LOGSTORAGE_FILTER_CONF_GZIP_COMPRESSION] = {
+    1615             :         .key = "GzipCompression",
+    1616             :         .func = dlt_logstorage_check_gzip_compression,
+    1617             :         .is_opt = 1
+    1618             :     },
+    1619             :     [DLT_LOGSTORAGE_FILTER_CONF_DISABLE_NETWORK] = {
+    1620             :         .key = NULL,
+    1621             :         .func = dlt_logstorage_check_disable_network,
+    1622             :         .is_opt = 1
+    1623             :     }
+    1624             : };
+    1625             : 
+    1626             : /**
+    1627             :  * Check filter configuration parameter is valid.
+    1628             :  *
+    1629             :  * @param config DltLogStorageFilterConfig
+    1630             :  * @param ctype  DltLogstorageFilterConfType
+    1631             :  * @param value specified property value from configuration file
+    1632             :  * @return 0 on success, -1 otherwise
+    1633             :  */
+    1634          26 : DLT_STATIC int dlt_logstorage_check_param(DltLogStorageFilterConfig *config,
+    1635             :                                           DltLogstorageFilterConfType ctype,
+    1636             :                                           char *value)
+    1637             : {
+    1638          26 :     if ((config == NULL) || (value == NULL))
+    1639             :         return -1;
+    1640             : 
+    1641          25 :     if (ctype < DLT_LOGSTORAGE_FILTER_CONF_COUNT)
+    1642          25 :         return filter_cfg_entries[ctype].func(config, value);
+    1643             : 
+    1644             :     return -1;
+    1645             : }
+    1646             : 
+    1647         540 : DLT_STATIC int dlt_logstorage_get_filter_section_value(DltConfigFile *config_file,
+    1648             :                                                        char *sec_name,
+    1649             :                                                        DltLogstorageFilterConf entry,
+    1650             :                                                        char *value)
+    1651             : {
+    1652             :     int ret = 0;
+    1653             : 
+    1654         540 :     if ((config_file == NULL) || (sec_name == NULL))
+    1655             :         return DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR;
+    1656             : 
+    1657         540 :     if (entry.key != NULL) {
+    1658         504 :         ret = dlt_config_file_get_value(config_file, sec_name,
+    1659             :                                         entry.key,
+    1660             :                                         value);
+    1661             : 
+    1662         504 :         if ((ret != 0) && (entry.is_opt == 0)) {
+    1663           0 :             dlt_vlog(LOG_WARNING,
+    1664             :                      "Invalid configuration in section: %s -> %s : %s\n",
+    1665             :                      sec_name, entry.key, value);
+    1666           0 :             return DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR;
+    1667             :         }
+    1668             : 
+    1669         504 :         if ((ret != 0) && (entry.is_opt == 1)) {
+    1670         197 :             dlt_vlog(LOG_DEBUG, "Optional parameter %s not specified\n",
+    1671             :                      entry.key);
+    1672         197 :             return DLT_OFFLINE_LOGSTORAGE_FILTER_CONTINUE;
+    1673             :         }
+    1674             :     }
+    1675             :     else {
+    1676             :         return DLT_OFFLINE_LOGSTORAGE_FILTER_CONTINUE;
+    1677             :     }
+    1678             : 
+    1679             :     return 0;
+    1680             : }
+    1681             : 
+    1682         540 : DLT_STATIC int dlt_logstorage_get_filter_value(DltConfigFile *config_file,
+    1683             :                                                char *sec_name,
+    1684             :                                                int index,
+    1685             :                                                char *value)
+    1686             : {
+    1687             :     int ret = 0;
+    1688             :     int config_sec_len = strlen(DLT_OFFLINE_LOGSTORAGE_CONFIG_SECTION);
+    1689             :     int storage_sec_len = strlen(DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_STORAGE_SECTION);
+    1690             :     int control_sec_len = strlen(DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_CONTROL_SECTION);
+    1691             : 
+    1692         540 :     if ((config_file == NULL) || (sec_name == NULL))
+    1693             :         return DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR;
+    1694             : 
+    1695             :     /* Branch based on section name, no complete string compare needed */
+    1696         540 :     if (strncmp(sec_name,
+    1697             :                 DLT_OFFLINE_LOGSTORAGE_CONFIG_SECTION,
+    1698             :                 config_sec_len) == 0) {
+    1699         540 :         ret = dlt_logstorage_get_filter_section_value(config_file, sec_name,
+    1700             :                                                       filter_cfg_entries[index],
+    1701             :                                                       value);
+    1702             :     }
+    1703           0 :     else if (strncmp(sec_name,
+    1704             :                      DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_STORAGE_SECTION,
+    1705             :                      storage_sec_len) == 0) {
+    1706           0 :         ret = dlt_logstorage_get_filter_section_value(config_file, sec_name,
+    1707             :                                                       filter_nonverbose_storage_entries[index],
+    1708             :                                                       value);
+    1709             :     }
+    1710           0 :     else if ((strncmp(sec_name,
+    1711             :                       DLT_OFFLINE_LOGSTORAGE_NONVERBOSE_CONTROL_SECTION,
+    1712             :                       control_sec_len) == 0)) {
+    1713           0 :         ret = dlt_logstorage_get_filter_section_value(config_file, sec_name,
+    1714             :                                                       filter_nonverbose_control_entries[index],
+    1715             :                                                       value);
+    1716             :     }
+    1717             :     else {
+    1718           0 :         dlt_log(LOG_ERR, "Error: Section name not valid \n");
+    1719             :         ret = DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR;
+    1720             :     }
+    1721             : 
+    1722             :     return ret;
+    1723             : }
+    1724             : 
+    1725          36 : DLT_STATIC int dlt_logstorage_setup_table(DltLogStorage *handle,
+    1726             :                                           DltLogStorageFilterConfig *tmp_data)
+    1727             : {
+    1728             :     int ret = 0;
+    1729             : 
+    1730             :     /* depending on the specified strategy set function pointers for
+    1731             :      * prepare, write and sync */
+    1732          36 :     dlt_logstorage_filter_set_strategy(tmp_data, tmp_data->sync);
+    1733             : 
+    1734          36 :     ret = dlt_logstorage_prepare_table(handle, tmp_data);
+    1735             : 
+    1736          36 :     if (ret != 0) {
+    1737           0 :         dlt_vlog(LOG_ERR, "%s Error: Storing filter values failed\n", __func__);
+    1738             :         ret = DLT_OFFLINE_LOGSTORAGE_STORE_FILTER_ERROR;
+    1739             :     }
+    1740             : 
+    1741          36 :     return ret;
+    1742             : }
+    1743             : /*Return :
+    1744             :  * DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR - On filter properties or value is not valid
+    1745             :  * DLT_OFFLINE_LOGSTORAGE_STORE_FILTER_ERROR - On error while storing in hash table
+    1746             :  */
+    1747             : 
+    1748          36 : DLT_STATIC int dlt_daemon_offline_setup_filter_properties(DltLogStorage *handle,
+    1749             :                                                           DltConfigFile *config_file,
+    1750             :                                                           char *sec_name)
+    1751             : {
+    1752             :     DltLogStorageFilterConfig tmp_data;
+    1753          36 :     char value[DLT_CONFIG_FILE_ENTRY_MAX_LEN + 1] = { '\0' };
+    1754             :     int i = 0;
+    1755             :     int ret = 0;
+    1756             : 
+    1757          36 :     if ((handle == NULL) || (config_file == NULL) || (sec_name == NULL))
+    1758             :         return DLT_OFFLINE_LOGSTORAGE_STORE_FILTER_ERROR;
+    1759             : 
+    1760             :     memset(&tmp_data, 0, sizeof(DltLogStorageFilterConfig));
+    1761          36 :     tmp_data.log_level = DLT_LOG_VERBOSE;
+    1762             :     tmp_data.reset_log_level = DLT_LOG_OFF;
+    1763          36 :     tmp_data.disable_network_routing = DLT_LOGSTORAGE_DISABLE_NW_OFF;
+    1764             : 
+    1765         576 :     for (i = 0; i < DLT_LOGSTORAGE_FILTER_CONF_COUNT; i++) {
+    1766         540 :         ret = dlt_logstorage_get_filter_value(config_file, sec_name, i, value);
+    1767             : 
+    1768         540 :         if (ret == DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR)
+    1769             :             return ret;
+    1770             : 
+    1771         540 :         if (ret == DLT_OFFLINE_LOGSTORAGE_FILTER_CONTINUE)
+    1772         233 :             continue;
+    1773             : 
+    1774             :         /* check value and store temporary */
+    1775         307 :         ret = dlt_logstorage_check_param(&tmp_data, i, value);
+    1776             : 
+    1777         307 :         if (ret != 0) {
+    1778           0 :             if (tmp_data.apids != NULL) {
+    1779           0 :                 free(tmp_data.apids);
+    1780           0 :                 tmp_data.apids = NULL;
+    1781             :             }
+    1782             : 
+    1783           0 :             if (tmp_data.ctids != NULL) {
+    1784           0 :                 free(tmp_data.ctids);
+    1785           0 :                 tmp_data.ctids = NULL;
+    1786             :             }
+    1787             : 
+    1788           0 :             if (tmp_data.excluded_apids != NULL) {
+    1789           0 :                 free(tmp_data.excluded_apids);
+    1790           0 :                 tmp_data.excluded_apids = NULL;
+    1791             :             }
+    1792             : 
+    1793           0 :             if (tmp_data.excluded_ctids != NULL) {
+    1794           0 :                 free(tmp_data.excluded_ctids);
+    1795           0 :                 tmp_data.excluded_ctids = NULL;
+    1796             :             }
+    1797             : 
+    1798           0 :             if (tmp_data.file_name != NULL) {
+    1799           0 :                 free(tmp_data.file_name);
+    1800           0 :                 tmp_data.file_name = NULL;
+    1801             :             }
+    1802             : 
+    1803           0 :             if (tmp_data.working_file_name != NULL) {
+    1804           0 :                 free(tmp_data.working_file_name);
+    1805           0 :                 tmp_data.working_file_name = NULL;
+    1806             :             }
+    1807             : 
+    1808           0 :             if (tmp_data.ecuid != NULL) {
+    1809           0 :                 free(tmp_data.ecuid);
+    1810             :                 tmp_data.ecuid = NULL;
+    1811             :             }
+    1812             : 
+    1813           0 :             return DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR;
+    1814             :         }
+    1815             :     }
+    1816             : 
+    1817          36 :     if(dlt_logstorage_count_ids(tmp_data.excluded_apids) > 1 && dlt_logstorage_count_ids(tmp_data.excluded_ctids) > 1) {
+    1818           0 :         dlt_vlog(LOG_WARNING, "%s: Logstorage does not support both multiple excluded applications and contexts\n", __func__);
+    1819           0 :         return DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR;
+    1820             :     }
+    1821             : 
+    1822             :     /* filter configuration is valid */
+    1823          36 :     ret = dlt_logstorage_setup_table(handle, &tmp_data);
+    1824             : 
+    1825          36 :     if (ret != 0) {
+    1826           0 :         dlt_vlog(LOG_ERR, "%s Error: Storing filter values failed\n", __func__);
+    1827             :         ret = DLT_OFFLINE_LOGSTORAGE_STORE_FILTER_ERROR;
+    1828             :     }
+    1829             :     else { /* move to next free filter configuration, if no error occurred */
+    1830          36 :         handle->num_configs += 1;
+    1831             :     }
+    1832             : 
+    1833             :     /* free tmp_data */
+    1834          36 :     dlt_logstorage_filter_config_free(&tmp_data);
+    1835             : 
+    1836          36 :     return ret;
+    1837             : }
+    1838             : 
+    1839             : /**
+    1840             :  * dlt_logstorage_check_maintain_logstorage_loglevel
+    1841             :  *
+    1842             :  * Evaluate to maintain the logstorage loglevel setting. This is an optional
+    1843             :  * configuration parameter
+    1844             :  * If the given value cannot be associated with an overwrite, the default value
+    1845             :  * will be assigned.
+    1846             :  *
+    1847             :  * @param config       DltLogStorage
+    1848             :  * @param value        string given in config file
+    1849             :  * @return             0 on success, -1 on error
+    1850             :  */
+    1851           0 : DLT_STATIC int dlt_logstorage_check_maintain_logstorage_loglevel(DltLogStorage *handle,
+    1852             :                                                   char *value)
+    1853             : {
+    1854           0 :     if ((handle == NULL) || (value == NULL))
+    1855             :     {
+    1856             :         return -1;
+    1857             :     }
+    1858             : 
+    1859           0 :     if ((strncmp(value, "OFF", 3) == 0) || (strncmp(value, "0", 1) == 0))
+    1860             :     {
+    1861           0 :         handle->maintain_logstorage_loglevel = DLT_MAINTAIN_LOGSTORAGE_LOGLEVEL_OFF;
+    1862             :     }
+    1863           0 :     else if ((strncmp(value, "ON", 2) == 0) || (strncmp(value, "1", 1) == 0))
+    1864             :     {
+    1865           0 :         handle->maintain_logstorage_loglevel = DLT_MAINTAIN_LOGSTORAGE_LOGLEVEL_ON;
+    1866             :     }
+    1867             :     else
+    1868             :     {
+    1869           0 :         dlt_vlog(LOG_ERR,
+    1870             :                  "Wrong value for Maintain logstorage loglevel section name: %s\n", value);
+    1871           0 :         handle->maintain_logstorage_loglevel = DLT_MAINTAIN_LOGSTORAGE_LOGLEVEL_ON;
+    1872           0 :         return -1;
+    1873             :     }
+    1874             : 
+    1875             :     return 0;
+    1876             : }
+    1877             : 
+    1878             : DLT_STATIC DltLogstorageGeneralConf
+    1879             :     general_cfg_entries[DLT_LOGSTORAGE_GENERAL_CONF_COUNT] = {
+    1880             :     [DLT_LOGSTORAGE_GENERAL_CONF_MAINTAIN_LOGSTORAGE_LOGLEVEL] = {
+    1881             :         .key = "MaintainLogstorageLogLevel",
+    1882             :         .func = dlt_logstorage_check_maintain_logstorage_loglevel,
+    1883             :         .is_opt = 1
+    1884             :     }
+    1885             : };
+    1886             : 
+    1887             : /**
+    1888             :  * Check if DltLogstorage General configuration parameter is valid.
+    1889             :  *
+    1890             :  * @param handle pointer to DltLogstorage structure
+    1891             :  * @param ctype Logstorage general configuration type
+    1892             :  * @param value specified property value from configuration file
+    1893             :  * @return 0 on success, -1 otherwise
+    1894             :  */
+    1895           0 : DLT_STATIC int dlt_logstorage_check_general_param(DltLogStorage *handle,
+    1896             :                                               DltLogstorageGeneralConfType ctype,
+    1897             :                                               char *value)
+    1898             : {
+    1899           0 :     if ((handle == NULL) || (value == NULL))
+    1900             :     {
+    1901             :         return -1;
+    1902             :     }
+    1903             : 
+    1904           0 :     if (ctype < DLT_LOGSTORAGE_GENERAL_CONF_COUNT)
+    1905             :     {
+    1906           0 :         return general_cfg_entries[ctype].func(handle, value);
+    1907             :     }
+    1908             : 
+    1909             :     return -1;
+    1910             : }
+    1911             : 
+    1912           0 : DLT_STATIC int dlt_daemon_setup_general_properties(DltLogStorage *handle,
+    1913             :                                                DltConfigFile *config_file,
+    1914             :                                                char *sec_name)
+    1915             : {
+    1916             :     DltLogstorageGeneralConfType type = DLT_LOGSTORAGE_GENERAL_CONF_MAINTAIN_LOGSTORAGE_LOGLEVEL;
+    1917           0 :     char value[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = {0};
+    1918             : 
+    1919           0 :     if ((handle == NULL) || (config_file == NULL) || (sec_name == NULL))
+    1920             :     {
+    1921             :         return -1;
+    1922             :     }
+    1923             : 
+    1924           0 :     for ( ; type < DLT_LOGSTORAGE_GENERAL_CONF_COUNT ; type++)
+    1925             :     {
+    1926           0 :         if (dlt_config_file_get_value(config_file,
+    1927             :                                       sec_name,
+    1928           0 :                                       general_cfg_entries[type].key,
+    1929             :                                       value) == 0)
+    1930             :         {
+    1931           0 :             if (dlt_logstorage_check_general_param(handle, type, value) != 0)
+    1932             :             {
+    1933           0 :                 dlt_vlog(LOG_WARNING,
+    1934             :                          "General parameter %s [%s] is invalid\n",
+    1935             :                          general_cfg_entries[type].key, value);
+    1936             :             }
+    1937             :         }
+    1938             :         else
+    1939             :         {
+    1940           0 :             if (general_cfg_entries[type].is_opt == 1)
+    1941             :             {
+    1942           0 :                 dlt_vlog(LOG_DEBUG,
+    1943             :                          "Optional General parameter %s not given\n",
+    1944             :                          general_cfg_entries[type].key);
+    1945             :             }
+    1946             :             else
+    1947             :             {
+    1948           0 :                 dlt_vlog(LOG_ERR,
+    1949             :                          "General parameter %s not given\n",
+    1950             :                          general_cfg_entries[type].key);
+    1951           0 :                 return -1;
+    1952             :             }
+    1953             :         }
+    1954             :     }
+    1955             : 
+    1956             :     return 0;
+    1957             : }
+    1958             : 
+    1959             : /**
+    1960             :  * dlt_logstorage_store_filters
+    1961             :  *
+    1962             :  * This function reads the filter keys and values
+    1963             :  * and stores them into the hash map
+    1964             :  *
+    1965             :  * @param handle             DLT Logstorage handle
+    1966             :  * @param config_file_name   Configuration file name
+    1967             :  * @return                   0 on success, -1 on error, 1 on warning
+    1968             :  *
+    1969             :  */
+    1970          11 : DLT_STATIC int dlt_logstorage_store_filters(DltLogStorage *handle,
+    1971             :                                             char *config_file_name)
+    1972             : {
+    1973             :     DltConfigFile *config = NULL;
+    1974             :     int sec = 0;
+    1975          11 :     int num_sec = 0;
+    1976             :     int ret = 0;
+    1977             :     /* we have to make sure that this function returns success if atleast one
+    1978             :      * filter configuration is valid and stored */
+    1979             :     int valid = -1;
+    1980             : 
+    1981          11 :     if (config_file_name == NULL) {
+    1982           1 :         dlt_vlog(LOG_ERR, "%s unexpected parameter received\n", __func__);
+    1983           1 :         return -1;
+    1984             :     }
+    1985             : 
+    1986          10 :     config = dlt_config_file_init(config_file_name);
+    1987             : 
+    1988          10 :     if (config == NULL) {
+    1989           0 :         dlt_log(LOG_CRIT, "Failed to open filter configuration file\n");
+    1990           0 :         return -1;
+    1991             :     }
+    1992             : 
+    1993          10 :     handle->maintain_logstorage_loglevel = DLT_MAINTAIN_LOGSTORAGE_LOGLEVEL_UNDEF;
+    1994          10 :     dlt_config_file_get_num_sections(config, &num_sec);
+    1995             : 
+    1996          46 :     for (sec = 0; sec < num_sec; sec++) {
+    1997             :         char sec_name[DLT_CONFIG_FILE_ENTRY_MAX_LEN + 1];
+    1998             : 
+    1999          36 :         if (dlt_config_file_get_section_name(config, sec, sec_name) == -1) {
+    2000           0 :             dlt_log(LOG_CRIT, "Failed to read section name\n");
+    2001           0 :             dlt_config_file_release(config);
+    2002           0 :             return -1;
+    2003             :         }
+    2004             : 
+    2005          36 :         if (strstr(sec_name, GENERAL_BASE_NAME) != NULL) {
+    2006           0 :             if (dlt_daemon_setup_general_properties(handle, config, sec_name) == -1)
+    2007             :             {
+    2008           0 :                 dlt_log(LOG_CRIT, "General configuration is invalid\n");
+    2009           0 :                 continue;
+    2010             :             }
+    2011             :         }
+    2012          36 :         else if (dlt_logstorage_validate_filter_name(sec_name) == 0)
+    2013             :         {
+    2014          36 :             ret = dlt_daemon_offline_setup_filter_properties(handle, config, sec_name);
+    2015             : 
+    2016          36 :             if (ret == DLT_OFFLINE_LOGSTORAGE_STORE_FILTER_ERROR) {
+    2017             :                 break;
+    2018             :             }
+    2019          36 :             else if (ret == DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR)
+    2020             :             {
+    2021             :                 valid = 1;
+    2022           0 :                 dlt_vlog(LOG_WARNING,
+    2023             :                          "%s filter configuration is invalid \n",
+    2024             :                          sec_name);
+    2025             :                 /* Continue reading next filter section */
+    2026           0 :                 continue;
+    2027             :             }
+    2028             :             else
+    2029             :             /* Filter properties read and stored successfuly */
+    2030          36 :             if (valid != 1)
+    2031             :                 valid = 0;
+    2032             :         }
+    2033             :         else { /* unknown section */
+    2034           0 :             dlt_vlog(LOG_WARNING, "Unknown section: %s", sec_name);
+    2035             :         }
+    2036             :     }
+    2037             : 
+    2038          10 :     dlt_config_file_release(config);
+    2039             : 
+    2040          10 :     return valid;
+    2041             : }
+    2042             : 
+    2043             : /**
+    2044             :  * dlt_logstorage_load_config
+    2045             :  *
+    2046             :  * Read dlt_logstorage.conf file and setup filters in hash table
+    2047             :  * Hash table key consists of "APID:CTID", e.g "APP1:CTX1". If
+    2048             :  * wildcards used for application id or context id, the hash table
+    2049             :  * key consists of none wildcard value, e.g. apid=.*, cxid=CTX1
+    2050             :  * results in "CTX1".
+    2051             :  *
+    2052             :  * Combination of two wildcards is not allowed if ECUID is not specified.
+    2053             :  *
+    2054             :  * @param handle        DLT Logstorage handle
+    2055             :  * @return              0 on success, -1 on error, 1 on warning
+    2056             :  */
+    2057          10 : DLT_STATIC int dlt_logstorage_load_config(DltLogStorage *handle)
+    2058             : {
+    2059          10 :     char config_file_name[PATH_MAX] = {0};
+    2060             :     int ret = 0;
+    2061             : 
+    2062             :     /* Check if handle is NULL or already initialized or already configured  */
+    2063          10 :     if ((handle == NULL) ||
+    2064           9 :         (handle->connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED))
+    2065             :         return -1;
+    2066             : 
+    2067             :     /* Check if this device config was already setup */
+    2068           9 :     if (handle->config_status == DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE) {
+    2069           0 :         dlt_vlog(LOG_ERR,
+    2070             :                  "%s: Device already configured. Send disconnect first.\n",
+    2071             :                  __func__);
+    2072           0 :         return -1;
+    2073             :     }
+    2074             : 
+    2075           9 :     if (snprintf(config_file_name,
+    2076             :                  PATH_MAX,
+    2077             :                  "%s/%s",
+    2078           9 :                  handle->device_mount_point,
+    2079             :                  DLT_OFFLINE_LOGSTORAGE_CONFIG_FILE_NAME) < 0) {
+    2080           0 :         dlt_log(LOG_ERR,
+    2081             :                 "Creating configuration file path string failed\n");
+    2082           0 :         return -1;
+    2083             :     }
+    2084           9 :     config_file_name[PATH_MAX - 1] = 0;
+    2085           9 :     ret = dlt_logstorage_store_filters(handle, config_file_name);
+    2086             : 
+    2087           9 :     if (ret == 1) {
+    2088           0 :         handle->config_status = DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE;
+    2089           0 :         return 1;
+    2090             :     }
+    2091           9 :     else if (ret != 0)
+    2092             :     {
+    2093           0 :         dlt_log(LOG_ERR,
+    2094             :                 "dlt_logstorage_load_config Error : Storing filters failed\n");
+    2095           0 :         return -1;
+    2096             :     }
+    2097             : 
+    2098           9 :     handle->config_status = DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE;
+    2099             : 
+    2100           9 :     return 0;
+    2101             : }
+    2102             : 
+    2103             : /**
+    2104             :  * dlt_logstorage_device_connected
+    2105             :  *
+    2106             :  * Initializes DLT Offline Logstorage with respect to device status
+    2107             :  *
+    2108             :  * @param handle         DLT Logstorage handle
+    2109             :  * @param mount_point    Device mount path
+    2110             :  * @return               0 on success, -1 on error, 1 on warning
+    2111             :  */
+    2112           9 : int dlt_logstorage_device_connected(DltLogStorage *handle, const char *mount_point)
+    2113             : {
+    2114           9 :     if ((handle == NULL) || (mount_point == NULL)) {
+    2115           1 :         dlt_log(LOG_ERR, "Handle error \n");
+    2116           1 :         return -1;
+    2117             :     }
+    2118             : 
+    2119           8 :     if (handle->connection_type == DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) {
+    2120           0 :         dlt_log(LOG_WARNING,
+    2121             :                 "Device already connected. Send disconnect, connect request\n");
+    2122             : 
+    2123           0 :         dlt_logstorage_device_disconnected(
+    2124             :             handle,
+    2125             :             DLT_LOGSTORAGE_SYNC_ON_DEVICE_DISCONNECT);
+    2126             :     }
+    2127             : 
+    2128           8 :     strncpy(handle->device_mount_point, mount_point, DLT_MOUNT_PATH_MAX);
+    2129           8 :     handle->device_mount_point[DLT_MOUNT_PATH_MAX] = 0;
+    2130           8 :     handle->connection_type = DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED;
+    2131           8 :     handle->config_status = 0;
+    2132           8 :     handle->write_errors = 0;
+    2133           8 :     handle->num_configs = 0;
+    2134           8 :     handle->newest_file_list = NULL;
+    2135             : 
+    2136           8 :     switch (handle->config_mode) {
+    2137           8 :       case DLT_LOGSTORAGE_CONFIG_FILE:
+    2138             :         /* Setup logstorage with config file settings */
+    2139           8 :         return dlt_logstorage_load_config(handle);
+    2140             :       default:
+    2141             :         return -1;
+    2142             :     }
+    2143             : }
+    2144             : 
+    2145             : /**
+    2146             :  * dlt_logstorage_device_disconnected
+    2147             :  *
+    2148             :  * De-Initializes DLT Offline Logstorage with respect to device status
+    2149             :  *
+    2150             :  * @param handle         DLT Logstorage handle
+    2151             :  * @param reason         Reason for disconnect
+    2152             :  * @return               0 on success, -1 on error
+    2153             :  *
+    2154             :  */
+    2155           8 : int dlt_logstorage_device_disconnected(DltLogStorage *handle, int reason)
+    2156             : {
+    2157             :     DltNewestFileName *tmp = NULL;
+    2158           8 :     if (handle == NULL)
+    2159             :         return -1;
+    2160             : 
+    2161             :     /* If configuration loading was done, free it */
+    2162           7 :     if (handle->config_status == DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE)
+    2163           6 :         dlt_logstorage_free(handle, reason);
+    2164             : 
+    2165             :     /* Reset all device status */
+    2166           7 :     memset(handle->device_mount_point, 0, sizeof(char) * (DLT_MOUNT_PATH_MAX + 1));
+    2167           7 :     handle->connection_type = DLT_OFFLINE_LOGSTORAGE_DEVICE_DISCONNECTED;
+    2168           7 :     handle->config_status = 0;
+    2169           7 :     handle->write_errors = 0;
+    2170           7 :     handle->num_configs = 0;
+    2171             : 
+    2172          39 :     while (handle->newest_file_list) {
+    2173             :         tmp = handle->newest_file_list;
+    2174          32 :         handle->newest_file_list = tmp->next;
+    2175          32 :         if (tmp->file_name) {
+    2176          32 :             free(tmp->file_name);
+    2177          32 :             tmp->file_name = NULL;
+    2178             :         }
+    2179          32 :         if (tmp->newest_file) {
+    2180          23 :             free(tmp->newest_file);
+    2181             :             tmp->newest_file = NULL;
+    2182             :         }
+    2183          32 :         free(tmp);
+    2184             :         tmp = NULL;
+    2185             :     }
+    2186             : 
+    2187             :     return 0;
+    2188             : }
+    2189             : 
+    2190             : /**
+    2191             :  * dlt_logstorage_get_loglevel_by_key
+    2192             :  *
+    2193             :  * Obtain the log level for the provided key
+    2194             :  * This function can be used to obtain log level when the actual
+    2195             :  * key stored in the Hash map is availble with the caller
+    2196             :  *
+    2197             :  * @param handle    DltLogstorage handle
+    2198             :  * @param key       key to search for in Hash MAP
+    2199             :  * @return          log level on success:, -1 on error
+    2200             :  */
+    2201          37 : int dlt_logstorage_get_loglevel_by_key(DltLogStorage *handle, char *key)
+    2202             : {
+    2203          37 :     DltLogStorageFilterConfig *config[DLT_CONFIG_FILE_SECTIONS_MAX] = { 0 };
+    2204             :     int num_configs = 0;
+    2205             :     int i = 0;
+    2206             :     int log_level = 0;
+    2207             : 
+    2208             :     /* Check if handle is NULL,already initialized or already configured  */
+    2209          37 :     if ((handle == NULL) ||
+    2210          37 :         (key == NULL) ||
+    2211          36 :         (handle->connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) ||
+    2212          36 :         (handle->config_status != DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE))
+    2213             :         return -1;
+    2214             : 
+    2215          36 :     num_configs = dlt_logstorage_list_find(key, &(handle->config_list), config);
+    2216             : 
+    2217          36 :     if (num_configs == 0)
+    2218             :     {
+    2219           0 :         dlt_vlog(LOG_WARNING, "Configuration for key [%s] not found!\n", key);
+    2220           0 :         return -1;
+    2221             :     }
+    2222          36 :     else if (num_configs == 1)
+    2223             :     {
+    2224          36 :         if (config[0] != NULL)
+    2225             :         {
+    2226          36 :             log_level = config[0]->log_level;
+    2227             :         }
+    2228             :     }
+    2229             :     else
+    2230             :     {
+    2231             :         /**
+    2232             :          * Multiple configurations found, raise a warning to the user and go
+    2233             :          * for the more verbose one.
+    2234             :          */
+    2235           0 :         dlt_vlog(LOG_WARNING, "Multiple configuration for key [%s] found,"
+    2236             :                  " return the highest log level!\n", key);
+    2237             : 
+    2238           0 :         for (i = 0; i < num_configs; i++)
+    2239             :         {
+    2240           0 :             if ((config[i] != NULL) && (config[i]->log_level > log_level))
+    2241             :             {
+    2242             :                 log_level = config[i]->log_level;
+    2243             :             }
+    2244             :         }
+    2245             :     }
+    2246             : 
+    2247             :     return log_level;
+    2248             : }
+    2249             : 
+    2250             : /**
+    2251             :  * dlt_logstorage_get_config
+    2252             :  *
+    2253             :  * Obtain the configuration data of all filters for provided apid and ctid
+    2254             :  *
+    2255             :  * @param handle    DltLogStorage handle
+    2256             :  * @param config    [out] Pointer to array of filter configurations
+    2257             :  * @param apid      application id
+    2258             :  * @param ctid      context id
+    2259             :  * @param ecuid     ecu id
+    2260             :  * @return          number of configurations found
+    2261             :  */
+    2262        5884 : int dlt_logstorage_get_config(DltLogStorage *handle,
+    2263             :                               DltLogStorageFilterConfig **config,
+    2264             :                               char *apid,
+    2265             :                               char *ctid,
+    2266             :                               char *ecuid)
+    2267             : {
+    2268             :     DltLogStorageFilterConfig **cur_config_ptr = NULL;
+    2269        5884 :     char key[DLT_CONFIG_FILE_SECTIONS_MAX][DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN] =
+    2270             :     { { '\0' }, { '\0' }, { '\0' } };
+    2271             :     int i = 0;
+    2272             :     int apid_len = 0;
+    2273             :     int ctid_len = 0;
+    2274             :     int ecuid_len = 0;
+    2275             :     int num_configs = 0;
+    2276             :     int num = 0;
+    2277             : 
+    2278             :     /* Check if handle is NULL,already initialized or already configured  */
+    2279        5884 :     if ((handle == NULL) || (config == NULL) ||
+    2280        5883 :         (handle->connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) ||
+    2281        5883 :         (handle->config_status != DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE) ||
+    2282             :         (ecuid == NULL))
+    2283             :         return 0;
+    2284             : 
+    2285             :     /* Prepare possible keys with
+    2286             :      * Possible combinations are
+    2287             :      * ecu::
+    2288             :      * ecu:apid:ctid
+    2289             :      * :apid:ctid
+    2290             :      * ecu::ctid
+    2291             :      * ecu:apid:
+    2292             :      * ::ctid
+    2293             :      * :apid: */
+    2294             : 
+    2295        5883 :     ecuid_len = strlen(ecuid);
+    2296             : 
+    2297             :     if (ecuid_len > DLT_ID_SIZE)
+    2298             :         ecuid_len = DLT_ID_SIZE;
+    2299             : 
+    2300        5883 :     if ((apid == NULL) && (ctid == NULL)) {
+    2301             :         /* ecu:: */
+    2302           0 :         strncpy(key[0], ecuid, ecuid_len);
+    2303             :         strncat(key[0], ":", 1);
+    2304             :         strncat(key[0], ":", 1);
+    2305             : 
+    2306           0 :         num_configs = dlt_logstorage_list_find(key[0], &(handle->config_list),
+    2307             :                                                config);
+    2308           0 :         return num_configs;
+    2309             :     }
+    2310             : 
+    2311        5883 :     if (apid != NULL){
+    2312        5883 :         apid_len = strlen(apid);
+    2313             : 
+    2314             :         if (apid_len > DLT_ID_SIZE)
+    2315             :             apid_len = DLT_ID_SIZE;
+    2316             :     }
+    2317             : 
+    2318        5883 :     if (ctid != NULL){
+    2319        5883 :         ctid_len = strlen(ctid);
+    2320             : 
+    2321             :         if (ctid_len > DLT_ID_SIZE)
+    2322             :             ctid_len = DLT_ID_SIZE;
+    2323             :     }
+    2324             : 
+    2325             :     /* :apid: */
+    2326             :     strncpy(key[0], ":", 1);
+    2327        5883 :     if (apid != NULL)
+    2328        5883 :         strncat(key[0], apid, apid_len);
+    2329             :     strncat(key[0], ":", 1);
+    2330             : 
+    2331             :     /* ::ctid */
+    2332             :     strncpy(key[1], ":", 1);
+    2333             :     strncat(key[1], ":", 1);
+    2334        5883 :     if (ctid != NULL)
+    2335        5883 :         strncat(key[1], ctid, ctid_len);
+    2336             : 
+    2337             :     /* :apid:ctid */
+    2338             :     strncpy(key[2], ":", 1);
+    2339        5883 :     if (apid != NULL)
+    2340        5883 :         strncat(key[2], apid, apid_len);
+    2341             :     strncat(key[2], ":", 1);
+    2342        5883 :     if (ctid != NULL)
+    2343        5883 :         strncat(key[2], ctid, ctid_len);
+    2344             : 
+    2345             :     /* ecu:apid:ctid */
+    2346        5883 :     strncpy(key[3], ecuid, ecuid_len);
+    2347             :     strncat(key[3], ":", 1);
+    2348        5883 :     if (apid != NULL)
+    2349        5883 :         strncat(key[3], apid, apid_len);
+    2350             :     strncat(key[3], ":", 1);
+    2351        5883 :     if (ctid != NULL)
+    2352        5883 :         strncat(key[3], ctid, ctid_len);
+    2353             : 
+    2354             :     /* ecu:apid: */
+    2355             :     strncpy(key[4], ecuid, ecuid_len);
+    2356             :     strncat(key[4], ":", 1);
+    2357        5883 :     if (apid != NULL)
+    2358        5883 :         strncat(key[4], apid, apid_len);
+    2359             :     strncat(key[4], ":", 1);
+    2360             : 
+    2361             :     /* ecu::ctid */
+    2362             :     strncpy(key[5], ecuid, ecuid_len);
+    2363             :     strncat(key[5], ":", 1);
+    2364             :     strncat(key[5], ":", 1);
+    2365        5883 :     if (ctid != NULL)
+    2366        5883 :         strncat(key[5], ctid, ctid_len);
+    2367             : 
+    2368             :     /* ecu:: */
+    2369             :     strncpy(key[6], ecuid, ecuid_len);
+    2370             :     strncat(key[6], ":", 1);
+    2371             :     strncat(key[6], ":", 1);
+    2372             : 
+    2373             :     /* Search the list three times with keys as -apid: , :ctid and apid:ctid */
+    2374       45860 :     for (i = 0; i < DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_KEYS; i++)
+    2375             :     {
+    2376       40278 :         cur_config_ptr = &config[num_configs];
+    2377       40278 :         num = dlt_logstorage_list_find(key[i], &(handle->config_list),
+    2378             :                                        cur_config_ptr);
+    2379       40278 :         num_configs += num;
+    2380             :         /* If all filter configurations matched, stop and return */
+    2381       40278 :         if (num_configs == handle->num_configs)
+    2382             :         {
+    2383             :             break;
+    2384             :         }
+    2385             :     }
+    2386             : 
+    2387             :     return num_configs;
+    2388             : }
+    2389             : 
+    2390             : /**
+    2391             :  * dlt_logstorage_filter
+    2392             :  *
+    2393             :  * Check if log message need to be stored in a certain device based on filter
+    2394             :  * config
+    2395             :  * - get all DltLogStorageFilterConfig from hash table possible by given
+    2396             :  *   apid/ctid (apid:, :ctid, apid:ctid
+    2397             :  * - for each found structure, compare message log level with configured one
+    2398             :  *
+    2399             :  * @param handle    DltLogStorage handle
+    2400             :  * @param config    Pointer to array of filter configurations
+    2401             :  * @param apid      application id
+    2402             :  * @param ctid      context id
+    2403             :  * @param log_level Log level of message
+    2404             :  * @param ecuid     EcuID given in the message
+    2405             :  * @return          number of found configurations
+    2406             :  */
+    2407        5849 : DLT_STATIC int dlt_logstorage_filter(DltLogStorage *handle,
+    2408             :                                      DltLogStorageFilterConfig **config,
+    2409             :                                      char *apid,
+    2410             :                                      char *ctid,
+    2411             :                                      char *ecuid,
+    2412             :                                      int log_level)
+    2413             : {
+    2414             :     int i = 0;
+    2415             :     int num = 0;
+    2416             : 
+    2417        5849 :     if ((handle == NULL) || (config == NULL) || (ecuid == NULL))
+    2418             :         return -1;
+    2419             : 
+    2420             :     /* filter on names: find DltLogStorageFilterConfig structures */
+    2421        5848 :     num = dlt_logstorage_get_config(handle, config, apid, ctid, ecuid);
+    2422             : 
+    2423        5848 :     if (num == 0) {
+    2424         231 :         dlt_vlog(LOG_DEBUG,
+    2425             :                  "%s: No valid filter configuration found for apid=[%.4s] ctid=[%.4s] ecuid=[%.4s]\n",
+    2426             :                  __func__, apid, ctid, ecuid);
+    2427         231 :         return 0;
+    2428             :     }
+    2429             : 
+    2430       11252 :     for (i = 0 ; i < num ; i++)
+    2431             :     {
+    2432        5635 :         if (config[i] == NULL)
+    2433             :         {
+    2434           0 :             dlt_vlog(LOG_DEBUG,
+    2435             :                      "%s: config[%d] is NULL, continue the filter loop\n",
+    2436             :                      __func__, i);
+    2437           0 :             continue;
+    2438             :         }
+    2439             : 
+    2440             :         /* filter on log level */
+    2441        5635 :         if (log_level > config[i]->log_level) {
+    2442           6 :             dlt_vlog(LOG_DEBUG,
+    2443             :                      "%s: Requested log level (%d) is higher than config[%d]->log_level (%d). Set the config to NULL and continue the filter loop\n",
+    2444             :                      __func__, log_level, i, config[i]->log_level);
+    2445           6 :             config[i] = NULL;
+    2446           6 :             continue;
+    2447             :         }
+    2448             : 
+    2449             :         /* filter on ECU id only if EcuID is set */
+    2450        5629 :         if (config[i]->ecuid != NULL) {
+    2451        5629 :             if (strncmp(ecuid, config[i]->ecuid, DLT_ID_SIZE) != 0)
+    2452             :             {
+    2453           0 :                 dlt_vlog(LOG_DEBUG,
+    2454             :                          "%s: ECUID does not match (Requested=%s, config[%d]=%s). Set the config to NULL and continue the filter loop\n",
+    2455             :                          __func__, ecuid, i, config[i]->ecuid);
+    2456           0 :                 config[i] = NULL;
+    2457           0 :                 continue;
+    2458             :             }
+    2459             :         }
+    2460             : 
+    2461        5629 :         if(config[i]->excluded_apids != NULL && config[i]->excluded_ctids != NULL) {
+    2462             :             /* Filter on excluded application and context */
+    2463           6 :             if(apid != NULL && ctid != NULL && dlt_logstorage_check_excluded_ids(apid, ",", config[i]->excluded_apids)
+    2464           3 :               && dlt_logstorage_check_excluded_ids(ctid, ",", config[i]->excluded_ctids)) {
+    2465           3 :                 dlt_vlog(LOG_DEBUG, "%s: %s matches with [%s] and %s matches with [%s]. Set the config to NULL and continue the filter loop\n",
+    2466           3 :                 __func__, apid, config[i]->excluded_apids, ctid, config[i]->excluded_ctids);
+    2467           3 :                 config[i] = NULL;
+    2468             :             }
+    2469             :         }
+    2470        5623 :         else if(config[i]->excluded_apids == NULL) {
+    2471             :             /* Only filter on excluded contexts */
+    2472        5617 :             if(ctid != NULL && config[i]->excluded_ctids != NULL && dlt_logstorage_check_excluded_ids(ctid, ",", config[i]->excluded_ctids)) {
+    2473           3 :                 dlt_vlog(LOG_DEBUG, "%s: %s matches with [%s]. Set the config to NULL and continue the filter loop\n",
+    2474           3 :                 __func__, ctid, config[i]->excluded_ctids);
+    2475           3 :                 config[i] = NULL;
+    2476             :             }
+    2477             :         }
+    2478           6 :         else if(config[i]->excluded_ctids == NULL) {
+    2479             :             /* Only filter on excluded applications */
+    2480           6 :             if(apid != NULL && config[i]->excluded_apids != NULL && dlt_logstorage_check_excluded_ids(apid, ",", config[i]->excluded_apids)) {
+    2481           3 :                 dlt_vlog(LOG_DEBUG, "%s: %s matches with [%s]. Set the config to NULL and continue the filter loop\n",
+    2482           3 :                 __func__, apid, config[i]->excluded_apids);
+    2483           3 :                 config[i] = NULL;
+    2484             :             }
+    2485             :         }
+    2486             :     }
+    2487             : 
+    2488             :     return num;
+    2489             : }
+    2490             : 
+    2491             : /**
+    2492             :  * dlt_logstorage_write
+    2493             :  *
+    2494             :  * Write a message to one or more configured log files, based on filter
+    2495             :  * configuration.
+    2496             :  *
+    2497             :  * @param handle    DltLogStorage handle
+    2498             :  * @param uconfig   User configurations for log file
+    2499             :  * @param data1     Data buffer of message header
+    2500             :  * @param size1     Size of message header buffer
+    2501             :  * @param data2     Data buffer of extended message body
+    2502             :  * @param size2     Size of extended message body
+    2503             :  * @param data3     Data buffer of message body
+    2504             :  * @param size3     Size of message body
+    2505             :  * @param disable_nw Flag to disable network routing
+    2506             :  * @return          0 on success or write errors < max write errors, -1 on error
+    2507             :  */
+    2508        5842 : int dlt_logstorage_write(DltLogStorage *handle,
+    2509             :                          DltLogStorageUserConfig *uconfig,
+    2510             :                          unsigned char *data1,
+    2511             :                          int size1,
+    2512             :                          unsigned char *data2,
+    2513             :                          int size2,
+    2514             :                          unsigned char *data3,
+    2515             :                          int size3,
+    2516             :                          int *disable_nw)
+    2517             : {
+    2518        5842 :     DltLogStorageFilterConfig *config[DLT_CONFIG_FILE_SECTIONS_MAX] = { 0 };
+    2519             : 
+    2520             :     int i = 0;
+    2521             :     int ret = 0;
+    2522             :     int num = 0;
+    2523             :     int err = 0;
+    2524             :     /* data2 contains DltStandardHeader, DltStandardHeaderExtra and
+    2525             :      * DltExtendedHeader. We are interested in ecuid, apid, ctid and loglevel */
+    2526             :     DltExtendedHeader *extendedHeader = NULL;
+    2527             :     DltStandardHeaderExtra *extraHeader = NULL;
+    2528             :     DltStandardHeader *standardHeader = NULL;
+    2529             :     unsigned int standardHeaderExtraLen = sizeof(DltStandardHeaderExtra);
+    2530             :     unsigned int header_len = 0;
+    2531             :     DltNewestFileName *tmp = NULL;
+    2532             :     int found = 0;
+    2533             : 
+    2534             :     int log_level = -1;
+    2535             : 
+    2536        5842 :     if ((handle == NULL) || (uconfig == NULL) ||
+    2537        5841 :         (data1 == NULL) || (data2 == NULL) || (data3 == NULL) ||
+    2538        5841 :         (handle->connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) ||
+    2539        5841 :         (handle->config_status != DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE))
+    2540             :         return 0;
+    2541             : 
+    2542             :     /* Calculate real length of DltStandardHeaderExtra */
+    2543             :     standardHeader = (DltStandardHeader *)data2;
+    2544             : 
+    2545        5841 :     if (!DLT_IS_HTYP_WEID(standardHeader->htyp))
+    2546             :         standardHeaderExtraLen -= DLT_ID_SIZE;
+    2547             : 
+    2548        5841 :     if (!DLT_IS_HTYP_WSID(standardHeader->htyp))
+    2549           5 :         standardHeaderExtraLen -= DLT_SIZE_WSID;
+    2550             : 
+    2551        5841 :     if (!DLT_IS_HTYP_WTMS(standardHeader->htyp))
+    2552           2 :         standardHeaderExtraLen -= DLT_SIZE_WTMS;
+    2553             : 
+    2554             :     extraHeader = (DltStandardHeaderExtra *)(data2
+    2555             :                                              + sizeof(DltStandardHeader));
+    2556             : 
+    2557        5841 :     if (DLT_IS_HTYP_UEH(standardHeader->htyp)) {
+    2558        5841 :         header_len = sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) + standardHeaderExtraLen;
+    2559             : 
+    2560             :         /* check if size2 is big enough to contain expected DLT message header */
+    2561        5841 :         if ((unsigned int)size2 < header_len) {
+    2562           0 :             dlt_vlog(LOG_ERR, "%s: DLT message header is too small\n", __func__);
+    2563           0 :             return 0;
+    2564             :         }
+    2565             : 
+    2566        5841 :         extendedHeader = (DltExtendedHeader *)(data2
+    2567        5841 :                                                + sizeof(DltStandardHeader) + standardHeaderExtraLen);
+    2568             : 
+    2569        5841 :         log_level = DLT_GET_MSIN_MTIN(extendedHeader->msin);
+    2570             : 
+    2571             :         /* check if log message need to be stored in a certain device based on
+    2572             :          * filter configuration */
+    2573        5841 :         num = dlt_logstorage_filter(handle, config, extendedHeader->apid,
+    2574        5841 :                                     extendedHeader->ctid, extraHeader->ecu, log_level);
+    2575             : 
+    2576        5841 :         if ((num == 0) || (num == -1)) {
+    2577         231 :             dlt_vlog(LOG_DEBUG,
+    2578             :                      "%s: No valid filter configuration found for apid=[%.4s] ctid=[%.4s] ecuid=[%.4s]!\n",
+    2579             :                      __func__, extendedHeader->apid, extendedHeader->ctid, extraHeader->ecu);
+    2580         231 :             return 0;
+    2581             :         }
+    2582             :     }
+    2583             :     else {
+    2584           0 :         header_len = sizeof(DltStandardHeader) + standardHeaderExtraLen;
+    2585             : 
+    2586             :         /* check if size2 is big enough to contain expected DLT message header */
+    2587           0 :         if ((unsigned int)size2 < header_len) {
+    2588           0 :             dlt_log(LOG_ERR, "DLT message header is too small (without extended header)\n");
+    2589           0 :             return 0;
+    2590             :         }
+    2591             : 
+    2592             :         log_level = DLT_LOG_VERBOSE;
+    2593             : 
+    2594             :         /* check if log message need to be stored in a certain device based on
+    2595             :          * filter configuration */
+    2596           0 :         num = dlt_logstorage_filter(handle, config, NULL,
+    2597           0 :                                     NULL, extraHeader->ecu, log_level);
+    2598             : 
+    2599           0 :         if ((num == 0) || (num == -1)) {
+    2600           0 :             dlt_log(LOG_DEBUG, "No valid filter configuration found!\n");
+    2601           0 :             return 0;
+    2602             :         }
+    2603             :     }
+    2604             : 
+    2605             :     /* store log message in every found filter */
+    2606       11224 :     for (i = 0; i < num; i++)
+    2607             :     {
+    2608        5614 :         if (config[i] == NULL)
+    2609             :         {
+    2610           6 :             dlt_vlog(LOG_DEBUG,
+    2611             :                      "%s: config[%d] is NULL. Continue the filter loop\n",
+    2612             :                      __func__, i);
+    2613           6 :             continue;
+    2614             :         }
+    2615             : 
+    2616             :         /* If file name is not present, the filter is non verbose control filter
+    2617             :          * hence skip storing */
+    2618        5608 :         if (config[i]->file_name == NULL)
+    2619             :         {
+    2620           0 :             dlt_vlog(LOG_DEBUG,
+    2621             :                      "%s: config[%d]->file_name is NULL, which equals to non verbose control filter. Continue the filter loop\n",
+    2622             :                      __func__, i);
+    2623           0 :             continue;
+    2624             :         }
+    2625             : 
+    2626             :         /* Disable network routing */
+    2627        5608 :         if ((config[i]->disable_network_routing & DLT_LOGSTORAGE_DISABLE_NW_ON) > 0) {
+    2628         201 :             *disable_nw = 1;
+    2629         201 :             if (config[i]->ecuid == NULL)
+    2630           0 :                 dlt_vlog(LOG_DEBUG, "%s: Disable routing to network for ApId-CtId-EcuId [%s]-[%s]-[]\n", __func__,
+    2631             :                          config[i]->apids, config[i]->ctids);
+    2632             :             else
+    2633         201 :                 dlt_vlog(LOG_DEBUG, "%s: Disable routing to network for ApId-CtId-EcuId [%s]-[%s]-[%s]\n", __func__,
+    2634             :                          config[i]->apids, config[i]->ctids, config[i]->ecuid);
+    2635             :         }
+    2636             : 
+    2637        5608 :         if (config[i]->skip == 1)
+    2638             :         {
+    2639        2156 :             dlt_vlog(LOG_DEBUG,
+    2640             :                      "%s: config[%d] (filename=%s) is skipped. Continue the filter loop\n",
+    2641             :                      __func__, i, config[i]->file_name);
+    2642        2156 :             continue;
+    2643             :         }
+    2644             : 
+    2645        3452 :         tmp = handle->newest_file_list;
+    2646       23250 :         while (tmp) {
+    2647       23250 :             if (strcmp(tmp->file_name, config[i]->file_name) == 0) {
+    2648             :                 found = 1;
+    2649             :                 break;
+    2650             :             }
+    2651             :             else {
+    2652       19798 :                 tmp = tmp->next;
+    2653             :             }
+    2654             :         }
+    2655        3452 :         if (!found) {
+    2656           0 :             dlt_vlog(LOG_ERR, "Cannot find out record for filename [%s]\n",
+    2657             :                     config[i]->file_name);
+    2658           0 :             return -1;
+    2659             :         }
+    2660             : 
+    2661             :         /* prepare log file (create and/or open)*/
+    2662        3452 :         if (config[i]->ecuid == NULL)
+    2663           0 :             dlt_vlog(LOG_DEBUG, "%s: ApId-CtId-EcuId [%s]-[%s]-[]\n", __func__,
+    2664             :                      config[i]->apids, config[i]->ctids);
+    2665             :         else
+    2666        3452 :             dlt_vlog(LOG_DEBUG, "%s: ApId-CtId-EcuId [%s]-[%s]-[%s]\n", __func__,
+    2667             :                      config[i]->apids, config[i]->ctids, config[i]->ecuid);
+    2668             : 
+    2669        3452 :         if (tmp != NULL) {
+    2670        3452 :             ret = config[i]->dlt_logstorage_prepare(config[i],
+    2671             :                                                     uconfig,
+    2672        3452 :                                                     handle->device_mount_point,
+    2673        3452 :                                                     size1 + size2 + size3,
+    2674             :                                                     tmp);
+    2675             :         }
+    2676             : 
+    2677        3452 :         if (ret == 0 && config[i]->skip == 1) {
+    2678           4 :             continue;
+    2679             :         }
+    2680             : 
+    2681        3448 :         if ((ret == 0) &&
+    2682        3428 :             (config[i]->sync == DLT_LOGSTORAGE_SYNC_UNSET ||
+    2683             :              config[i]->sync == DLT_LOGSTORAGE_SYNC_ON_MSG)) {
+    2684             :             /* It is abnormal if working file is still NULL after preparation. */
+    2685         339 :             if (!config[i]->working_file_name) {
+    2686           0 :                 dlt_vlog(LOG_ERR, "Failed to prepare working file for %s\n",
+    2687             :                         config[i]->file_name);
+    2688           0 :                 return -1;
+    2689             :             }
+    2690             :             else {
+    2691             :                 /* After preparation phase, update newest file info
+    2692             :                  * it means there is new file created, newest file info must be updated.
+    2693             :                  */
+    2694         339 :                 if (tmp->newest_file) {
+    2695         332 :                     free(tmp->newest_file);
+    2696         332 :                     tmp->newest_file = NULL;
+    2697             :                 }
+    2698         339 :                 tmp->newest_file = strdup(config[i]->working_file_name);
+    2699         339 :                 tmp->wrap_id = config[i]->wrap_id;
+    2700             :             }
+    2701             :         }
+    2702             : 
+    2703        3448 :         if (ret == 0) { /* log data (write) */
+    2704        3428 :             ret = config[i]->dlt_logstorage_write(config[i],
+    2705             :                                                   uconfig,
+    2706        3428 :                                                   handle->device_mount_point,
+    2707             :                                                   data1,
+    2708             :                                                   size1,
+    2709             :                                                   data2,
+    2710             :                                                   size2,
+    2711             :                                                   data3,
+    2712             :                                                   size3);
+    2713             : 
+    2714        3428 :             if (ret == 0) {
+    2715             :                 /* In case of behavior CACHED_BASED, the newest file info
+    2716             :                  * must be updated right after writing phase.
+    2717             :                  * That is because in writing phase, it could also perform
+    2718             :                  * sync to file which actions could impact to the log file info.
+    2719             :                  * If both working file name and newest file name are unavailable,
+    2720             :                  * it means the sync to file is not performed yet, wait for next times.
+    2721             :                  */
+    2722        3428 :                 if (config[i]->sync != DLT_LOGSTORAGE_SYNC_ON_MSG &&
+    2723             :                         config[i]->sync != DLT_LOGSTORAGE_SYNC_UNSET) {
+    2724        3089 :                     if (config[i]->working_file_name) {
+    2725        1690 :                         if (tmp->newest_file) {
+    2726        1674 :                             free(tmp->newest_file);
+    2727        1674 :                             tmp->newest_file = NULL;
+    2728             :                         }
+    2729        1690 :                         tmp->newest_file = strdup(config[i]->working_file_name);
+    2730        1690 :                         tmp->wrap_id = config[i]->wrap_id;
+    2731             :                     }
+    2732             :                 }
+    2733             : 
+    2734             :                 /* flush to be sure log is stored on device */
+    2735        3428 :                 ret = config[i]->dlt_logstorage_sync(config[i],
+    2736             :                                                      uconfig,
+    2737             :                                                      handle->device_mount_point,
+    2738             :                                                      DLT_LOGSTORAGE_SYNC_ON_MSG);
+    2739             : 
+    2740        3428 :                 if (ret != 0)
+    2741           0 :                     dlt_log(LOG_ERR,
+    2742             :                             "dlt_logstorage_write: Unable to sync.\n");
+    2743             :             }
+    2744             :             else {
+    2745           0 :                 handle->write_errors += 1;
+    2746             : 
+    2747           0 :                 if (handle->write_errors >=
+    2748             :                     DLT_OFFLINE_LOGSTORAGE_MAX_ERRORS)
+    2749             :                     err = -1;
+    2750             : 
+    2751           0 :                 dlt_log(LOG_ERR,
+    2752             :                         "dlt_logstorage_write: Unable to write.\n");
+    2753             :             }
+    2754             :         }
+    2755             :         else {
+    2756          20 :             handle->prepare_errors += 1;
+    2757             : 
+    2758          20 :             if (handle->prepare_errors >=
+    2759             :                 DLT_OFFLINE_LOGSTORAGE_MAX_ERRORS) {
+    2760           4 :                 config[i]->skip = 1;
+    2761           4 :                 dlt_vlog(LOG_WARNING,
+    2762             :                          "%s: Unable to prepare. Skip filename [%s] because maxmimum trial has been reached.\n",
+    2763             :                          __func__, config[i]->file_name);
+    2764             :             } else {
+    2765          16 :                 dlt_vlog(LOG_ERR,
+    2766             :                          "%s: Unable to prepare.\n", __func__);
+    2767             :             }
+    2768             :         }
+    2769             :     }
+    2770             : 
+    2771             :     return err;
+    2772             : }
+    2773             : 
+    2774             : /**
+    2775             :  * dlt_logstorage_sync_caches
+    2776             :  *
+    2777             :  * Write Cache data to file
+    2778             :  *
+    2779             :  * @param handle     DltLogStorage handle
+    2780             :  * @return           0 on success, -1 on error
+    2781             :  */
+    2782           4 : int dlt_logstorage_sync_caches(DltLogStorage *handle)
+    2783             : {
+    2784             :     DltLogStorageFilterList **tmp = NULL;
+    2785             : 
+    2786           4 :     if (handle == NULL)
+    2787             :         return -1;
+    2788             : 
+    2789           4 :     tmp = &(handle->config_list);
+    2790             : 
+    2791          30 :     while (*(tmp) != NULL) {
+    2792          26 :         if ((*tmp)->data != NULL) {
+    2793          26 :             if ((*tmp)->data->dlt_logstorage_sync((*tmp)->data,
+    2794             :                                                   &handle->uconfig,
+    2795          26 :                                                   handle->device_mount_point,
+    2796             :                                                   DLT_LOGSTORAGE_SYNC_ON_DEMAND) != 0)
+    2797           0 :                 dlt_vlog(LOG_ERR,
+    2798             :                          "%s: Sync failed. Continue with next cache.\n",
+    2799             :                          __func__);
+    2800             :         }
+    2801             : 
+    2802          26 :         tmp = &(*tmp)->next;
+    2803             : 
+    2804             :     }
+    2805             : 
+    2806             :     return 0;
+    2807             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage_behavior.c.func-sort-c.html b/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage_behavior.c.func-sort-c.html new file mode 100644 index 000000000..1358ffc05 --- /dev/null +++ b/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage_behavior.c.func-sort-c.html @@ -0,0 +1,152 @@ + + + + + + + LCOV - dlt_final_coverage.info - offlinelogstorage/dlt_offline_logstorage_behavior.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - offlinelogstorage - dlt_offline_logstorage_behavior.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:40548783.2 %
Date:2024-12-05 09:07:13Functions:2020100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_logstorage_rearrange_file_name3
dlt_logstorage_close_file4
dlt_logstorage_write_to_log5
dlt_logstorage_find_last_dlt_header86
dlt_logstorage_log_file_name130
dlt_logstorage_sync_to_file187
dlt_logstorage_open_log_output_file196
dlt_logstorage_check_write_ret200
dlt_logstorage_concat_logfile_name263
dlt_logstorage_find_dlt_header270
dlt_logstorage_sort_file_name302
dlt_logstorage_open_log_file305
dlt_logstorage_storage_dir_info306
dlt_logstorage_write_on_msg341
dlt_logstorage_sync_on_msg362
dlt_logstorage_prepare_on_msg363
dlt_logstorage_get_idx_of_log_file407
dlt_logstorage_write_msg_cache3093
dlt_logstorage_prepare_msg_cache3098
dlt_logstorage_sync_msg_cache3299
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage_behavior.c.func.html b/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage_behavior.c.func.html new file mode 100644 index 000000000..ec55e847b --- /dev/null +++ b/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage_behavior.c.func.html @@ -0,0 +1,152 @@ + + + + + + + LCOV - dlt_final_coverage.info - offlinelogstorage/dlt_offline_logstorage_behavior.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - offlinelogstorage - dlt_offline_logstorage_behavior.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:40548783.2 %
Date:2024-12-05 09:07:13Functions:2020100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_logstorage_check_write_ret200
dlt_logstorage_close_file4
dlt_logstorage_concat_logfile_name263
dlt_logstorage_find_dlt_header270
dlt_logstorage_find_last_dlt_header86
dlt_logstorage_get_idx_of_log_file407
dlt_logstorage_log_file_name130
dlt_logstorage_open_log_file305
dlt_logstorage_open_log_output_file196
dlt_logstorage_prepare_msg_cache3098
dlt_logstorage_prepare_on_msg363
dlt_logstorage_rearrange_file_name3
dlt_logstorage_sort_file_name302
dlt_logstorage_storage_dir_info306
dlt_logstorage_sync_msg_cache3299
dlt_logstorage_sync_on_msg362
dlt_logstorage_sync_to_file187
dlt_logstorage_write_msg_cache3093
dlt_logstorage_write_on_msg341
dlt_logstorage_write_to_log5
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage_behavior.c.gcov.html b/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage_behavior.c.gcov.html new file mode 100644 index 000000000..8f979867c --- /dev/null +++ b/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage_behavior.c.gcov.html @@ -0,0 +1,1674 @@ + + + + + + + LCOV - dlt_final_coverage.info - offlinelogstorage/dlt_offline_logstorage_behavior.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - offlinelogstorage - dlt_offline_logstorage_behavior.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:40548783.2 %
Date:2024-12-05 09:07:13Functions:2020100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /**
+       2             :  * Copyright (C) 2015  Advanced Driver Information Technology.
+       3             :  * This code is developed by Advanced Driver Information Technology.
+       4             :  * Copyright of Advanced Driver Information Technology, Bosch and DENSO.
+       5             :  *
+       6             :  * DLT offline log storage functionality source file.
+       7             :  *
+       8             :  * \copyright
+       9             :  * This Source Code Form is subject to the terms of the
+      10             :  * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
+      11             :  * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+      12             :  *
+      13             :  *
+      14             :  * \author Christoph Lipka <clipka@jp.adit-jv.com> ADIT 2015
+      15             :  * \author Syed Hameed <shameed@jp.adit-jv.com> ADIT 2015
+      16             :  *
+      17             :  * \file: dlt_offline_logstorage_behavior.c
+      18             :  * For further information see http://www.covesa.org/.
+      19             :  */
+      20             : 
+      21             : #include <syslog.h>
+      22             : #include <limits.h>
+      23             : #include <dirent.h>
+      24             : #include <string.h>
+      25             : #include <sys/types.h>
+      26             : #include <sys/stat.h>
+      27             : #include <unistd.h>
+      28             : #include <stdlib.h>
+      29             : #include <errno.h>
+      30             : #include <libgen.h>
+      31             : 
+      32             : #include "dlt_log.h"
+      33             : #include "dlt_offline_logstorage.h"
+      34             : #include "dlt_offline_logstorage_behavior.h"
+      35             : #include "dlt_offline_logstorage_behavior_internal.h"
+      36             : 
+      37             : unsigned int g_logstorage_cache_size;
+      38             : 
+      39             : /**
+      40             :  * dlt_logstorage_concat
+      41             :  *
+      42             :  * Concatenates two strings but keeps the size of the result less than dst_size.
+      43             :  *
+      44             :  * @param dst       The destination string
+      45             :  * @param src       The source string to concat
+      46             :  */
+      47         263 : DLT_STATIC void dlt_logstorage_concat_logfile_name(char *log_file_name, const char *append)
+      48             : {
+      49         263 :     size_t dst_len = strnlen(log_file_name, DLT_MOUNT_PATH_MAX);
+      50         263 :     size_t src_len = strlen(append);
+      51             : 
+      52         263 :     if (dst_len < DLT_MOUNT_PATH_MAX) {
+      53         263 :         size_t rem_len = DLT_MOUNT_PATH_MAX - dst_len + 1;
+      54             :         strncat(log_file_name, append, rem_len);
+      55             :     } else {
+      56           0 :         dlt_vlog(LOG_ERR, "Log file name reached max len: %s [%d]\n", log_file_name, DLT_MOUNT_PATH_MAX);
+      57             :     }
+      58             : 
+      59         263 :     if (src_len + dst_len >= DLT_MOUNT_PATH_MAX) {
+      60           0 :         dlt_vlog(LOG_ERR, "Log file path too long. Truncated: %s", log_file_name);
+      61             :     }
+      62         263 : }
+      63             : 
+      64             : /**
+      65             :  * dlt_logstorage_log_file_name
+      66             :  *
+      67             :  * Create log file name in the form configured by the user
+      68             :  *      \<filename\>\<delimiter\>\<index\>\<delimiter\>\<timestamp\>.dlt
+      69             :  *
+      70             :  *      filename:       given in configuration file
+      71             :  *      delimiter:      Punctuation characters (configured in dlt.conf)
+      72             :  *      timestamp:      yyyy-mm-dd-hh-mm-ss (enabled/disabled in dlt.conf)
+      73             :  *      index:          Index len depends on wrap around value in dlt.conf
+      74             :  *                      ex: wrap around = 99, index will 01..99
+      75             :  *                      (enabled/disabled in dlt.conf)
+      76             :  *
+      77             :  * @param[out] log_file_name     target buffer for the complete logfile name.
+      78             :  *                               it needs to fit DLT_MOUNT_PATH_MAX chars
+      79             :  * @param[in]  file_config       User configurations for log file
+      80             :  * @param[in]  name              file name given in configuration file
+      81             :  * @param[in]  num_files         max files given in configuration file
+      82             :  * @param[in]  idx               continous index of log files
+      83             :  * @ return                 None
+      84             :  */
+      85         130 : void dlt_logstorage_log_file_name(char *log_file_name,
+      86             :                                   DltLogStorageUserConfig *file_config,
+      87             :                                   const DltLogStorageFilterConfig *filter_config,
+      88             :                                   const char *name,
+      89             :                                   const int num_files,
+      90             :                                   const int idx)
+      91             : {
+      92         130 :     if ((log_file_name == NULL) || (file_config == NULL) || (filter_config == NULL))
+      93             :         return;
+      94             : 
+      95         129 :     const char delim = file_config->logfile_delimiter;
+      96         129 :     int index_width = file_config->logfile_counteridxlen;
+      97             : 
+      98         129 :     if (file_config->logfile_maxcounter == UINT_MAX) {
+      99             :         index_width = 0;
+     100             :     }
+     101             : 
+     102             :     const char * suffix = ".dlt";
+     103             :     const int smax = DLT_MOUNT_PATH_MAX - strlen(suffix) - 1;
+     104             :     int spos = 0;
+     105         129 :     log_file_name[spos] = '\0';
+     106             :     int rt;
+     107             : 
+     108             :     /* Append file name */
+     109         129 :     spos += strlen(name);
+     110         129 :     dlt_logstorage_concat_logfile_name(log_file_name, filter_config->file_name);
+     111             : 
+     112             :     /* Append index */
+     113             :     /* Do not append if there is only one file and optional index mode is true*/
+     114         129 :     if (!(num_files == 1 && file_config->logfile_optional_counter)) {
+     115          81 :         rt = snprintf(log_file_name+spos, smax-spos, "%c%0*d", delim, index_width, idx);
+     116          81 :         if (rt >= smax-spos) {
+     117           0 :             dlt_vlog(LOG_WARNING, "%s: snprintf truncation %s\n", __func__, log_file_name);
+     118             :             spos = smax;
+     119          81 :         } else if (rt < 0) {
+     120           0 :             dlt_vlog(LOG_ERR, "%s: snprintf error rt=%d\n", __func__, rt);
+     121             :             const char *fmt_err = "fmt_err";
+     122             :             memcpy(log_file_name, fmt_err, strlen(fmt_err)+1);
+     123             :             spos = strlen(fmt_err) + 1;
+     124             :         } else {
+     125             :             spos += rt;
+     126             :         }
+     127             :     }
+     128             : 
+     129             :     /* Add time stamp if user has configured */
+     130         129 :     if (file_config->logfile_timestamp) {
+     131           5 :         char stamp[DLT_OFFLINE_LOGSTORAGE_TIMESTAMP_LEN + 1] = { 0 };
+     132           5 :         time_t t = time(NULL);
+     133             :         struct tm tm_info;
+     134             :         ssize_t n = 0;
+     135           5 :         tzset();
+     136           5 :         localtime_r(&t, &tm_info);
+     137           5 :         n = snprintf(stamp,
+     138             :                      DLT_OFFLINE_LOGSTORAGE_TIMESTAMP_LEN + 1,
+     139             :                      "%c%04d%02d%02d-%02d%02d%02d",
+     140             :                      delim,
+     141           5 :                      1900 + tm_info.tm_year,
+     142           5 :                      1 + tm_info.tm_mon,
+     143             :                      tm_info.tm_mday,
+     144             :                      tm_info.tm_hour,
+     145             :                      tm_info.tm_min,
+     146             :                      tm_info.tm_sec);
+     147           5 :         if (n < 0 || (size_t)n > (DLT_OFFLINE_LOGSTORAGE_TIMESTAMP_LEN + 1)) {
+     148           0 :             dlt_vlog(LOG_WARNING, "%s: snprintf truncation %s\n", __func__,
+     149             :                      stamp);
+     150             :         }
+     151           5 :         dlt_logstorage_concat_logfile_name(log_file_name, stamp);
+     152             :     }
+     153             : 
+     154         129 :     dlt_logstorage_concat_logfile_name(log_file_name, ".dlt");
+     155         129 :     if (filter_config->gzip_compression) {
+     156           0 :         dlt_logstorage_concat_logfile_name(log_file_name, ".gz");
+     157             :     }
+     158             : }
+     159             : 
+     160             : /**
+     161             :  * dlt_logstorage_sort_file_name
+     162             :  *
+     163             :  * Sort the filenames with index based ascending order (bubble sort)
+     164             :  *
+     165             :  * @param head              Log filename list
+     166             :  * @ return                 The last (biggest) index
+     167             :  */
+     168         302 : unsigned int dlt_logstorage_sort_file_name(DltLogStorageFileList **head)
+     169             : {
+     170             :     int done = 0;
+     171             :     unsigned int max_idx = 0;
+     172             : 
+     173         302 :     if ((head == NULL) || (*head == NULL) || ((*head)->next == NULL))
+     174             :         return 0;
+     175             : 
+     176         327 :     while (!done) {
+     177             :         /* "source" of the pointer to the current node in the list struct */
+     178             :         DltLogStorageFileList **pv = head;
+     179         169 :         DltLogStorageFileList *nd = *head; /* local iterator pointer */
+     180         169 :         DltLogStorageFileList *nx = (*head)->next; /* local next pointer */
+     181             : 
+     182             :         done = 1;
+     183             : 
+     184         353 :         while (nx) {
+     185         184 :             max_idx = nx->idx;
+     186         184 :             if (nd->idx > nx->idx) {
+     187             :                 max_idx = nd->idx;
+     188          12 :                 nd->next = nx->next;
+     189          12 :                 nx->next = nd;
+     190          12 :                 *pv = nx;
+     191             : 
+     192             :                 done = 0;
+     193             :             }
+     194             : 
+     195         184 :             pv = &nd->next;
+     196             :             nd = nx;
+     197         184 :             nx = nx->next;
+     198             :         }
+     199             :     }
+     200             : 
+     201             :     return max_idx;
+     202             : }
+     203             : 
+     204             : /**
+     205             :  * dlt_logstorage_rearrange_file_name
+     206             :  *
+     207             :  * Rearrange the filenames in the order of latest and oldest
+     208             :  *
+     209             :  * @param head              Log filename list
+     210             :  * @ return                 None
+     211             :  */
+     212           3 : void dlt_logstorage_rearrange_file_name(DltLogStorageFileList **head)
+     213             : {
+     214             :     DltLogStorageFileList *n_prev = NULL;
+     215             :     DltLogStorageFileList *tail = NULL;
+     216             :     DltLogStorageFileList *wrap_pre = NULL;
+     217             :     DltLogStorageFileList *wrap_post = NULL;
+     218             :     DltLogStorageFileList *n = NULL;
+     219             : 
+     220           3 :     if ((head == NULL) || (*head == NULL) || ((*head)->next == NULL))
+     221             :         return;
+     222             : 
+     223           2 :     if ((*head)->idx != 1)
+     224             :     {
+     225             :         /* Do not sort */
+     226             :         return;
+     227             :     }
+     228             : 
+     229           4 :     for (n = *head; n != NULL; n = n->next) {
+     230             :         /* Compare the diff between n->idx and n_prev->idx only if
+     231             :          * wrap_post and wrap_pre are not set yet. Otherwise continue the loop
+     232             :          * until the tail */
+     233           3 :         if (n && n_prev && !wrap_post && !wrap_pre) {
+     234           1 :             if ((n->idx - n_prev->idx) != 1) {
+     235             :                 wrap_post = n;
+     236             :                 wrap_pre = n_prev;
+     237             :             }
+     238             :         }
+     239             : 
+     240             :         n_prev = n;
+     241             :     }
+     242             : 
+     243             :     tail = n_prev;
+     244             : 
+     245           1 :     if (wrap_post && wrap_pre) {
+     246           1 :         wrap_pre->next = NULL;
+     247           1 :         tail->next = *head;
+     248           1 :         *head = wrap_post;
+     249             :     }
+     250             : }
+     251             : 
+     252             : /**
+     253             :  * dlt_logstorage_get_idx_of_log_file
+     254             :  *
+     255             :  * Extract index of log file name passed as input argument
+     256             :  *
+     257             :  * @param file_config   User configurations for log file
+     258             :  * @param config        Filter configurations for log file
+     259             :  * @param file          file name to extract the index from
+     260             :  * @return index on success, -1 if no index is found
+     261             :  */
+     262         407 : unsigned int dlt_logstorage_get_idx_of_log_file(DltLogStorageUserConfig *file_config,
+     263             :                                                 DltLogStorageFilterConfig *config,
+     264             :                                                 char *file)
+     265             : {
+     266         407 :     if (file_config == NULL || config == NULL || file == NULL)
+     267             :         return -1;
+     268             : 
+     269             :     int idx = 0;
+     270             :     int basename_len;
+     271             :     char *sptr, *eptr;
+     272             : 
+     273             :     /* Find the next delimiter after the first one:
+     274             :      * Eg. base-log-name_<idx>_<timestamp>.dlt
+     275             :      *                   ^    ^
+     276             :      *                   |    |
+     277             :      *       From here --+    +--- To this position
+     278             :      */
+     279         406 :     basename_len = strlen(config->file_name);
+     280         406 :     sptr = file + basename_len + 1;
+     281         406 :     eptr = strchr(sptr, file_config->logfile_delimiter);
+     282         406 :     idx = strtol(sptr, &eptr, 10);
+     283             : 
+     284         406 :     if (idx == 0)
+     285           0 :         dlt_log(LOG_ERR,
+     286             :                 "Unable to calculate index from log file name. Reset to 001.\n");
+     287             : 
+     288         406 :     return idx;
+     289             : }
+     290             : 
+     291             : /**
+     292             :  * dlt_logstorage_storage_dir_info
+     293             :  *
+     294             :  * Read file names of storage directory.
+     295             :  * Update the file list, arrange it in order of latest and oldest
+     296             :  *
+     297             :  * @param file_config   User configurations for log file
+     298             :  * @param path          Path to storage directory
+     299             :  * @param  config       DltLogStorageFilterConfig
+     300             :  * @return              0 on success, -1 on error
+     301             :  */
+     302         306 : int dlt_logstorage_storage_dir_info(DltLogStorageUserConfig *file_config,
+     303             :                                     char *path,
+     304             :                                     DltLogStorageFilterConfig *config)
+     305             : {
+     306             :     int check = 0;
+     307             :     int i = 0;
+     308             :     int cnt = 0;
+     309             :     int ret = 0;
+     310             :     unsigned int max_idx = 0;
+     311         306 :     struct dirent **files = { 0 };
+     312             :     unsigned int current_idx = 0;
+     313             :     DltLogStorageFileList *n = NULL;
+     314             :     DltLogStorageFileList *n1 = NULL;
+     315         306 :     char storage_path[DLT_OFFLINE_LOGSTORAGE_MAX_PATH_LEN + 1] = { '\0' };
+     316         306 :     char file_name[DLT_OFFLINE_LOGSTORAGE_MAX_FILE_NAME_LEN + 1] = { '\0' };
+     317             :     char* dir = NULL;
+     318             : 
+     319         306 :     if ((config == NULL) ||
+     320         306 :         (file_config == NULL) ||
+     321         305 :         (path == NULL) ||
+     322         305 :         (config->file_name == NULL))
+     323             :         return -1;
+     324             : 
+     325             :     strncpy(storage_path, path, DLT_OFFLINE_LOGSTORAGE_MAX_PATH_LEN);
+     326             : 
+     327         305 :     if (strstr(config->file_name, "/") != NULL) {
+     328             :         /* Append directory path */
+     329          14 :         char tmpdir[DLT_OFFLINE_LOGSTORAGE_MAX_FILE_NAME_LEN + 1] = { '\0' };
+     330          14 :         char tmpfile[DLT_OFFLINE_LOGSTORAGE_MAX_FILE_NAME_LEN + 1] = { '\0' };
+     331             :         char *file;
+     332             :         strncpy(tmpdir, config->file_name, DLT_OFFLINE_LOGSTORAGE_MAX_FILE_NAME_LEN);
+     333             :         strncpy(tmpfile, config->file_name, DLT_OFFLINE_LOGSTORAGE_MAX_FILE_NAME_LEN);
+     334          14 :         dir = dirname(tmpdir);
+     335          14 :         file = basename(tmpfile);
+     336          14 :         if ((strlen(path) + strlen(dir)) > DLT_OFFLINE_LOGSTORAGE_MAX_PATH_LEN) {
+     337           0 :             dlt_vlog(LOG_ERR, "%s: Directory name [%s] is too long to store (file name [%s])\n",
+     338             :                      __func__, dir, file);
+     339           0 :             return -1;
+     340             :         }
+     341          14 :         strncat(storage_path, dir, DLT_OFFLINE_LOGSTORAGE_MAX_PATH_LEN - strlen(storage_path));
+     342             :         strncpy(file_name, file, DLT_OFFLINE_LOGSTORAGE_MAX_FILE_NAME_LEN);
+     343             :     } else {
+     344             :         strncpy(file_name, config->file_name, DLT_OFFLINE_LOGSTORAGE_MAX_FILE_NAME_LEN);
+     345             :     }
+     346             : 
+     347         305 :     cnt = scandir(storage_path, &files, 0, alphasort);
+     348             : 
+     349         305 :     if (cnt < 0) {
+     350           5 :         dlt_vlog(LOG_ERR, "%s: Failed to scan directory [%s] for file name [%s]\n",
+     351             :                  __func__, storage_path, file_name);
+     352           5 :         return -1;
+     353             :     }
+     354             : 
+     355         300 :     dlt_vlog(LOG_DEBUG, "%s: Scanned [%d] files from %s\n", __func__, cnt, storage_path);
+     356             : 
+     357             :     /* In order to have a latest status of file list,
+     358             :      * the existing records must be deleted before updating
+     359             :      */
+     360         300 :     n = config->records;
+     361         300 :     if (config->records) {
+     362         714 :         while (n) {
+     363             :             n1 = n;
+     364         449 :             n = n->next;
+     365         449 :             free(n1->name);
+     366             :             n1->name = NULL;
+     367         449 :             free(n1);
+     368             :             n1 = NULL;
+     369             :         }
+     370         265 :         config->records = NULL;
+     371             :     }
+     372             : 
+     373         300 :     char *suffix = config->gzip_compression ? ".dlt.gz" : ".dlt";
+     374             : 
+     375        7205 :     for (i = 0; i < cnt; i++) {
+     376             :         int len = 0;
+     377        6905 :         len = strlen(file_name);
+     378             : 
+     379        6905 :         dlt_vlog(LOG_DEBUG,
+     380             :                  "%s: Scanned file name=[%s], filter file name=[%s]\n",
+     381        6905 :                   __func__, files[i]->d_name, file_name);
+     382        6905 :         if (strncmp(files[i]->d_name, file_name, len) == 0) {
+     383         822 :             if (config->num_files == 1 && file_config->logfile_optional_counter) {
+     384             :                 /* <filename>.dlt or <filename>_<tmsp>.dlt */
+     385         159 :                 if ((files[i]->d_name[len] == suffix[0]) ||
+     386          73 :                     (file_config->logfile_timestamp &&
+     387           0 :                      (files[i]->d_name[len] == file_config->logfile_delimiter))) {
+     388             :                     current_idx = 1;
+     389             :                 } else {
+     390         397 :                     continue;
+     391             :                 }
+     392             :             } else {
+     393             :                 /* <filename>_idx.dlt or <filename>_idx_<tmsp>.dlt */
+     394         663 :                 if (files[i]->d_name[len] == file_config->logfile_delimiter) {
+     395         339 :                     current_idx = dlt_logstorage_get_idx_of_log_file(file_config, config,
+     396             :                                                                      files[i]->d_name);
+     397             :                 } else {
+     398         324 :                     continue;
+     399             :                 }
+     400             :             }
+     401             : 
+     402             :             DltLogStorageFileList **tmp = NULL;
+     403             : 
+     404         425 :             if (config->records == NULL) {
+     405         268 :                 config->records = malloc(sizeof(DltLogStorageFileList));
+     406             : 
+     407         268 :                 if (config->records == NULL) {
+     408             :                     ret = -1;
+     409           0 :                     dlt_log(LOG_ERR, "Memory allocation failed\n");
+     410           0 :                     break;
+     411             :                 }
+     412             : 
+     413         268 :                 tmp = &config->records;
+     414             :             }
+     415             :             else {
+     416         157 :                 tmp = &config->records;
+     417             : 
+     418         314 :                 while (*(tmp) != NULL)
+     419         157 :                     tmp = &(*tmp)->next;
+     420             : 
+     421         157 :                 *tmp = malloc(sizeof(DltLogStorageFileList));
+     422             : 
+     423         157 :                 if (*tmp == NULL) {
+     424             :                     ret = -1;
+     425           0 :                     dlt_log(LOG_ERR, "Memory allocation failed\n");
+     426           0 :                     break;
+     427             :                 }
+     428             :             }
+     429             : 
+     430         425 :             char tmpfile[DLT_OFFLINE_LOGSTORAGE_MAX_LOG_FILE_LEN + 1] = { '\0' };
+     431         425 :             if (dir != NULL) {
+     432             :                 /* Append directory path */
+     433             :                 strcat(tmpfile, dir);
+     434             :                 strcat(tmpfile, "/");
+     435             :             }
+     436         425 :             strcat(tmpfile, files[i]->d_name);
+     437         425 :             (*tmp)->name = strdup(tmpfile);
+     438         425 :             (*tmp)->idx = current_idx;
+     439         425 :             (*tmp)->next = NULL;
+     440         425 :             check++;
+     441             :         }
+     442             :     }
+     443             : 
+     444         300 :     dlt_vlog(LOG_DEBUG, "%s: After dir scan: [%d] files of [%s]\n", __func__,
+     445             :              check, file_name);
+     446             : 
+     447         300 :     if (ret == 0) {
+     448         300 :         max_idx = dlt_logstorage_sort_file_name(&config->records);
+     449             : 
+     450             :         /* Fault tolerance:
+     451             :          * In case there are some log files are removed but
+     452             :          * the index is still not reaching maxcounter, no need
+     453             :          * to perform rearrangement of filename.
+     454             :          * This would help the log keeps growing until maxcounter is reached and
+     455             :          * the maximum number of log files could be obtained.
+     456             :          */
+     457         300 :         if (max_idx == file_config->logfile_maxcounter)
+     458           0 :             dlt_logstorage_rearrange_file_name(&config->records);
+     459             :     }
+     460             : 
+     461             :     /* free scandir result */
+     462        7205 :     for (i = 0; i < cnt; i++)
+     463        6905 :         free(files[i]);
+     464             : 
+     465         300 :     free(files);
+     466             : 
+     467         300 :     return ret;
+     468             : }
+     469             : 
+     470             : /**
+     471             :  * dlt_logstorage_open_log_output_file
+     472             :  *
+     473             :  * Open a handle to the logfile
+     474             :  *
+     475             :  * @param config    A pointer to the current DltLogStorageFilterConfig
+     476             :  * @param fpath     The file path
+     477             :  * @param mode      The mode to open the file with
+     478             :  */
+     479         196 : DLT_STATIC void dlt_logstorage_open_log_output_file(DltLogStorageFilterConfig *config,
+     480             :                                                     const char *fpath,
+     481             :                                                     const char *mode)
+     482             : {
+     483         196 :     FILE *file = fopen(fpath, mode);
+     484         196 :     if (file == NULL) {
+     485           0 :         dlt_vlog(LOG_DEBUG, "%s: could not open configuration file\n", __func__);
+     486           0 :         return;
+     487             :     }
+     488         196 :     config->fd = fileno(file);
+     489         196 :     if (config->gzip_compression) {
+     490             : #ifdef DLT_LOGSTORAGE_USE_GZIP
+     491             :         dlt_vlog(LOG_DEBUG, "%s: Opening GZIP log file\n", __func__);
+     492             :         config->gzlog = gzdopen(config->fd, mode);
+     493             : #endif
+     494             :     } else {
+     495         196 :         dlt_vlog(LOG_DEBUG, "%s: Opening log file\n", __func__);
+     496         196 :         config->log = file;
+     497             :     }
+     498             : }
+     499             : 
+     500             : /**
+     501             :  * dlt_logstorage_open_log_file
+     502             :  *
+     503             :  * Open a log file. Check storage directory for already created files and open
+     504             :  * the oldest if there is enough space to store at least msg_size.
+     505             :  * Otherwise create a new file, but take configured max number of files into
+     506             :  * account and remove the oldest file if needed.
+     507             :  *
+     508             :  * @param  config    DltLogStorageFilterConfig
+     509             :  * @param  file_config   User configurations for log file
+     510             :  * @param  dev_path      Storage device path
+     511             :  * @param  msg_size  Size of incoming message
+     512             :  * @param  is_update_required   The file list needs to be updated
+     513             :  * @return 0 on succes, -1 on error
+     514             :  */
+     515         305 : int dlt_logstorage_open_log_file(DltLogStorageFilterConfig *config,
+     516             :                                  DltLogStorageUserConfig *file_config,
+     517             :                                  char *dev_path,
+     518             :                                  int msg_size,
+     519             :                                  bool is_update_required,
+     520             :                                  bool is_sync)
+     521             : {
+     522             :     int ret = 0;
+     523         305 :     char absolute_file_path[DLT_OFFLINE_LOGSTORAGE_MAX_PATH_LEN + 1] = { '\0' };
+     524         305 :     char storage_path[DLT_MOUNT_PATH_MAX + 1] = { '\0' };
+     525         305 :     char file_name[DLT_OFFLINE_LOGSTORAGE_MAX_LOG_FILE_LEN + 1] = { '\0' };
+     526             :     unsigned int num_log_files = 0;
+     527             :     struct stat s;
+     528             :     memset(&s, 0, sizeof(struct stat));
+     529             :     DltLogStorageFileList **tmp = NULL;
+     530             :     DltLogStorageFileList **newest = NULL;
+     531             : 
+     532         305 :     if (config == NULL)
+     533             :         return -1;
+     534             : 
+     535         304 :     if (strlen(dev_path) > DLT_MOUNT_PATH_MAX) {
+     536           0 :         dlt_vlog(LOG_ERR, "device path '%s' is too long to store\n", dev_path);
+     537           0 :         return -1;
+     538             :     }
+     539             : 
+     540             :     snprintf(storage_path, DLT_MOUNT_PATH_MAX, "%s/", dev_path);
+     541             : 
+     542             :     /* check if there are already files stored */
+     543         304 :     if (config->records == NULL || is_update_required) {
+     544         304 :         if (dlt_logstorage_storage_dir_info(file_config, storage_path, config) != 0)
+     545             :             return -1;
+     546             :     }
+     547             : 
+     548             :     /* obtain locations of newest, current file names, file count */
+     549         299 :     tmp = &config->records;
+     550             : 
+     551         724 :     while (*(tmp) != NULL) {
+     552         425 :         num_log_files += 1;
+     553             : 
+     554         425 :         if ((*tmp)->next == NULL)
+     555             :             newest = tmp;
+     556             : 
+     557         425 :         tmp = &(*tmp)->next;
+     558             :     }
+     559             : 
+     560             :     /* need new file*/
+     561         299 :     if (num_log_files == 0) {
+     562          31 :         dlt_logstorage_log_file_name(file_name,
+     563             :                                      file_config,
+     564             :                                      config,
+     565          31 :                                      config->file_name,
+     566          31 :                                      config->num_files,
+     567             :                                      1);
+     568             : 
+     569             :         /* concatenate path and file and open absolute path */
+     570             :         strcat(absolute_file_path, storage_path);
+     571             :         strcat(absolute_file_path, file_name);
+     572          31 :         config->working_file_name = strdup(file_name);
+     573          31 :         dlt_logstorage_open_log_output_file(config, absolute_file_path, "a");
+     574             : 
+     575             :         /* Add file to file list */
+     576          31 :         *tmp = malloc(sizeof(DltLogStorageFileList));
+     577             : 
+     578          31 :         if (*tmp == NULL) {
+     579           0 :             dlt_log(LOG_ERR, "Memory allocation for file name failed\n");
+     580           0 :             return -1;
+     581             :         }
+     582             : 
+     583          31 :         (*tmp)->name = strdup(file_name);
+     584          31 :         (*tmp)->idx = 1;
+     585          31 :         (*tmp)->next = NULL;
+     586             :     }
+     587             :     else {
+     588             :         strcat(absolute_file_path, storage_path);
+     589             : 
+     590             :         /* newest file available
+     591             :          * Since the working file is already updated from newest file info
+     592             :          * So if there is already wrap-up, the newest file will be the working file
+     593             :          */
+     594         268 :         if ((config->wrap_id == 0) || (config->working_file_name == NULL)) {
+     595         266 :             if (config->working_file_name != NULL) {
+     596         265 :                 free(config->working_file_name);
+     597         265 :                 config->working_file_name = NULL;
+     598             :             }
+     599         266 :             config->working_file_name = strdup((*newest)->name);
+     600             :         }
+     601         268 :         strncat(absolute_file_path, config->working_file_name, strlen(config->working_file_name));
+     602             : 
+     603         268 :         dlt_vlog(LOG_DEBUG,
+     604             :                  "%s: Number of log files-newest file-wrap_id [%u]-[%s]-[%u]\n",
+     605             :                  __func__, num_log_files, config->working_file_name,
+     606             :                  config->wrap_id);
+     607             : 
+     608         268 :         ret = stat(absolute_file_path, &s);
+     609             : 
+     610             :         /* if file stats is read and, either
+     611             :          * is_sync is true and (other than ON_MSG sync behavior and current size is less than configured size) or
+     612             :          * msg_size fit into the size (ON_MSG or par of cache needs to be written into new file), open it */
+     613         268 :         if ((ret == 0) &&
+     614         268 :             ((is_sync && (s.st_size < (int)config->file_size)) ||
+     615         103 :              (!is_sync && (s.st_size + msg_size <= (int)config->file_size)))) {
+     616         165 :             dlt_logstorage_open_log_output_file(config, absolute_file_path, "a");
+     617         165 :             config->current_write_file_offset = s.st_size;
+     618             :         }
+     619             :         else {
+     620             :             /* no space in file or file stats cannot be read */
+     621             :             unsigned int idx = 0;
+     622             : 
+     623             :             /* get index of newest log file */
+     624         103 :             if (config->num_files == 1 && file_config->logfile_optional_counter) {
+     625             :                 idx = 1;
+     626             :             } else {
+     627          65 :                 idx = dlt_logstorage_get_idx_of_log_file(file_config, config,
+     628             :                                                          config->working_file_name);
+     629             :             }
+     630             : 
+     631             :             /* Check if file logging shall be stopped */
+     632         103 :             if (config->overwrite == DLT_LOGSTORAGE_OVERWRITE_DISCARD_NEW) {
+     633          14 :                 dlt_vlog(LOG_DEBUG,
+     634             :                          "%s: num_files=%d, current_idx=%d (filename=%s)\n",
+     635             :                          __func__, config->num_files, idx,
+     636             :                          config->file_name);
+     637             : 
+     638          14 :                 if (config->num_files == idx) {
+     639          10 :                     dlt_vlog(LOG_INFO,
+     640             :                              "%s: logstorage limit reached, stopping capture for filter: %s\n",
+     641             :                              __func__, config->file_name);
+     642          10 :                     config->skip = 1;
+     643          10 :                     return 0;
+     644             :                 }
+     645             :             }
+     646             : 
+     647          93 :             idx += 1;
+     648             : 
+     649             :             /* wrap around if max index is reached or an error occurred
+     650             :              * while calculating index from file name */
+     651          93 :             if ((idx > file_config->logfile_maxcounter) || (idx == 0)) {
+     652             :                 idx = 1;
+     653           2 :                 config->wrap_id += 1;
+     654             :             }
+     655             : 
+     656          93 :             dlt_logstorage_log_file_name(file_name,
+     657             :                                          file_config,
+     658             :                                          config,
+     659          93 :                                          config->file_name,
+     660          93 :                                          config->num_files,
+     661             :                                          idx);
+     662             : 
+     663             :             /* concatenate path and file and open absolute path */
+     664             :             memset(absolute_file_path,
+     665             :                    0,
+     666             :                    sizeof(absolute_file_path) / sizeof(char));
+     667             :             strcat(absolute_file_path, storage_path);
+     668             :             strcat(absolute_file_path, file_name);
+     669             : 
+     670          93 :             if(config->working_file_name) {
+     671          93 :                 free(config->working_file_name);
+     672          93 :                 config->working_file_name = strdup(file_name);
+     673             :             }
+     674             : 
+     675             :             /* If there is already wrap-up, check the existence of file
+     676             :              * remove it and reopen it.
+     677             :              * In this case number of log file won't be increased*/
+     678          93 :             if (config->wrap_id && stat(absolute_file_path, &s) == 0) {
+     679           1 :                 remove(absolute_file_path);
+     680           1 :                 num_log_files -= 1;
+     681           1 :                 dlt_vlog(LOG_DEBUG,
+     682             :                          "%s: Remove '%s' (num_log_files: %u, config->num_files:%u)\n",
+     683             :                          __func__, absolute_file_path, num_log_files, config->num_files);
+     684             :             }
+     685             : 
+     686          93 :             config->log = fopen(absolute_file_path, "w+");
+     687             : 
+     688          93 :             dlt_vlog(LOG_DEBUG,
+     689             :                      "%s: Filename and Index after updating [%s]-[%u]\n",
+     690             :                      __func__, file_name, idx);
+     691             : 
+     692             :             /* Add file to file list */
+     693          93 :             *tmp = malloc(sizeof(DltLogStorageFileList));
+     694             : 
+     695          93 :             if (*tmp == NULL) {
+     696           0 :                 dlt_log(LOG_ERR, "Memory allocation for file name failed\n");
+     697           0 :                 return -1;
+     698             :             }
+     699             : 
+     700          93 :             (*tmp)->name = strdup(file_name);
+     701          93 :             (*tmp)->idx = idx;
+     702          93 :             (*tmp)->next = NULL;
+     703             : 
+     704          93 :             num_log_files += 1;
+     705             : 
+     706             :             /* check if number of log files exceeds configured max value */
+     707          93 :             if (num_log_files > config->num_files) {
+     708          85 :                 if (!(config->num_files == 1 && file_config->logfile_optional_counter)) {
+     709             :                     /* delete oldest */
+     710             :                     DltLogStorageFileList **head = &config->records;
+     711          53 :                     DltLogStorageFileList *n = *head;
+     712             :                     memset(absolute_file_path,
+     713             :                            0,
+     714             :                            sizeof(absolute_file_path) / sizeof(char));
+     715             :                     strcat(absolute_file_path, storage_path);
+     716          53 :                     strncat(absolute_file_path, (*head)->name, strlen((*head)->name));
+     717          53 :                     dlt_vlog(LOG_DEBUG,
+     718             :                              "%s: Remove '%s' (num_log_files: %d, config->num_files:%d, file_name:%s)\n",
+     719             :                              __func__, absolute_file_path, num_log_files,
+     720             :                              config->num_files, config->file_name);
+     721          53 :                     if (remove(absolute_file_path) != 0)
+     722           0 :                         dlt_log(LOG_ERR, "Could not remove file\n");
+     723             : 
+     724          53 :                     free((*head)->name);
+     725          53 :                     (*head)->name = NULL;
+     726          53 :                     *head = n->next;
+     727             :                     n->next = NULL;
+     728          53 :                     free(n);
+     729             :                 }
+     730             :             }
+     731             : 
+     732             :         }
+     733             :     }
+     734             : 
+     735             : #ifdef DLT_LOGSTORAGE_USE_GZIP
+     736             :     if (config->gzlog == NULL && config->log == NULL) {
+     737             : #else
+     738         289 :     if (config->log == NULL) {
+     739             : #endif
+     740           0 :         if (*tmp != NULL) {
+     741           0 :             if ((*tmp)->name != NULL) {
+     742           0 :                 free((*tmp)->name);
+     743           0 :                 (*tmp)->name = NULL;
+     744             :             }
+     745           0 :             free(*tmp);
+     746           0 :             *tmp = NULL;
+     747             :         }
+     748             : 
+     749           0 :         if (config->working_file_name != NULL) {
+     750           0 :             free(config->working_file_name);
+     751           0 :             config->working_file_name = NULL;
+     752             :         }
+     753             : 
+     754           0 :         dlt_vlog(LOG_ERR, "%s: Unable to open log file.\n", __func__);
+     755           0 :         return -1;
+     756             :     }
+     757             : 
+     758             :     return ret;
+     759             : }
+     760             : 
+     761             : /**
+     762             :  * dlt_logstorage_find_dlt_header
+     763             :  *
+     764             :  * search for dlt header in cache
+     765             :  *
+     766             :  * @param ptr         cache starting position
+     767             :  * @param offset      offset
+     768             :  * @param cnt         count
+     769             :  * @return index on success, -1 on error
+     770             :  */
+     771         270 : DLT_STATIC int dlt_logstorage_find_dlt_header(void *ptr,
+     772             :                                               unsigned int offset,
+     773             :                                               unsigned int cnt)
+     774             : {
+     775         270 :     const char magic[] = { 'D', 'L', 'T', 0x01 };
+     776         270 :     const char *cache = (char*)ptr + offset;
+     777             : 
+     778             :     unsigned int i;
+     779         284 :     for (i = 0; i < cnt; i++) {
+     780         283 :         if ((cache[i] == 'D') && (strncmp(&cache[i], magic, 4) == 0))
+     781         269 :            return i;
+     782             :     }
+     783             : 
+     784             :     return -1;
+     785             : }
+     786             : 
+     787             : /**
+     788             :  * dlt_logstorage_find_last_dlt_header
+     789             :  *
+     790             :  * search for last dlt header in cache
+     791             :  *
+     792             :  * @param ptr         cache starting position
+     793             :  * @param offset      offset
+     794             :  * @param cnt         count
+     795             :  * @return index on success, -1 on error
+     796             :  */
+     797          86 : DLT_STATIC int dlt_logstorage_find_last_dlt_header(void *ptr,
+     798             :                                                    unsigned int offset,
+     799             :                                                    unsigned int cnt)
+     800             : {
+     801          86 :     const char magic[] = {'D', 'L', 'T', 0x01};
+     802          86 :     const char *cache = (char*)ptr + offset;
+     803             : 
+     804             :     int i;
+     805        6016 :     for (i = cnt - (DLT_ID_SIZE - 1) ; i > 0; i--) {
+     806        5953 :         if ((cache[i] == 'D') && (strncmp(&cache[i], magic, 4) == 0))
+     807          23 :             return i;
+     808             :     }
+     809             : 
+     810             :     return -1;
+     811             : }
+     812             : 
+     813             : /**
+     814             :  * dlt_logstorage_write_to_log
+     815             :  *
+     816             :  * Write logdata to log storage file
+     817             :  *
+     818             :  * @param ptr       A pointer to the data to write
+     819             :  * @param size      The size of the data blocks
+     820             :  * @param nmemb     The number of blocks to write
+     821             :  * @param config    A pointer to DltLogStorageFilterConfig
+     822             :  */
+     823           5 : DLT_STATIC int dlt_logstorage_write_to_log(void *ptr, size_t size, size_t nmemb,
+     824             :                                            DltLogStorageFilterConfig *config)
+     825             : {
+     826             : #ifdef DLT_LOGSTORAGE_USE_GZIP
+     827             :     if (config->gzip_compression) {
+     828             :         return gzfwrite(ptr, size, nmemb, config->gzlog);
+     829             :     } else {
+     830             :         return fwrite(ptr, size, nmemb, config->log);
+     831             :     }
+     832             : #else
+     833           5 :     return fwrite(ptr, size, nmemb, config->log);
+     834             : #endif
+     835             : }
+     836             : 
+     837             : /**
+     838             :  * dlt_logstorage_check_write_ret
+     839             :  *
+     840             :  * check the return value of fwrite/gzfwrite
+     841             :  *
+     842             :  * @param config      DltLogStorageFilterConfig
+     843             :  * @param ret         return value of fwrite/gzfwrite call
+     844             :  */
+     845         200 : DLT_STATIC void dlt_logstorage_check_write_ret(DltLogStorageFilterConfig *config,
+     846             :                                                int ret)
+     847             : {
+     848         200 :     if (config == NULL) {
+     849           0 :         dlt_vlog(LOG_ERR, "%s: cannot retrieve config information\n", __func__);
+     850           0 :         return;
+     851             :     }
+     852             : 
+     853         200 :     if (ret <= 0) {
+     854           0 :         if (config->gzip_compression) {
+     855             : #ifdef DLT_LOGSTORAGE_USE_GZIP
+     856             :             const char *msg = gzerror(config->gzlog, &ret);
+     857             :             if (msg != NULL) {
+     858             :                 dlt_vlog(LOG_ERR, "%s: failed to write cache into log file: %s\n", __func__, msg);
+     859             :             }
+     860             : #endif
+     861             :         } else {
+     862           0 :             if (ferror(config->log) != 0)
+     863           0 :                 dlt_vlog(LOG_ERR, "%s: failed to write cache into log file\n", __func__);
+     864             :         }
+     865             :     }
+     866             :     else {
+     867             :         /* force sync */
+     868         200 :         if (config->gzip_compression) {
+     869             : #ifdef DLT_LOGSTORAGE_USE_GZIP
+     870             :             if (gzflush(config->gzlog, Z_SYNC_FLUSH) != 0)
+     871             :                 dlt_vlog(LOG_ERR, "%s: failed to gzflush log file\n", __func__);
+     872             : #endif
+     873             :         } else {
+     874         200 :             if (fflush(config->log) != 0)
+     875           0 :                 dlt_vlog(LOG_ERR, "%s: failed to flush log file\n", __func__);
+     876             :         }
+     877             : 
+     878         200 :         if (fsync(config->fd) != 0) {
+     879             :             /* some filesystem doesn't support fsync() */
+     880           0 :             if (errno != ENOSYS) {
+     881           0 :                 dlt_vlog(LOG_ERR, "%s: failed to sync log file\n",
+     882             :                         __func__);
+     883             :             }
+     884             :         }
+     885             :     }
+     886             : }
+     887             : 
+     888             : /**
+     889             :  * dlt_logstorage_close_file
+     890             :  *
+     891             :  * Close open file handles if any exist in the provided
+     892             :  * DltLogStorageFilterConfig
+     893             :  *
+     894             :  * @param config    The DltLogStorageFilterConfig to operate on
+     895             :  */
+     896           4 : DLT_STATIC void dlt_logstorage_close_file(DltLogStorageFilterConfig *config)
+     897             : {
+     898             : 
+     899             : #ifdef DLT_LOGSTORAGE_USE_GZIP
+     900             :     if (config->gzlog) {
+     901             :         gzclose(config->gzlog);
+     902             :         config->gzlog = NULL;
+     903             :     }
+     904             : #endif
+     905         174 :     if (config->log) {
+     906         280 :         fclose(config->log);
+     907         280 :         config->log = NULL;
+     908             :     }
+     909           4 : }
+     910             : 
+     911             : /**
+     912             :  * dlt_logstorage_sync_to_file
+     913             :  *
+     914             :  * Write the log message to log file
+     915             :  *
+     916             :  * @param config        DltLogStorageFilterConfig
+     917             :  * @param file_config   DltLogStorageUserConfig
+     918             :  * @param dev_path      Storage device mount point path
+     919             :  * @param footer        DltLogStorageCacheFooter
+     920             :  * @param start_offset  Start offset of the cache
+     921             :  * @param end_offset    End offset of the cache
+     922             :  * @return 0 on success, -1 on error
+     923             :  */
+     924         187 : DLT_STATIC int dlt_logstorage_sync_to_file(DltLogStorageFilterConfig *config,
+     925             :                                            DltLogStorageUserConfig *file_config,
+     926             :                                            char *dev_path,
+     927             :                                            DltLogStorageCacheFooter *footer,
+     928             :                                            unsigned int start_offset,
+     929             :                                            unsigned int end_offset)
+     930             : {
+     931             :     int ret = 0;
+     932             :     int start_index = 0;
+     933             :     int end_index = 0;
+     934             :     int count = 0;
+     935             :     int remain_file_size = 0;
+     936             : 
+     937         187 :     if ((config == NULL) || (file_config == NULL) || (dev_path == NULL) ||
+     938         186 :         (footer == NULL))
+     939             :     {
+     940           1 :         dlt_vlog(LOG_ERR, "%s: cannot retrieve config information\n", __func__);
+     941           1 :         return -1;
+     942             :     }
+     943             : 
+     944         186 :     count = end_offset - start_offset;
+     945             : 
+     946             :     /* In case of cached-based strategy, the newest file information
+     947             :      * must be updated everytime of synchronization.
+     948             :      */
+     949           2 :     dlt_logstorage_close_file(config);
+     950         186 :     config->current_write_file_offset = 0;
+     951             : 
+     952         186 :     if (dlt_logstorage_open_log_file(config, file_config,
+     953             :             dev_path, count, true, true) != 0) {
+     954           0 :         dlt_vlog(LOG_ERR, "%s: failed to open log file\n", __func__);
+     955           0 :         return -1;
+     956             :     }
+     957             : 
+     958         186 :     if (config->skip == 1) {
+     959           0 :         dlt_logstorage_close_file(config);
+     960           2 :         return 0;
+     961             :     }
+     962             : 
+     963         184 :     remain_file_size = config->file_size - config->current_write_file_offset;
+     964             : 
+     965         184 :     if (count > remain_file_size)
+     966             :     {
+     967             :         /* Check if more than one message can fit into the remaining file */
+     968          84 :         start_index = dlt_logstorage_find_dlt_header(config->cache, start_offset,
+     969             :                                                      remain_file_size);
+     970          84 :         end_index = dlt_logstorage_find_last_dlt_header(config->cache,
+     971             :                                                      start_offset + start_index,
+     972          84 :                                                      remain_file_size - start_index);
+     973          84 :         count = end_index - start_index;
+     974             : 
+     975          84 :         if ((start_index >= 0) && (end_index > start_index) &&
+     976          22 :             (count > 0) && (count <= remain_file_size))
+     977             :         {
+     978          22 :             ret = dlt_logstorage_write_to_log((uint8_t*)config->cache + start_offset + start_index, count, 1, config);
+     979          22 :             dlt_logstorage_check_write_ret(config, ret);
+     980             : 
+     981             :             /* Close log file */
+     982           0 :             dlt_logstorage_close_file(config);
+     983          22 :             config->current_write_file_offset = 0;
+     984             : 
+     985          22 :             footer->last_sync_offset = start_offset + count;
+     986          22 :             start_offset = footer->last_sync_offset;
+     987             :         }
+     988             :         else
+     989             :         {
+     990             :             /* Close log file */
+     991           0 :             dlt_logstorage_close_file(config);
+     992          62 :             config->current_write_file_offset = 0;
+     993             :         }
+     994             :     }
+     995             : 
+     996         184 :     start_index = dlt_logstorage_find_dlt_header(config->cache, start_offset, count);
+     997         184 :     count = end_offset - start_offset - start_index;
+     998             : 
+     999         184 :     if ((start_index >= 0) && (count > 0))
+    1000             :     {
+    1001             :         /* Prepare log file */
+    1002             : #ifdef DLT_LOGSTORAGE_USE_GZIP
+    1003             :         if (config->log == NULL && config->gzlog == NULL)
+    1004             : #else
+    1005         184 :         if (config->log == NULL)
+    1006             : #endif
+    1007             :         {
+    1008          84 :             if (dlt_logstorage_open_log_file(config, file_config, dev_path,
+    1009             :                                              count, true, false) != 0)
+    1010             :             {
+    1011           0 :                 dlt_vlog(LOG_ERR, "%s: failed to open log file\n", __func__);
+    1012           0 :                 dlt_logstorage_close_file(config);
+    1013           0 :                 return -1;
+    1014             :             }
+    1015             : 
+    1016          84 :             if (config->skip == 1)
+    1017             :             {
+    1018           0 :                 dlt_logstorage_close_file(config);
+    1019           6 :                 return 0;
+    1020             :             }
+    1021             :         }
+    1022             : 
+    1023         178 :         ret = dlt_logstorage_write_to_log((uint8_t *)config->cache + start_offset + start_index, count, 1, config);
+    1024         178 :         dlt_logstorage_check_write_ret(config, ret);
+    1025             : 
+    1026         178 :         config->current_write_file_offset += count;
+    1027         178 :         footer->last_sync_offset = end_offset;
+    1028             :     }
+    1029             : 
+    1030         178 :     footer->wrap_around_cnt = 0;
+    1031           2 :     dlt_logstorage_close_file(config);
+    1032           2 :     return 0;
+    1033             : }
+    1034             : 
+    1035             : /**
+    1036             :  * dlt_logstorage_prepare_on_msg
+    1037             :  *
+    1038             :  * Prepare the log file for a certain filer. If log file not open or log
+    1039             :  * files max size reached, open a new file.
+    1040             :  *
+    1041             :  * @param config        DltLogStorageFilterConfig
+    1042             :  * @param file_config   User configurations for log file
+    1043             :  * @param dev_path      Storage device path
+    1044             :  * @param log_msg_size  Size of log message
+    1045             :  * @param newest_file_info   Info of newest file for corresponding filename
+    1046             :  * @return 0 on success, -1 on error
+    1047             :  */
+    1048         363 : int dlt_logstorage_prepare_on_msg(DltLogStorageFilterConfig *config,
+    1049             :                                   DltLogStorageUserConfig *file_config,
+    1050             :                                   char *dev_path,
+    1051             :                                   int log_msg_size,
+    1052             :                                   DltNewestFileName *newest_file_info)
+    1053             : {
+    1054             :     int ret = 0;
+    1055             :     struct stat s;
+    1056             : 
+    1057         363 :     if ((config == NULL) || (file_config == NULL) || (dev_path == NULL) ||
+    1058         362 :         (newest_file_info == NULL)) {
+    1059           1 :         dlt_vlog(LOG_INFO, "%s: Wrong paratemters\n", __func__);
+    1060           1 :         return -1;
+    1061             :     }
+    1062             : 
+    1063             :     /* This is for ON_MSG/UNSET strategy */
+    1064             : #ifdef DLT_LOGSTORAGE_USE_GZIP
+    1065             :     if (config->log == NULL && config->gzlog == NULL) {
+    1066             : #else
+    1067         362 :     if (config->log == NULL) {
+    1068             : #endif
+    1069             :         /* Sync the wrap id and working file name before opening log file */
+    1070          16 :         if (config->wrap_id < newest_file_info->wrap_id) {
+    1071           2 :             config->wrap_id = newest_file_info->wrap_id;
+    1072           2 :             if (config->working_file_name) {
+    1073           1 :                 free(config->working_file_name);
+    1074           1 :                 config->working_file_name = NULL;
+    1075             :             }
+    1076           2 :             config->working_file_name = strdup(newest_file_info->newest_file);
+    1077             :         }
+    1078             : 
+    1079             :         /* open a new log file */
+    1080          16 :         ret = dlt_logstorage_open_log_file(config,
+    1081             :                                            file_config,
+    1082             :                                            dev_path,
+    1083             :                                            log_msg_size,
+    1084             :                                            true,
+    1085             :                                            false);
+    1086             :     }
+    1087             :     else { /* already open, check size and create a new file if needed */
+    1088         346 :         ret = fstat(config->fd, &s);
+    1089             : 
+    1090         346 :         if (ret == 0) {
+    1091             :             /* Check if adding new data do not exceed max file size
+    1092             :              *
+    1093             :              * This is inaccurate for gz compressed files but as long as log
+    1094             :              * messages aren't gigantic it should be negligeble
+    1095             :              *
+    1096             :              * Also check if wrap id needs to be updated */
+    1097         336 :             if ((s.st_size + log_msg_size > (int)config->file_size) ||
+    1098         320 :                 (strcmp(config->working_file_name, newest_file_info->newest_file) != 0) ||
+    1099         320 :                 (config->wrap_id < newest_file_info->wrap_id)) {
+    1100             : 
+    1101             :                 /* Sync only if on_msg */
+    1102          16 :                 if ((config->sync == DLT_LOGSTORAGE_SYNC_ON_MSG) ||
+    1103             :                     (config->sync == DLT_LOGSTORAGE_SYNC_UNSET)) {
+    1104          16 :                     if (config->gzip_compression) {
+    1105           0 :                         if (fsync(fileno(config->gzlog)) != 0) {
+    1106           0 :                             if (errno != ENOSYS) {
+    1107           0 :                                 dlt_vlog(LOG_ERR, "%s: failed to sync gzip log file\n", __func__);
+    1108             :                             }
+    1109             :                         }
+    1110             :                     }
+    1111             :                     else {
+    1112          16 :                         if (fsync(fileno(config->log)) != 0) {
+    1113           0 :                             if (errno != ENOSYS) {
+    1114           0 :                                 dlt_vlog(LOG_ERR, "%s: failed to sync log file\n", __func__);
+    1115             :                             }
+    1116             :                         }
+    1117             :                     }
+    1118             :                 }
+    1119             : 
+    1120           0 :                 dlt_logstorage_close_file(config);
+    1121             : 
+    1122             :                 /* Sync the wrap id and working file name before opening log file */
+    1123          16 :                 if (config->wrap_id <= newest_file_info->wrap_id) {
+    1124          16 :                     config->wrap_id = newest_file_info->wrap_id;
+    1125          16 :                     if (config->working_file_name) {
+    1126          16 :                         free(config->working_file_name);
+    1127          16 :                         config->working_file_name = NULL;
+    1128             :                     }
+    1129          16 :                     config->working_file_name = strdup(newest_file_info->newest_file);
+    1130             :                 }
+    1131             : 
+    1132          16 :                 ret = dlt_logstorage_open_log_file(config,
+    1133             :                                                    file_config,
+    1134             :                                                    dev_path,
+    1135             :                                                    log_msg_size,
+    1136             :                                                    true,
+    1137             :                                                    false);
+    1138             :             }
+    1139             :             else { /*everything is prepared */
+    1140             :                 ret = 0;
+    1141             :             }
+    1142             :         }
+    1143             :         else {
+    1144          10 :             dlt_vlog(LOG_ERR, "%s: stat() failed.\n", __func__);
+    1145             :             ret = -1;
+    1146             :         }
+    1147             :     }
+    1148             : 
+    1149             :     return ret;
+    1150             : }
+    1151             : 
+    1152             : /**
+    1153             :  * dlt_logstorage_write_on_msg
+    1154             :  *
+    1155             :  * Write the log message.
+    1156             :  *
+    1157             :  * @param config        DltLogStorageFilterConfig
+    1158             :  * @param file_config   DltLogStorageUserConfig
+    1159             :  * @param dev_path      Path to device
+    1160             :  * @param data1         header
+    1161             :  * @param size1         header size
+    1162             :  * @param data2         storage header
+    1163             :  * @param size2         storage header size
+    1164             :  * @param data3         payload
+    1165             :  * @param size3         payload size
+    1166             :  * @return 0 on success, -1 on error
+    1167             :  */
+    1168         341 : int dlt_logstorage_write_on_msg(DltLogStorageFilterConfig *config,
+    1169             :                                 DltLogStorageUserConfig *file_config,
+    1170             :                                 char *dev_path,
+    1171             :                                 unsigned char *data1,
+    1172             :                                 int size1,
+    1173             :                                 unsigned char *data2,
+    1174             :                                 int size2,
+    1175             :                                 unsigned char *data3,
+    1176             :                                 int size3)
+    1177             : {
+    1178             :     int ret;
+    1179             : 
+    1180         341 :     if ((config == NULL) || (data1 == NULL) || (data2 == NULL) || (data3 == NULL) ||
+    1181         340 :         (file_config == NULL) || (dev_path == NULL))
+    1182             :     {
+    1183             :         return -1;
+    1184             :     }
+    1185             : 
+    1186         340 :     ret = dlt_logstorage_write_to_log(data1, 1, size1, config);
+    1187             : 
+    1188         340 :     if (ret != size1)
+    1189           0 :         dlt_log(LOG_WARNING, "Wrote less data than specified\n");
+    1190             : 
+    1191         340 :     ret = dlt_logstorage_write_to_log(data2, 1, size2, config);
+    1192         340 :     if (ret != size2)
+    1193           0 :         dlt_log(LOG_WARNING, "Wrote less data than specified\n");
+    1194             : 
+    1195         340 :     ret = dlt_logstorage_write_to_log(data3, 1, size3, config);
+    1196         340 :     if (ret != size3)
+    1197           0 :         dlt_log(LOG_WARNING, "Wrote less data than specified\n");
+    1198             : 
+    1199             : #ifdef DLT_LOGSTORAGE_USE_GZIP
+    1200             :     if (config->gzip_compression) {
+    1201             :         gzerror(config->gzlog, &ret);
+    1202             :         return ret;
+    1203             :     } else {
+    1204             :         return ferror(config->log);
+    1205             :     }
+    1206             : #else
+    1207         340 :     return ferror(config->log);
+    1208             : #endif
+    1209             : }
+    1210             : 
+    1211             : /**
+    1212             :  * dlt_logstorage_sync_on_msg
+    1213             :  *
+    1214             :  * sync data to disk.
+    1215             :  *
+    1216             :  * @param config        DltLogStorageFilterConfig
+    1217             :  * @param file_config   User configurations for log file
+    1218             :  * @param dev_path      Storage device path
+    1219             :  * @param status        Strategy flag
+    1220             :  * @return 0 on success, -1 on error
+    1221             :  */
+    1222         362 : int dlt_logstorage_sync_on_msg(DltLogStorageFilterConfig *config,
+    1223             :                                DltLogStorageUserConfig *file_config,
+    1224             :                                char *dev_path,
+    1225             :                                int status)
+    1226             : {
+    1227             :     (void)file_config;  /* satisfy compiler */
+    1228             :     (void)dev_path;
+    1229             : 
+    1230         362 :     if (config == NULL)
+    1231             :         return -1;
+    1232             : 
+    1233         361 :     if (status == DLT_LOGSTORAGE_SYNC_ON_MSG) { /* sync on every message */
+    1234         340 :         if (config->gzip_compression) {
+    1235             : #ifdef DLT_LOGSTORAGE_USE_GZIP
+    1236             :             if (gzflush(config->gzlog, Z_SYNC_FLUSH) != 0)
+    1237             :                 dlt_vlog(LOG_ERR, "%s: failed to gzflush log file\n", __func__);
+    1238             : #endif
+    1239             :         } else {
+    1240         340 :             if (fflush(config->log) != 0)
+    1241           0 :                 dlt_vlog(LOG_ERR, "%s: failed to flush log file\n", __func__);
+    1242             :         }
+    1243             :     }
+    1244             : 
+    1245             :     return 0;
+    1246             : }
+    1247             : 
+    1248             : /**
+    1249             :  * dlt_logstorage_prepare_msg_cache
+    1250             :  *
+    1251             :  * Prepare the log file for a certain filer. If log file not open or log
+    1252             :  * files max size reached, open a new file.
+    1253             :  * Create a memory area to cache data.
+    1254             :  *
+    1255             :  * @param config        DltLogStorageFilterConfig
+    1256             :  * @param file_config   User configurations for log file
+    1257             :  * @param dev_path      Storage device path
+    1258             :  * @param log_msg_size  Size of log message
+    1259             :  * @param newest_file_info   Info of newest files for corresponding filename
+    1260             :  * @return 0 on success, -1 on error
+    1261             :  */
+    1262        3098 : int dlt_logstorage_prepare_msg_cache(DltLogStorageFilterConfig *config,
+    1263             :                                      DltLogStorageUserConfig *file_config,
+    1264             :                                      char *dev_path,
+    1265             :                                      int log_msg_size,
+    1266             :                                      DltNewestFileName *newest_file_info )
+    1267             : {
+    1268        3098 :     if ((config == NULL) || (file_config == NULL) ||
+    1269        3097 :             (dev_path == NULL) || (newest_file_info == NULL))
+    1270             :         return -1;
+    1271             : 
+    1272             :     /* check if newest file info is available
+    1273             :      * + working file name is NULL => update directly to newest file
+    1274             :      * + working file name is not NULL: check if
+    1275             :      * ++ wrap_ids are different from each other or
+    1276             :      * ++ newest file name <> working file name
+    1277             :      */
+    1278        3097 :     if (newest_file_info->newest_file) {
+    1279        1675 :         if (config->working_file_name &&
+    1280        1674 :                 ((config->wrap_id != newest_file_info->wrap_id) ||
+    1281        1674 :                 (strcmp(newest_file_info->newest_file, config->working_file_name) != 0))) {
+    1282           0 :             free(config->working_file_name);
+    1283           0 :             config->working_file_name = NULL;
+    1284             :         }
+    1285        1675 :         if (config->working_file_name == NULL) {
+    1286           1 :             config->working_file_name = strdup(newest_file_info->newest_file);
+    1287           1 :             config->wrap_id = newest_file_info->wrap_id;
+    1288             :         }
+    1289             :     }
+    1290             : 
+    1291             :     /* Combinations allowed: on Daemon_Exit with on Demand,File_Size with Daemon_Exit
+    1292             :      *  File_Size with on Demand, Specific_Size with Daemon_Exit,Specific_Size with on Demand
+    1293             :      * Combination not allowed : File_Size with Specific_Size
+    1294             :      */
+    1295             :     /* check for combinations of specific_size and file_size strategy */
+    1296        3097 :     if ((DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync, DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) > 0) &&
+    1297         452 :         ((DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync, DLT_LOGSTORAGE_SYNC_ON_FILE_SIZE)) > 0)) {
+    1298           0 :         dlt_log(LOG_WARNING, "wrong combination of sync strategies \n");
+    1299           0 :         return -1;
+    1300             :     }
+    1301             : 
+    1302             :     (void)log_msg_size; /* satisfy compiler */
+    1303             : 
+    1304             :     /* check specific size is smaller than file size */
+    1305        3097 :     if ((DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
+    1306         452 :                      DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) > 0) &&
+    1307         452 :                      (config->specific_size > config->file_size))
+    1308             :     {
+    1309           0 :         dlt_log(LOG_ERR,
+    1310             :                 "Cache size is larger than file size. "
+    1311             :                 "Cannot prepare log file for ON_SPECIFIC_SIZE sync\n");
+    1312           0 :         return -1;
+    1313             :     }
+    1314             : 
+    1315        3097 :     if (config->cache == NULL)
+    1316             :     {
+    1317             :         unsigned int cache_size = 0;
+    1318             : 
+    1319             :         /* check for sync_specific_size strategy */
+    1320          29 :         if (DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
+    1321             :                DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) > 0)
+    1322             :         {
+    1323           4 :             cache_size = config->specific_size;
+    1324             :         }
+    1325             :         else  /* other cache strategies */
+    1326             :         {
+    1327          25 :             cache_size = config->file_size;
+    1328             :         }
+    1329             : 
+    1330             :         /* check total logstorage cache size */
+    1331          29 :         if ((g_logstorage_cache_size + cache_size +
+    1332          29 :              sizeof(DltLogStorageCacheFooter)) >
+    1333             :              g_logstorage_cache_max)
+    1334             :         {
+    1335           5 :             dlt_vlog(LOG_ERR,
+    1336             :                      "%s: Max size of Logstorage Cache already used. (ApId=[%s] CtId=[%s]) \n",
+    1337             :                      __func__, config->apids, config->ctids);
+    1338           5 :             return -1;
+    1339             :         } else {
+    1340          24 :             dlt_vlog(LOG_DEBUG,
+    1341             :                      "%s: Logstorage total: %d , requested cache size: %d, max: %d (ApId=[%s] CtId=[%s])\n",
+    1342             :                      __func__, g_logstorage_cache_size, cache_size,
+    1343             :                      g_logstorage_cache_max, config->apids, config->ctids);
+    1344             :         }
+    1345             : 
+    1346             :         /* create cache */
+    1347          24 :         config->cache = calloc(1, cache_size + sizeof(DltLogStorageCacheFooter));
+    1348             : 
+    1349          24 :         if (config->cache == NULL)
+    1350             :         {
+    1351           0 :             dlt_log(LOG_CRIT,
+    1352             :                     "Cannot allocate memory for filter ring buffer\n");
+    1353             :         }
+    1354             :         else
+    1355             :         {
+    1356             :             /* update current used cache size */
+    1357          24 :             g_logstorage_cache_size += cache_size + sizeof(DltLogStorageCacheFooter);
+    1358             :         }
+    1359             :     }
+    1360             : 
+    1361             :     return 0;
+    1362             : }
+    1363             : 
+    1364             : /**
+    1365             :  * dlt_logstorage_write_msg_cache
+    1366             :  *
+    1367             :  * Write the log message.
+    1368             :  *
+    1369             :  * @param config        DltLogStorageFilterConfig
+    1370             :  * @param file_config   User configurations for log file
+    1371             :  * @param dev_path      Storage device path
+    1372             :  * @param data1         header
+    1373             :  * @param size1         header size
+    1374             :  * @param data2         storage header
+    1375             :  * @param size2         storage header size
+    1376             :  * @param data3         payload
+    1377             :  * @param size3         payload size
+    1378             :  * @return 0 on success, -1 on error
+    1379             :  */
+    1380        3093 : int dlt_logstorage_write_msg_cache(DltLogStorageFilterConfig *config,
+    1381             :                                    DltLogStorageUserConfig *file_config,
+    1382             :                                    char *dev_path,
+    1383             :                                    unsigned char *data1,
+    1384             :                                    int size1,
+    1385             :                                    unsigned char *data2,
+    1386             :                                    int size2,
+    1387             :                                    unsigned char *data3,
+    1388             :                                    int size3)
+    1389             : {
+    1390             :     DltLogStorageCacheFooter *footer = NULL;
+    1391             :     int msg_size;
+    1392             :     int remain_cache_size;
+    1393             :     uint8_t *curr_write_addr = NULL;
+    1394             :     int ret = 0;
+    1395             :     unsigned int cache_size;
+    1396             : 
+    1397        3093 :     if ((config == NULL) || (data1 == NULL) || (size1 < 0) || (data2 == NULL) ||
+    1398        3092 :         (size2 < 0) || (data3 == NULL) || (size3 < 0) || (config->cache == NULL) ||
+    1399        3092 :         (file_config == NULL) || (dev_path == NULL))
+    1400             :     {
+    1401             :         return -1;
+    1402             :     }
+    1403             : 
+    1404        3092 :     if (DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
+    1405             :                                      DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) > 0)
+    1406             :     {
+    1407         452 :         cache_size = config->specific_size;
+    1408             :     }
+    1409             :     else
+    1410             :     {
+    1411        2640 :         cache_size = config->file_size;
+    1412             :     }
+    1413             : 
+    1414        3092 :     footer = (DltLogStorageCacheFooter *)((uint8_t*)config->cache + cache_size);
+    1415        3092 :     msg_size = size1 + size2 + size3;
+    1416        3092 :     remain_cache_size = cache_size - footer->offset;
+    1417             : 
+    1418        3092 :     if (msg_size <= remain_cache_size) /* add at current position */
+    1419             :     {
+    1420        2824 :         curr_write_addr = (uint8_t*)config->cache + footer->offset;
+    1421        2824 :         footer->offset += msg_size;
+    1422        2824 :         if (footer->wrap_around_cnt < 1) {
+    1423        1510 :             footer->end_sync_offset = footer->offset;
+    1424             :         }
+    1425             : 
+    1426             :         /* write data to cache */
+    1427        2824 :         memcpy(curr_write_addr, data1, size1);
+    1428        2824 :         curr_write_addr += size1;
+    1429        2824 :         memcpy(curr_write_addr, data2, size2);
+    1430        2824 :         curr_write_addr += size2;
+    1431        2824 :         memcpy(curr_write_addr, data3, size3);
+    1432             :     }
+    1433             : 
+    1434             :     /*
+    1435             :      * In case the msg_size is equal to remaining cache size,
+    1436             :      * the message is still written in cache.
+    1437             :      * Then whole cache data is synchronized to file.
+    1438             :      */
+    1439        3092 :     if (msg_size >= remain_cache_size)
+    1440             :     {
+    1441             :         /*check for message size exceeds cache size for specific_size strategy */
+    1442         268 :         if ((unsigned int) msg_size > cache_size)
+    1443             :         {
+    1444           0 :             dlt_log(LOG_WARNING, "Message is larger than cache. Discard.\n");
+    1445           0 :             return -1;
+    1446             :         }
+    1447             : 
+    1448             :          /*sync to file for specific_size or file_size  */
+    1449         268 :          if (DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
+    1450             :                                                     DLT_LOGSTORAGE_SYNC_ON_FILE_SIZE) > 0)
+    1451             :          {
+    1452          62 :              ret = config->dlt_logstorage_sync(config,
+    1453             :                                                file_config,
+    1454             :                                                dev_path,
+    1455             :                                                DLT_LOGSTORAGE_SYNC_ON_FILE_SIZE);
+    1456          62 :              if (ret != 0)
+    1457             :              {
+    1458           0 :                  dlt_log(LOG_ERR,"dlt_logstorage_sync: Unable to sync.\n");
+    1459           0 :                  return -1;
+    1460             :              }
+    1461             :          }
+    1462         206 :          else if (DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
+    1463             :                                                          DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) > 0)
+    1464             :          {
+    1465             : 
+    1466         102 :              ret = config->dlt_logstorage_sync(config,
+    1467             :                                                file_config,
+    1468             :                                                dev_path,
+    1469             :                                                DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE);
+    1470         102 :              if (ret != 0)
+    1471             :              {
+    1472           0 :                  dlt_log(LOG_ERR,"dlt_logstorage_sync: Unable to sync.\n");
+    1473           0 :                  return -1;
+    1474             :              }
+    1475             :          }
+    1476         104 :          else if ((DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
+    1477          52 :                                                          DLT_LOGSTORAGE_SYNC_ON_DEMAND) > 0) ||
+    1478          52 :                   (DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
+    1479             :                                                          DLT_LOGSTORAGE_SYNC_ON_DAEMON_EXIT) > 0))
+    1480             :          {
+    1481         104 :              footer->wrap_around_cnt += 1;
+    1482             :          }
+    1483             : 
+    1484         268 :          if (msg_size > remain_cache_size)
+    1485             :          {
+    1486             :             /* start writing from beginning */
+    1487         268 :             footer->end_sync_offset = footer->offset;
+    1488         268 :             curr_write_addr = config->cache;
+    1489         268 :             footer->offset = msg_size;
+    1490             : 
+    1491             :             /* write data to cache */
+    1492         268 :             memcpy(curr_write_addr, data1, size1);
+    1493         268 :             curr_write_addr += size1;
+    1494         268 :             memcpy(curr_write_addr, data2, size2);
+    1495         268 :             curr_write_addr += size2;
+    1496         268 :             memcpy(curr_write_addr, data3, size3);
+    1497             :         }
+    1498             :     }
+    1499             : 
+    1500             : 
+    1501             :     return 0;
+    1502             : }
+    1503             : 
+    1504             : /**
+    1505             :  * dlt_logstorage_sync_msg_cache
+    1506             :  *
+    1507             :  * sync data to disk.
+    1508             :  *
+    1509             :  * @param config        DltLogStorageFilterConfig
+    1510             :  * @param file_config   User configurations for log file
+    1511             :  * @param dev_path      Storage device path
+    1512             :  * @param status        Strategy flag
+    1513             :  * @return 0 on success, -1 on error
+    1514             :  */
+    1515        3299 : int dlt_logstorage_sync_msg_cache(DltLogStorageFilterConfig *config,
+    1516             :                                   DltLogStorageUserConfig *file_config,
+    1517             :                                   char *dev_path,
+    1518             :                                   int status)
+    1519             : {
+    1520             :     unsigned int cache_size;
+    1521             : 
+    1522             :     DltLogStorageCacheFooter *footer = NULL;
+    1523             : 
+    1524        3299 :     if ((config == NULL) || (file_config == NULL) || (dev_path == NULL))
+    1525             :     {
+    1526             :         return -1;
+    1527             :     }
+    1528             : 
+    1529             :     /* sync only, if given strategy is set */
+    1530        3298 :     if (DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync, status) > 0)
+    1531             :     {
+    1532         177 :         if (config->cache == NULL)
+    1533             :         {
+    1534           0 :             dlt_log(LOG_ERR,
+    1535             :                     "Cannot copy cache to file. Cache is NULL\n");
+    1536           0 :             return -1;
+    1537             :         }
+    1538             : 
+    1539         177 :         if (DLT_OFFLINE_LOGSTORAGE_IS_STRATEGY_SET(config->sync,
+    1540             :                                                    DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) > 0)
+    1541             :         {
+    1542         102 :             cache_size = config->specific_size;
+    1543             :         }
+    1544             :         else
+    1545             :         {
+    1546          75 :             cache_size = config->file_size;
+    1547             :         }
+    1548             : 
+    1549         177 :         footer = (DltLogStorageCacheFooter *)((uint8_t*)config->cache + cache_size);
+    1550             : 
+    1551             :         /* sync cache data to file */
+    1552         177 :         if (footer->wrap_around_cnt < 1)
+    1553             :         {
+    1554             :             /* Sync whole cache */
+    1555         169 :             dlt_logstorage_sync_to_file(config, file_config, dev_path, footer,
+    1556             :                                         footer->last_sync_offset, footer->offset);
+    1557             : 
+    1558             :         }
+    1559           8 :         else if ((footer->wrap_around_cnt == 1) &&
+    1560           0 :                  (footer->offset < footer->last_sync_offset))
+    1561             :         {
+    1562             :             /* sync (1) footer->last_sync_offset to footer->end_sync_offset,
+    1563             :              * and (2) footer->last_sync_offset (= 0) to footer->offset */
+    1564           0 :             dlt_logstorage_sync_to_file(config, file_config, dev_path, footer,
+    1565             :                                         footer->last_sync_offset, footer->end_sync_offset);
+    1566           0 :             footer->last_sync_offset = 0;
+    1567           0 :             dlt_logstorage_sync_to_file(config, file_config, dev_path, footer,
+    1568             :                                         footer->last_sync_offset, footer->offset);
+    1569             :         }
+    1570             :         else
+    1571             :         {
+    1572             :             /* sync (1) footer->offset + index to footer->end_sync_offset,
+    1573             :              * and (2) footer->last_sync_offset (= 0) to footer->offset */
+    1574           8 :             dlt_logstorage_sync_to_file(config, file_config, dev_path, footer,
+    1575             :                                         footer->offset, footer->end_sync_offset);
+    1576           8 :             footer->last_sync_offset = 0;
+    1577           8 :             dlt_logstorage_sync_to_file(config, file_config, dev_path, footer,
+    1578             :                                         footer->last_sync_offset, footer->offset);
+    1579             :         }
+    1580             : 
+    1581             :         /* Initialize cache if needed */
+    1582         177 :         if ((status == DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE) ||
+    1583         177 :             (status == DLT_LOGSTORAGE_SYNC_ON_FILE_SIZE))
+    1584             :         {
+    1585             :             /* clean ring buffer and reset footer information */
+    1586         164 :             memset(config->cache, 0,
+    1587             :                    cache_size + sizeof(DltLogStorageCacheFooter));
+    1588             :         }
+    1589             : 
+    1590         177 :         if (status == DLT_LOGSTORAGE_SYNC_ON_FILE_SIZE)
+    1591             :         {
+    1592             :             /* Close log file */
+    1593           0 :             dlt_logstorage_close_file(config);
+    1594          62 :             config->current_write_file_offset = 0;
+    1595             :         }
+    1596             :     }
+    1597             :     return 0;
+    1598             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/offlinelogstorage/index-sort-f.html b/dlt_lcov_report/offlinelogstorage/index-sort-f.html new file mode 100644 index 000000000..2c07d7380 --- /dev/null +++ b/dlt_lcov_report/offlinelogstorage/index-sort-f.html @@ -0,0 +1,103 @@ + + + + + + + LCOV - dlt_final_coverage.info - offlinelogstorage + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - offlinelogstorageHitTotalCoverage
Test:dlt_final_coverage.infoLines:1003133175.4 %
Date:2024-12-05 09:07:13Functions:667489.2 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_offline_logstorage.c +
70.9%70.9%
+
70.9 %598 / 84485.2 %46 / 54
dlt_offline_logstorage_behavior.c +
83.2%83.2%
+
83.2 %405 / 487100.0 %20 / 20
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/offlinelogstorage/index-sort-l.html b/dlt_lcov_report/offlinelogstorage/index-sort-l.html new file mode 100644 index 000000000..e4916ae51 --- /dev/null +++ b/dlt_lcov_report/offlinelogstorage/index-sort-l.html @@ -0,0 +1,103 @@ + + + + + + + LCOV - dlt_final_coverage.info - offlinelogstorage + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - offlinelogstorageHitTotalCoverage
Test:dlt_final_coverage.infoLines:1003133175.4 %
Date:2024-12-05 09:07:13Functions:667489.2 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_offline_logstorage.c +
70.9%70.9%
+
70.9 %598 / 84485.2 %46 / 54
dlt_offline_logstorage_behavior.c +
83.2%83.2%
+
83.2 %405 / 487100.0 %20 / 20
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/offlinelogstorage/index.html b/dlt_lcov_report/offlinelogstorage/index.html new file mode 100644 index 000000000..af8a6b722 --- /dev/null +++ b/dlt_lcov_report/offlinelogstorage/index.html @@ -0,0 +1,103 @@ + + + + + + + LCOV - dlt_final_coverage.info - offlinelogstorage + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - offlinelogstorageHitTotalCoverage
Test:dlt_final_coverage.infoLines:1003133175.4 %
Date:2024-12-05 09:07:13Functions:667489.2 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_offline_logstorage.c +
70.9%70.9%
+
70.9 %598 / 84485.2 %46 / 54
dlt_offline_logstorage_behavior.c +
83.2%83.2%
+
83.2 %405 / 487100.0 %20 / 20
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/ruby.png b/dlt_lcov_report/ruby.png new file mode 100644 index 0000000000000000000000000000000000000000..991b6d4ec9e78be165e3ef757eed1aada287364d GIT binary patch literal 141 zcmeAS@N?(olHy`uVBq!ia0vp^j3CU&3?x-=hn)ga>?NMQuI!iC1^FceV#7`HfI^%F z9+AZi4BSE>%y{W;-5;PJOS+@4BLl<6e(pbstUx|nfKQ0)e^Y%R^MdiLxj>4`)5S5Q b;#P73kj=!v_*DHKNFRfztDnm{r-UW|iOwIS literal 0 HcmV?d00001 diff --git a/dlt_lcov_report/shared/dlt_common.c.func-sort-c.html b/dlt_lcov_report/shared/dlt_common.c.func-sort-c.html new file mode 100644 index 000000000..8c7363325 --- /dev/null +++ b/dlt_lcov_report/shared/dlt_common.c.func-sort-c.html @@ -0,0 +1,452 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared/dlt_common.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - shared - dlt_common.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:1005162561.8 %
Date:2024-12-05 09:07:13Functions:819585.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_buffer_free_static0
dlt_buffer_init_static_client0
dlt_buffer_init_static_server0
dlt_convert_serial_speed0
dlt_execute_command0
dlt_file_close0
dlt_file_read_header_raw0
dlt_file_read_raw0
dlt_filter_delete0
dlt_filter_save0
dlt_hex_ascii_to_binary0
dlt_print_hex0
dlt_print_with_attributes0
dlt_setup_serial0
dlt_filter_free1
dlt_buffer_info2
dlt_buffer_status2
dlt_set_loginfo_parse_service_id2
dlt_buffer_get_total_size3
dlt_file_quick_parsing3
get_filename_ext5
dlt_extract_base_name_without_ext6
dlt_file_set_filter6
dlt_filter_load6
dlt_buffer_increase_size7
dlt_buffer_remove7
dlt_filter_init7
dlt_buffer_minimize_size8
dlt_buffer_pull8
dlt_buffer_reset9
dlt_check_rcv_data_size9
dlt_get_major_version9
dlt_get_minor_version9
dlt_receiver_free_global_buffer9
dlt_receiver_init_global_buffer9
dlt_getloginfo_conv_ascii_to_string11
dlt_filter_add12
dlt_filter_find12
dlt_getloginfo_conv_ascii_to_int16_t12
dlt_buffer_copy13
dlt_getloginfo_conv_ascii_to_uint16_t14
dlt_getloginfo_conv_ascii_to_id20
dlt_get_version22
dlt_file_open50
dlt_file_free51
dlt_buffer_read_block53
dlt_file_init54
dlt_buffer_get64
dlt_message_free107
dlt_receiver_check_and_get133
dlt_message_print_ascii328
dlt_message_print_header328
dlt_message_print_hex328
dlt_message_print_mixed_html328
dlt_message_print_mixed_plain328
dlt_message_filter_check742
dlt_buffer_check_size859
dlt_print_mixed_string1062
dlt_clean_string1159
dlt_print_char_string1661
dlt_receiver_move_to_begin1958
dlt_receiver_receive1964
dlt_message_header2420
dlt_buffer_get_used_size2503
dlt_print_hex_string2724
dlt_print_hex_string_delim2733
dlt_file_read2752
dlt_message_argument_print2771
dlt_message_payload3131
dlt_file_message3770
dlt_file_read_data3875
dlt_file_read_header_extended4505
dlt_message_header_flags5122
dlt_print_id5620
dlt_strnlen_s5622
dlt_receiver_remove6097
dlt_message_init6109
dlt_message_set_extraparameters6247
dlt_uptime6301
dlt_check_storageheader6589
dlt_file_read_header6627
dlt_message_read6680
dlt_message_get_extraparameters7222
dlt_buffer_push7516
dlt_buffer_get_message_count8527
dlt_set_storageheader12103
dlt_buffer_push315284
dlt_check_envvar16786
dlt_log_set_fifo_basedir16795
dlt_receiver_free16827
dlt_receiver_init16828
dlt_buffer_free_dynamic16891
dlt_buffer_init_dynamic16916
dlt_buffer_write_block41031
dlt_set_id77315
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/dlt_common.c.func.html b/dlt_lcov_report/shared/dlt_common.c.func.html new file mode 100644 index 000000000..2776d3e78 --- /dev/null +++ b/dlt_lcov_report/shared/dlt_common.c.func.html @@ -0,0 +1,452 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared/dlt_common.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - shared - dlt_common.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:1005162561.8 %
Date:2024-12-05 09:07:13Functions:819585.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_buffer_check_size859
dlt_buffer_copy13
dlt_buffer_free_dynamic16891
dlt_buffer_free_static0
dlt_buffer_get64
dlt_buffer_get_message_count8527
dlt_buffer_get_total_size3
dlt_buffer_get_used_size2503
dlt_buffer_increase_size7
dlt_buffer_info2
dlt_buffer_init_dynamic16916
dlt_buffer_init_static_client0
dlt_buffer_init_static_server0
dlt_buffer_minimize_size8
dlt_buffer_pull8
dlt_buffer_push7516
dlt_buffer_push315284
dlt_buffer_read_block53
dlt_buffer_remove7
dlt_buffer_reset9
dlt_buffer_status2
dlt_buffer_write_block41031
dlt_check_envvar16786
dlt_check_rcv_data_size9
dlt_check_storageheader6589
dlt_clean_string1159
dlt_convert_serial_speed0
dlt_execute_command0
dlt_extract_base_name_without_ext6
dlt_file_close0
dlt_file_free51
dlt_file_init54
dlt_file_message3770
dlt_file_open50
dlt_file_quick_parsing3
dlt_file_read2752
dlt_file_read_data3875
dlt_file_read_header6627
dlt_file_read_header_extended4505
dlt_file_read_header_raw0
dlt_file_read_raw0
dlt_file_set_filter6
dlt_filter_add12
dlt_filter_delete0
dlt_filter_find12
dlt_filter_free1
dlt_filter_init7
dlt_filter_load6
dlt_filter_save0
dlt_get_major_version9
dlt_get_minor_version9
dlt_get_version22
dlt_getloginfo_conv_ascii_to_id20
dlt_getloginfo_conv_ascii_to_int16_t12
dlt_getloginfo_conv_ascii_to_string11
dlt_getloginfo_conv_ascii_to_uint16_t14
dlt_hex_ascii_to_binary0
dlt_log_set_fifo_basedir16795
dlt_message_argument_print2771
dlt_message_filter_check742
dlt_message_free107
dlt_message_get_extraparameters7222
dlt_message_header2420
dlt_message_header_flags5122
dlt_message_init6109
dlt_message_payload3131
dlt_message_print_ascii328
dlt_message_print_header328
dlt_message_print_hex328
dlt_message_print_mixed_html328
dlt_message_print_mixed_plain328
dlt_message_read6680
dlt_message_set_extraparameters6247
dlt_print_char_string1661
dlt_print_hex0
dlt_print_hex_string2724
dlt_print_hex_string_delim2733
dlt_print_id5620
dlt_print_mixed_string1062
dlt_print_with_attributes0
dlt_receiver_check_and_get133
dlt_receiver_free16827
dlt_receiver_free_global_buffer9
dlt_receiver_init16828
dlt_receiver_init_global_buffer9
dlt_receiver_move_to_begin1958
dlt_receiver_receive1964
dlt_receiver_remove6097
dlt_set_id77315
dlt_set_loginfo_parse_service_id2
dlt_set_storageheader12103
dlt_setup_serial0
dlt_strnlen_s5622
dlt_uptime6301
get_filename_ext5
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/dlt_common.c.gcov.html b/dlt_lcov_report/shared/dlt_common.c.gcov.html new file mode 100644 index 000000000..47cce8631 --- /dev/null +++ b/dlt_lcov_report/shared/dlt_common.c.gcov.html @@ -0,0 +1,4595 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared/dlt_common.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - shared - dlt_common.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:1005162561.8 %
Date:2024-12-05 09:07:13Functions:819585.3 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2011-2015, BMW AG
+       5             :  *
+       6             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       7             :  *
+       8             :  * This Source Code Form is subject to the terms of the
+       9             :  * Mozilla Public License (MPL), v. 2.0.
+      10             :  * If a copy of the MPL was not distributed with this file,
+      11             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      12             :  *
+      13             :  * For further information see http://www.covesa.org/.
+      14             :  */
+      15             : 
+      16             : /*!
+      17             :  * \author
+      18             :  * Alexander Wenzel <alexander.aw.wenzel@bmw.de>
+      19             :  * Markus Klein <Markus.Klein@esk.fraunhofer.de>
+      20             :  * Mikko Rapeli <mikko.rapeli@bmw.de>
+      21             :  *
+      22             :  * \copyright Copyright © 2011-2015 BMW AG. \n
+      23             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      24             :  *
+      25             :  * \file dlt_common.c
+      26             :  */
+      27             : 
+      28             : #include <stdio.h>
+      29             : #include <stdlib.h>   /* for malloc(), free() */
+      30             : #include <string.h>   /* for strlen(), memcmp(), memmove() */
+      31             : #include <time.h>     /* for localtime_r(), strftime() */
+      32             : #include <limits.h>   /* for NAME_MAX */
+      33             : #include <inttypes.h> /* for PRI formatting macro */
+      34             : #include <stdarg.h>   /* va_list, va_start */
+      35             : #include <err.h>
+      36             : 
+      37             : #include <errno.h>
+      38             : #include <sys/stat.h> /* for mkdir() */
+      39             : #include <sys/wait.h>
+      40             : 
+      41             : #include "dlt_user_shared.h"
+      42             : #include "dlt_common.h"
+      43             : #include "dlt_common_cfg.h"
+      44             : #include "dlt_multiple_files.h"
+      45             : 
+      46             : #include "dlt_version.h"
+      47             : 
+      48             : #if defined (__WIN32__) || defined (_MSC_VER)
+      49             : #   include <winsock2.h> /* for socket(), connect(), send(), and recv() */
+      50             : #else
+      51             : #   include <sys/socket.h> /* for socket(), connect(), send(), and recv() */
+      52             : #   include <syslog.h>
+      53             : #   include <time.h> /* for clock_gettime() */
+      54             : #endif
+      55             : 
+      56             : #if defined (_MSC_VER)
+      57             : #   include <io.h>
+      58             : #else
+      59             : #   include <unistd.h>  /* for read(), close() */
+      60             : #   include <fcntl.h>
+      61             : #   include <sys/time.h> /* for gettimeofday() */
+      62             : #endif
+      63             : 
+      64             : #if defined (__MSDOS__) || defined (_MSC_VER)
+      65             : #   pragma warning(disable : 4996) /* Switch off C4996 warnings */
+      66             : #   include <windows.h>
+      67             : #   include <winbase.h>
+      68             : #endif
+      69             : 
+      70             : const char dltSerialHeader[DLT_ID_SIZE] = { 'D', 'L', 'S', 1 };
+      71             : char dltSerialHeaderChar[DLT_ID_SIZE] = { 'D', 'L', 'S', 1 };
+      72             : 
+      73             : #if defined DLT_DAEMON_USE_FIFO_IPC || defined DLT_LIB_USE_FIFO_IPC
+      74             : char dltFifoBaseDir[DLT_PATH_MAX] = "/tmp";
+      75             : #endif
+      76             : 
+      77             : #ifdef DLT_SHM_ENABLE
+      78             : char dltShmName[NAME_MAX + 1] = "/dlt-shm";
+      79             : #endif
+      80             : 
+      81             : static bool print_with_attributes = false;
+      82             : 
+      83             : char *message_type[] = { "log", "app_trace", "nw_trace", "control", "", "", "", "" };
+      84             : char *log_info[] = { "", "fatal", "error", "warn", "info", "debug", "verbose", "", "", "", "", "", "", "", "", "" };
+      85             : char *trace_type[] = { "", "variable", "func_in", "func_out", "state", "vfb", "", "", "", "", "", "", "", "", "", "" };
+      86             : char *nw_trace_type[] = { "", "ipc", "can", "flexray", "most", "vfb", "", "", "", "", "", "", "", "", "", "" };
+      87             : char *control_type[] = { "", "request", "response", "time", "", "", "", "", "", "", "", "", "", "", "", "" };
+      88             : static char *service_id_name[] =
+      89             : { "", "set_log_level", "set_trace_status", "get_log_info", "get_default_log_level", "store_config",
+      90             :   "reset_to_factory_default",
+      91             :   "set_com_interface_status", "set_com_interface_max_bandwidth", "set_verbose_mode",
+      92             :   "set_message_filtering", "set_timing_packets",
+      93             :   "get_local_time", "use_ecu_id", "use_session_id", "use_timestamp", "use_extended_header",
+      94             :   "set_default_log_level", "set_default_trace_status",
+      95             :   "get_software_version", "message_buffer_overflow" };
+      96             : static char *return_type[] =
+      97             : { "ok", "not_supported", "error", "perm_denied", "warning", "", "", "", "no_matching_context_id" };
+      98             : 
+      99             : /* internal function definitions */
+     100             : int dlt_buffer_get(DltBuffer *buf, unsigned char *data, int max_size, int delete);
+     101             : int dlt_buffer_reset(DltBuffer *buf);
+     102             : int dlt_buffer_increase_size(DltBuffer *buf);
+     103             : int dlt_buffer_minimize_size(DltBuffer *buf);
+     104             : void dlt_buffer_write_block(DltBuffer *buf, int *write, const unsigned char *data, unsigned int size);
+     105             : void dlt_buffer_read_block(DltBuffer *buf, int *read, unsigned char *data, unsigned int size);
+     106             : 
+     107             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+     108             : static int32_t dlt_output_soft_limit_over_warning(
+     109             :     DltTraceLoadSettings* tl_settings,
+     110             :     DltLogInternal log_internal,
+     111             :     void *log_params);
+     112             : 
+     113             : static int32_t dlt_output_hard_limit_warning(
+     114             :     DltTraceLoadSettings* tl_settings,
+     115             :     DltLogInternal log_internal,
+     116             :     void *log_params);
+     117             : 
+     118             : static bool dlt_user_cleanup_window(DltTraceLoadStat *tl_stat);
+     119             : 
+     120             : static int32_t dlt_switch_slot_if_needed(
+     121             :     DltTraceLoadSettings* tl_settings,
+     122             :     DltLogInternal log_internal,
+     123             :     void *log_internal_params,
+     124             :     uint32_t timestamp);
+     125             : 
+     126             : static void dlt_record_trace_load(DltTraceLoadStat *const tl_stat, int32_t size);
+     127             : static inline bool dlt_is_over_trace_load_soft_limit(DltTraceLoadSettings* tl_settings);
+     128             : static inline bool dlt_is_over_trace_load_hard_limit(DltTraceLoadSettings* tl_settings, int size);
+     129             : #endif
+     130             : 
+     131           0 : void dlt_print_hex(uint8_t *ptr, int size)
+     132             : {
+     133             :     int num;
+     134             : 
+     135           0 :     if (ptr == NULL)
+     136             :         return;
+     137             : 
+     138           0 :     for (num = 0; num < size; num++) {
+     139           0 :         if (num > 0)
+     140           0 :             dlt_user_printf(" ");
+     141             : 
+     142           0 :         dlt_user_printf("%.2x", ((uint8_t *)ptr)[num]);
+     143             :     }
+     144             : }
+     145             : 
+     146        2733 : static DltReturnValue dlt_print_hex_string_delim(char *text, int textlength, uint8_t *ptr, int size, char delim)
+     147             : {
+     148             :     int num;
+     149             : 
+     150        2733 :     if ((ptr == NULL) || (text == NULL) || (textlength <= 0) || (size < 0) || (delim == '\0'))
+     151             :         return DLT_RETURN_WRONG_PARAMETER;
+     152             : 
+     153             :     /* Length 3: AB_ , A is first digit of hex number, B is second digit of hex number, _ is space */
+     154        2730 :     if (textlength < (size * 3)) {
+     155           0 :         dlt_vlog(LOG_WARNING,
+     156             :                  "String does not fit hex data (available=%d, required=%d) !\n",
+     157             :                  textlength, size * 3);
+     158           0 :         return DLT_RETURN_ERROR;
+     159             :     }
+     160             : 
+     161       36449 :     for (num = 0; num < size; num++) {
+     162       33719 :         if (num > 0) {
+     163       31017 :             snprintf(text, 2, "%c", delim);
+     164       31017 :             text++;
+     165             :         }
+     166             : 
+     167       33719 :         snprintf(text, 3, "%.2x", ((uint8_t *)ptr)[num]);
+     168       33719 :         text += 2; /* 2 chars */
+     169             :     }
+     170             : 
+     171             :     return DLT_RETURN_OK;
+     172             : }
+     173             : 
+     174        2724 : DltReturnValue dlt_print_hex_string(char *text, int textlength, uint8_t *ptr, int size)
+     175             : {
+     176        2724 :     return dlt_print_hex_string_delim(text, textlength, ptr, size, ' ');
+     177             : }
+     178             : 
+     179        1062 : DltReturnValue dlt_print_mixed_string(char *text, int textlength, uint8_t *ptr, int size, int html)
+     180             : {
+     181             :     int required_size = 0;
+     182             :     int lines, rest, i;
+     183             : 
+     184        1062 :     if ((ptr == NULL) || (text == NULL) || (textlength <= 0) || (size < 0))
+     185             :         return DLT_RETURN_WRONG_PARAMETER;
+     186             : 
+     187             :     /* Check maximum required size and do a length check */
+     188        1056 :     if (html == 0)
+     189         528 :         required_size =
+     190             :             (DLT_COMMON_HEX_LINELEN + (2 * DLT_COMMON_HEX_CHARS + (DLT_COMMON_HEX_CHARS - 1)) + DLT_COMMON_CHARLEN +
+     191             :              DLT_COMMON_HEX_CHARS + DLT_COMMON_CHARLEN) *
+     192         528 :             ((size / DLT_COMMON_HEX_CHARS) + 1);
+     193             :     /* Example: (8 chars line number + (2*16 chars + 15 spaces) + space + 16 ascii chars + CR) *
+     194             :      * ((size/16) lines + extra line for the rest) */
+     195             :     else
+     196         528 :         required_size =
+     197             :             (DLT_COMMON_HEX_LINELEN + (2 * DLT_COMMON_HEX_CHARS + (DLT_COMMON_HEX_CHARS - 1)) + DLT_COMMON_CHARLEN +
+     198             :              DLT_COMMON_HEX_CHARS + 4 * DLT_COMMON_CHARLEN) *
+     199         528 :             ((size / DLT_COMMON_HEX_CHARS) + 1);
+     200             : 
+     201             :     /* Example: (8 chars line number + (2*16 chars + 15 spaces) + space + 16 ascii chars + 4 [HTML CR: <BR>]) *
+     202             :      * ((size/16) lines + extra line for the rest) */
+     203             : 
+     204        1056 :     if (textlength < required_size) {
+     205           0 :         dlt_vlog(LOG_WARNING,
+     206             :                  "String does not fit mixed data (available=%d, required=%d) !\n",
+     207             :                  textlength, required_size);
+     208           0 :         return DLT_RETURN_ERROR;
+     209             :     }
+     210             : 
+     211             :     /* print full lines */
+     212        1728 :     for (lines = 0; lines < (size / DLT_COMMON_HEX_CHARS); lines++) {
+     213             :         int ret = 0;
+     214             :         /* Line number */
+     215         672 :         ret = snprintf(text, DLT_COMMON_HEX_LINELEN + 1, "%.6x: ", (uint32_t)lines * DLT_COMMON_HEX_CHARS);
+     216             : 
+     217         672 :         if ((ret < 0) || (ret >= (DLT_COMMON_HEX_LINELEN + 1)))
+     218           0 :             dlt_log(LOG_WARNING, "line was truncated\n");
+     219             : 
+     220         672 :         text += DLT_COMMON_HEX_LINELEN; /* 'XXXXXX: ' */
+     221             : 
+     222             :         /* Hex-Output */
+     223             :         /* It is not required to decrement textlength, as it was already checked, that
+     224             :          * there is enough space for the complete output */
+     225         672 :         if (dlt_print_hex_string(text, textlength,
+     226         672 :                 (uint8_t *)(ptr + (lines * DLT_COMMON_HEX_CHARS)),
+     227             :                 DLT_COMMON_HEX_CHARS) < DLT_RETURN_OK)
+     228             :             return DLT_RETURN_ERROR;
+     229         672 :         text += ((2 * DLT_COMMON_HEX_CHARS) + (DLT_COMMON_HEX_CHARS - 1)); /* 32 characters + 15 spaces */
+     230             : 
+     231             :         snprintf(text, 2, " ");
+     232         672 :         text += DLT_COMMON_CHARLEN;
+     233             : 
+     234             :         /* Char-Output */
+     235             :         /* It is not required to decrement textlength, as it was already checked, that
+     236             :          * there is enough space for the complete output */
+     237         672 :         if (dlt_print_char_string(&text, textlength,
+     238             :                 (uint8_t *)(ptr + (lines * DLT_COMMON_HEX_CHARS)),
+     239             :                 DLT_COMMON_HEX_CHARS) < DLT_RETURN_OK)
+     240             :             return DLT_RETURN_ERROR;
+     241             : 
+     242         672 :         if (html == 0) {
+     243         336 :             snprintf(text, 2, "\n");
+     244         336 :             text += DLT_COMMON_CHARLEN;
+     245             :         }
+     246             :         else {
+     247         336 :             snprintf(text, 5, "<BR>");
+     248         336 :             text += (4 * DLT_COMMON_CHARLEN);
+     249             :         }
+     250             :     }
+     251             : 
+     252             :     /* print partial line */
+     253        1056 :     rest = size % DLT_COMMON_HEX_CHARS;
+     254             : 
+     255        1056 :     if (rest > 0) {
+     256             :         /* Line number */
+     257             :         int ret = 0;
+     258         984 :         ret = snprintf(text, 9, "%.6x: ", (uint32_t)(size / DLT_COMMON_HEX_CHARS) * DLT_COMMON_HEX_CHARS);
+     259             : 
+     260         984 :         if ((ret < 0) || (ret >= 9))
+     261           0 :             dlt_log(LOG_WARNING, "line number was truncated");
+     262             : 
+     263         984 :         text += DLT_COMMON_HEX_LINELEN; /* 'XXXXXX: ' */
+     264             : 
+     265             :         /* Hex-Output */
+     266             :         /* It is not required to decrement textlength, as it was already checked, that
+     267             :          * there is enough space for the complete output */
+     268         984 :         if (dlt_print_hex_string(text,
+     269             :                              textlength,
+     270         984 :                              (uint8_t *)(ptr + ((size / DLT_COMMON_HEX_CHARS) * DLT_COMMON_HEX_CHARS)),
+     271             :                              rest) < DLT_RETURN_OK)
+     272             :             return DLT_RETURN_ERROR;
+     273         984 :         text += 2 * rest + (rest - 1);
+     274             : 
+     275        9450 :         for (i = 0; i < (DLT_COMMON_HEX_CHARS - rest); i++) {
+     276        8466 :             snprintf(text, 4, " xx");
+     277        8466 :             text += (3 * DLT_COMMON_CHARLEN);
+     278             :         }
+     279             : 
+     280         984 :         snprintf(text, 2, " ");
+     281         984 :         text += DLT_COMMON_CHARLEN;
+     282             : 
+     283             :         /* Char-Output */
+     284             :         /* It is not required to decrement textlength, as it was already checked, that
+     285             :          * there is enough space for the complete output */
+     286         984 :         if (dlt_print_char_string(&text, textlength,
+     287             :                               (uint8_t *)(ptr + ((size / DLT_COMMON_HEX_CHARS) * DLT_COMMON_HEX_CHARS)),
+     288             :                               rest) < DLT_RETURN_OK)
+     289           0 :             return DLT_RETURN_ERROR;
+     290             :     }
+     291             : 
+     292             :     return DLT_RETURN_OK;
+     293             : }
+     294             : 
+     295        1661 : DltReturnValue dlt_print_char_string(char **text, int textlength, uint8_t *ptr, int size)
+     296             : {
+     297             :     int num;
+     298             : 
+     299        1661 :     if ((text == NULL) || (ptr == NULL) || (*text == NULL) || (textlength <= 0) || (size < 0))
+     300             :         return DLT_RETURN_WRONG_PARAMETER;
+     301             : 
+     302        1658 :     if (textlength < size) {
+     303           0 :         dlt_vlog(LOG_WARNING,
+     304             :                  "String does not fit character data (available=%d, required=%d) !\n",
+     305             :                  textlength, size);
+     306           0 :         return DLT_RETURN_WRONG_PARAMETER;
+     307             :     }
+     308             : 
+     309       19729 :     for (num = 0; num < size; num++) {
+     310       18071 :         if ((((char *)ptr)[num] < DLT_COMMON_ASCII_CHAR_SPACE) || (((char *)ptr)[num] > DLT_COMMON_ASCII_CHAR_TILDE)) {
+     311       10240 :             snprintf(*text, 2, ".");
+     312             :         }
+     313             :         else {
+     314             :             /* replace < with . */
+     315        7831 :             if (((char *)ptr)[num] != DLT_COMMON_ASCII_CHAR_LT)
+     316        7831 :                 snprintf(*text, 2, "%c", ((char *)ptr)[num]);
+     317             :             else
+     318           0 :                 snprintf(*text, 2, ".");
+     319             :         }
+     320             : 
+     321       18071 :         (*text)++;
+     322             :     }
+     323             : 
+     324             :     return DLT_RETURN_OK;
+     325             : }
+     326             : 
+     327        5622 : size_t dlt_strnlen_s(const char* str, size_t maxsize)
+     328             : {
+     329        5622 :     if (str == NULL)
+     330             :         return 0;
+     331             : 
+     332       24796 :     for (size_t i = 0; i < maxsize; ++i) {
+     333       22517 :         if (str[i] == '\0')
+     334        3342 :             return i;
+     335             :     }
+     336             :     return maxsize;
+     337             : }
+     338             : 
+     339        5620 : void dlt_print_id(char *text, const char *id)
+     340             : {
+     341             :     /* check nullpointer */
+     342        5620 :     if ((text == NULL) || (id == NULL))
+     343             :         return;
+     344             : 
+     345             :     /* Initialize text */
+     346             :     memset(text, '-', DLT_ID_SIZE);
+     347             : 
+     348        5617 :     text[DLT_ID_SIZE] = 0;
+     349             : 
+     350        5617 :     size_t len = dlt_strnlen_s(id, DLT_ID_SIZE);
+     351             : 
+     352             :     memcpy(text, id, len);
+     353             : }
+     354             : 
+     355       77315 : void dlt_set_id(char *id, const char *text)
+     356             : {
+     357             :     /* check nullpointer */
+     358       77315 :     if ((id == NULL) || (text == NULL))
+     359             :         return;
+     360             : 
+     361       77312 :     id[0] = 0;
+     362       77312 :     id[1] = 0;
+     363       77312 :     id[2] = 0;
+     364       70773 :     id[3] = 0;
+     365             : 
+     366       77312 :     if (text[0] != 0)
+     367       49545 :         id[0] = text[0];
+     368             :     else
+     369             :         return;
+     370             : 
+     371       49545 :     if (text[1] != 0)
+     372       49539 :         id[1] = text[1];
+     373             :     else
+     374             :         return;
+     375             : 
+     376       49539 :     if (text[2] != 0)
+     377       49531 :         id[2] = text[2];
+     378             :     else
+     379             :         return;
+     380             : 
+     381       49531 :     if (text[3] != 0)
+     382       49354 :         id[3] = text[3];
+     383             :     else
+     384             :         return;
+     385             : }
+     386             : 
+     387        1159 : void dlt_clean_string(char *text, int length)
+     388             : {
+     389             :     int num;
+     390             : 
+     391        1159 :     if (text == NULL)
+     392             :         return;
+     393             : 
+     394       10286 :     for (num = 0; num < length; num++)
+     395        9127 :         if ((text[num] == '\r') || (text[num] == '\n'))
+     396           0 :             text[num] = ' ';
+     397             : }
+     398             : 
+     399           7 : DltReturnValue dlt_filter_init(DltFilter *filter, int verbose)
+     400             : {
+     401           7 :     PRINT_FUNCTION_VERBOSE(verbose);
+     402             : 
+     403           7 :     if (filter == NULL)
+     404             :         return DLT_RETURN_WRONG_PARAMETER;
+     405             : 
+     406           7 :     filter->counter = 0;
+     407             : 
+     408           7 :     return DLT_RETURN_OK;
+     409             : }
+     410             : 
+     411           1 : DltReturnValue dlt_filter_free(DltFilter *filter, int verbose)
+     412             : {
+     413           1 :     PRINT_FUNCTION_VERBOSE(verbose);
+     414             : 
+     415           1 :     if (filter == NULL)
+     416           0 :         return DLT_RETURN_WRONG_PARAMETER;
+     417             : 
+     418             :     return DLT_RETURN_OK;
+     419             : }
+     420             : 
+     421           6 : DltReturnValue dlt_filter_load(DltFilter *filter, const char *filename, int verbose)
+     422             : {
+     423           6 :     if ((filter == NULL) || (filename == NULL))
+     424             :         return DLT_RETURN_WRONG_PARAMETER;
+     425             : 
+     426             :     FILE *handle;
+     427             :     char str1[DLT_COMMON_BUFFER_LENGTH + 1];
+     428             :     char apid[DLT_ID_SIZE], ctid[DLT_ID_SIZE];
+     429             : 
+     430           6 :     PRINT_FUNCTION_VERBOSE(verbose);
+     431             : 
+     432           6 :     handle = fopen(filename, "r");
+     433             : 
+     434           6 :     if (handle == NULL) {
+     435           0 :         dlt_vlog(LOG_WARNING, "Filter file %s cannot be opened!\n", filename);
+     436           0 :         return DLT_RETURN_ERROR;
+     437             :     }
+     438             : 
+     439             :     #define FORMAT_STRING_(x) "%" #x "s"
+     440             :     #define FORMAT_STRING(x) FORMAT_STRING_(x)
+     441             : 
+     442             :     /* Reset filters */
+     443           6 :     filter->counter = 0;
+     444             : 
+     445          18 :     while (!feof(handle)) {
+     446          18 :         str1[0] = 0;
+     447             : 
+     448          18 :         if (fscanf(handle, FORMAT_STRING(DLT_COMMON_BUFFER_LENGTH), str1) != 1)
+     449             :             break;
+     450             : 
+     451          12 :         if (str1[0] == 0)
+     452             :             break;
+     453             : 
+     454             :         printf(" %s", str1);
+     455             : 
+     456          12 :         if (strcmp(str1, "----") == 0)
+     457           0 :             dlt_set_id(apid, "");
+     458             :         else
+     459          12 :             dlt_set_id(apid, str1);
+     460             : 
+     461          12 :         str1[0] = 0;
+     462             : 
+     463          12 :         if (fscanf(handle, FORMAT_STRING(DLT_COMMON_BUFFER_LENGTH), str1) != 1)
+     464             :             break;
+     465             : 
+     466          12 :         if (str1[0] == 0)
+     467             :             break;
+     468             : 
+     469             :         printf(" %s\r\n", str1);
+     470             : 
+     471          12 :         if (strcmp(str1, "----") == 0)
+     472           0 :             dlt_set_id(ctid, "");
+     473             :         else
+     474          12 :             dlt_set_id(ctid, str1);
+     475             : 
+     476          12 :         if (filter->counter < DLT_FILTER_MAX)
+     477          12 :             dlt_filter_add(filter, apid, ctid, 0, 0, INT32_MAX, verbose);
+     478             :         else
+     479           0 :             dlt_vlog(LOG_WARNING,
+     480             :                      "Maximum number (%d) of allowed filters reached, ignoring rest of filters!\n",
+     481             :                      DLT_FILTER_MAX);
+     482             :     }
+     483             : 
+     484           6 :     fclose(handle);
+     485             : 
+     486           6 :     return DLT_RETURN_OK;
+     487             : }
+     488             : 
+     489           0 : DltReturnValue dlt_filter_save(DltFilter *filter, const char *filename, int verbose)
+     490             : {
+     491           0 :     if ((filter == NULL) || (filename == NULL))
+     492             :         return DLT_RETURN_WRONG_PARAMETER;
+     493             : 
+     494             :     FILE *handle;
+     495             :     int num;
+     496             :     char buf[DLT_COMMON_BUFFER_LENGTH];
+     497             : 
+     498           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+     499             : 
+     500           0 :     handle = fopen(filename, "w");
+     501             : 
+     502           0 :     if (handle == NULL) {
+     503           0 :         dlt_vlog(LOG_WARNING, "Filter file %s cannot be opened!\n", filename);
+     504           0 :         return DLT_RETURN_ERROR;
+     505             :     }
+     506             : 
+     507           0 :     for (num = 0; num < filter->counter; num++) {
+     508           0 :         if (filter->apid[num][0] == 0) {
+     509             :             fprintf(handle, "---- ");
+     510             :         }
+     511             :         else {
+     512           0 :             dlt_print_id(buf, filter->apid[num]);
+     513             :             fprintf(handle, "%s ", buf);
+     514             :         }
+     515             : 
+     516           0 :         if (filter->ctid[num][0] == 0) {
+     517             :             fprintf(handle, "---- ");
+     518             :         }
+     519             :         else {
+     520           0 :             dlt_print_id(buf, filter->ctid[num]);
+     521             :             fprintf(handle, "%s ", buf);
+     522             :         }
+     523             :     }
+     524             : 
+     525           0 :     fclose(handle);
+     526             : 
+     527           0 :     return DLT_RETURN_OK;
+     528             : }
+     529             : 
+     530          12 : int dlt_filter_find(DltFilter *filter, const char *apid, const char *ctid, const int log_level,
+     531             :                     const int32_t payload_min, const int32_t payload_max, int verbose)
+     532             : {
+     533             :     int num;
+     534             : 
+     535          12 :     PRINT_FUNCTION_VERBOSE(verbose);
+     536             : 
+     537          12 :     if ((filter == NULL) || (apid == NULL))
+     538             :         return -1;
+     539             : 
+     540          18 :     for (num = 0; num < filter->counter; num++)
+     541           6 :         if (memcmp(filter->apid[num], apid, DLT_ID_SIZE) == 0) {
+     542             :             /* apid matches, now check for ctid */
+     543           0 :             if (ctid == NULL) {
+     544             :                 /* check if empty ctid matches */
+     545             :                 /*if (memcmp(filter->ctid[num],"",DLT_ID_SIZE)==0)//coverity complains here about Out-of-bounds access. */
+     546           0 :                 char empty_ctid[DLT_ID_SIZE] = "";
+     547             : 
+     548           0 :                 if (memcmp(filter->ctid[num], empty_ctid, DLT_ID_SIZE) == 0)
+     549           0 :                     if ((filter->log_level[num] == log_level) || (filter->log_level[num] == 0))
+     550           0 :                         if (filter->payload_min[num] <= payload_min)
+     551           0 :                             if (filter->payload_max[num] >= payload_max)
+     552           0 :                                 return num;
+     553             :             }
+     554           0 :             else if (memcmp(filter->ctid[num], ctid, DLT_ID_SIZE) == 0)
+     555             :             {
+     556           0 :                 if ((filter->log_level[num] == log_level) || (filter->log_level[num] == 0))
+     557           0 :                     if (filter->payload_min[num] <= payload_min)
+     558           0 :                         if (filter->payload_max[num] >= payload_max)
+     559           0 :                             return num;
+     560             :             }
+     561             :         }
+     562             : 
+     563             :     return -1; /* Not found */
+     564             : }
+     565             : 
+     566          12 : DltReturnValue dlt_filter_add(DltFilter *filter, const char *apid, const char *ctid, const int log_level,
+     567             :                               const int32_t payload_min, const int32_t payload_max, int verbose)
+     568             : {
+     569          12 :     PRINT_FUNCTION_VERBOSE(verbose);
+     570             : 
+     571          12 :     if ((filter == NULL) || (apid == NULL))
+     572             :         return DLT_RETURN_WRONG_PARAMETER;
+     573             : 
+     574          12 :     if (filter->counter >= DLT_FILTER_MAX) {
+     575           0 :         dlt_vlog(LOG_WARNING,
+     576             :                  "Maximum number (%d) of allowed filters reached, ignoring filter!\n",
+     577             :                  DLT_FILTER_MAX);
+     578           0 :         return DLT_RETURN_ERROR;
+     579             :     }
+     580             : 
+     581             :     /* add each filter (apid, ctid, log_level, payload_min, payload_max) only once to filter array */
+     582          12 :     if (dlt_filter_find(filter, apid, ctid, log_level, payload_min, payload_max, verbose) < 0) {
+     583             :         /* filter not found, so add it to filter array */
+     584          12 :         dlt_set_id(filter->apid[filter->counter], apid);
+     585          12 :         dlt_set_id(filter->ctid[filter->counter], (ctid ? ctid : ""));
+     586          12 :         filter->log_level[filter->counter] = log_level;
+     587          12 :         filter->payload_min[filter->counter] = payload_min;
+     588          12 :         filter->payload_max[filter->counter] = payload_max;
+     589             : 
+     590          12 :         filter->counter++;
+     591             : 
+     592          12 :         return DLT_RETURN_OK;
+     593             :     }
+     594             : 
+     595             :     return DLT_RETURN_ERROR;
+     596             : }
+     597             : 
+     598           0 : DltReturnValue dlt_filter_delete(DltFilter *filter, const char *apid, const char *ctid, const int log_level,
+     599             :                                  const int32_t payload_min, const int32_t payload_max, int verbose)
+     600             : {
+     601             :     int j, k;
+     602             :     int found = 0;
+     603             : 
+     604           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+     605             : 
+     606           0 :     if ((filter == NULL) || (apid == NULL) || (ctid == NULL))
+     607             :         return DLT_RETURN_WRONG_PARAMETER;
+     608             : 
+     609           0 :     if (filter->counter > 0) {
+     610             :         /* Get first occurence of apid and ctid in filter array */
+     611           0 :         for (j = 0; j < filter->counter; j++)
+     612           0 :             if ((memcmp(filter->apid[j], apid, DLT_ID_SIZE) == 0) &&
+     613           0 :                 (memcmp(filter->ctid[j], ctid, DLT_ID_SIZE) == 0) &&
+     614           0 :                 ((filter->log_level[j] == log_level) || (filter->log_level[j] == 0)) &&
+     615           0 :                 (filter->payload_min[j] == payload_min) &&
+     616           0 :                 (filter->payload_max[j] == payload_max)
+     617             :                 ) {
+     618             :                 found = 1;
+     619             :                 break;
+     620             :             }
+     621             : 
+     622           0 :         if (found) {
+     623             :             /* j is index */
+     624             :             /* Copy from j+1 til end to j til end-1 */
+     625             : 
+     626           0 :             dlt_set_id(filter->apid[j], "");
+     627           0 :             dlt_set_id(filter->ctid[j], "");
+     628           0 :             filter->log_level[j] = 0;
+     629           0 :             filter->payload_min[j] = 0;
+     630           0 :             filter->payload_max[j] = INT32_MAX;
+     631             : 
+     632           0 :             for (k = j; k < (filter->counter - 1); k++) {
+     633           0 :                 dlt_set_id(filter->apid[k], filter->apid[k + 1]);
+     634           0 :                 dlt_set_id(filter->ctid[k], filter->ctid[k + 1]);
+     635           0 :                 filter->log_level[k] = filter->log_level[k + 1];
+     636           0 :                 filter->payload_min[k] = filter->payload_min[k + 1];
+     637           0 :                 filter->payload_max[k] = filter->payload_max[k + 1];
+     638             :             }
+     639             : 
+     640           0 :             filter->counter--;
+     641           0 :             return DLT_RETURN_OK;
+     642             :         }
+     643             :     }
+     644             : 
+     645             :     return DLT_RETURN_ERROR;
+     646             : }
+     647             : 
+     648        6109 : DltReturnValue dlt_message_init(DltMessage *msg, int verbose)
+     649             : {
+     650        6109 :     PRINT_FUNCTION_VERBOSE(verbose);
+     651             : 
+     652        6109 :     if (msg == NULL)
+     653             :         return DLT_RETURN_WRONG_PARAMETER;
+     654             : 
+     655             :     /* initalise structure parameters */
+     656        6107 :     msg->headersize = 0;
+     657        6107 :     msg->datasize = 0;
+     658             : 
+     659        6107 :     msg->databuffer = NULL;
+     660        6107 :     msg->databuffersize = 0;
+     661             : 
+     662        6107 :     msg->storageheader = NULL;
+     663        6107 :     msg->standardheader = NULL;
+     664        6107 :     msg->extendedheader = NULL;
+     665             : 
+     666        6107 :     msg->found_serialheader = 0;
+     667             : 
+     668        6107 :     return DLT_RETURN_OK;
+     669             : }
+     670             : 
+     671         107 : DltReturnValue dlt_message_free(DltMessage *msg, int verbose)
+     672             : {
+     673         107 :     PRINT_FUNCTION_VERBOSE(verbose);
+     674             : 
+     675         107 :     if (msg == NULL)
+     676             :         return DLT_RETURN_WRONG_PARAMETER;
+     677             : 
+     678             :     /* delete databuffer if exists */
+     679         105 :     if (msg->databuffer) {
+     680          82 :         free(msg->databuffer);
+     681          82 :         msg->databuffer = NULL;
+     682          82 :         msg->databuffersize = 0;
+     683             :     }
+     684             : 
+     685             :     return DLT_RETURN_OK;
+     686             : }
+     687             : 
+     688        2420 : DltReturnValue dlt_message_header(DltMessage *msg, char *text, size_t textlength, int verbose)
+     689             : {
+     690        2420 :     return dlt_message_header_flags(msg, text, textlength, DLT_HEADER_SHOW_ALL, verbose);
+     691             : }
+     692             : 
+     693        5122 : DltReturnValue dlt_message_header_flags(DltMessage *msg, char *text, size_t textlength, int flags, int verbose)
+     694             : {
+     695             :     struct tm timeinfo;
+     696             :     char buffer [DLT_COMMON_BUFFER_LENGTH];
+     697             : 
+     698        5122 :     PRINT_FUNCTION_VERBOSE(verbose);
+     699             : 
+     700        5122 :     if ((msg == NULL) || (text == NULL) || (textlength <= 0))
+     701             :         return DLT_RETURN_WRONG_PARAMETER;
+     702             : 
+     703        4926 :     if ((DLT_IS_HTYP_UEH(msg->standardheader->htyp)) && (msg->extendedheader == NULL))
+     704             :         return DLT_RETURN_WRONG_PARAMETER;
+     705             : 
+     706        4926 :     if ((flags < DLT_HEADER_SHOW_NONE) || (flags > DLT_HEADER_SHOW_ALL))
+     707             :         return DLT_RETURN_WRONG_PARAMETER;
+     708             : 
+     709        4926 :     text[0] = 0;
+     710             : 
+     711        4926 :     if ((flags & DLT_HEADER_SHOW_TIME) == DLT_HEADER_SHOW_TIME) {
+     712             :         /* print received time */
+     713        2826 :         time_t tt = msg->storageheader->seconds;
+     714        2826 :         tzset();
+     715        2826 :         localtime_r(&tt, &timeinfo);
+     716        2826 :         strftime (buffer, sizeof(buffer), "%Y/%m/%d %H:%M:%S", &timeinfo);
+     717        2826 :         snprintf(text, textlength, "%s.%.6d ", buffer, msg->storageheader->microseconds);
+     718             :     }
+     719             : 
+     720        4926 :     if ((flags & DLT_HEADER_SHOW_TMSTP) == DLT_HEADER_SHOW_TMSTP) {
+     721             :         /* print timestamp if available */
+     722        2826 :         if (DLT_IS_HTYP_WTMS(msg->standardheader->htyp))
+     723         647 :             snprintf(text + strlen(text), textlength - strlen(text), "%10u ", msg->headerextra.tmsp);
+     724             :         else
+     725        2179 :             snprintf(text + strlen(text), textlength - strlen(text), "---------- ");
+     726             :     }
+     727             : 
+     728        4926 :     if ((flags & DLT_HEADER_SHOW_MSGCNT) == DLT_HEADER_SHOW_MSGCNT)
+     729             :         /* print message counter */
+     730        2826 :         snprintf(text + strlen(text), textlength - strlen(text), "%.3d ", msg->standardheader->mcnt);
+     731             : 
+     732        4926 :     if ((flags & DLT_HEADER_SHOW_ECUID) == DLT_HEADER_SHOW_ECUID) {
+     733             :         /* print ecu id, use header extra if available, else storage header value */
+     734        2826 :         if (DLT_IS_HTYP_WEID(msg->standardheader->htyp))
+     735         647 :             dlt_print_id(text + strlen(text), msg->headerextra.ecu);
+     736             :         else
+     737        2179 :             dlt_print_id(text + strlen(text), msg->storageheader->ecu);
+     738             :     }
+     739             : 
+     740             :     /* print app id and context id if extended header available, else '----' */ #
+     741             : 
+     742        4926 :     if ((flags & DLT_HEADER_SHOW_APID) == DLT_HEADER_SHOW_APID) {
+     743        2826 :         snprintf(text + strlen(text), textlength - strlen(text), " ");
+     744             : 
+     745        2826 :         if ((DLT_IS_HTYP_UEH(msg->standardheader->htyp)) && (msg->extendedheader->apid[0] != 0))
+     746        1395 :             dlt_print_id(text + strlen(text), msg->extendedheader->apid);
+     747             :         else
+     748        1431 :             snprintf(text + strlen(text), textlength - strlen(text), "----");
+     749             : 
+     750        2826 :         snprintf(text + strlen(text), textlength - strlen(text), " ");
+     751             :     }
+     752             : 
+     753        4926 :     if ((flags & DLT_HEADER_SHOW_CTID) == DLT_HEADER_SHOW_CTID) {
+     754        2826 :         if ((DLT_IS_HTYP_UEH(msg->standardheader->htyp)) && (msg->extendedheader->ctid[0] != 0))
+     755        1395 :             dlt_print_id(text + strlen(text), msg->extendedheader->ctid);
+     756             :         else
+     757        1431 :             snprintf(text + strlen(text), textlength - strlen(text), "----");
+     758             : 
+     759        2826 :         snprintf(text + strlen(text), textlength - strlen(text), " ");
+     760             :     }
+     761             : 
+     762             :     /* print info about message type and length */
+     763        4926 :     if (DLT_IS_HTYP_UEH(msg->standardheader->htyp)) {
+     764        2435 :         if ((flags & DLT_HEADER_SHOW_MSGTYPE) == DLT_HEADER_SHOW_MSGTYPE) {
+     765        1395 :             snprintf(text + strlen(text), textlength - strlen(text), "%s",
+     766        1395 :                      message_type[DLT_GET_MSIN_MSTP(msg->extendedheader->msin)]);
+     767        1395 :             snprintf(text + strlen(text), textlength - strlen(text), " ");
+     768             :         }
+     769             : 
+     770        2435 :         if ((flags & DLT_HEADER_SHOW_MSGSUBTYPE) == DLT_HEADER_SHOW_MSGSUBTYPE) {
+     771        1395 :             if ((DLT_GET_MSIN_MSTP(msg->extendedheader->msin)) == DLT_TYPE_LOG)
+     772        1256 :                 snprintf(text + strlen(text), textlength - strlen(text), "%s",
+     773        1256 :                          log_info[DLT_GET_MSIN_MTIN(msg->extendedheader->msin)]);
+     774             : 
+     775        1395 :             if ((DLT_GET_MSIN_MSTP(msg->extendedheader->msin)) == DLT_TYPE_APP_TRACE)
+     776           0 :                 snprintf(text + strlen(text), textlength - strlen(text), "%s",
+     777           0 :                          trace_type[DLT_GET_MSIN_MTIN(msg->extendedheader->msin)]);
+     778             : 
+     779        1395 :             if ((DLT_GET_MSIN_MSTP(msg->extendedheader->msin)) == DLT_TYPE_NW_TRACE)
+     780           0 :                 snprintf(text + strlen(text), textlength - strlen(text), "%s",
+     781           0 :                          nw_trace_type[DLT_GET_MSIN_MTIN(msg->extendedheader->msin)]);
+     782             : 
+     783        1395 :             if ((DLT_GET_MSIN_MSTP(msg->extendedheader->msin)) == DLT_TYPE_CONTROL)
+     784         139 :                 snprintf(text + strlen(text), textlength - strlen(text), "%s",
+     785         139 :                          control_type[DLT_GET_MSIN_MTIN(msg->extendedheader->msin)]);
+     786             : 
+     787        1395 :             snprintf(text + strlen(text), textlength - strlen(text), " ");
+     788             :         }
+     789             : 
+     790        2435 :         if ((flags & DLT_HEADER_SHOW_VNVSTATUS) == DLT_HEADER_SHOW_VNVSTATUS) {
+     791             :             /* print verbose status pf message */
+     792        1395 :             if (DLT_IS_MSIN_VERB(msg->extendedheader->msin))
+     793        1256 :                 snprintf(text + strlen(text), textlength - strlen(text), "V");
+     794             :             else
+     795         139 :                 snprintf(text + strlen(text), textlength - strlen(text), "N");
+     796             : 
+     797        1395 :             snprintf(text + strlen(text), textlength - strlen(text), " ");
+     798             :         }
+     799             : 
+     800        2435 :         if ((flags & DLT_HEADER_SHOW_NOARG) == DLT_HEADER_SHOW_NOARG)
+     801             :             /* print number of arguments */
+     802        1395 :             snprintf(text + strlen(text), textlength - strlen(text), "%d", msg->extendedheader->noar);
+     803             :     }
+     804             :     else {
+     805        2491 :         if ((flags & DLT_HEADER_SHOW_MSGTYPE) == DLT_HEADER_SHOW_MSGTYPE)
+     806        1431 :             snprintf(text + strlen(text), textlength - strlen(text), "--- ");
+     807             : 
+     808        2491 :         if ((flags & DLT_HEADER_SHOW_MSGSUBTYPE) == DLT_HEADER_SHOW_MSGSUBTYPE)
+     809        1431 :             snprintf(text + strlen(text), textlength - strlen(text), "--- ");
+     810             : 
+     811        2491 :         if ((flags & DLT_HEADER_SHOW_VNVSTATUS) == DLT_HEADER_SHOW_VNVSTATUS)
+     812        1431 :             snprintf(text + strlen(text), textlength - strlen(text), "N ");
+     813             : 
+     814        2491 :         if ((flags & DLT_HEADER_SHOW_NOARG) == DLT_HEADER_SHOW_NOARG)
+     815        1431 :             snprintf(text + strlen(text), textlength - strlen(text), "-");
+     816             :     }
+     817             : 
+     818             :     return DLT_RETURN_OK;
+     819             : }
+     820             : 
+     821        3131 : DltReturnValue dlt_message_payload(DltMessage *msg, char *text, size_t textlength, int type, int verbose)
+     822             : {
+     823             :     uint32_t id = 0, id_tmp = 0;
+     824             :     uint8_t retval = 0;
+     825             : 
+     826             :     uint8_t *ptr;
+     827             :     int32_t datalength;
+     828             : 
+     829             :     /* Pointer to ptr and datalength */
+     830             :     uint8_t **pptr;
+     831             :     int32_t *pdatalength;
+     832             : 
+     833             :     int ret = 0;
+     834             : 
+     835             :     int num;
+     836             :     uint32_t type_info = 0, type_info_tmp = 0;
+     837             :     int text_offset = 0;
+     838             : 
+     839        3131 :     PRINT_FUNCTION_VERBOSE(verbose);
+     840             : 
+     841        3131 :     if ((msg == NULL) || (msg->databuffer == NULL) || (text == NULL) ||
+     842        3072 :         (type < DLT_OUTPUT_HEX) || (type > DLT_OUTPUT_ASCII_LIMITED))
+     843             :         return DLT_RETURN_WRONG_PARAMETER;
+     844             : 
+     845        2941 :     if (textlength <= 0) {
+     846          10 :         dlt_log(LOG_WARNING, "String does not fit binary data!\n");
+     847          10 :         return DLT_RETURN_WRONG_PARAMETER;
+     848             :     }
+     849             : 
+     850             :     /* start with empty string */
+     851        2931 :     text[0] = 0;
+     852             : 
+     853             :     /* print payload only as hex */
+     854        2931 :     if (type == DLT_OUTPUT_HEX)
+     855         526 :         return dlt_print_hex_string(text, (int)textlength, msg->databuffer, (int)msg->datasize);
+     856             : 
+     857             :     /* print payload as mixed */
+     858        2405 :     if (type == DLT_OUTPUT_MIXED_FOR_PLAIN)
+     859         526 :         return dlt_print_mixed_string(text, (int)textlength, msg->databuffer, (int)msg->datasize, 0);
+     860             : 
+     861        1879 :     if (type == DLT_OUTPUT_MIXED_FOR_HTML)
+     862         526 :         return dlt_print_mixed_string(text, (int)textlength, msg->databuffer, (int)msg->datasize, 1);
+     863             : 
+     864        1353 :     ptr = msg->databuffer;
+     865        1353 :     datalength = (int32_t)msg->datasize;
+     866             : 
+     867             :     /* Pointer to ptr and datalength */
+     868             :     pptr = &ptr;
+     869             :     pdatalength = &datalength;
+     870             : 
+     871             :     /* non-verbose mode */
+     872             : 
+     873             :     /* print payload as hex */
+     874        1353 :     if (DLT_MSG_IS_NONVERBOSE(msg)) {
+     875             : 
+     876         537 :         DLT_MSG_READ_VALUE(id_tmp, ptr, datalength, uint32_t);
+     877         537 :         id = DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp);
+     878             : 
+     879         537 :         if (textlength < (((unsigned int)datalength * 3) + 20)) {
+     880           0 :             dlt_vlog(LOG_WARNING,
+     881             :                      "String does not fit binary data (available=%d, required=%d) !\n",
+     882           0 :                      (int)textlength, (datalength * 3) + 20);
+     883           0 :             return DLT_RETURN_ERROR;
+     884             :         }
+     885             : 
+     886             :         /* process message id / service id */
+     887         537 :         if (DLT_MSG_IS_CONTROL(msg)) {
+     888          60 :             if ((id > 0) && (id < DLT_SERVICE_ID_LAST_ENTRY))
+     889          57 :                 snprintf(text + strlen(text), textlength - strlen(text), "%s",
+     890             :                          service_id_name[id]); /* service id */
+     891           3 :             else if (!(DLT_MSG_IS_CONTROL_TIME(msg)))
+     892           3 :                 snprintf(text + strlen(text), textlength - strlen(text), "service(%u)", id); /* service id */
+     893             : 
+     894          60 :             if (datalength > 0)
+     895          60 :                 snprintf(text + strlen(text), textlength - strlen(text), ", ");
+     896             :         }
+     897             :         else {
+     898         477 :             snprintf(text + strlen(text), textlength - strlen(text), "%u, ", id); /* message id */
+     899             :         }
+     900             : 
+     901             :         /* process return value */
+     902         537 :         if (DLT_MSG_IS_CONTROL_RESPONSE(msg)) {
+     903           4 :             if (datalength > 0) {
+     904           4 :                 DLT_MSG_READ_VALUE(retval, ptr, datalength, uint8_t); /* No endian conversion necessary */
+     905             : 
+     906           4 :                 if ((retval < DLT_SERVICE_RESPONSE_LAST) || (retval == 8))
+     907           3 :                     snprintf(text + strlen(text), textlength - strlen(text), "%s", return_type[retval]);
+     908             :                 else
+     909           1 :                     snprintf(text + strlen(text), textlength - strlen(text), "%.2x", retval);
+     910             : 
+     911           4 :                 if (datalength >= 1)
+     912           2 :                     snprintf(text + strlen(text), textlength - strlen(text), ", ");
+     913             :             }
+     914             :         }
+     915             : 
+     916         537 :         if (type == DLT_OUTPUT_ASCII_LIMITED) {
+     917         122 :             ret = dlt_print_hex_string(text + strlen(text),
+     918         122 :                                        (int)(textlength - strlen(
+     919             :                                                  text)),
+     920             :                                        ptr,
+     921             :                                        (datalength >
+     922         122 :                                         DLT_COMMON_ASCII_LIMIT_MAX_CHARS ? DLT_COMMON_ASCII_LIMIT_MAX_CHARS : datalength));
+     923             : 
+     924         122 :             if ((datalength > DLT_COMMON_ASCII_LIMIT_MAX_CHARS) &&
+     925           6 :                 ((textlength - strlen(text)) > 4))
+     926           6 :                 snprintf(text + strlen(text), textlength - strlen(text), " ...");
+     927             :         }
+     928             :         else {
+     929         415 :             ret = dlt_print_hex_string(text + strlen(text), (int)(textlength - strlen(text)), ptr, datalength);
+     930             :         }
+     931             : 
+     932         537 :         return ret;
+     933             :     }
+     934             : 
+     935             :     /* At this point, it is ensured that a extended header is available */
+     936             : 
+     937             :     /* verbose mode */
+     938             :     type_info = 0;
+     939             :     type_info_tmp = 0;
+     940             : 
+     941        3361 :     for (num = 0; num < (int)(msg->extendedheader->noar); num++) {
+     942        2545 :         if (num != 0) {
+     943        1743 :             text_offset = (int)strlen(text);
+     944        1743 :             snprintf(text + text_offset, textlength - (size_t)text_offset, " ");
+     945             :         }
+     946             : 
+     947             :         /* first read the type info of the argument */
+     948        2545 :         DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+     949        2545 :         type_info = DLT_ENDIAN_GET_32(msg->standardheader->htyp, type_info_tmp);
+     950             : 
+     951             :         /* print out argument */
+     952        2545 :         text_offset = (int)strlen(text);
+     953             : 
+     954        2545 :         if (dlt_message_argument_print(msg, type_info, pptr, pdatalength,
+     955        2545 :                                        (text + text_offset), (textlength - (size_t)text_offset), -1,
+     956             :                                        0) == DLT_RETURN_ERROR)
+     957             :             return DLT_RETURN_ERROR;
+     958             :     }
+     959             : 
+     960             :     return DLT_RETURN_OK;
+     961             : }
+     962             : 
+     963         742 : DltReturnValue dlt_message_filter_check(DltMessage *msg, DltFilter *filter, int verbose)
+     964             : {
+     965             :     /* check the filters if message is used */
+     966             :     int num;
+     967             :     DltReturnValue found = DLT_RETURN_OK;
+     968             : 
+     969         742 :     PRINT_FUNCTION_VERBOSE(verbose);
+     970             : 
+     971         742 :     if ((msg == NULL) || (filter == NULL))
+     972             :         return DLT_RETURN_WRONG_PARAMETER;
+     973             : 
+     974         736 :     if ((filter->counter == 0) || (!(DLT_IS_HTYP_UEH(msg->standardheader->htyp))))
+     975             :         /* no filter is set, or no extended header is available, so do as filter is matching */
+     976             :         return DLT_RETURN_TRUE;
+     977             : 
+     978         936 :     for (num = 0; num < filter->counter; num++)
+     979             :         /* check each filter if it matches */
+     980         624 :         if ((DLT_IS_HTYP_UEH(msg->standardheader->htyp)) &&
+     981         624 :             ((filter->apid[num][0] == 0) || (memcmp(filter->apid[num], msg->extendedheader->apid, DLT_ID_SIZE) == 0)) &&
+     982           0 :             ((filter->ctid[num][0] == 0) || (memcmp(filter->ctid[num], msg->extendedheader->ctid, DLT_ID_SIZE) == 0)) &&
+     983           0 :             ((filter->log_level[num] == 0) ||
+     984           0 :              (filter->log_level[num] == DLT_GET_MSIN_MTIN(msg->extendedheader->msin))) &&
+     985           0 :             ((filter->payload_min[num] == 0) || (filter->payload_min[num] <= msg->datasize)) &&
+     986           0 :             ((filter->payload_max[num] == 0) || (filter->payload_max[num] >= msg->datasize))) {
+     987             :             found = DLT_RETURN_TRUE;
+     988             :             break;
+     989             :         }
+     990             : 
+     991             :     return found;
+     992             : }
+     993             : 
+     994        6680 : int dlt_message_read(DltMessage *msg, uint8_t *buffer, unsigned int length, int resync, int verbose)
+     995             : {
+     996             :     uint32_t extra_size = 0;
+     997             : 
+     998        6680 :     PRINT_FUNCTION_VERBOSE(verbose);
+     999             : 
+    1000        6680 :     if ((msg == NULL) || (buffer == NULL) || (length <= 0))
+    1001             :         return DLT_MESSAGE_ERROR_UNKNOWN;
+    1002             : 
+    1003             :     /* initialize resync_offset */
+    1004        6245 :     msg->resync_offset = 0;
+    1005             : 
+    1006             :     /* check if message contains serial header, smaller than standard header */
+    1007        6245 :     if (length < sizeof(dltSerialHeader))
+    1008             :         /* dlt_log(LOG_ERR, "Length smaller than serial header!\n"); */
+    1009             :         return DLT_MESSAGE_ERROR_SIZE;
+    1010             : 
+    1011        6245 :     if (memcmp(buffer, dltSerialHeader, sizeof(dltSerialHeader)) == 0) {
+    1012             :         /* serial header found */
+    1013           0 :         msg->found_serialheader = 1;
+    1014           0 :         buffer += sizeof(dltSerialHeader);
+    1015           0 :         length -= (unsigned int)sizeof(dltSerialHeader);
+    1016             :     }
+    1017             :     else {
+    1018             :         /* serial header not found */
+    1019        6245 :         msg->found_serialheader = 0;
+    1020             : 
+    1021        6245 :         if (resync) {
+    1022             :             /* resync if necessary */
+    1023             :             msg->resync_offset = 0;
+    1024             : 
+    1025             :             do {
+    1026           0 :                 if (memcmp(buffer + msg->resync_offset, dltSerialHeader, sizeof(dltSerialHeader)) == 0) {
+    1027             :                     /* serial header found */
+    1028           0 :                     msg->found_serialheader = 1;
+    1029           0 :                     buffer += sizeof(dltSerialHeader);
+    1030           0 :                     length -= (unsigned int)sizeof(dltSerialHeader);
+    1031           0 :                     break;
+    1032             :                 }
+    1033             : 
+    1034           0 :                 msg->resync_offset++;
+    1035           0 :             } while ((sizeof(dltSerialHeader) + (size_t)msg->resync_offset) <= length);
+    1036             : 
+    1037             :             /* Set new start offset */
+    1038           0 :             if (msg->resync_offset > 0) {
+    1039             :                 /* Resyncing connection */
+    1040           0 :                 buffer += msg->resync_offset;
+    1041           0 :                 length -= (unsigned int)msg->resync_offset;
+    1042             :             }
+    1043             :         }
+    1044             :     }
+    1045             : 
+    1046             :     /* check that standard header fits buffer */
+    1047        6245 :     if (length < sizeof(DltStandardHeader))
+    1048             :         /* dlt_log(LOG_ERR, "Length smaller than standard header!\n"); */
+    1049             :         return DLT_MESSAGE_ERROR_SIZE;
+    1050             : 
+    1051        6245 :     memcpy(msg->headerbuffer + sizeof(DltStorageHeader), buffer, sizeof(DltStandardHeader));
+    1052             : 
+    1053             :     /* set ptrs to structures */
+    1054        6245 :     msg->storageheader = (DltStorageHeader *)msg->headerbuffer;
+    1055        6245 :     msg->standardheader = (DltStandardHeader *)(msg->headerbuffer + sizeof(DltStorageHeader));
+    1056             : 
+    1057             :     /* calculate complete size of headers */
+    1058        6245 :     extra_size = (uint32_t) (DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp) +
+    1059             :         (DLT_IS_HTYP_UEH(msg->standardheader->htyp) ? sizeof(DltExtendedHeader) : 0));
+    1060        6245 :     msg->headersize = (uint32_t) (sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + extra_size);
+    1061        6245 :     msg->datasize = (uint32_t) DLT_BETOH_16(msg->standardheader->len) - msg->headersize + (uint32_t) sizeof(DltStorageHeader);
+    1062             : 
+    1063             :     /* calculate complete size of payload */
+    1064             :     int32_t temp_datasize;
+    1065        6245 :     temp_datasize = DLT_BETOH_16(msg->standardheader->len) - (int32_t) msg->headersize + (int32_t) sizeof(DltStorageHeader);
+    1066             : 
+    1067             :     /* check data size */
+    1068        6245 :     if (temp_datasize < 0) {
+    1069           0 :         dlt_vlog(LOG_WARNING,
+    1070             :                  "Plausibility check failed. Complete message size too short (%d)!\n",
+    1071             :                  temp_datasize);
+    1072           0 :         return DLT_MESSAGE_ERROR_CONTENT;
+    1073             :     }
+    1074             :     else {
+    1075        6245 :         msg->datasize = (uint32_t) temp_datasize;
+    1076             :     }
+    1077             : 
+    1078             :     /* check if verbose mode is on*/
+    1079        6245 :     if (verbose) {
+    1080           0 :         dlt_vlog(LOG_DEBUG, "BufferLength=%u, HeaderSize=%u, DataSize=%u\n",
+    1081             :                  length, msg->headersize, msg->datasize);
+    1082             :     }
+    1083             : 
+    1084             :     /* load standard header extra parameters and Extended header if used */
+    1085        6245 :     if (extra_size > 0) {
+    1086        6245 :         if (length < (msg->headersize - sizeof(DltStorageHeader)))
+    1087             :             return DLT_MESSAGE_ERROR_SIZE;
+    1088             : 
+    1089        6245 :         memcpy(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader),
+    1090        6245 :                buffer + sizeof(DltStandardHeader), (size_t)extra_size);
+    1091             : 
+    1092             :         /* set extended header ptr and get standard header extra parameters */
+    1093        6245 :         if (DLT_IS_HTYP_UEH(msg->standardheader->htyp))
+    1094        6245 :             msg->extendedheader =
+    1095        6245 :                 (DltExtendedHeader *)(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+    1096        6245 :                                       DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp));
+    1097             :         else
+    1098           0 :             msg->extendedheader = NULL;
+    1099             : 
+    1100        6245 :         dlt_message_get_extraparameters(msg, verbose);
+    1101             :     }
+    1102             : 
+    1103             :     /* check if payload fits length */
+    1104        6245 :     if (length < (msg->headersize - sizeof(DltStorageHeader) + msg->datasize))
+    1105             :         /* dlt_log(LOG_ERR,"length does not fit!\n"); */
+    1106             :         return DLT_MESSAGE_ERROR_SIZE;
+    1107             : 
+    1108             :     /* free last used memory for buffer */
+    1109        6040 :     if (msg->databuffer) {
+    1110        6028 :         if (msg->datasize > msg->databuffersize) {
+    1111           7 :             free(msg->databuffer);
+    1112           7 :             msg->databuffer = (uint8_t *)malloc(msg->datasize);
+    1113           7 :             msg->databuffersize = msg->datasize;
+    1114             :         }
+    1115             :     }
+    1116             :     else {
+    1117             :         /* get new memory for buffer */
+    1118          12 :         msg->databuffer = (uint8_t *)malloc(msg->datasize);
+    1119          12 :         msg->databuffersize = msg->datasize;
+    1120             :     }
+    1121             : 
+    1122        6040 :     if (msg->databuffer == NULL) {
+    1123           0 :         dlt_vlog(LOG_WARNING,
+    1124             :                  "Cannot allocate memory for payload buffer of size %u!\n",
+    1125             :                  msg->datasize);
+    1126           0 :         return DLT_MESSAGE_ERROR_UNKNOWN;
+    1127             :     }
+    1128             : 
+    1129             :     /* load payload data from buffer */
+    1130        6040 :     memcpy(msg->databuffer, buffer + (msg->headersize - sizeof(DltStorageHeader)), msg->datasize);
+    1131             : 
+    1132        6040 :     return DLT_MESSAGE_ERROR_OK;
+    1133             : }
+    1134             : 
+    1135        7222 : DltReturnValue dlt_message_get_extraparameters(DltMessage *msg, int verbose)
+    1136             : {
+    1137        7222 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1138             : 
+    1139        7222 :     if (msg == NULL)
+    1140             :         return DLT_RETURN_WRONG_PARAMETER;
+    1141             : 
+    1142        7220 :     if (DLT_IS_HTYP_WEID(msg->standardheader->htyp))
+    1143        7026 :         memcpy(msg->headerextra.ecu,
+    1144             :                msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader),
+    1145             :                DLT_ID_SIZE);
+    1146             : 
+    1147        7220 :     if (DLT_IS_HTYP_WSID(msg->standardheader->htyp)) {
+    1148        6730 :         memcpy(&(msg->headerextra.seid), msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader)
+    1149        6730 :                + (DLT_IS_HTYP_WEID(msg->standardheader->htyp) ? DLT_SIZE_WEID : 0), DLT_SIZE_WSID);
+    1150        6730 :         msg->headerextra.seid = DLT_BETOH_32(msg->headerextra.seid);
+    1151             :     }
+    1152             : 
+    1153        7220 :     if (DLT_IS_HTYP_WTMS(msg->standardheader->htyp)) {
+    1154       14052 :         memcpy(&(msg->headerextra.tmsp), msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader)
+    1155        7026 :                + (DLT_IS_HTYP_WEID(msg->standardheader->htyp) ? DLT_SIZE_WEID : 0)
+    1156        7026 :                + (DLT_IS_HTYP_WSID(msg->standardheader->htyp) ? DLT_SIZE_WSID : 0), DLT_SIZE_WTMS);
+    1157        7026 :         msg->headerextra.tmsp = DLT_BETOH_32(msg->headerextra.tmsp);
+    1158             :     }
+    1159             : 
+    1160             :     return DLT_RETURN_OK;
+    1161             : }
+    1162             : 
+    1163        6247 : DltReturnValue dlt_message_set_extraparameters(DltMessage *msg, int verbose)
+    1164             : {
+    1165        6247 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1166             : 
+    1167        6247 :     if (msg == NULL)
+    1168             :         return DLT_RETURN_WRONG_PARAMETER;
+    1169             : 
+    1170        6245 :     if (DLT_IS_HTYP_WEID(msg->standardheader->htyp))
+    1171        6049 :         memcpy(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader),
+    1172        6049 :                msg->headerextra.ecu,
+    1173             :                DLT_ID_SIZE);
+    1174             : 
+    1175        6245 :     if (DLT_IS_HTYP_WSID(msg->standardheader->htyp)) {
+    1176        5999 :         msg->headerextra.seid = DLT_HTOBE_32(msg->headerextra.seid);
+    1177        5999 :         memcpy(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader)
+    1178        5999 :                + (DLT_IS_HTYP_WEID(msg->standardheader->htyp) ? DLT_SIZE_WEID : 0),
+    1179        5999 :                &(msg->headerextra.seid),
+    1180             :                DLT_SIZE_WSID);
+    1181             :     }
+    1182             : 
+    1183        6245 :     if (DLT_IS_HTYP_WTMS(msg->standardheader->htyp)) {
+    1184        6049 :         msg->headerextra.tmsp = DLT_HTOBE_32(msg->headerextra.tmsp);
+    1185       12098 :         memcpy(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader)
+    1186        6049 :                + (DLT_IS_HTYP_WEID(msg->standardheader->htyp) ? DLT_SIZE_WEID : 0)
+    1187        6049 :                + (DLT_IS_HTYP_WSID(msg->standardheader->htyp) ? DLT_SIZE_WSID : 0),
+    1188        6049 :                &(msg->headerextra.tmsp),
+    1189             :                DLT_SIZE_WTMS);
+    1190             :     }
+    1191             : 
+    1192             :     return DLT_RETURN_OK;
+    1193             : }
+    1194             : 
+    1195          54 : DltReturnValue dlt_file_init(DltFile *file, int verbose)
+    1196             : {
+    1197          54 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1198             : 
+    1199          54 :     if (file == NULL)
+    1200             :         return DLT_RETURN_WRONG_PARAMETER;
+    1201             : 
+    1202             :     /* initalise structure parameters */
+    1203          54 :     file->handle = NULL;
+    1204          54 :     file->counter = 0;
+    1205          54 :     file->counter_total = 0;
+    1206          54 :     file->index = NULL;
+    1207             : 
+    1208          54 :     file->filter = NULL;
+    1209          54 :     file->filter_counter = 0;
+    1210          54 :     file->file_position = 0;
+    1211             : 
+    1212          54 :     file->position = 0;
+    1213             : 
+    1214          54 :     file->error_messages = 0;
+    1215             : 
+    1216          54 :     return dlt_message_init(&(file->msg), verbose);
+    1217             : }
+    1218             : 
+    1219           6 : DltReturnValue dlt_file_set_filter(DltFile *file, DltFilter *filter, int verbose)
+    1220             : {
+    1221           6 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1222             : 
+    1223           6 :     if (file == NULL)
+    1224             :         return DLT_RETURN_WRONG_PARAMETER;
+    1225             : 
+    1226             :     /* set filter */
+    1227           6 :     file->filter = filter;
+    1228             : 
+    1229           6 :     return DLT_RETURN_OK;
+    1230             : }
+    1231             : 
+    1232        6627 : DltReturnValue dlt_file_read_header(DltFile *file, int verbose)
+    1233             : {
+    1234        6627 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1235             : 
+    1236        6627 :     if (file == NULL)
+    1237             :         return DLT_RETURN_WRONG_PARAMETER;
+    1238             : 
+    1239             :     /* Loop until storage header is found */
+    1240             :     while (1) {
+    1241             :         /* load header from file */
+    1242       13254 :         if (fread(file->msg.headerbuffer,
+    1243             :                   sizeof(DltStorageHeader) + sizeof(DltStandardHeader), 1,
+    1244             :                   file->handle) != 1) {
+    1245          38 :             if (!feof(file->handle))
+    1246           0 :                 dlt_log(LOG_WARNING, "Cannot read header from file!\n");
+    1247             :             else
+    1248          38 :                 dlt_log(LOG_DEBUG, "Reached end of file\n");
+    1249             : 
+    1250          38 :             return DLT_RETURN_ERROR;
+    1251             :         }
+    1252             : 
+    1253             :         /* set ptrs to structures */
+    1254        6589 :         file->msg.storageheader = (DltStorageHeader *)file->msg.headerbuffer;
+    1255        6589 :         file->msg.standardheader = (DltStandardHeader *)(file->msg.headerbuffer +
+    1256             :                                                          sizeof(DltStorageHeader));
+    1257             : 
+    1258             :         /* check id of storage header */
+    1259        6589 :         if (dlt_check_storageheader(file->msg.storageheader) != DLT_RETURN_TRUE) {
+    1260             :             /* Shift the position back to the place where it stared to read + 1 */
+    1261           0 :             if (fseek(file->handle,
+    1262             :                       (long) (1 - (sizeof(DltStorageHeader) + sizeof(DltStandardHeader))),
+    1263             :                       SEEK_CUR) < 0) {
+    1264           0 :                 dlt_log(LOG_WARNING, "DLT storage header pattern not found!\n");
+    1265           0 :                 return DLT_RETURN_ERROR;
+    1266             :             }
+    1267             :         }
+    1268             :         else {
+    1269             :             /* storage header is found */
+    1270             :             break;
+    1271             :         }
+    1272             :     }
+    1273             : 
+    1274             :     /* calculate complete size of headers */
+    1275        6589 :     file->msg.headersize = (uint32_t) (sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+    1276        6589 :         DLT_STANDARD_HEADER_EXTRA_SIZE(file->msg.standardheader->htyp) +
+    1277             :         (DLT_IS_HTYP_UEH(file->msg.standardheader->htyp) ? sizeof(DltExtendedHeader) : 0));
+    1278             : 
+    1279             :     /* calculate complete size of payload */
+    1280             :     int32_t temp_datasize;
+    1281        6589 :     temp_datasize = DLT_BETOH_16(file->msg.standardheader->len) + (int32_t) sizeof(DltStorageHeader) - (int32_t) file->msg.headersize;
+    1282             : 
+    1283             :     /* check data size */
+    1284        6589 :     if (temp_datasize < 0) {
+    1285           0 :         dlt_vlog(LOG_WARNING,
+    1286             :                  "Plausibility check failed. Complete message size too short! (%d)\n",
+    1287             :                  temp_datasize);
+    1288           0 :         return DLT_RETURN_ERROR;
+    1289             :     } else {
+    1290        6589 :         file->msg.datasize = (uint32_t) temp_datasize;
+    1291             :     }
+    1292             : 
+    1293             :     /* check if verbose mode is on */
+    1294        6589 :     if (verbose) {
+    1295           0 :         dlt_vlog(LOG_DEBUG, "HeaderSize=%u, DataSize=%u\n",
+    1296             :                  file->msg.headersize, file->msg.datasize);
+    1297             :     }
+    1298             : 
+    1299             :     return DLT_RETURN_OK;
+    1300             : }
+    1301             : 
+    1302           0 : DltReturnValue dlt_file_read_header_raw(DltFile *file, int resync, int verbose)
+    1303             : {
+    1304             :     char dltSerialHeaderBuffer[DLT_ID_SIZE];
+    1305             : 
+    1306           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1307             : 
+    1308           0 :     if (file == NULL)
+    1309             :         return DLT_RETURN_WRONG_PARAMETER;
+    1310             : 
+    1311             :     /* check if serial header exists, ignore if found */
+    1312           0 :     if (fread(dltSerialHeaderBuffer, sizeof(dltSerialHeaderBuffer), 1, file->handle) != 1) {
+    1313             :         /* cannot read serial header, not enough data available in file */
+    1314           0 :         if (!feof(file->handle))
+    1315           0 :             dlt_log(LOG_WARNING, "Cannot read header from file!\n");
+    1316             : 
+    1317           0 :         return DLT_RETURN_ERROR;
+    1318             :     }
+    1319             : 
+    1320           0 :     if (memcmp(dltSerialHeaderBuffer, dltSerialHeader, sizeof(dltSerialHeader)) == 0) {
+    1321             :         /* serial header found */
+    1322             :         /* nothing to do continue reading */
+    1323             : 
+    1324             :     }
+    1325             :     else {
+    1326             :         /* serial header not found */
+    1327           0 :         if (resync) {
+    1328             :             /* increase error counter */
+    1329           0 :             file->error_messages++;
+    1330             : 
+    1331             :             /* resync to serial header */
+    1332             :             do {
+    1333             :                 memmove(dltSerialHeaderBuffer, dltSerialHeaderBuffer + 1, sizeof(dltSerialHeader) - 1);
+    1334             : 
+    1335           0 :                 if (fread(dltSerialHeaderBuffer + 3, 1, 1, file->handle) != 1)
+    1336             :                     /* cannot read any data, perhaps end of file reached */
+    1337             :                     return DLT_RETURN_ERROR;
+    1338             : 
+    1339           0 :                 if (memcmp(dltSerialHeaderBuffer, dltSerialHeader, sizeof(dltSerialHeader)) == 0)
+    1340             :                     /* serial header synchronised */
+    1341             :                     break;
+    1342             :             } while (1);
+    1343             :         }
+    1344             :         else
+    1345             :         /* go back to last file position */
+    1346           0 :         if (0 != fseek(file->handle, file->file_position, SEEK_SET))
+    1347             :         {
+    1348             :             return DLT_RETURN_ERROR;
+    1349             :         }
+    1350             :     }
+    1351             : 
+    1352             :     /* load header from file */
+    1353           0 :     if (fread(file->msg.headerbuffer + sizeof(DltStorageHeader), sizeof(DltStandardHeader), 1, file->handle) != 1) {
+    1354           0 :         if (!feof(file->handle))
+    1355           0 :             dlt_log(LOG_WARNING, "Cannot read header from file!\n");
+    1356             : 
+    1357           0 :         return DLT_RETURN_ERROR;
+    1358             :     }
+    1359             : 
+    1360             :     /* set ptrs to structures */
+    1361           0 :     file->msg.storageheader = (DltStorageHeader *)file->msg.headerbuffer; /* this points now to a empty storage header (filled with '0') */
+    1362           0 :     file->msg.standardheader = (DltStandardHeader *)(file->msg.headerbuffer + sizeof(DltStorageHeader));
+    1363             : 
+    1364             :     /* Skip storage header field, fill this field with '0' */
+    1365             :     memset(file->msg.storageheader, 0, sizeof(DltStorageHeader));
+    1366             : 
+    1367             :     /* Set storage header */
+    1368           0 :     dlt_set_storageheader(file->msg.storageheader, DLT_COMMON_DUMMY_ECUID);
+    1369             : 
+    1370             :     /* no check for storage header id*/
+    1371             : 
+    1372             :     /* calculate complete size of headers */
+    1373           0 :     file->msg.headersize = (uint32_t) (sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+    1374           0 :         DLT_STANDARD_HEADER_EXTRA_SIZE(file->msg.standardheader->htyp) +
+    1375             :         (DLT_IS_HTYP_UEH(file->msg.standardheader->htyp) ? sizeof(DltExtendedHeader) : 0));
+    1376             : 
+    1377             :     /* calculate complete size of payload */
+    1378             :     int32_t temp_datasize;
+    1379           0 :     temp_datasize = DLT_BETOH_16(file->msg.standardheader->len) + (int32_t) sizeof(DltStorageHeader) - (int32_t) file->msg.headersize;
+    1380             : 
+    1381             :     /* check data size */
+    1382           0 :     if (temp_datasize < 0) {
+    1383           0 :         dlt_vlog(LOG_WARNING,
+    1384             :                  "Plausibility check failed. Complete message size too short! (%d)\n",
+    1385             :                  temp_datasize);
+    1386           0 :         return DLT_RETURN_ERROR;
+    1387             :     }
+    1388             :     else {
+    1389           0 :         file->msg.datasize = (uint32_t) temp_datasize;
+    1390             :     }
+    1391             : 
+    1392             :     /* check if verbose mode is on */
+    1393           0 :     if (verbose) {
+    1394           0 :         dlt_vlog(LOG_DEBUG, "HeaderSize=%u, DataSize=%u\n",
+    1395             :                  file->msg.headersize, file->msg.datasize);
+    1396             :     }
+    1397             : 
+    1398             :     return DLT_RETURN_OK;
+    1399             : }
+    1400             : 
+    1401        4505 : DltReturnValue dlt_file_read_header_extended(DltFile *file, int verbose)
+    1402             : {
+    1403        4505 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1404             : 
+    1405        4505 :     if (file == NULL)
+    1406             :         return DLT_RETURN_WRONG_PARAMETER;
+    1407             : 
+    1408             :     /* load standard header extra parameters if used */
+    1409        4505 :     if (DLT_STANDARD_HEADER_EXTRA_SIZE(file->msg.standardheader->htyp)) {
+    1410        1530 :         if (fread(file->msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader),
+    1411             :                   DLT_STANDARD_HEADER_EXTRA_SIZE(file->msg.standardheader->htyp),
+    1412             :                   1, file->handle) != 1) {
+    1413           0 :             dlt_log(LOG_WARNING, "Cannot read standard header extra parameters from file!\n");
+    1414           0 :             return DLT_RETURN_ERROR;
+    1415             :         }
+    1416             : 
+    1417         765 :         dlt_message_get_extraparameters(&(file->msg), verbose);
+    1418             :     }
+    1419             : 
+    1420             :     /* load Extended header if used */
+    1421        4505 :     if (DLT_IS_HTYP_UEH(file->msg.standardheader->htyp) == 0)
+    1422             :         /* there is nothing to be loaded */
+    1423             :         return DLT_RETURN_OK;
+    1424             : 
+    1425        2173 :     if (fread(file->msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+    1426        2173 :               DLT_STANDARD_HEADER_EXTRA_SIZE(file->msg.standardheader->htyp),
+    1427             :               (DLT_IS_HTYP_UEH(file->msg.standardheader->htyp) ? sizeof(DltExtendedHeader) : 0),
+    1428             :               1, file->handle) != 1) {
+    1429           0 :         dlt_log(LOG_WARNING, "Cannot read extended header from file!\n");
+    1430           0 :         return DLT_RETURN_ERROR;
+    1431             :     }
+    1432             : 
+    1433             :     /* set extended header ptr */
+    1434        2173 :     if (DLT_IS_HTYP_UEH(file->msg.standardheader->htyp))
+    1435        2173 :         file->msg.extendedheader =
+    1436        2173 :             (DltExtendedHeader *)(file->msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+    1437        2173 :                                   DLT_STANDARD_HEADER_EXTRA_SIZE(file->msg.standardheader->htyp));
+    1438             :     else
+    1439           0 :         file->msg.extendedheader = NULL;
+    1440             : 
+    1441             :     return DLT_RETURN_OK;
+    1442             : }
+    1443             : 
+    1444        3875 : DltReturnValue dlt_file_read_data(DltFile *file, int verbose)
+    1445             : {
+    1446        3875 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1447             : 
+    1448        3875 :     if (file == NULL)
+    1449             :         return DLT_RETURN_WRONG_PARAMETER;
+    1450             : 
+    1451             :     /* free last used memory for buffer */
+    1452        3875 :     if (file->msg.databuffer && (file->msg.databuffersize < file->msg.datasize)) {
+    1453         129 :         free(file->msg.databuffer);
+    1454         129 :         file->msg.databuffer = NULL;
+    1455             :     }
+    1456             : 
+    1457        3875 :     if (file->msg.databuffer == NULL) {
+    1458             :         /* get new memory for buffer */
+    1459         168 :         file->msg.databuffer = (uint8_t *)malloc(file->msg.datasize);
+    1460         168 :         file->msg.databuffersize = file->msg.datasize;
+    1461             :     }
+    1462             : 
+    1463        3875 :     if (file->msg.databuffer == NULL) {
+    1464           0 :         dlt_vlog(LOG_WARNING,
+    1465             :                  "Cannot allocate memory for payload buffer of size %u!\n",
+    1466             :                  file->msg.datasize);
+    1467           0 :         return DLT_RETURN_ERROR;
+    1468             :     }
+    1469             : 
+    1470             :     /* load payload data from file */
+    1471        7750 :     if (fread(file->msg.databuffer, file->msg.datasize, 1, file->handle) != 1) {
+    1472          52 :         if (file->msg.datasize != 0) {
+    1473           0 :             dlt_vlog(LOG_WARNING,
+    1474             :                      "Cannot read payload data from file of size %u!\n",
+    1475             :                      file->msg.datasize);
+    1476           0 :             return DLT_RETURN_ERROR;
+    1477             :         }
+    1478             :     }
+    1479             : 
+    1480             :     return DLT_RETURN_OK;
+    1481             : }
+    1482             : 
+    1483          50 : DltReturnValue dlt_file_open(DltFile *file, const char *filename, int verbose)
+    1484             : {
+    1485          50 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1486             : 
+    1487          50 :     if ((file == NULL) || (filename == NULL))
+    1488             :         return DLT_RETURN_WRONG_PARAMETER;
+    1489             : 
+    1490             :     /* reset counters */
+    1491          44 :     file->counter = 0;
+    1492          44 :     file->counter_total = 0;
+    1493          44 :     file->position = 0;
+    1494          44 :     file->file_position = 0;
+    1495          44 :     file->file_length = 0;
+    1496          44 :     file->error_messages = 0;
+    1497             : 
+    1498          44 :     if (file->handle)
+    1499           0 :         fclose(file->handle);
+    1500             : 
+    1501             :     /* open dlt file */
+    1502          44 :     file->handle = fopen(filename, "rb");
+    1503             : 
+    1504          44 :     if (file->handle == NULL) {
+    1505           1 :         dlt_vlog(LOG_WARNING, "File %s cannot be opened!\n", filename);
+    1506           1 :         return DLT_RETURN_ERROR;
+    1507             :     }
+    1508             : 
+    1509          43 :     if (0 != fseek(file->handle, 0, SEEK_END)) {
+    1510           0 :         dlt_vlog(LOG_WARNING, "dlt_file_open: Seek failed to 0,SEEK_END");
+    1511           0 :         return DLT_RETURN_ERROR;
+    1512             :     }
+    1513             : 
+    1514          43 :     file->file_length = ftell(file->handle);
+    1515             : 
+    1516          43 :     if (0 != fseek(file->handle, 0, SEEK_SET)) {
+    1517           0 :         dlt_vlog(LOG_WARNING, "dlt_file_open: Seek failed to 0,SEEK_SET");
+    1518           0 :         return DLT_RETURN_ERROR;
+    1519             :     }
+    1520             : 
+    1521          43 :     if (verbose)
+    1522             :         /* print file length */
+    1523           1 :         dlt_vlog(LOG_DEBUG, "File is %" PRIu64 "bytes long\n", file->file_length);
+    1524             : 
+    1525             :     return DLT_RETURN_OK;
+    1526             : }
+    1527             : 
+    1528        2752 : DltReturnValue dlt_file_read(DltFile *file, int verbose)
+    1529             : {
+    1530             :     long *ptr;
+    1531             :     int found = DLT_RETURN_OK;
+    1532             : 
+    1533        2752 :     if (file == NULL)
+    1534             :         return DLT_RETURN_WRONG_PARAMETER;
+    1535             : 
+    1536        2752 :     if (verbose)
+    1537           0 :         dlt_vlog(LOG_DEBUG, "%s: Message %d:\n", __func__, file->counter_total);
+    1538             : 
+    1539             :     /* allocate new memory for index if number of messages exceeds a multiple of DLT_COMMON_INDEX_ALLOC (e.g.: 1000) */
+    1540        2752 :     if (file->counter % DLT_COMMON_INDEX_ALLOC == 0) {
+    1541         350 :         ptr = (long *)malloc(((file->counter / DLT_COMMON_INDEX_ALLOC) + 1) * DLT_COMMON_INDEX_ALLOC * sizeof(long));
+    1542             : 
+    1543         350 :         if (ptr == NULL)
+    1544             :             return DLT_RETURN_ERROR;
+    1545             : 
+    1546         350 :         if (file->index) {
+    1547         312 :             memcpy(ptr, file->index, (size_t)(file->counter) * sizeof(long));
+    1548         312 :             free(file->index);
+    1549             :         }
+    1550             : 
+    1551         350 :         file->index = ptr;
+    1552             :     }
+    1553             : 
+    1554             :     /* set to end of last succesful read message, because of conflicting calls to dlt_file_read and dlt_file_message */
+    1555        2752 :     if (0 != fseek(file->handle, file->file_position, SEEK_SET)) {
+    1556           0 :         dlt_vlog(LOG_WARNING, "Seek failed to file_position %" PRIu64 "\n",
+    1557             :                  file->file_position);
+    1558           0 :         return DLT_RETURN_ERROR;
+    1559             :     }
+    1560             : 
+    1561             :     /* get file position at start of DLT message */
+    1562        2752 :     if (verbose)
+    1563           0 :         dlt_vlog(LOG_INFO, "Position in file: %" PRIu64 "\n", file->file_position);
+    1564             : 
+    1565             :     /* read header */
+    1566        2752 :     if (dlt_file_read_header(file, verbose) < DLT_RETURN_OK) {
+    1567             :         /* go back to last position in file */
+    1568          38 :         if (0 != fseek(file->handle, file->file_position, SEEK_SET)) {
+    1569           0 :             dlt_vlog(LOG_WARNING, "Seek failed to file_position %ld \n",
+    1570             :                     file->file_position);
+    1571             :         }
+    1572          38 :         return DLT_RETURN_ERROR;
+    1573             :     }
+    1574             : 
+    1575        2714 :     if (file->filter) {
+    1576             :         /* read the extended header if filter is enabled and extended header exists */
+    1577         630 :         if (dlt_file_read_header_extended(file, verbose) < DLT_RETURN_OK) {
+    1578             :             /* go back to last position in file */
+    1579           0 :             if (0 != fseek(file->handle, file->file_position, SEEK_SET))
+    1580           0 :                 dlt_vlog(LOG_WARNING, "Seek to last file pos failed!\n");
+    1581             : 
+    1582           0 :             return DLT_RETURN_ERROR;
+    1583             :         }
+    1584             : 
+    1585             :         /* check the filters if message is used */
+    1586         630 :         if (dlt_message_filter_check(&(file->msg), file->filter, verbose) == DLT_RETURN_TRUE) {
+    1587             :             /* filter matched, consequently store current message */
+    1588             :             /* store index pointer to message position in DLT file */
+    1589         318 :             file->index[file->counter] = file->file_position;
+    1590         318 :             file->counter++;
+    1591         318 :             file->position = file->counter - 1;
+    1592             : 
+    1593             :             found = DLT_RETURN_TRUE;
+    1594             :         }
+    1595             : 
+    1596             :         /* skip payload data */
+    1597         630 :         if (fseek(file->handle, file->msg.datasize, SEEK_CUR) != 0) {
+    1598             :             /* go back to last position in file */
+    1599           0 :             dlt_vlog(LOG_WARNING,
+    1600             :                      "Seek failed to skip payload data of size %u!\n",
+    1601             :                      file->msg.datasize);
+    1602             : 
+    1603           0 :             if (0 != fseek(file->handle, file->file_position, SEEK_SET))
+    1604           0 :                 dlt_log(LOG_WARNING, "Seek back also failed!\n");
+    1605             : 
+    1606           0 :             return DLT_RETURN_ERROR;
+    1607             :         }
+    1608             :     }
+    1609             :     else {
+    1610             :         /* filter is disabled */
+    1611             :         /* skip additional header parameters and payload data */
+    1612        2084 :         if (fseek(file->handle,
+    1613        2084 :                   (long) (file->msg.headersize - sizeof(DltStorageHeader) - sizeof(DltStandardHeader) + file->msg.datasize),
+    1614             :                   SEEK_CUR)) {
+    1615             : 
+    1616           0 :             dlt_vlog(LOG_WARNING,
+    1617             :                      "Seek failed to skip extra header and payload data from file of size %u!\n",
+    1618           0 :                      file->msg.headersize - (int32_t)sizeof(DltStorageHeader) -
+    1619           0 :                      (int32_t)sizeof(DltStandardHeader) + file->msg.datasize);
+    1620             : 
+    1621             :             /* go back to last position in file */
+    1622           0 :             if (fseek(file->handle, file->file_position, SEEK_SET))
+    1623           0 :                 dlt_log(LOG_WARNING, "Seek back also failed!\n");
+    1624             : 
+    1625           0 :             return DLT_RETURN_ERROR;
+    1626             :         }
+    1627             : 
+    1628             :         /* store index pointer to message position in DLT file */
+    1629        2084 :         file->index[file->counter] = file->file_position;
+    1630        2084 :         file->counter++;
+    1631        2084 :         file->position = file->counter - 1;
+    1632             : 
+    1633             :         found = DLT_RETURN_TRUE;
+    1634             :     }
+    1635             : 
+    1636             :     /* increase total message counter */
+    1637        2714 :     file->counter_total++;
+    1638             : 
+    1639             :     /* store position to next message */
+    1640        2714 :     file->file_position = ftell(file->handle);
+    1641             : 
+    1642        2714 :     return found;
+    1643             : }
+    1644             : 
+    1645           0 : DltReturnValue dlt_file_read_raw(DltFile *file, int resync, int verbose)
+    1646             : {
+    1647             :     int found = DLT_RETURN_OK;
+    1648             :     long *ptr;
+    1649             : 
+    1650           0 :     if (verbose)
+    1651           0 :         dlt_vlog(LOG_DEBUG, "%s: Message %d:\n", __func__, file->counter_total);
+    1652             : 
+    1653           0 :     if (file == NULL)
+    1654             :         return DLT_RETURN_WRONG_PARAMETER;
+    1655             : 
+    1656             :     /* allocate new memory for index if number of messages exceeds a multiple of DLT_COMMON_INDEX_ALLOC (e.g.: 1000) */
+    1657           0 :     if (file->counter % DLT_COMMON_INDEX_ALLOC == 0) {
+    1658           0 :         ptr = (long *)malloc(((file->counter / DLT_COMMON_INDEX_ALLOC) + 1) * DLT_COMMON_INDEX_ALLOC * sizeof(long));
+    1659             : 
+    1660           0 :         if (ptr == NULL)
+    1661             :             return DLT_RETURN_ERROR;
+    1662             : 
+    1663           0 :         if (file->index) {
+    1664           0 :             memcpy(ptr, file->index, (size_t)(file->counter) * sizeof(long));
+    1665           0 :             free(file->index);
+    1666             :         }
+    1667             : 
+    1668           0 :         file->index = ptr;
+    1669             :     }
+    1670             : 
+    1671             :     /* set to end of last successful read message, because of conflicting calls to dlt_file_read and dlt_file_message */
+    1672           0 :     if (0 != fseek(file->handle, file->file_position, SEEK_SET))
+    1673             :         return DLT_RETURN_ERROR;
+    1674             : 
+    1675             :     /* get file position at start of DLT message */
+    1676           0 :     if (verbose)
+    1677           0 :         dlt_vlog(LOG_DEBUG, "Position in file: %" PRIu64 "\n", file->file_position);
+    1678             : 
+    1679             :     /* read header */
+    1680           0 :     if (dlt_file_read_header_raw(file, resync, verbose) < DLT_RETURN_OK) {
+    1681             :         /* go back to last position in file */
+    1682           0 :         if (0 != fseek(file->handle, file->file_position, SEEK_SET))
+    1683           0 :             dlt_log(LOG_WARNING, "dlt_file_read_raw, fseek failed 1\n");
+    1684             : 
+    1685           0 :         return DLT_RETURN_ERROR;
+    1686             :     }
+    1687             : 
+    1688             :     /* read the extended header if filter is enabled and extended header exists */
+    1689           0 :     if (dlt_file_read_header_extended(file, verbose) < DLT_RETURN_OK) {
+    1690             :         /* go back to last position in file */
+    1691           0 :         if (0 != fseek(file->handle, file->file_position, SEEK_SET))
+    1692           0 :             dlt_log(LOG_WARNING, "dlt_file_read_raw, fseek failed 2\n");
+    1693             : 
+    1694           0 :         return DLT_RETURN_ERROR;
+    1695             :     }
+    1696             : 
+    1697           0 :     if (dlt_file_read_data(file, verbose) < DLT_RETURN_OK) {
+    1698             :         /* go back to last position in file */
+    1699           0 :         if (0 != fseek(file->handle, file->file_position, SEEK_SET))
+    1700           0 :             dlt_log(LOG_WARNING, "dlt_file_read_raw, fseek failed 3\n");
+    1701             : 
+    1702           0 :         return DLT_RETURN_ERROR;
+    1703             :     }
+    1704             : 
+    1705             :     /* store index pointer to message position in DLT file */
+    1706           0 :     file->index[file->counter] = file->file_position;
+    1707           0 :     file->counter++;
+    1708           0 :     file->position = file->counter - 1;
+    1709             : 
+    1710             :     found = DLT_RETURN_TRUE;
+    1711             : 
+    1712             :     /* increase total message counter */
+    1713           0 :     file->counter_total++;
+    1714             : 
+    1715             :     /* store position to next message */
+    1716           0 :     file->file_position = ftell(file->handle);
+    1717             : 
+    1718           0 :     return found;
+    1719             : }
+    1720             : 
+    1721           0 : DltReturnValue dlt_file_close(DltFile *file, int verbose)
+    1722             : {
+    1723           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1724             : 
+    1725           0 :     if (file == NULL)
+    1726             :         return DLT_RETURN_WRONG_PARAMETER;
+    1727             : 
+    1728           0 :     if (file->handle)
+    1729           0 :         fclose(file->handle);
+    1730             : 
+    1731           0 :     file->handle = NULL;
+    1732             : 
+    1733           0 :     return DLT_RETURN_OK;
+    1734             : }
+    1735             : 
+    1736        3770 : DltReturnValue dlt_file_message(DltFile *file, int index, int verbose)
+    1737             : {
+    1738        3770 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1739             : 
+    1740        3770 :     if (file == NULL)
+    1741             :         return DLT_RETURN_WRONG_PARAMETER;
+    1742             : 
+    1743             :     /* check if message is in range */
+    1744        3770 :     if (index < 0 || index >= file->counter) {
+    1745           0 :         dlt_vlog(LOG_WARNING, "Message %d out of range!\r\n", index);
+    1746           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    1747             :     }
+    1748             : 
+    1749             :     /* seek to position in file */
+    1750        3770 :     if (fseek(file->handle, file->index[index], SEEK_SET) != 0) {
+    1751           0 :         dlt_vlog(LOG_WARNING, "Seek to message %d to position %ld failed!\r\n",
+    1752           0 :                  index, file->index[index]);
+    1753           0 :         return DLT_RETURN_ERROR;
+    1754             :     }
+    1755             : 
+    1756             :     /* read all header and payload */
+    1757        3770 :     if (dlt_file_read_header(file, verbose) < DLT_RETURN_OK)
+    1758             :         return DLT_RETURN_ERROR;
+    1759             : 
+    1760        3770 :     if (dlt_file_read_header_extended(file, verbose) < DLT_RETURN_OK)
+    1761             :         return DLT_RETURN_ERROR;
+    1762             : 
+    1763        3770 :     if (dlt_file_read_data(file, verbose) < DLT_RETURN_OK)
+    1764             :         return DLT_RETURN_ERROR;
+    1765             : 
+    1766             :     /* set current position in file */
+    1767        3770 :     file->position = index;
+    1768             : 
+    1769        3770 :     return DLT_RETURN_OK;
+    1770             : }
+    1771             : 
+    1772          51 : DltReturnValue dlt_file_free(DltFile *file, int verbose)
+    1773             : {
+    1774          51 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1775             : 
+    1776          51 :     if (file == NULL)
+    1777             :         return DLT_RETURN_WRONG_PARAMETER;
+    1778             : 
+    1779             :     /* delete index lost if exists */
+    1780          51 :     if (file->index)
+    1781          36 :         free(file->index);
+    1782             : 
+    1783          51 :     file->index = NULL;
+    1784             : 
+    1785             :     /* close file */
+    1786          51 :     if (file->handle)
+    1787          41 :         fclose(file->handle);
+    1788             : 
+    1789          51 :     file->handle = NULL;
+    1790             : 
+    1791          51 :     return dlt_message_free(&(file->msg), verbose);
+    1792             : }
+    1793             : 
+    1794             : #if defined DLT_DAEMON_USE_FIFO_IPC || defined DLT_LIB_USE_FIFO_IPC
+    1795       16795 : void dlt_log_set_fifo_basedir(const char *pipe_dir)
+    1796             : {
+    1797             :     strncpy(dltFifoBaseDir, pipe_dir, DLT_PATH_MAX);
+    1798       16795 :     dltFifoBaseDir[DLT_PATH_MAX - 1] = 0;
+    1799       16786 : }
+    1800             : #endif
+    1801             : 
+    1802             : #ifdef DLT_SHM_ENABLE
+    1803             : void dlt_log_set_shm_name(const char *env_shm_name)
+    1804             : {
+    1805             :     strncpy(dltShmName, env_shm_name, NAME_MAX);
+    1806             :     dltShmName[NAME_MAX] = 0;
+    1807             : }
+    1808             : #endif
+    1809             : 
+    1810           0 : void dlt_print_with_attributes(bool state)
+    1811             : {
+    1812           0 :     print_with_attributes = state;
+    1813           0 : }
+    1814             : 
+    1815       16828 : DltReturnValue dlt_receiver_init(DltReceiver *receiver, int fd, DltReceiverType type, int buffersize)
+    1816             : {
+    1817       16828 :     if (NULL == receiver)
+    1818             :         return DLT_RETURN_WRONG_PARAMETER;
+    1819             : 
+    1820       16828 :     receiver->fd = fd;
+    1821       16828 :     receiver->type = type;
+    1822             : 
+    1823             :     /** Reuse the receiver buffer if it exists and the buffer size
+    1824             :       * is not changed. If not, free the old one and allocate a new buffer.
+    1825             :       */
+    1826       16828 :     if ((NULL != receiver->buffer) && ( buffersize != receiver->buffersize)) {
+    1827           0 :        free(receiver->buffer);
+    1828           0 :        receiver->buffer = NULL;
+    1829             :     }
+    1830             : 
+    1831       16828 :     if (NULL == receiver->buffer) {
+    1832       16828 :         receiver->lastBytesRcvd = 0;
+    1833       16828 :         receiver->bytesRcvd = 0;
+    1834       16828 :         receiver->totalBytesRcvd = 0;
+    1835       16828 :         receiver->buf = NULL;
+    1836       16828 :         receiver->backup_buf = NULL;
+    1837       16828 :         receiver->buffer = (char *)calloc(1, (size_t)buffersize);
+    1838       16828 :         receiver->buffersize = (uint32_t)buffersize;
+    1839             :     }
+    1840             : 
+    1841       16828 :     if (NULL == receiver->buffer) {
+    1842           0 :         dlt_log(LOG_ERR, "allocate memory for receiver buffer failed.\n");
+    1843           0 :         return DLT_RETURN_ERROR;
+    1844             :     }
+    1845             :     else {
+    1846       16828 :         receiver->buf = receiver->buffer;
+    1847             :     }
+    1848             : 
+    1849       16828 :     return DLT_RETURN_OK;
+    1850             : }
+    1851             : 
+    1852           9 : DltReturnValue dlt_receiver_init_global_buffer(DltReceiver *receiver, int fd, DltReceiverType type, char **buffer)
+    1853             : {
+    1854           9 :     if (receiver == NULL)
+    1855             :         return DLT_RETURN_WRONG_PARAMETER;
+    1856             : 
+    1857           9 :     if (*buffer == NULL) {
+    1858             :         /* allocating the buffer once and using it for all application receivers
+    1859             :          * by keeping allocated buffer in app_recv_buffer global handle
+    1860             :          */
+    1861           9 :         *buffer = (char *)malloc(DLT_RECEIVE_BUFSIZE);
+    1862             : 
+    1863           9 :         if (*buffer == NULL)
+    1864             :             return DLT_RETURN_ERROR;
+    1865             :     }
+    1866             : 
+    1867           9 :     receiver->lastBytesRcvd = 0;
+    1868           9 :     receiver->bytesRcvd = 0;
+    1869           9 :     receiver->totalBytesRcvd = 0;
+    1870           9 :     receiver->buffersize = DLT_RECEIVE_BUFSIZE;
+    1871           9 :     receiver->fd = fd;
+    1872           9 :     receiver->type = type;
+    1873           9 :     receiver->buffer = *buffer;
+    1874           9 :     receiver->backup_buf = NULL;
+    1875           9 :     receiver->buf = receiver->buffer;
+    1876             : 
+    1877           9 :     return DLT_RETURN_OK;
+    1878             : }
+    1879             : 
+    1880       16827 : DltReturnValue dlt_receiver_free(DltReceiver *receiver)
+    1881             : {
+    1882             : 
+    1883       16827 :     if (receiver == NULL)
+    1884             :         return DLT_RETURN_WRONG_PARAMETER;
+    1885             : 
+    1886       16827 :     if (receiver->buffer)
+    1887       16825 :         free(receiver->buffer);
+    1888             : 
+    1889       16827 :     if (receiver->backup_buf)
+    1890           0 :         free(receiver->backup_buf);
+    1891             : 
+    1892       16827 :     receiver->buffer = NULL;
+    1893       16827 :     receiver->buf = NULL;
+    1894       16827 :     receiver->backup_buf = NULL;
+    1895             : 
+    1896       16827 :     return DLT_RETURN_OK;
+    1897             : }
+    1898             : 
+    1899           9 : DltReturnValue dlt_receiver_free_global_buffer(DltReceiver *receiver)
+    1900             : {
+    1901             : 
+    1902           9 :     if (receiver == NULL)
+    1903             :         return DLT_RETURN_WRONG_PARAMETER;
+    1904             : 
+    1905           9 :     if (receiver->backup_buf)
+    1906           0 :         free(receiver->backup_buf);
+    1907             : 
+    1908           9 :     receiver->buffer = NULL;
+    1909           9 :     receiver->buf = NULL;
+    1910           9 :     receiver->backup_buf = NULL;
+    1911             : 
+    1912           9 :     return DLT_RETURN_OK;
+    1913             : }
+    1914             : 
+    1915        1964 : int dlt_receiver_receive(DltReceiver *receiver)
+    1916             : {
+    1917             :     socklen_t addrlen;
+    1918             : 
+    1919        1964 :     if (receiver == NULL)
+    1920             :         return -1;
+    1921             : 
+    1922        1964 :     if (receiver->buffer == NULL)
+    1923             :         return -1;
+    1924             : 
+    1925        1963 :     receiver->buf = (char *)receiver->buffer;
+    1926        1963 :     receiver->lastBytesRcvd = receiver->bytesRcvd;
+    1927             : 
+    1928        1963 :     if ((receiver->lastBytesRcvd) && (receiver->backup_buf != NULL)) {
+    1929           0 :         memcpy(receiver->buf, receiver->backup_buf, (size_t)receiver->lastBytesRcvd);
+    1930           0 :         free(receiver->backup_buf);
+    1931           0 :         receiver->backup_buf = NULL;
+    1932             :     }
+    1933             : 
+    1934        1963 :     if (receiver->type == DLT_RECEIVE_SOCKET)
+    1935             :         /* wait for data from socket */
+    1936         431 :         receiver->bytesRcvd = recv(receiver->fd,
+    1937         431 :                                    receiver->buf + receiver->lastBytesRcvd,
+    1938         431 :                                    receiver->buffersize - (uint32_t) receiver->lastBytesRcvd,
+    1939             :                                    0);
+    1940        1532 :     else if (receiver->type == DLT_RECEIVE_FD)
+    1941             :         /* wait for data from fd */
+    1942        1532 :         receiver->bytesRcvd = read(receiver->fd,
+    1943        1532 :                                    receiver->buf + receiver->lastBytesRcvd,
+    1944        1532 :                                    receiver->buffersize - (uint32_t) receiver->lastBytesRcvd);
+    1945             : 
+    1946             :     else { /* receiver->type == DLT_RECEIVE_UDP_SOCKET */
+    1947             :         /* wait for data from UDP socket */
+    1948           0 :         addrlen = sizeof(receiver->addr);
+    1949           0 :         receiver->bytesRcvd = recvfrom(receiver->fd,
+    1950           0 :                                        receiver->buf + receiver->lastBytesRcvd,
+    1951           0 :                                        receiver->buffersize - receiver->lastBytesRcvd,
+    1952             :                                        0,
+    1953           0 :                                        (struct sockaddr *)&(receiver->addr),
+    1954             :                                        &addrlen);
+    1955             :     }
+    1956             : 
+    1957        1963 :     if (receiver->bytesRcvd <= 0) {
+    1958           6 :         receiver->bytesRcvd = 0;
+    1959           6 :         return receiver->bytesRcvd;
+    1960             :     } /* if */
+    1961             : 
+    1962        1957 :     receiver->totalBytesRcvd += receiver->bytesRcvd;
+    1963        1957 :     receiver->bytesRcvd += receiver->lastBytesRcvd;
+    1964             : 
+    1965        1957 :     return receiver->bytesRcvd;
+    1966             : }
+    1967             : 
+    1968        6097 : DltReturnValue dlt_receiver_remove(DltReceiver *receiver, int size)
+    1969             : {
+    1970        6097 :     if (receiver == NULL)
+    1971             :         return DLT_RETURN_WRONG_PARAMETER;
+    1972             : 
+    1973        6140 :     if (receiver->buf == NULL)
+    1974             :         return DLT_RETURN_ERROR;
+    1975             : 
+    1976        6140 :     if ((size > receiver->bytesRcvd) || (size <= 0)) {
+    1977           0 :         receiver->buf = receiver->buf + receiver->bytesRcvd;
+    1978           0 :         receiver->bytesRcvd = 0;
+    1979           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    1980             :     }
+    1981             : 
+    1982        6140 :     receiver->bytesRcvd = receiver->bytesRcvd - size;
+    1983         263 :     receiver->buf = receiver->buf + size;
+    1984             : 
+    1985        6097 :     return DLT_RETURN_OK;
+    1986             : }
+    1987             : 
+    1988        1958 : DltReturnValue dlt_receiver_move_to_begin(DltReceiver *receiver)
+    1989             : {
+    1990        1958 :     if (receiver == NULL)
+    1991             :         return DLT_RETURN_WRONG_PARAMETER;
+    1992             : 
+    1993        1958 :     if ((receiver->buffer == NULL) || (receiver->buf == NULL))
+    1994             :         return DLT_RETURN_ERROR;
+    1995             : 
+    1996        1958 :     if ((receiver->buffer != receiver->buf) && (receiver->bytesRcvd != 0)) {
+    1997           0 :         receiver->backup_buf = calloc((size_t)(receiver->bytesRcvd + 1), sizeof(char));
+    1998             : 
+    1999           0 :         if (receiver->backup_buf == NULL)
+    2000           0 :             dlt_vlog(LOG_WARNING,
+    2001             :                      "Can't allocate memory for backup buf, there will be atleast"
+    2002             :                      "one corrupted message for fd[%d] \n", receiver->fd);
+    2003             :         else
+    2004           0 :             memcpy(receiver->backup_buf, receiver->buf, (size_t)receiver->bytesRcvd);
+    2005             :     }
+    2006             : 
+    2007             :     return DLT_RETURN_OK;
+    2008             : }
+    2009             : 
+    2010         133 : int dlt_receiver_check_and_get(DltReceiver *receiver,
+    2011             :                                void *dest,
+    2012             :                                unsigned int to_get,
+    2013             :                                unsigned int flags)
+    2014             : {
+    2015         133 :     size_t min_size = (size_t)to_get;
+    2016             :     uint8_t *src = NULL;
+    2017             : 
+    2018         133 :     if (flags & DLT_RCV_SKIP_HEADER)
+    2019          88 :         min_size += sizeof(DltUserHeader);
+    2020             : 
+    2021         133 :     if (!receiver ||
+    2022         133 :         (receiver->bytesRcvd < (int32_t) min_size) ||
+    2023         133 :         !receiver->buf ||
+    2024             :         !dest)
+    2025             :         return DLT_RETURN_WRONG_PARAMETER;
+    2026             : 
+    2027             :     src = (uint8_t *)receiver->buf;
+    2028             : 
+    2029         133 :     if (flags & DLT_RCV_SKIP_HEADER)
+    2030          88 :         src += sizeof(DltUserHeader);
+    2031             : 
+    2032             :     memcpy(dest, src, to_get);
+    2033             : 
+    2034         133 :     if (flags & DLT_RCV_REMOVE) {
+    2035           0 :         if (dlt_receiver_remove(receiver, (int)min_size) != DLT_RETURN_OK) {
+    2036           0 :             dlt_log(LOG_WARNING, "Can't remove bytes from receiver\n");
+    2037           0 :             return DLT_RETURN_ERROR;
+    2038             :         }
+    2039             :     }
+    2040             : 
+    2041         133 :     return to_get;
+    2042             : }
+    2043             : 
+    2044       12103 : DltReturnValue dlt_set_storageheader(DltStorageHeader *storageheader, const char *ecu)
+    2045             : {
+    2046             : 
+    2047             : #if !defined(_MSC_VER)
+    2048             :     struct timeval tv;
+    2049             : #endif
+    2050             : 
+    2051       12103 :     if ((storageheader == NULL) || (ecu == NULL))
+    2052             :         return DLT_RETURN_WRONG_PARAMETER;
+    2053             : 
+    2054             :     /* get time of day */
+    2055             : #if defined(_MSC_VER)
+    2056             :     time(&(storageheader->seconds));
+    2057             : #else
+    2058       12103 :     gettimeofday(&tv, NULL);
+    2059             : #endif
+    2060             : 
+    2061             :     /* prepare storage header */
+    2062       12103 :     storageheader->pattern[0] = 'D';
+    2063       12103 :     storageheader->pattern[1] = 'L';
+    2064       12103 :     storageheader->pattern[2] = 'T';
+    2065       12103 :     storageheader->pattern[3] = 0x01;
+    2066             : 
+    2067       12103 :     dlt_set_id(storageheader->ecu, ecu);
+    2068             : 
+    2069             :     /* Set current time */
+    2070             : #if defined(_MSC_VER)
+    2071             :     storageheader->microseconds = 0;
+    2072             : #else
+    2073       12103 :     storageheader->seconds = (uint32_t) tv.tv_sec; /* value is long */
+    2074       12103 :     storageheader->microseconds = (int32_t) tv.tv_usec; /* value is long */
+    2075             : #endif
+    2076             : 
+    2077       12103 :     return DLT_RETURN_OK;
+    2078             : }
+    2079             : 
+    2080           9 : DltReturnValue dlt_check_rcv_data_size(int received, int required)
+    2081             : {
+    2082             :     int _ret = DLT_RETURN_OK;
+    2083           9 :     if (received < required) {
+    2084           1 :         dlt_vlog(LOG_WARNING, "%s: Received data not complete\n", __func__);
+    2085             :         _ret = DLT_RETURN_ERROR;
+    2086             :     }
+    2087             : 
+    2088           9 :     return _ret;
+    2089             : }
+    2090             : 
+    2091        6589 : DltReturnValue dlt_check_storageheader(DltStorageHeader *storageheader)
+    2092             : {
+    2093        6589 :     if (storageheader == NULL)
+    2094             :         return DLT_RETURN_WRONG_PARAMETER;
+    2095             : 
+    2096       13178 :     return ((storageheader->pattern[0] == 'D') &&
+    2097        6589 :             (storageheader->pattern[1] == 'L') &&
+    2098        6589 :             (storageheader->pattern[2] == 'T') &&
+    2099        6589 :             (storageheader->pattern[3] == 1))
+    2100       13178 :            ? DLT_RETURN_TRUE : DLT_RETURN_OK;
+    2101             : }
+    2102             : 
+    2103           0 : DltReturnValue dlt_buffer_init_static_server(DltBuffer *buf, const unsigned char *ptr, uint32_t size)
+    2104             : {
+    2105           0 :     if ((buf == NULL) || (ptr == NULL))
+    2106             :         return DLT_RETURN_WRONG_PARAMETER;
+    2107             : 
+    2108             :     DltBufferHead *head;
+    2109             : 
+    2110             :     /* Init parameters */
+    2111           0 :     buf->shm = (unsigned char *)ptr;
+    2112           0 :     buf->min_size = size;
+    2113           0 :     buf->max_size = size;
+    2114           0 :     buf->step_size = 0;
+    2115             : 
+    2116             :     /* Init pointers */
+    2117             :     head = (DltBufferHead *)buf->shm;
+    2118           0 :     head->read = 0;
+    2119           0 :     head->write = 0;
+    2120           0 :     head->count = 0;
+    2121           0 :     buf->mem = (unsigned char *)(buf->shm + sizeof(DltBufferHead));
+    2122           0 :     buf->size = (unsigned int) buf->min_size - (unsigned int) sizeof(DltBufferHead);
+    2123             : 
+    2124             :     /* clear memory */
+    2125           0 :     memset(buf->mem, 0, buf->size);
+    2126             : 
+    2127           0 :     dlt_vlog(LOG_DEBUG,
+    2128             :              "%s: Buffer: Size %u, Start address %lX\n",
+    2129           0 :              __func__, buf->size, (unsigned long)buf->mem);
+    2130             : 
+    2131           0 :     return DLT_RETURN_OK; /* OK */
+    2132             : }
+    2133             : 
+    2134           0 : DltReturnValue dlt_buffer_init_static_client(DltBuffer *buf, const unsigned char *ptr, uint32_t size)
+    2135             : {
+    2136           0 :     if ((buf == NULL) || (ptr == NULL))
+    2137             :         return DLT_RETURN_WRONG_PARAMETER;
+    2138             : 
+    2139             :     /* Init parameters */
+    2140           0 :     buf->shm = (unsigned char *)ptr;
+    2141           0 :     buf->min_size = size;
+    2142           0 :     buf->max_size = size;
+    2143           0 :     buf->step_size = 0;
+    2144             : 
+    2145             :     /* Init pointers */
+    2146           0 :     buf->mem = (unsigned char *)(buf->shm + sizeof(DltBufferHead));
+    2147           0 :     buf->size = (uint32_t)(buf->min_size - sizeof(DltBufferHead));
+    2148             : 
+    2149           0 :     dlt_vlog(LOG_DEBUG,
+    2150             :              "%s: Buffer: Size %u, Start address %lX\n",
+    2151             :              __func__, buf->size, (unsigned long)buf->mem);
+    2152             : 
+    2153           0 :     return DLT_RETURN_OK; /* OK */
+    2154             : }
+    2155             : 
+    2156       16916 : DltReturnValue dlt_buffer_init_dynamic(DltBuffer *buf, uint32_t min_size, uint32_t max_size, uint32_t step_size)
+    2157             : {
+    2158             :     /*Do not DLT_SEM_LOCK inside here! */
+    2159             :     DltBufferHead *head;
+    2160             : 
+    2161             :     /* catch null pointer */
+    2162       16916 :     if (buf == NULL)
+    2163             :         return DLT_RETURN_WRONG_PARAMETER;
+    2164             : 
+    2165             :     /* catch 0 logical errors */
+    2166       16908 :     if ((min_size == 0) || (max_size == 0) || (step_size == 0))
+    2167             :         return DLT_RETURN_WRONG_PARAMETER;
+    2168             : 
+    2169       16901 :     if (min_size > max_size)
+    2170             :         return DLT_RETURN_WRONG_PARAMETER;
+    2171             : 
+    2172       16901 :     if (step_size > max_size)
+    2173             :         return DLT_RETURN_WRONG_PARAMETER;
+    2174             : 
+    2175             :     /* Init parameters */
+    2176       16901 :     buf->min_size = min_size;
+    2177       16901 :     buf->max_size = max_size;
+    2178       16901 :     buf->step_size = step_size;
+    2179             : 
+    2180             :     /* allocat memory */
+    2181       16901 :     buf->shm = malloc(buf->min_size);
+    2182             : 
+    2183       16901 :     if (buf->shm == NULL) {
+    2184           0 :         dlt_vlog(LOG_EMERG,
+    2185             :                  "%s: Buffer: Cannot allocate %u bytes\n",
+    2186             :                  __func__, buf->min_size);
+    2187           0 :         return DLT_RETURN_ERROR;
+    2188             :     }
+    2189             : 
+    2190             :     /* Init pointers */
+    2191             :     head = (DltBufferHead *)buf->shm;
+    2192       16901 :     head->read = 0;
+    2193       16901 :     head->write = 0;
+    2194       16901 :     head->count = 0;
+    2195       16901 :     buf->mem = (unsigned char *)(buf->shm + sizeof(DltBufferHead));
+    2196             : 
+    2197       16901 :     if (buf->min_size < (uint32_t)sizeof(DltBufferHead)) {
+    2198           0 :         dlt_vlog(LOG_ERR,
+    2199             :                  "%s: min_size is too small [%u]\n",
+    2200             :                  __func__, buf->min_size);
+    2201           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    2202             :     }
+    2203             : 
+    2204       16901 :     buf->size = (uint32_t) (buf->min_size - sizeof(DltBufferHead));
+    2205             : 
+    2206       16901 :     dlt_vlog(LOG_DEBUG,
+    2207             :              "%s: Buffer: Size %u, Start address %lX\n",
+    2208             :              __func__, buf->size, (unsigned long)buf->mem);
+    2209             : 
+    2210             :     /* clear memory */
+    2211       16901 :     memset(buf->mem, 0, (size_t)buf->size);
+    2212             : 
+    2213       16901 :     return DLT_RETURN_OK; /* OK */
+    2214             : }
+    2215             : 
+    2216           0 : DltReturnValue dlt_buffer_free_static(DltBuffer *buf)
+    2217             : {
+    2218             :     /* catch null pointer */
+    2219           0 :     if (buf == NULL)
+    2220             :         return DLT_RETURN_WRONG_PARAMETER;
+    2221             : 
+    2222           0 :     if (buf->mem == NULL) {
+    2223             :         /* buffer not initialized */
+    2224           0 :         dlt_vlog(LOG_WARNING, "%s: Buffer: Buffer not initialized\n", __func__);
+    2225           0 :         return DLT_RETURN_ERROR; /* ERROR */
+    2226             :     }
+    2227             : 
+    2228             :     return DLT_RETURN_OK;
+    2229             : }
+    2230             : 
+    2231       16891 : DltReturnValue dlt_buffer_free_dynamic(DltBuffer *buf)
+    2232             : {
+    2233             :     /* catch null pointer */
+    2234       16891 :     if (buf == NULL)
+    2235             :         return DLT_RETURN_WRONG_PARAMETER;
+    2236             : 
+    2237       16890 :     if (buf->shm == NULL) {
+    2238             :         /* buffer not initialized */
+    2239           0 :         dlt_vlog(LOG_WARNING, "%s: Buffer: Buffer not initialized\n", __func__);
+    2240           0 :         return DLT_RETURN_ERROR; /* ERROR */
+    2241             :     }
+    2242             : 
+    2243       16890 :     free(buf->shm);
+    2244       16890 :     buf->shm = NULL;
+    2245       16890 :     buf->mem = NULL;
+    2246             : 
+    2247       16890 :     return DLT_RETURN_OK;
+    2248             : }
+    2249             : 
+    2250       41031 : void dlt_buffer_write_block(DltBuffer *buf, int *write, const unsigned char *data, unsigned int size)
+    2251             : {
+    2252             :     /* catch null pointer */
+    2253       41031 :     if ((buf != NULL) && (write != NULL) && (data != NULL)) {
+    2254       40012 :         if (size <= buf->size){
+    2255       40012 :             if (( (unsigned int) (*write ) + size) <= buf->size) {
+    2256             :                 /* write one block */
+    2257       40011 :                 memcpy(buf->mem + *write, data, size);
+    2258       40011 :                 *write += (int) size;
+    2259             :             }
+    2260             :             else {
+    2261             :                 /* when (*write) = buf->size, write only the second block
+    2262             :                 * and update write position correspondingly.
+    2263             :                 */
+    2264           1 :                 if((unsigned int) (*write) <= buf->size) {
+    2265             :                     /* write two blocks */
+    2266           1 :                     memcpy(buf->mem + *write, data, buf->size - (unsigned int) (*write));
+    2267           1 :                     memcpy(buf->mem, data + buf->size - *write, size - buf->size + (unsigned int) (*write));
+    2268           1 :                     *write += (int) (size - buf->size);
+    2269             :                 }
+    2270             :             }
+    2271             :         }
+    2272             :         else {
+    2273           0 :             dlt_vlog(LOG_WARNING, "%s: Write error: ring buffer to small\n", __func__);
+    2274             :         }
+    2275             :     }
+    2276             :     else {
+    2277        1019 :         dlt_vlog(LOG_WARNING, "%s: Wrong parameter: Null pointer\n", __func__);
+    2278             :     }
+    2279       41031 : }
+    2280             : 
+    2281          53 : void dlt_buffer_read_block(DltBuffer *buf, int *read, unsigned char *data, unsigned int size)
+    2282             : {
+    2283             :     /* catch nullpointer */
+    2284          53 :     if ((buf != NULL) && (read != NULL) && (data != NULL)) {
+    2285          37 :         if (((unsigned int)(*read) + size) <= buf->size) {
+    2286             :             /* read one block */
+    2287          35 :             memcpy(data, buf->mem + *read, size);
+    2288          35 :             *read += (int)size;
+    2289             :         }
+    2290             :         else {
+    2291             :             /* when (*read) = buf->size, read only the second block
+    2292             :             * and update read position correspondingly.
+    2293             :             */
+    2294           2 :             if ((unsigned int)(*read) <= buf->size) {
+    2295             :                 /* read two blocks */
+    2296           1 :                 memcpy(data, buf->mem + *read, buf->size - (unsigned int)(*read));
+    2297           1 :                 memcpy(data + buf->size - *read, buf->mem, size - buf->size + (unsigned int)(*read));
+    2298           1 :                 *read += (int) (size - buf->size);
+    2299             :             }
+    2300             :         }
+    2301             :     }
+    2302             :     else {
+    2303          16 :         dlt_vlog(LOG_WARNING, "%s: Wrong parameter: Null pointer\n", __func__);
+    2304             :     }
+    2305          53 : }
+    2306             : 
+    2307         859 : int dlt_buffer_check_size(DltBuffer *buf, int needed)
+    2308             : {
+    2309         859 :     if (buf == NULL)
+    2310             :         return DLT_RETURN_WRONG_PARAMETER;
+    2311             : 
+    2312         859 :     if ((buf->size + sizeof(DltBufferHead) + (size_t) needed) > buf->max_size)
+    2313           0 :         return DLT_RETURN_ERROR;
+    2314             : 
+    2315             :     return DLT_RETURN_OK;
+    2316             : }
+    2317             : 
+    2318           7 : int dlt_buffer_increase_size(DltBuffer *buf)
+    2319             : {
+    2320             :     DltBufferHead *head, *new_head;
+    2321             :     unsigned char *new_ptr;
+    2322             : 
+    2323             :     /* catch null pointer */
+    2324           7 :     if (buf == NULL) {
+    2325           1 :         dlt_vlog(LOG_WARNING, "%s: Wrong parameter: Null pointer\n", __func__);
+    2326           1 :         return DLT_RETURN_WRONG_PARAMETER;
+    2327             :     }
+    2328             : 
+    2329             :     /* check size */
+    2330           6 :     if (buf->step_size == 0)
+    2331             :         /* cannot increase size */
+    2332             :         return DLT_RETURN_ERROR;
+    2333             : 
+    2334             :     /* check size */
+    2335           6 :     if ((buf->size + sizeof(DltBufferHead) + buf->step_size) > buf->max_size)
+    2336             :         /* max size reached, do not increase */
+    2337             :         return DLT_RETURN_ERROR;
+    2338             : 
+    2339             :     /* allocate new buffer */
+    2340           6 :     new_ptr = malloc(buf->size + sizeof(DltBufferHead) + buf->step_size);
+    2341             : 
+    2342           6 :     if (new_ptr == NULL) {
+    2343           0 :         dlt_vlog(LOG_WARNING,
+    2344             :                  "%s: Buffer: Cannot increase size because allocate %u bytes failed\n",
+    2345             :                  __func__, buf->min_size);
+    2346           0 :         return DLT_RETURN_ERROR;
+    2347             :     }
+    2348             : 
+    2349             :     /* copy data */
+    2350           6 :     head = (DltBufferHead *)buf->shm;
+    2351             :     new_head = (DltBufferHead *)new_ptr;
+    2352             : 
+    2353           6 :     if (head->read < head->write) {
+    2354           4 :         memcpy(new_ptr + sizeof(DltBufferHead), buf->mem + head->read, (size_t)(head->write - head->read));
+    2355           4 :         new_head->read = 0;
+    2356           4 :         new_head->write = head->write - head->read;
+    2357           4 :         new_head->count = head->count;
+    2358             :     }
+    2359             :     else {
+    2360           2 :         memcpy(new_ptr + sizeof(DltBufferHead), buf->mem + head->read, buf->size - (uint32_t)(head->read));
+    2361           2 :         memcpy(new_ptr + sizeof(DltBufferHead) + buf->size - head->read, buf->mem, (size_t)head->write);
+    2362           2 :         new_head->read = 0;
+    2363           2 :         new_head->write = (int)(buf->size) + head->write - head->read;
+    2364           2 :         new_head->count = head->count;
+    2365             :     }
+    2366             : 
+    2367             :     /* free old data */
+    2368           6 :     free(buf->shm);
+    2369             : 
+    2370             :     /* update data */
+    2371           6 :     buf->shm = new_ptr;
+    2372           6 :     buf->mem = new_ptr + sizeof(DltBufferHead);
+    2373           6 :     buf->size += buf->step_size;
+    2374             : 
+    2375           6 :     dlt_vlog(LOG_DEBUG,
+    2376             :              "%s: Buffer: Size increased to %u bytes with start address %lX\n",
+    2377             :              __func__,
+    2378             :              buf->size + (int32_t)sizeof(DltBufferHead),
+    2379             :              (unsigned long)buf->mem);
+    2380             : 
+    2381           6 :     return DLT_RETURN_OK; /* OK */
+    2382             : }
+    2383             : 
+    2384           8 : int dlt_buffer_minimize_size(DltBuffer *buf)
+    2385             : {
+    2386             :     unsigned char *new_ptr;
+    2387             : 
+    2388             :     /* catch null pointer */
+    2389           8 :     if (buf == NULL) {
+    2390           1 :         dlt_vlog(LOG_WARNING, "%s: Wrong parameter: Null pointer\n", __func__);
+    2391           1 :         return DLT_RETURN_WRONG_PARAMETER;
+    2392             :     }
+    2393             : 
+    2394           7 :     if ((buf->size + sizeof(DltBufferHead)) == buf->min_size)
+    2395             :         /* already minimized */
+    2396             :         return DLT_RETURN_OK;
+    2397             : 
+    2398             :     /* allocate new buffer */
+    2399           0 :     new_ptr = malloc(buf->min_size);
+    2400             : 
+    2401           0 :     if (new_ptr == NULL) {
+    2402           0 :         dlt_vlog(LOG_WARNING,
+    2403             :                  "%s: Buffer: Cannot set to min size of %u bytes\n",
+    2404             :                  __func__, buf->min_size);
+    2405           0 :         return DLT_RETURN_ERROR;
+    2406             :     }
+    2407             : 
+    2408             :     /* free old data */
+    2409           0 :     free(buf->shm);
+    2410             : 
+    2411             :     /* update data */
+    2412           0 :     buf->shm = new_ptr;
+    2413           0 :     buf->mem = new_ptr + sizeof(DltBufferHead);
+    2414           0 :     buf->size = (uint32_t)(buf->min_size - sizeof(DltBufferHead));
+    2415             : 
+    2416             :     /* reset pointers and counters */
+    2417           0 :     ((int *)(buf->shm))[0] = 0;  /* pointer to write memory */
+    2418           0 :     ((int *)(buf->shm))[1] = 0;  /* pointer to read memory */
+    2419           0 :     ((int *)(buf->shm))[2] = 0;  /* number of packets */
+    2420             : 
+    2421           0 :     dlt_vlog(LOG_DEBUG,
+    2422             :              "%s: Buffer: Buffer minimized to Size %u bytes with start address %lX\n",
+    2423             :              __func__, buf->size, (unsigned long)buf->mem);
+    2424             : 
+    2425             :     /* clear memory */
+    2426           0 :     memset(buf->mem, 0, buf->size);
+    2427             : 
+    2428           0 :     return DLT_RETURN_OK; /* OK */
+    2429             : }
+    2430             : 
+    2431           9 : int dlt_buffer_reset(DltBuffer *buf)
+    2432             : {
+    2433             :     /* catch null pointer */
+    2434           9 :     if (buf == NULL) {
+    2435           1 :         dlt_vlog(LOG_WARNING, "%s: Wrong parameter: Null pointer\n", __func__);
+    2436           1 :         return DLT_RETURN_WRONG_PARAMETER;
+    2437             :     }
+    2438             : 
+    2439           8 :     dlt_vlog(LOG_WARNING,
+    2440             :              "%s: Buffer: Buffer reset triggered. Size: %u, Start address: %lX\n",
+    2441           8 :              __func__, buf->size, (unsigned long)buf->mem);
+    2442             : 
+    2443             :     /* reset pointers and counters */
+    2444           8 :     ((int *)(buf->shm))[0] = 0;  /* pointer to write memory */
+    2445           8 :     ((int *)(buf->shm))[1] = 0;  /* pointer to read memory */
+    2446           8 :     ((int *)(buf->shm))[2] = 0;  /* number of packets */
+    2447             : 
+    2448             :     /* clear memory */
+    2449           8 :     memset(buf->mem, 0, buf->size);
+    2450             : 
+    2451           8 :     return DLT_RETURN_OK; /* OK */
+    2452             : }
+    2453             : 
+    2454        7516 : DltReturnValue dlt_buffer_push(DltBuffer *buf, const unsigned char *data, unsigned int size)
+    2455             : {
+    2456        7516 :     return dlt_buffer_push3(buf, data, size, 0, 0, 0, 0);
+    2457             : }
+    2458             : 
+    2459       15284 : int dlt_buffer_push3(DltBuffer *buf,
+    2460             :                      const unsigned char *data1,
+    2461             :                      unsigned int size1,
+    2462             :                      const unsigned char *data2,
+    2463             :                      unsigned int size2,
+    2464             :                      const unsigned char *data3,
+    2465             :                      unsigned int size3)
+    2466             : {
+    2467             :     int free_size;
+    2468             :     int write, read, count;
+    2469             :     DltBufferBlockHead head;
+    2470             : 
+    2471             :     /* catch null pointer */
+    2472       15284 :     if (buf == NULL)
+    2473             :         return DLT_RETURN_WRONG_PARAMETER;
+    2474             : 
+    2475       15216 :     if (buf->shm == NULL) {
+    2476             :         /* buffer not initialised */
+    2477           0 :         dlt_vlog(LOG_ERR, "%s: Buffer: Buffer not initialized\n", __func__);
+    2478           0 :         return DLT_RETURN_ERROR; /* ERROR */
+    2479             :     }
+    2480             : 
+    2481             :     /* get current write pointer */
+    2482       15216 :     write = ((int *)(buf->shm))[0];
+    2483       15216 :     read = ((int *)(buf->shm))[1];
+    2484       15216 :     count = ((int *)(buf->shm))[2];
+    2485             : 
+    2486             :     /* check pointers */
+    2487       15216 :     if (((unsigned int)read > buf->size) || ((unsigned int)write > buf->size)) {
+    2488           0 :         dlt_vlog(LOG_ERR,
+    2489             :                  "%s: Buffer: Pointer out of range. Read: %d, Write: %d, Size: %u\n",
+    2490             :                  __func__, read, write, buf->size);
+    2491           0 :         dlt_buffer_reset(buf);
+    2492           0 :         return DLT_RETURN_ERROR; /* ERROR */
+    2493             :     }
+    2494             : 
+    2495             :     /* calculate free size */
+    2496       15216 :     if (read > write)
+    2497           0 :         free_size = read - write;
+    2498       15216 :     else if (count && (write == read))
+    2499             :         free_size = 0;
+    2500             :     else
+    2501       15216 :         free_size = (int)buf->size - write + read;
+    2502             : 
+    2503             :     /* check size */
+    2504       15220 :     while (free_size < (int) (sizeof(DltBufferBlockHead) + size1 + size2 + size3)) {
+    2505             :         /* try to increase size if possible */
+    2506           4 :         if (dlt_buffer_increase_size(buf))
+    2507             :             /* increase size is not possible */
+    2508             :             /*dlt_log(LOG_ERR, "Buffer: Buffer is full\n"); */
+    2509             :             return DLT_RETURN_ERROR; /* ERROR */
+    2510             : 
+    2511             :         /* update pointers */
+    2512           4 :         write = ((int *)(buf->shm))[0];
+    2513           4 :         read = ((int *)(buf->shm))[1];
+    2514             : 
+    2515             :             /* update free size */
+    2516           4 :         if (read > write)
+    2517           0 :             free_size = read - write;
+    2518           4 :         else if (count && (write == read))
+    2519             :             free_size = 0;
+    2520             :         else
+    2521           4 :             free_size = buf->size - write + read;
+    2522             :     }
+    2523             : 
+    2524             :     /* set header */
+    2525             :     strncpy(head.head, DLT_BUFFER_HEAD, 4);
+    2526             :     head.head[3] = 0;
+    2527       15216 :     head.status = 2;
+    2528       15216 :     head.size = (int)(size1 + size2 + size3);
+    2529             : 
+    2530             :     /* write data */
+    2531       15216 :     dlt_buffer_write_block(buf, &write, (unsigned char *)&head, sizeof(DltBufferBlockHead));
+    2532             : 
+    2533       15216 :     if (size1)
+    2534       15216 :         dlt_buffer_write_block(buf, &write, data1, size1);
+    2535             : 
+    2536       15216 :     if (size2)
+    2537        7702 :         dlt_buffer_write_block(buf, &write, data2, size2);
+    2538             : 
+    2539       15216 :     if (size3)
+    2540        1877 :         dlt_buffer_write_block(buf, &write, data3, size3);
+    2541             : 
+    2542             :     /* update global shm pointers */
+    2543       15216 :     ((int *)(buf->shm))[0] = write; /* set new write pointer */
+    2544       15216 :     ((int *)(buf->shm))[2] += 1; /* increase counter */
+    2545             : 
+    2546       15216 :     return DLT_RETURN_OK; /* OK */
+    2547             : 
+    2548             : }
+    2549             : 
+    2550          64 : int dlt_buffer_get(DltBuffer *buf, unsigned char *data, int max_size, int delete)
+    2551             : {
+    2552             :     int used_size;
+    2553             :     int write, read, count;
+    2554          64 :     char head_compare[] = DLT_BUFFER_HEAD;
+    2555             :     DltBufferBlockHead head;
+    2556             : 
+    2557             :     /* catch null pointer */
+    2558          64 :     if (buf == NULL)
+    2559             :         return DLT_RETURN_WRONG_PARAMETER;
+    2560             : 
+    2561          47 :     if (buf->shm == NULL) {
+    2562             :         /* shm not initialised */
+    2563           0 :         dlt_vlog(LOG_ERR, "%s: Buffer: SHM not initialized\n", __func__);
+    2564           0 :         return DLT_RETURN_ERROR; /* ERROR */
+    2565             :     }
+    2566             : 
+    2567             :     /* get current write pointer */
+    2568          47 :     write = ((int *)(buf->shm))[0];
+    2569          47 :     read = ((int *)(buf->shm))[1];
+    2570          47 :     count = ((int *)(buf->shm))[2];
+    2571             : 
+    2572             :     /* check pointers */
+    2573          47 :     if (((unsigned int)read > buf->size) || ((unsigned int)write > buf->size) || (count < 0)) {
+    2574           3 :         dlt_vlog(LOG_ERR,
+    2575             :                  "%s: Buffer: Pointer out of range. Read: %d, Write: %d, Count: %d, Size: %u\n",
+    2576             :                  __func__, read, write, count, buf->size);
+    2577           3 :         dlt_buffer_reset(buf);
+    2578           3 :         return DLT_RETURN_ERROR; /* ERROR */
+    2579             :     }
+    2580             : 
+    2581             :     /* check if data is in there */
+    2582          44 :     if (count == 0) {
+    2583          22 :         if (write != read) {
+    2584           1 :             dlt_vlog(LOG_ERR,
+    2585             :                      "%s: Buffer: SHM should be empty, but is not. Read: %d, Write: %d\n",
+    2586             :                      __func__, read, write);
+    2587           1 :             dlt_buffer_reset(buf);
+    2588             :         }
+    2589             : 
+    2590          22 :         return DLT_RETURN_ERROR; /* ERROR */
+    2591             :     }
+    2592             : 
+    2593             :     /* calculate used size */
+    2594          22 :     if (write > read)
+    2595          21 :         used_size = write - read;
+    2596             :     else
+    2597           1 :         used_size = (int)buf->size - read + write;
+    2598             : 
+    2599             :     /* first check size */
+    2600          22 :     if (used_size < (int)(sizeof(DltBufferBlockHead))) {
+    2601           1 :         dlt_vlog(LOG_ERR,
+    2602             :                  "%s: Buffer: Used size is smaller than buffer block header size. Used size: %d\n",
+    2603             :                  __func__, used_size);
+    2604           1 :         dlt_buffer_reset(buf);
+    2605           1 :         return DLT_RETURN_ERROR; /* ERROR */
+    2606             :     }
+    2607             : 
+    2608             :     /* read header */
+    2609          21 :     dlt_buffer_read_block(buf, &read, (unsigned char *)&head, sizeof(DltBufferBlockHead));
+    2610             : 
+    2611             :     /* check header */
+    2612          21 :     if (memcmp((unsigned char *)(head.head), head_compare, sizeof(head_compare)) != 0) {
+    2613           1 :         dlt_vlog(LOG_ERR, "%s: Buffer: Header head check failed\n", __func__);
+    2614           1 :         dlt_buffer_reset(buf);
+    2615           1 :         return DLT_RETURN_ERROR; /* ERROR */
+    2616             :     }
+    2617             : 
+    2618          20 :     if (head.status != 2) {
+    2619           0 :         dlt_vlog(LOG_ERR, "%s: Buffer: Header status check failed\n", __func__);
+    2620           0 :         dlt_buffer_reset(buf);
+    2621           0 :         return DLT_RETURN_ERROR; /* ERROR */
+    2622             :     }
+    2623             : 
+    2624             :     /* second check size */
+    2625          20 :     if (used_size < ((int)sizeof(DltBufferBlockHead) + head.size)) {
+    2626           1 :         dlt_vlog(LOG_ERR,
+    2627             :                  "%s: Buffer: Used size is smaller than buffer block header size And read header size. Used size: %d\n",
+    2628             :                  __func__, used_size);
+    2629           1 :         dlt_buffer_reset(buf);
+    2630           1 :         return DLT_RETURN_ERROR; /* ERROR */
+    2631             :     }
+    2632             : 
+    2633             :     /* third check size */
+    2634          19 :     if (max_size && (head.size > max_size))
+    2635           1 :         dlt_vlog(LOG_WARNING,
+    2636             :                  "%s: Buffer: Max size is smaller than read header size. Max size: %d\n",
+    2637             :                  __func__, max_size);
+    2638             : 
+    2639             :     /* nothing to do but data does not fit provided buffer */
+    2640             : 
+    2641          19 :     if ((data != NULL) && max_size) {
+    2642             :         /* read data */
+    2643          14 :         dlt_buffer_read_block(buf, &read, data, (unsigned int)head.size);
+    2644             : 
+    2645          14 :         if (delete)
+    2646             :             /* update buffer pointers */
+    2647           3 :             ((int *)(buf->shm))[1] = read; /* set new read pointer */
+    2648             : 
+    2649             :     }
+    2650           5 :     else if (delete)
+    2651             :     {
+    2652           5 :         if ((unsigned int)(read + head.size) <= buf->size)
+    2653           5 :             ((int *)(buf->shm))[1] = read + head.size;  /* set new read pointer */
+    2654             :         else
+    2655           0 :             ((int *)(buf->shm))[1] = read + head.size - (int)buf->size;  /* set new read pointer */
+    2656             : 
+    2657             :     }
+    2658             : 
+    2659          19 :     if (delete) {
+    2660           8 :         ((int *)(buf->shm))[2] -= 1; /* decrease counter */
+    2661             : 
+    2662           8 :         if (((int *)(buf->shm))[2] == 0)
+    2663             :             /* try to minimize size */
+    2664           5 :             dlt_buffer_minimize_size(buf);
+    2665             :     }
+    2666             : 
+    2667          19 :     return head.size; /* OK */
+    2668             : }
+    2669             : 
+    2670           8 : int dlt_buffer_pull(DltBuffer *buf, unsigned char *data, int max_size)
+    2671             : {
+    2672           8 :     return dlt_buffer_get(buf, data, max_size, 1);
+    2673             : }
+    2674             : 
+    2675          13 : int dlt_buffer_copy(DltBuffer *buf, unsigned char *data, int max_size)
+    2676             : {
+    2677          13 :     return dlt_buffer_get(buf, data, max_size, 0);
+    2678             : }
+    2679             : 
+    2680           7 : int dlt_buffer_remove(DltBuffer *buf)
+    2681             : {
+    2682           7 :     return dlt_buffer_get(buf, 0, 0, 1);
+    2683             : }
+    2684             : 
+    2685           2 : void dlt_buffer_info(DltBuffer *buf)
+    2686             : {
+    2687             :     /* check nullpointer */
+    2688           2 :     if (buf == NULL) {
+    2689           1 :         dlt_vlog(LOG_WARNING, "%s: Wrong parameter: Null pointer\n", __func__);
+    2690           1 :         return;
+    2691             :     }
+    2692             : 
+    2693           1 :     dlt_vlog(LOG_DEBUG,
+    2694             :              "Buffer: Available size: %u, Buffer: Buffer full start address: %lX, Buffer: Buffer start address: %lX\n",
+    2695           1 :              buf->size, (unsigned long)buf->shm, (unsigned long)buf->mem);
+    2696             : }
+    2697             : 
+    2698           2 : void dlt_buffer_status(DltBuffer *buf)
+    2699             : {
+    2700             :     int write, read, count;
+    2701             : 
+    2702             :     /* check nullpointer */
+    2703           2 :     if (buf == NULL) {
+    2704           1 :         dlt_vlog(LOG_WARNING, "%s: Wrong parameter: Null pointer\n", __func__);
+    2705           1 :         return;
+    2706             :     }
+    2707             : 
+    2708             :     /* check if buffer available */
+    2709           1 :     if (buf->shm == NULL)
+    2710             :         return;
+    2711             : 
+    2712           1 :     write = ((int *)(buf->shm))[0];
+    2713           1 :     read = ((int *)(buf->shm))[1];
+    2714           1 :     count = ((int *)(buf->shm))[2];
+    2715             : 
+    2716           1 :     dlt_vlog(LOG_DEBUG,
+    2717             :              "Buffer: Write: %d, Read: %d, Count: %d\n",
+    2718             :              write, read, count);
+    2719             : }
+    2720             : 
+    2721           3 : uint32_t dlt_buffer_get_total_size(DltBuffer *buf)
+    2722             : {
+    2723             :     /* catch null pointer */
+    2724           3 :     if (buf == NULL)
+    2725             :         return DLT_RETURN_WRONG_PARAMETER;
+    2726             : 
+    2727           2 :     return buf->max_size;
+    2728             : }
+    2729             : 
+    2730        2503 : int dlt_buffer_get_used_size(DltBuffer *buf)
+    2731             : {
+    2732             :     int write, read, count;
+    2733             : 
+    2734             :     /* catch null pointer */
+    2735        2503 :     if (buf == NULL)
+    2736             :         return DLT_RETURN_WRONG_PARAMETER;
+    2737             : 
+    2738             :     /* check if buffer available */
+    2739        2502 :     if (buf->shm == NULL)
+    2740             :         return DLT_RETURN_OK;
+    2741             : 
+    2742        2502 :     write = ((int *)(buf->shm))[0];
+    2743        2502 :     read = ((int *)(buf->shm))[1];
+    2744        2502 :     count = ((int *)(buf->shm))[2];
+    2745             : 
+    2746        2502 :     if (count == 0)
+    2747             :         return DLT_RETURN_OK;
+    2748             : 
+    2749        2501 :     if (write > read)
+    2750        2501 :         return write - read;
+    2751             : 
+    2752           0 :     return (int)buf->size - read + write;
+    2753             : }
+    2754             : 
+    2755        8527 : int dlt_buffer_get_message_count(DltBuffer *buf)
+    2756             : {
+    2757             :     /* catch null pointer */
+    2758        8527 :     if (buf == NULL)
+    2759             :         return DLT_RETURN_WRONG_PARAMETER;
+    2760             : 
+    2761             :     /* check if buffer available */
+    2762        8527 :     if (buf->shm == NULL)
+    2763             :         return DLT_RETURN_OK;
+    2764             : 
+    2765        8527 :     return ((int *)(buf->shm))[2];
+    2766             : }
+    2767             : 
+    2768             : #if !defined (__WIN32__)
+    2769             : 
+    2770           0 : DltReturnValue dlt_setup_serial(int fd, speed_t speed)
+    2771             : {
+    2772             : #   if !defined (__WIN32__) && !defined(_MSC_VER)
+    2773             :     struct termios config;
+    2774             : 
+    2775           0 :     if (isatty(fd) == 0)
+    2776             :         return DLT_RETURN_ERROR;
+    2777             : 
+    2778           0 :     if (tcgetattr(fd, &config) < 0)
+    2779             :         return DLT_RETURN_ERROR;
+    2780             : 
+    2781             :     /* Input flags - Turn off input processing
+    2782             :      * convert break to null byte, no CR to NL translation,
+    2783             :      * no NL to CR translation, don't mark parity errors or breaks
+    2784             :      * no input parity check, don't strip high bit off,
+    2785             :      * no XON/XOFF software flow control
+    2786             :      */
+    2787           0 :     config.c_iflag &= ~(IGNBRK | BRKINT | ICRNL |
+    2788             :                         INLCR | PARMRK | INPCK | ISTRIP | IXON);
+    2789             : 
+    2790             :     /* Output flags - Turn off output processing
+    2791             :      * no CR to NL translation, no NL to CR-NL translation,
+    2792             :      * no NL to CR translation, no column 0 CR suppression,
+    2793             :      * no Ctrl-D suppression, no fill characters, no case mapping,
+    2794             :      * no local output processing
+    2795             :      *
+    2796             :      * config.c_oflag &= ~(OCRNL | ONLCR | ONLRET |
+    2797             :      *                     ONOCR | ONOEOT| OFILL | OLCUC | OPOST);
+    2798             :      */
+    2799           0 :     config.c_oflag = 0;
+    2800             : 
+    2801             :     /* No line processing:
+    2802             :      * echo off, echo newline off, canonical mode off,
+    2803             :      * extended input processing off, signal chars off
+    2804             :      */
+    2805           0 :     config.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN | ISIG);
+    2806             : 
+    2807             :     /* Turn off character processing
+    2808             :      * clear current char size mask, no parity checking,
+    2809             :      * no output processing, force 8 bit input
+    2810             :      */
+    2811           0 :     config.c_cflag &= ~(CSIZE | PARENB);
+    2812           0 :     config.c_cflag |= CS8;
+    2813             : 
+    2814             :     /* One input byte is enough to return from read()
+    2815             :      * Inter-character timer off
+    2816             :      */
+    2817           0 :     config.c_cc[VMIN] = 1;
+    2818           0 :     config.c_cc[VTIME] = 0;
+    2819             : 
+    2820             :     /* Communication speed (simple version, using the predefined
+    2821             :      * constants)
+    2822             :      */
+    2823           0 :     if ((cfsetispeed(&config, speed) < 0) || (cfsetospeed(&config, speed) < 0))
+    2824           0 :         return DLT_RETURN_ERROR;
+    2825             : 
+    2826             :     /* Finally, apply the configuration
+    2827             :      */
+    2828           0 :     if (tcsetattr(fd, TCSAFLUSH, &config) < 0)
+    2829           0 :         return DLT_RETURN_ERROR;
+    2830             : 
+    2831             :     return DLT_RETURN_OK;
+    2832             : #   else
+    2833             :     return DLT_RETURN_ERROR;
+    2834             : #   endif
+    2835             : }
+    2836             : 
+    2837           0 : speed_t dlt_convert_serial_speed(int baudrate)
+    2838             : {
+    2839             : #   if !defined (__WIN32__) && !defined(_MSC_VER) && !defined(__CYGWIN__)
+    2840             :     speed_t ret;
+    2841             : 
+    2842           0 :     switch (baudrate) {
+    2843             :     case  50:
+    2844             :     {
+    2845             :         ret = B50;
+    2846             :         break;
+    2847             :     }
+    2848           0 :     case  75:
+    2849             :     {
+    2850             :         ret = B75;
+    2851           0 :         break;
+    2852             :     }
+    2853           0 :     case  110:
+    2854             :     {
+    2855             :         ret = B110;
+    2856           0 :         break;
+    2857             :     }
+    2858           0 :     case  134:
+    2859             :     {
+    2860             :         ret = B134;
+    2861           0 :         break;
+    2862             :     }
+    2863           0 :     case  150:
+    2864             :     {
+    2865             :         ret = B150;
+    2866           0 :         break;
+    2867             :     }
+    2868           0 :     case  200:
+    2869             :     {
+    2870             :         ret = B200;
+    2871           0 :         break;
+    2872             :     }
+    2873           0 :     case  300:
+    2874             :     {
+    2875             :         ret = B300;
+    2876           0 :         break;
+    2877             :     }
+    2878           0 :     case  600:
+    2879             :     {
+    2880             :         ret = B600;
+    2881           0 :         break;
+    2882             :     }
+    2883           0 :     case  1200:
+    2884             :     {
+    2885             :         ret = B1200;
+    2886           0 :         break;
+    2887             :     }
+    2888           0 :     case  1800:
+    2889             :     {
+    2890             :         ret = B1800;
+    2891           0 :         break;
+    2892             :     }
+    2893           0 :     case  2400:
+    2894             :     {
+    2895             :         ret = B2400;
+    2896           0 :         break;
+    2897             :     }
+    2898           0 :     case  4800:
+    2899             :     {
+    2900             :         ret = B4800;
+    2901           0 :         break;
+    2902             :     }
+    2903           0 :     case  9600:
+    2904             :     {
+    2905             :         ret = B9600;
+    2906           0 :         break;
+    2907             :     }
+    2908           0 :     case  19200:
+    2909             :     {
+    2910             :         ret = B19200;
+    2911           0 :         break;
+    2912             :     }
+    2913           0 :     case  38400:
+    2914             :     {
+    2915             :         ret = B38400;
+    2916           0 :         break;
+    2917             :     }
+    2918           0 :     case  57600:
+    2919             :     {
+    2920             :         ret = B57600;
+    2921           0 :         break;
+    2922             :     }
+    2923           0 :     case  115200:
+    2924             :     {
+    2925             :         ret = B115200;
+    2926           0 :         break;
+    2927             :     }
+    2928             : #      ifdef __linux__
+    2929           0 :     case 230400:
+    2930             :     {
+    2931             :         ret = B230400;
+    2932           0 :         break;
+    2933             :     }
+    2934           0 :     case 460800:
+    2935             :     {
+    2936             :         ret = B460800;
+    2937           0 :         break;
+    2938             :     }
+    2939           0 :     case  500000:
+    2940             :     {
+    2941             :         ret = B500000;
+    2942           0 :         break;
+    2943             :     }
+    2944           0 :     case  576000:
+    2945             :     {
+    2946             :         ret = B576000;
+    2947           0 :         break;
+    2948             :     }
+    2949           0 :     case  921600:
+    2950             :     {
+    2951             :         ret = B921600;
+    2952           0 :         break;
+    2953             :     }
+    2954           0 :     case  1000000:
+    2955             :     {
+    2956             :         ret = B1000000;
+    2957           0 :         break;
+    2958             :     }
+    2959           0 :     case  1152000:
+    2960             :     {
+    2961             :         ret = B1152000;
+    2962           0 :         break;
+    2963             :     }
+    2964           0 :     case  1500000:
+    2965             :     {
+    2966             :         ret = B1500000;
+    2967           0 :         break;
+    2968             :     }
+    2969           0 :     case  2000000:
+    2970             :     {
+    2971             :         ret = B2000000;
+    2972           0 :         break;
+    2973             :     }
+    2974             : #ifdef B2500000
+    2975           0 :     case  2500000:
+    2976             :     {
+    2977             :         ret = B2500000;
+    2978           0 :         break;
+    2979             :     }
+    2980             : #endif
+    2981             : #ifdef B3000000
+    2982           0 :     case  3000000:
+    2983             :     {
+    2984             :         ret = B3000000;
+    2985           0 :         break;
+    2986             :     }
+    2987             : #endif
+    2988             : #ifdef B3500000
+    2989           0 :     case  3500000:
+    2990             :     {
+    2991             :         ret = B3500000;
+    2992           0 :         break;
+    2993             :     }
+    2994             : #endif
+    2995             : #ifdef B4000000
+    2996           0 :     case  4000000:
+    2997             :     {
+    2998             :         ret = B4000000;
+    2999           0 :         break;
+    3000             :     }
+    3001             : #endif
+    3002             : #      endif /* __linux__ */
+    3003           0 :     default:
+    3004             :     {
+    3005             :         ret = B115200;
+    3006           0 :         break;
+    3007             :     }
+    3008             :     }
+    3009             : 
+    3010           0 :     return ret;
+    3011             : #   else
+    3012             :     return 0;
+    3013             : #   endif
+    3014             : }
+    3015             : 
+    3016             : #endif
+    3017             : 
+    3018          22 : void dlt_get_version(char *buf, size_t size)
+    3019             : {
+    3020          22 :     if ((buf == NULL) && (size > 0)) {
+    3021           0 :         dlt_log(LOG_WARNING, "Wrong parameter: Null pointer\n");
+    3022           0 :         return;
+    3023             :     }
+    3024             : 
+    3025             : /* Clang does not like these macros, because they are not reproducable */
+    3026             : #pragma GCC diagnostic push
+    3027             : #pragma GCC diagnostic ignored "-Wdate-time"
+    3028             :     snprintf(buf,
+    3029             :              size,
+    3030             :              "DLT Package Version: %s %s, Package Revision: %s, build on %s %s\n%s %s %s %s\n",
+    3031             :              _DLT_PACKAGE_VERSION,
+    3032             :              _DLT_PACKAGE_VERSION_STATE,
+    3033             :              _DLT_PACKAGE_REVISION,
+    3034             :              __DATE__,
+    3035             :              __TIME__,
+    3036             :              _DLT_SYSTEMD_ENABLE,
+    3037             :              _DLT_SYSTEMD_WATCHDOG_ENABLE,
+    3038             :              _DLT_TEST_ENABLE,
+    3039             :              _DLT_SHM_ENABLE);
+    3040             : #pragma GCC diagnostic pop
+    3041             : }
+    3042             : 
+    3043           9 : void dlt_get_major_version(char *buf, size_t size)
+    3044             : {
+    3045           9 :     if ((buf == NULL) && (size > 0)) {
+    3046           0 :         dlt_log(LOG_WARNING, "Wrong parameter: Null pointer\n");
+    3047           0 :         return;
+    3048             :     }
+    3049             : 
+    3050             :     snprintf(buf, size, "%s", _DLT_PACKAGE_MAJOR_VERSION);
+    3051             : }
+    3052             : 
+    3053           9 : void dlt_get_minor_version(char *buf, size_t size)
+    3054             : {
+    3055           9 :     if ((buf == NULL) && (size > 0)) {
+    3056           0 :         dlt_log(LOG_WARNING, "Wrong parameter: Null pointer\n");
+    3057           0 :         return;
+    3058             :     }
+    3059             : 
+    3060             :     snprintf(buf, size, "%s", _DLT_PACKAGE_MINOR_VERSION);
+    3061             : }
+    3062             : 
+    3063             : 
+    3064        6301 : uint32_t dlt_uptime(void)
+    3065             : {
+    3066             : 
+    3067             : #if defined (__WIN32__) || defined(_MSC_VER)
+    3068             : 
+    3069             :     return (uint32_t)(GetTickCount() * 10); /* GetTickCount() return DWORD */
+    3070             : 
+    3071             : #else
+    3072             :     struct timespec ts;
+    3073             : 
+    3074        6301 :     if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
+    3075        6301 :         return (uint32_t)ts.tv_sec * 10000 + (uint32_t)ts.tv_nsec / 100000; /* in 0.1 ms = 100 us */
+    3076             :     else
+    3077             :         return 0;
+    3078             : 
+    3079             : #endif
+    3080             : 
+    3081             : }
+    3082             : 
+    3083         328 : DltReturnValue dlt_message_print_header(DltMessage *message, char *text, uint32_t size, int verbose)
+    3084             : {
+    3085         328 :     if ((message == NULL) || (text == NULL))
+    3086             :         return DLT_RETURN_WRONG_PARAMETER;
+    3087             : 
+    3088         316 :     if (dlt_message_header(message, text, size, verbose) < DLT_RETURN_OK)
+    3089             :         return DLT_RETURN_ERROR;
+    3090         316 :     dlt_user_printf("%s\n", text);
+    3091             : 
+    3092         316 :     return DLT_RETURN_OK;
+    3093             : }
+    3094             : 
+    3095         328 : DltReturnValue dlt_message_print_hex(DltMessage *message, char *text, uint32_t size, int verbose)
+    3096             : {
+    3097         328 :     if ((message == NULL) || (text == NULL))
+    3098             :         return DLT_RETURN_WRONG_PARAMETER;
+    3099             : 
+    3100         316 :     if (dlt_message_header(message, text, size, verbose) < DLT_RETURN_OK)
+    3101             :         return DLT_RETURN_ERROR;
+    3102         316 :     dlt_user_printf("%s ", text);
+    3103             : 
+    3104         316 :     if (dlt_message_payload(message, text, size, DLT_OUTPUT_HEX, verbose) < DLT_RETURN_OK)
+    3105             :         return DLT_RETURN_ERROR;
+    3106         316 :     dlt_user_printf("[%s]\n", text);
+    3107             : 
+    3108         316 :     return DLT_RETURN_OK;
+    3109             : }
+    3110             : 
+    3111         328 : DltReturnValue dlt_message_print_ascii(DltMessage *message, char *text, uint32_t size, int verbose)
+    3112             : {
+    3113         328 :     if ((message == NULL) || (text == NULL))
+    3114             :         return DLT_RETURN_WRONG_PARAMETER;
+    3115             : 
+    3116         316 :     if (dlt_message_header(message, text, size, verbose) < DLT_RETURN_OK)
+    3117             :         return DLT_RETURN_ERROR;
+    3118         316 :     dlt_user_printf("%s ", text);
+    3119             : 
+    3120         316 :     if (dlt_message_payload(message, text, size, DLT_OUTPUT_ASCII, verbose) < DLT_RETURN_OK)
+    3121             :         return DLT_RETURN_ERROR;
+    3122         316 :     dlt_user_printf("[%s]\n", text);
+    3123             : 
+    3124         316 :     return DLT_RETURN_OK;
+    3125             : }
+    3126             : 
+    3127         328 : DltReturnValue dlt_message_print_mixed_plain(DltMessage *message, char *text, uint32_t size, int verbose)
+    3128             : {
+    3129         328 :     if ((message == NULL) || (text == NULL))
+    3130             :         return DLT_RETURN_WRONG_PARAMETER;
+    3131             : 
+    3132         316 :     if (dlt_message_header(message, text, size, verbose) < DLT_RETURN_OK)
+    3133             :         return DLT_RETURN_ERROR;
+    3134         316 :     dlt_user_printf("%s \n", text);
+    3135             : 
+    3136         316 :     if (dlt_message_payload(message, text, size, DLT_OUTPUT_MIXED_FOR_PLAIN, verbose) < DLT_RETURN_OK)
+    3137             :         return DLT_RETURN_ERROR;
+    3138         316 :     dlt_user_printf("[%s]\n", text);
+    3139             : 
+    3140         316 :     return DLT_RETURN_OK;
+    3141             : }
+    3142             : 
+    3143         328 : DltReturnValue dlt_message_print_mixed_html(DltMessage *message, char *text, uint32_t size, int verbose)
+    3144             : {
+    3145         328 :     if ((message == NULL) || (text == NULL))
+    3146             :         return DLT_RETURN_WRONG_PARAMETER;
+    3147             : 
+    3148         316 :     if (dlt_message_header(message, text, size, verbose) < DLT_RETURN_OK)
+    3149             :         return DLT_RETURN_ERROR;
+    3150         316 :     dlt_user_printf("%s \n", text);
+    3151             : 
+    3152         316 :     if (dlt_message_payload(message, text, size, DLT_OUTPUT_MIXED_FOR_HTML, verbose) < DLT_RETURN_OK)
+    3153             :         return DLT_RETURN_ERROR;
+    3154             : 
+    3155         316 :     dlt_user_printf("[%s]\n", text);
+    3156             : 
+    3157         316 :     return DLT_RETURN_OK;
+    3158             : }
+    3159             : 
+    3160        2771 : DltReturnValue dlt_message_argument_print(DltMessage *msg,
+    3161             :                                           uint32_t type_info,
+    3162             :                                           uint8_t **ptr,
+    3163             :                                           int32_t *datalength,
+    3164             :                                           char *text,
+    3165             :                                           size_t textlength,
+    3166             :                                           int byteLength,
+    3167             :                                           int __attribute__((unused)) verbose)
+    3168             : {
+    3169             :     /* check null pointers */
+    3170        2771 :     if ((msg == NULL) || (ptr == NULL) || (datalength == NULL) || (text == NULL))
+    3171             :         return DLT_RETURN_WRONG_PARAMETER;
+    3172             : 
+    3173             :     uint16_t length = 0, length2 = 0, length3 = 0;
+    3174             : 
+    3175             :     uint8_t value8u = 0;
+    3176             :     uint16_t value16u = 0, value16u_tmp = 0;
+    3177             :     uint32_t value32u = 0, value32u_tmp = 0;
+    3178             :     uint64_t value64u = 0, value64u_tmp = 0;
+    3179             : 
+    3180             :     int8_t value8i = 0;
+    3181             :     int16_t value16i = 0, value16i_tmp = 0;
+    3182             :     int32_t value32i = 0, value32i_tmp = 0;
+    3183             :     int64_t value64i = 0, value64i_tmp = 0;
+    3184             : 
+    3185        2756 :     float32_t value32f = 0, value32f_tmp = 0;
+    3186        2756 :     int32_t value32f_tmp_int32i = 0, value32f_tmp_int32i_swaped = 0;
+    3187        2756 :     float64_t value64f = 0, value64f_tmp = 0;
+    3188        2756 :     int64_t value64f_tmp_int64i = 0, value64f_tmp_int64i_swaped = 0;
+    3189             : 
+    3190             :     uint32_t quantisation_tmp = 0;
+    3191             : 
+    3192             :     // pointer to the value string
+    3193             :     char* value_text = text;
+    3194             :     // pointer to the "unit" attribute string, if there is one (only for *INT and FLOAT*)
+    3195             :     const uint8_t* unit_text_src = NULL;
+    3196             :     // length of the "unit" attribute string, if there is one (only for *INT and FLOAT*)
+    3197             :     size_t unit_text_len = 0;
+    3198             : 
+    3199             :     /* apparently this makes no sense but needs to be done to prevent compiler warning.
+    3200             :      * This variable is only written by DLT_MSG_READ_VALUE macro in if (type_info & DLT_TYPE_INFO_FIXP)
+    3201             :      * case but never read anywhere */
+    3202             :     quantisation_tmp += quantisation_tmp;
+    3203             : 
+    3204        2756 :     if ((type_info & DLT_TYPE_INFO_STRG) &&
+    3205        1159 :         (((type_info & DLT_TYPE_INFO_SCOD) == DLT_SCOD_ASCII) || ((type_info & DLT_TYPE_INFO_SCOD) == DLT_SCOD_UTF8))) {
+    3206             :         /* string type or utf8-encoded string type */
+    3207        1159 :         if (byteLength < 0) {
+    3208        1159 :             DLT_MSG_READ_VALUE(value16u_tmp, *ptr, *datalength, uint16_t);
+    3209             : 
+    3210        1159 :             if ((*datalength) < 0)
+    3211             :                 return DLT_RETURN_ERROR;
+    3212             : 
+    3213        1159 :             length = (uint16_t) DLT_ENDIAN_GET_16(msg->standardheader->htyp, value16u_tmp);
+    3214             :         }
+    3215             :         else {
+    3216           0 :             length = (uint16_t)byteLength;
+    3217             :         }
+    3218             : 
+    3219        1159 :         if (type_info & DLT_TYPE_INFO_VARI) {
+    3220           0 :             DLT_MSG_READ_VALUE(value16u_tmp, *ptr, *datalength, uint16_t);
+    3221             : 
+    3222           0 :             if ((*datalength) < 0)
+    3223             :                 return DLT_RETURN_ERROR;
+    3224             : 
+    3225           0 :             length2 = (uint16_t) DLT_ENDIAN_GET_16(msg->standardheader->htyp, value16u_tmp);
+    3226             : 
+    3227           0 :             if ((*datalength) < length2)
+    3228             :                 return DLT_RETURN_ERROR;
+    3229             : 
+    3230           0 :             if (print_with_attributes) {
+    3231             :                 // Print "name" attribute, if we have one with non-zero size.
+    3232           0 :                 if (length2 > 1) {
+    3233           0 :                     snprintf(text, textlength, "%s:", *ptr);
+    3234           0 :                     value_text += length2+1-1;  // +1 for ":" and -1 for NUL
+    3235           0 :                     textlength -= length2+1-1;
+    3236             :                 }
+    3237             :             }
+    3238             : 
+    3239           0 :             *ptr += length2;
+    3240           0 :             *datalength -= length2;
+    3241             :         }
+    3242             : 
+    3243        1159 :         DLT_MSG_READ_STRING(value_text, *ptr, *datalength, textlength, length);
+    3244             : 
+    3245        1159 :         if ((*datalength) < 0)
+    3246             :             return DLT_RETURN_ERROR;
+    3247             :     }
+    3248        1597 :     else if (type_info & DLT_TYPE_INFO_BOOL)
+    3249             :     {
+    3250             :         /* Boolean type */
+    3251         112 :         if (type_info & DLT_TYPE_INFO_VARI) {
+    3252           0 :             DLT_MSG_READ_VALUE(value16u_tmp, *ptr, *datalength, uint16_t);
+    3253             : 
+    3254           0 :             if ((*datalength) < 0)
+    3255             :                 return DLT_RETURN_ERROR;
+    3256             : 
+    3257           0 :             length2 = (uint16_t) DLT_ENDIAN_GET_16(msg->standardheader->htyp, value16u_tmp);
+    3258             : 
+    3259           0 :             if ((*datalength) < length2)
+    3260             :                 return DLT_RETURN_ERROR;
+    3261             : 
+    3262           0 :             if (print_with_attributes) {
+    3263             :                 // Print "name" attribute, if we have one with non-zero size.
+    3264           0 :                 if (length2 > 1) {
+    3265           0 :                     snprintf(text, textlength, "%s:", *ptr);
+    3266           0 :                     value_text += length2+1-1;  // +1 for ":" and -1 for NUL
+    3267           0 :                     textlength -= length2+1-2;
+    3268             :                 }
+    3269             :             }
+    3270             : 
+    3271           0 :             *ptr += length2;
+    3272           0 :             *datalength -= length2;
+    3273             :         }
+    3274             : 
+    3275             :         value8u = 0;
+    3276         112 :         DLT_MSG_READ_VALUE(value8u, *ptr, *datalength, uint8_t); /* No endian conversion necessary */
+    3277             : 
+    3278         112 :         if ((*datalength) < 0)
+    3279             :             return DLT_RETURN_ERROR;
+    3280             : 
+    3281         110 :         snprintf(value_text, textlength, "%d", value8u);
+    3282             :     }
+    3283        1485 :     else if ((type_info & DLT_TYPE_INFO_UINT) && (DLT_SCOD_BIN == (type_info & DLT_TYPE_INFO_SCOD)))
+    3284             :     {
+    3285           0 :         if (DLT_TYLE_8BIT == (type_info & DLT_TYPE_INFO_TYLE)) {
+    3286           0 :             DLT_MSG_READ_VALUE(value8u, *ptr, *datalength, uint8_t); /* No endian conversion necessary */
+    3287             : 
+    3288           0 :             if ((*datalength) < 0)
+    3289           0 :                 return DLT_RETURN_ERROR;
+    3290             : 
+    3291           0 :             char binary[10] = { '\0' }; /* e.g.: "0b1100 0010" */
+    3292             :             int i;
+    3293             : 
+    3294           0 :             for (i = (1 << 7); i > 0; i >>= 1) {
+    3295           0 :                 if ((1 << 3) == i)
+    3296             :                     strcat(binary, " ");
+    3297             : 
+    3298           0 :                 strcat(binary, (i == (value8u & i)) ? "1" : "0");
+    3299             :             }
+    3300             : 
+    3301             :             snprintf(value_text, textlength, "0b%s", binary);
+    3302             :         }
+    3303             : 
+    3304           0 :         if (DLT_TYLE_16BIT == (type_info & DLT_TYPE_INFO_TYLE)) {
+    3305           0 :             DLT_MSG_READ_VALUE(value16u, *ptr, *datalength, uint16_t);
+    3306             : 
+    3307           0 :             if ((*datalength) < 0)
+    3308           0 :                 return DLT_RETURN_ERROR;
+    3309             : 
+    3310           0 :             char binary[20] = { '\0' }; /* e.g.: "0b1100 0010 0011 0110" */
+    3311             :             int i;
+    3312             : 
+    3313           0 :             for (i = (1 << 15); i > 0; i >>= 1) {
+    3314           0 :                 if (((1 << 3) == i) || ((1 << 7) == i) || ((1 << 11) == i))
+    3315             :                     strcat(binary, " ");
+    3316             : 
+    3317           0 :                 strcat(binary, (i == (value16u & i)) ? "1" : "0");
+    3318             :             }
+    3319             : 
+    3320             :             snprintf(value_text, textlength, "0b%s", binary);
+    3321             :         }
+    3322             :     }
+    3323        1485 :     else if ((type_info & DLT_TYPE_INFO_UINT) && (DLT_SCOD_HEX == (type_info & DLT_TYPE_INFO_SCOD)))
+    3324             :     {
+    3325           0 :         if (DLT_TYLE_8BIT == (type_info & DLT_TYPE_INFO_TYLE)) {
+    3326           0 :             DLT_MSG_READ_VALUE(value8u, *ptr, *datalength, uint8_t); /* No endian conversion necessary */
+    3327             : 
+    3328           0 :             if ((*datalength) < 0)
+    3329             :                 return DLT_RETURN_ERROR;
+    3330             : 
+    3331           0 :             snprintf(value_text, textlength, "0x%02x", value8u);
+    3332             :         }
+    3333             : 
+    3334           0 :         if (DLT_TYLE_16BIT == (type_info & DLT_TYPE_INFO_TYLE)) {
+    3335           0 :             DLT_MSG_READ_VALUE(value16u, *ptr, *datalength, uint16_t);
+    3336             : 
+    3337           0 :             if ((*datalength) < 0)
+    3338             :                 return DLT_RETURN_ERROR;
+    3339             : 
+    3340           0 :             snprintf(value_text, textlength, "0x%04x", value16u);
+    3341             :         }
+    3342             : 
+    3343           0 :         if (DLT_TYLE_32BIT == (type_info & DLT_TYPE_INFO_TYLE)) {
+    3344           0 :             DLT_MSG_READ_VALUE(value32u, *ptr, *datalength, uint32_t);
+    3345             : 
+    3346           0 :             if ((*datalength) < 0)
+    3347             :                 return DLT_RETURN_ERROR;
+    3348             : 
+    3349             :             snprintf(value_text, textlength, "0x%08x", value32u);
+    3350             :         }
+    3351             : 
+    3352           0 :         if (DLT_TYLE_64BIT == (type_info & DLT_TYPE_INFO_TYLE)) {
+    3353           0 :             *ptr += 4;
+    3354           0 :             DLT_MSG_READ_VALUE(value32u, *ptr, *datalength, uint32_t);
+    3355             : 
+    3356           0 :             if ((*datalength) < 0)
+    3357             :                 return DLT_RETURN_ERROR;
+    3358             : 
+    3359             :             snprintf(value_text, textlength, "0x%08x", value32u);
+    3360           0 :             *ptr -= 8;
+    3361           0 :             DLT_MSG_READ_VALUE(value32u, *ptr, *datalength, uint32_t);
+    3362             : 
+    3363           0 :             if ((*datalength) < 0)
+    3364             :                 return DLT_RETURN_ERROR;
+    3365             : 
+    3366           0 :             snprintf(value_text + strlen(value_text), textlength - strlen(value_text), "%08x", value32u);
+    3367           0 :             *ptr += 4;
+    3368             :         }
+    3369             :     }
+    3370        1485 :     else if ((type_info & DLT_TYPE_INFO_SINT) || (type_info & DLT_TYPE_INFO_UINT))
+    3371             :     {
+    3372             :         /* signed or unsigned argument received */
+    3373        1358 :         if (type_info & DLT_TYPE_INFO_VARI) {
+    3374           0 :             DLT_MSG_READ_VALUE(value16u_tmp, *ptr, *datalength, uint16_t);
+    3375             : 
+    3376           0 :             if ((*datalength) < 0)
+    3377             :                 return DLT_RETURN_ERROR;
+    3378             : 
+    3379           0 :             length2 = (uint16_t) DLT_ENDIAN_GET_16(msg->standardheader->htyp, value16u_tmp);
+    3380           0 :             DLT_MSG_READ_VALUE(value16u_tmp, *ptr, *datalength, uint16_t);
+    3381             : 
+    3382           0 :             if ((*datalength) < 0)
+    3383             :                 return DLT_RETURN_ERROR;
+    3384             : 
+    3385           0 :             length3 = (uint16_t) DLT_ENDIAN_GET_16(msg->standardheader->htyp, value16u_tmp);
+    3386             : 
+    3387           0 :             if ((*datalength) < length2)
+    3388             :                 return DLT_RETURN_ERROR;
+    3389             : 
+    3390           0 :             if (print_with_attributes) {
+    3391             :                 // Print "name" attribute, if we have one with non-zero size.
+    3392           0 :                 if (length2 > 1) {
+    3393           0 :                     snprintf(text, textlength, "%s:", *ptr);
+    3394           0 :                     value_text += length2+1-1;  // +1 for the ":", and -1 for nul
+    3395           0 :                     textlength -= length2+1-1;
+    3396             :                 }
+    3397             :             }
+    3398             : 
+    3399           0 :             *ptr += length2;
+    3400           0 :             *datalength -= length2;
+    3401             : 
+    3402           0 :             if ((*datalength) < length3)
+    3403             :                 return DLT_RETURN_ERROR;
+    3404             : 
+    3405             :             // We want to add the "unit" attribute only after the value, so remember its pointer and length here.
+    3406             :             unit_text_src = *ptr;
+    3407           0 :             unit_text_len = length3;
+    3408             : 
+    3409           0 :             *ptr += length3;
+    3410           0 :             *datalength -= length3;
+    3411             :         }
+    3412             : 
+    3413        1358 :         if (type_info & DLT_TYPE_INFO_FIXP) {
+    3414           0 :             DLT_MSG_READ_VALUE(quantisation_tmp, *ptr, *datalength, uint32_t);
+    3415             : 
+    3416           0 :             if ((*datalength) < 0)
+    3417             :                 return DLT_RETURN_ERROR;
+    3418             : 
+    3419           0 :             switch (type_info & DLT_TYPE_INFO_TYLE) {
+    3420           0 :             case DLT_TYLE_8BIT:
+    3421             :             case DLT_TYLE_16BIT:
+    3422             :             case DLT_TYLE_32BIT:
+    3423             :             {
+    3424           0 :                 if ((*datalength) < 4)
+    3425             :                     return DLT_RETURN_ERROR;
+    3426             : 
+    3427           0 :                 *ptr += 4;
+    3428           0 :                 *datalength -= 4;
+    3429           0 :                 break;
+    3430             :             }
+    3431           0 :             case DLT_TYLE_64BIT:
+    3432             :             {
+    3433           0 :                 if ((*datalength) < 8)
+    3434             :                     return DLT_RETURN_ERROR;
+    3435             : 
+    3436           0 :                 *ptr += 8;
+    3437           0 :                 *datalength -= 8;
+    3438           0 :                 break;
+    3439             :             }
+    3440           0 :             case DLT_TYLE_128BIT:
+    3441             :             {
+    3442           0 :                 if ((*datalength) < 16)
+    3443             :                     return DLT_RETURN_ERROR;
+    3444             : 
+    3445           0 :                 *ptr += 16;
+    3446           0 :                 *datalength -= 16;
+    3447           0 :                 break;
+    3448             :             }
+    3449             :             default:
+    3450             :             {
+    3451             :                 return DLT_RETURN_ERROR;
+    3452             :             }
+    3453             :             }
+    3454             :         }
+    3455             : 
+    3456        1358 :         switch (type_info & DLT_TYPE_INFO_TYLE) {
+    3457          14 :         case DLT_TYLE_8BIT:
+    3458             :         {
+    3459          14 :             if (type_info & DLT_TYPE_INFO_SINT) {
+    3460             :                 value8i = 0;
+    3461           7 :                 DLT_MSG_READ_VALUE(value8i, *ptr, *datalength, int8_t);  /* No endian conversion necessary */
+    3462             : 
+    3463           7 :                 if ((*datalength) < 0)
+    3464             :                     return DLT_RETURN_ERROR;
+    3465             : 
+    3466           7 :                 snprintf(value_text, textlength, "%d", value8i);
+    3467             :             }
+    3468             :             else {
+    3469             :                 value8u = 0;
+    3470           7 :                 DLT_MSG_READ_VALUE(value8u, *ptr, *datalength, uint8_t);  /* No endian conversion necessary */
+    3471             : 
+    3472           7 :                 if ((*datalength) < 0)
+    3473             :                     return DLT_RETURN_ERROR;
+    3474             : 
+    3475           7 :                 snprintf(value_text, textlength, "%d", value8u);
+    3476             :             }
+    3477             : 
+    3478             :             break;
+    3479             :         }
+    3480          21 :         case DLT_TYLE_16BIT:
+    3481             :         {
+    3482          21 :             if (type_info & DLT_TYPE_INFO_SINT) {
+    3483             :                 value16i = 0;
+    3484             :                 value16i_tmp = 0;
+    3485           7 :                 DLT_MSG_READ_VALUE(value16i_tmp, *ptr, *datalength, int16_t);
+    3486             : 
+    3487           7 :                 if ((*datalength) < 0)
+    3488             :                     return DLT_RETURN_ERROR;
+    3489             : 
+    3490           7 :                 value16i = (int16_t) DLT_ENDIAN_GET_16(msg->standardheader->htyp, value16i_tmp);
+    3491           7 :                 snprintf(value_text, textlength, "%hd", value16i);
+    3492             :             }
+    3493             :             else {
+    3494             :                 value16u = 0;
+    3495             :                 value16u_tmp = 0;
+    3496          14 :                 DLT_MSG_READ_VALUE(value16u_tmp, *ptr, *datalength, uint16_t);
+    3497             : 
+    3498          14 :                 if ((*datalength) < 0)
+    3499             :                     return DLT_RETURN_ERROR;
+    3500             : 
+    3501          14 :                 value16u = (uint16_t) DLT_ENDIAN_GET_16(msg->standardheader->htyp, value16u_tmp);
+    3502          14 :                 snprintf(value_text, textlength, "%hu", value16u);
+    3503             :             }
+    3504             : 
+    3505             :             break;
+    3506             :         }
+    3507        1309 :         case DLT_TYLE_32BIT:
+    3508             :         {
+    3509        1309 :             if (type_info & DLT_TYPE_INFO_SINT) {
+    3510             :                 value32i = 0;
+    3511             :                 value32i_tmp = 0;
+    3512         287 :                 DLT_MSG_READ_VALUE(value32i_tmp, *ptr, *datalength, int32_t);
+    3513             : 
+    3514         287 :                 if ((*datalength) < 0)
+    3515             :                     return DLT_RETURN_ERROR;
+    3516             : 
+    3517         287 :                 value32i = (int32_t) DLT_ENDIAN_GET_32(msg->standardheader->htyp, (uint32_t)value32i_tmp);
+    3518             :                 snprintf(value_text, textlength, "%d", value32i);
+    3519             :             }
+    3520             :             else {
+    3521             :                 value32u = 0;
+    3522             :                 value32u_tmp = 0;
+    3523        1022 :                 DLT_MSG_READ_VALUE(value32u_tmp, *ptr, *datalength, uint32_t);
+    3524             : 
+    3525        1022 :                 if ((*datalength) < 0)
+    3526             :                     return DLT_RETURN_ERROR;
+    3527             : 
+    3528        1022 :                 value32u = DLT_ENDIAN_GET_32(msg->standardheader->htyp, value32u_tmp);
+    3529             :                 snprintf(value_text, textlength, "%u", value32u);
+    3530             :             }
+    3531             : 
+    3532             :             break;
+    3533             :         }
+    3534          14 :         case DLT_TYLE_64BIT:
+    3535             :         {
+    3536          14 :             if (type_info & DLT_TYPE_INFO_SINT) {
+    3537             :                 value64i = 0;
+    3538             :                 value64i_tmp = 0;
+    3539           7 :                 DLT_MSG_READ_VALUE(value64i_tmp, *ptr, *datalength, int64_t);
+    3540             : 
+    3541           7 :                 if ((*datalength) < 0)
+    3542             :                     return DLT_RETURN_ERROR;
+    3543             : 
+    3544           7 :                 value64i = (int64_t) DLT_ENDIAN_GET_64(msg->standardheader->htyp, (uint64_t)value64i_tmp);
+    3545             :     #if defined (__WIN32__) && !defined(_MSC_VER)
+    3546             :                 snprintf(value_text, textlength, "%I64d", value64i);
+    3547             :     #else
+    3548             :                 snprintf(value_text, textlength, "%" PRId64, value64i);
+    3549             :     #endif
+    3550             :             }
+    3551             :             else {
+    3552             :                 value64u = 0;
+    3553             :                 value64u_tmp = 0;
+    3554           7 :                 DLT_MSG_READ_VALUE(value64u_tmp, *ptr, *datalength, uint64_t);
+    3555             : 
+    3556           7 :                 if ((*datalength) < 0)
+    3557             :                     return DLT_RETURN_ERROR;
+    3558             : 
+    3559           7 :                 value64u = DLT_ENDIAN_GET_64(msg->standardheader->htyp, value64u_tmp);
+    3560             :     #if defined (__WIN32__) && !defined(_MSC_VER)
+    3561             :                 snprintf(value_text, textlength, "%I64u", value64u);
+    3562             :     #else
+    3563             :                 snprintf(value_text, textlength, "%" PRIu64, value64u);
+    3564             :     #endif
+    3565             :             }
+    3566             : 
+    3567             :             break;
+    3568             :         }
+    3569           0 :         case DLT_TYLE_128BIT:
+    3570             :         {
+    3571           0 :             if (*datalength >= 16)
+    3572           0 :                 dlt_print_hex_string(value_text, (int) textlength, *ptr, 16);
+    3573             : 
+    3574           0 :             if ((*datalength) < 16)
+    3575             :                 return DLT_RETURN_ERROR;
+    3576             : 
+    3577           0 :             *ptr += 16;
+    3578           0 :             *datalength -= 16;
+    3579           0 :             break;
+    3580             :         }
+    3581             :         default:
+    3582             :         {
+    3583             :             return DLT_RETURN_ERROR;
+    3584             :         }
+    3585             :         }
+    3586             :     }
+    3587         127 :     else if (type_info & DLT_TYPE_INFO_FLOA)
+    3588             :     {
+    3589             :         /* float data argument */
+    3590          14 :         if (type_info & DLT_TYPE_INFO_VARI) {
+    3591           0 :             DLT_MSG_READ_VALUE(value16u_tmp, *ptr, *datalength, uint16_t);
+    3592             : 
+    3593           0 :             if ((*datalength) < 0)
+    3594             :                 return DLT_RETURN_ERROR;
+    3595             : 
+    3596           0 :             length2 = DLT_ENDIAN_GET_16(msg->standardheader->htyp, value16u_tmp);
+    3597           0 :             DLT_MSG_READ_VALUE(value16u_tmp, *ptr, *datalength, uint16_t);
+    3598             : 
+    3599           0 :             if ((*datalength) < 0)
+    3600             :                 return DLT_RETURN_ERROR;
+    3601             : 
+    3602           0 :             length3 = DLT_ENDIAN_GET_16(msg->standardheader->htyp, value16u_tmp);
+    3603             : 
+    3604           0 :             if ((*datalength) < length2)
+    3605             :                 return DLT_RETURN_ERROR;
+    3606             : 
+    3607           0 :             if (print_with_attributes) {
+    3608             :                 // Print "name" attribute, if we have one with non-zero size.
+    3609           0 :                 if (length2 > 1) {
+    3610           0 :                     snprintf(text, textlength, "%s:", *ptr);
+    3611           0 :                     value_text += length2+1-1;  // +1 for ":" and -1 for NUL
+    3612           0 :                     textlength -= length2+1-1;
+    3613             :                 }
+    3614             :             }
+    3615             : 
+    3616           0 :             *ptr += length2;
+    3617           0 :             *datalength -= length2;
+    3618             : 
+    3619           0 :             if ((*datalength) < length3)
+    3620             :                 return DLT_RETURN_ERROR;
+    3621             : 
+    3622             :             // We want to add the "unit" attribute only after the value, so remember its pointer and length here.
+    3623             :             unit_text_src = *ptr;
+    3624           0 :             unit_text_len = length3;
+    3625             : 
+    3626           0 :             *ptr += length3;
+    3627           0 :             *datalength -= length3;
+    3628             :         }
+    3629             : 
+    3630          14 :         switch (type_info & DLT_TYPE_INFO_TYLE) {
+    3631           0 :         case DLT_TYLE_8BIT:
+    3632             :         {
+    3633           0 :             if (*datalength >= 1)
+    3634           0 :                 dlt_print_hex_string(value_text, (int) textlength, *ptr, 1);
+    3635             : 
+    3636           0 :             if ((*datalength) < 1)
+    3637             :                 return DLT_RETURN_ERROR;
+    3638             : 
+    3639           0 :             *ptr += 1;
+    3640           0 :             *datalength -= 1;
+    3641           0 :             break;
+    3642             :         }
+    3643           0 :         case DLT_TYLE_16BIT:
+    3644             :         {
+    3645           0 :             if (*datalength >= 2)
+    3646           0 :                 dlt_print_hex_string(value_text, (int) textlength, *ptr, 2);
+    3647             : 
+    3648           0 :             if ((*datalength) < 2)
+    3649             :                 return DLT_RETURN_ERROR;
+    3650             : 
+    3651           0 :             *ptr += 2;
+    3652           0 :             *datalength -= 2;
+    3653           0 :             break;
+    3654             :         }
+    3655             :         case DLT_TYLE_32BIT:
+    3656             :         {
+    3657             :             if (sizeof(float32_t) == 4) {
+    3658             :                 value32f = 0;
+    3659             :                 value32f_tmp = 0;
+    3660             :                 value32f_tmp_int32i = 0;
+    3661             :                 value32f_tmp_int32i_swaped = 0;
+    3662           7 :                 DLT_MSG_READ_VALUE(value32f_tmp, *ptr, *datalength, float32_t);
+    3663             : 
+    3664           7 :                 if ((*datalength) < 0)
+    3665             :                     return DLT_RETURN_ERROR;
+    3666             : 
+    3667             :                 memcpy(&value32f_tmp_int32i, &value32f_tmp, sizeof(float32_t));
+    3668             :                 value32f_tmp_int32i_swaped =
+    3669           7 :                     (int32_t) DLT_ENDIAN_GET_32(msg->standardheader->htyp, (uint32_t)value32f_tmp_int32i);
+    3670             :                 memcpy(&value32f, &value32f_tmp_int32i_swaped, sizeof(float32_t));
+    3671           7 :                 snprintf(value_text, textlength, "%g", value32f);
+    3672             :             }
+    3673             :             else {
+    3674             :                 dlt_log(LOG_ERR, "Invalid size of float32_t\n");
+    3675             :                 return DLT_RETURN_ERROR;
+    3676             :             }
+    3677             : 
+    3678             :             break;
+    3679             :         }
+    3680             :         case DLT_TYLE_64BIT:
+    3681             :         {
+    3682             :             if (sizeof(float64_t) == 8) {
+    3683             :                 value64f = 0;
+    3684             :                 value64f_tmp = 0;
+    3685             :                 value64f_tmp_int64i = 0;
+    3686             :                 value64f_tmp_int64i_swaped = 0;
+    3687           7 :                 DLT_MSG_READ_VALUE(value64f_tmp, *ptr, *datalength, float64_t);
+    3688             : 
+    3689           7 :                 if ((*datalength) < 0)
+    3690             :                     return DLT_RETURN_ERROR;
+    3691             : 
+    3692             :                 memcpy(&value64f_tmp_int64i, &value64f_tmp, sizeof(float64_t));
+    3693             :                 value64f_tmp_int64i_swaped =
+    3694           7 :                     (int64_t) DLT_ENDIAN_GET_64(msg->standardheader->htyp, (uint64_t)value64f_tmp_int64i);
+    3695             :                 memcpy(&value64f, &value64f_tmp_int64i_swaped, sizeof(float64_t));
+    3696             : #ifdef __arm__
+    3697             :                 snprintf(value_text, textlength, "ILLEGAL");
+    3698             : #else
+    3699             :                 snprintf(value_text, textlength, "%g", value64f);
+    3700             : #endif
+    3701             :             }
+    3702             :             else {
+    3703             :                 dlt_log(LOG_ERR, "Invalid size of float64_t\n");
+    3704             :                 return DLT_RETURN_ERROR;
+    3705             :             }
+    3706             : 
+    3707             :             break;
+    3708             :         }
+    3709           0 :         case DLT_TYLE_128BIT:
+    3710             :         {
+    3711           0 :             if (*datalength >= 16)
+    3712           0 :                 dlt_print_hex_string(value_text, textlength, *ptr, 16);
+    3713             : 
+    3714           0 :             if ((*datalength) < 16)
+    3715             :                 return DLT_RETURN_ERROR;
+    3716             : 
+    3717           0 :             *ptr += 16;
+    3718           0 :             *datalength -= 16;
+    3719           0 :             break;
+    3720             :         }
+    3721             :         default:
+    3722             :         {
+    3723             :             return DLT_RETURN_ERROR;
+    3724             :         }
+    3725             :         }
+    3726             :     }
+    3727         113 :     else if (type_info & DLT_TYPE_INFO_RAWD)
+    3728             :     {
+    3729             :         /* raw data argument */
+    3730         112 :         DLT_MSG_READ_VALUE(value16u_tmp, *ptr, *datalength, uint16_t);
+    3731             : 
+    3732         112 :         if ((*datalength) < 0)
+    3733             :             return DLT_RETURN_ERROR;
+    3734             : 
+    3735         110 :         length = DLT_ENDIAN_GET_16(msg->standardheader->htyp, value16u_tmp);
+    3736             : 
+    3737         110 :         if (type_info & DLT_TYPE_INFO_VARI) {
+    3738           0 :             DLT_MSG_READ_VALUE(value16u_tmp, *ptr, *datalength, uint16_t);
+    3739             : 
+    3740           0 :             if ((*datalength) < 0)
+    3741             :                 return DLT_RETURN_ERROR;
+    3742             : 
+    3743           0 :             length2 = DLT_ENDIAN_GET_16(msg->standardheader->htyp, value16u_tmp);
+    3744             : 
+    3745           0 :             if ((*datalength) < length2)
+    3746             :                 return DLT_RETURN_ERROR;
+    3747             : 
+    3748           0 :             if (print_with_attributes) {
+    3749             :                 // Print "name" attribute, if we have one with non-zero size.
+    3750           0 :                 if (length2 > 1) {
+    3751           0 :                     snprintf(text, textlength, "%s:", *ptr);
+    3752           0 :                     value_text += length2+1-1;  // +1 for ":" and -1 for NUL
+    3753           0 :                     textlength -= length2+1-1;
+    3754             :                 }
+    3755             :             }
+    3756             : 
+    3757           0 :             *ptr += length2;
+    3758           0 :             *datalength -= length2;
+    3759             :         }
+    3760             : 
+    3761         110 :         if ((*datalength) < length)
+    3762             :             return DLT_RETURN_ERROR;
+    3763             : 
+    3764           9 :         if (dlt_print_hex_string_delim(value_text, (int) textlength, *ptr, length, '\'') < DLT_RETURN_OK)
+    3765             :             return DLT_RETURN_ERROR;
+    3766           9 :         *ptr += length;
+    3767           9 :         *datalength -= length;
+    3768             :     }
+    3769           1 :     else if (type_info & DLT_TYPE_INFO_TRAI)
+    3770             :     {
+    3771             :         /* trace info argument */
+    3772           0 :         DLT_MSG_READ_VALUE(value16u_tmp, *ptr, *datalength, uint16_t);
+    3773             : 
+    3774           0 :         if ((*datalength) < 0)
+    3775             :             return DLT_RETURN_ERROR;
+    3776             : 
+    3777           0 :         length = DLT_ENDIAN_GET_16(msg->standardheader->htyp, value16u_tmp);
+    3778             : 
+    3779           0 :         DLT_MSG_READ_STRING(value_text, *ptr, *datalength, textlength, length);
+    3780             : 
+    3781           0 :         if ((*datalength) < 0)
+    3782             :             return DLT_RETURN_ERROR;
+    3783             :     }
+    3784             :     else {
+    3785             :         return DLT_RETURN_ERROR;
+    3786             :     }
+    3787             : 
+    3788        2650 :     if (*datalength < 0) {
+    3789           0 :         dlt_log(LOG_ERR, "Payload of DLT message corrupted\n");
+    3790           0 :         return DLT_RETURN_ERROR;
+    3791             :     }
+    3792             : 
+    3793             :     // Now write "unit" attribute, but only if it has more than only a nul-termination char.
+    3794        2650 :     if (print_with_attributes) {
+    3795           0 :         if (unit_text_len > 1) {
+    3796             :             // 'value_text' still points to the +start+ of the value text
+    3797           0 :             size_t currLen = strlen(value_text);
+    3798             : 
+    3799           0 :             char* unitText = value_text + currLen;
+    3800           0 :             textlength -= currLen;
+    3801             :             snprintf(unitText, textlength, ":%s", unit_text_src);
+    3802             :         }
+    3803             :     }
+    3804             : 
+    3805             :     return DLT_RETURN_OK;
+    3806             : }
+    3807             : 
+    3808       16786 : void dlt_check_envvar()
+    3809             : {
+    3810       16786 :     char *env_log_filename = getenv("DLT_LOG_FILENAME");
+    3811             : 
+    3812       16786 :     if (env_log_filename != NULL)
+    3813           0 :         dlt_log_set_filename(env_log_filename);
+    3814             : 
+    3815       16786 :     char *env_log_level_str = getenv("DLT_LOG_LEVEL");
+    3816             : 
+    3817       16786 :     if (env_log_level_str != NULL) {
+    3818           0 :         int level = 0;
+    3819             : 
+    3820           0 :         if (sscanf(env_log_level_str, "%d", &level) == 1)
+    3821           0 :             dlt_log_set_level(level);
+    3822             :     }
+    3823             : 
+    3824       16786 :     char *env_log_mode = getenv("DLT_LOG_MODE");
+    3825             : 
+    3826       16786 :     if (env_log_mode != NULL) {
+    3827           0 :         int mode = 0;
+    3828             : 
+    3829           0 :         if (sscanf(env_log_mode, "%d", &mode) == 1)
+    3830           0 :             dlt_log_init(mode);
+    3831             :     }
+    3832             : 
+    3833             : #if defined DLT_DAEMON_USE_FIFO_IPC || defined DLT_LIB_USE_FIFO_IPC
+    3834       16786 :     char *env_pipe_dir = getenv("DLT_PIPE_DIR");
+    3835             : 
+    3836       16786 :     if (env_pipe_dir != NULL)
+    3837           0 :         dlt_log_set_fifo_basedir(env_pipe_dir);
+    3838             :     else
+    3839       16786 :         dlt_log_set_fifo_basedir(DLT_USER_IPC_PATH);
+    3840             : 
+    3841             : #endif
+    3842             : 
+    3843             : #ifdef DLT_SHM_ENABLE
+    3844             :     char *env_shm_name = getenv("DLT_SHM_NAME");
+    3845             : 
+    3846             :     if (env_shm_name != NULL)
+    3847             :         dlt_log_set_shm_name(env_shm_name);
+    3848             : 
+    3849             : #endif
+    3850       16786 : }
+    3851             : 
+    3852           2 : int dlt_set_loginfo_parse_service_id(char *resp_text,
+    3853             :                                      uint32_t *service_id,
+    3854             :                                      uint8_t *service_opt)
+    3855             : {
+    3856             :     int ret = -1;
+    3857             :     char get_log_info_tag[GET_LOG_INFO_LENGTH];
+    3858             :     char service_opt_str[SERVICE_OPT_LENGTH];
+    3859             : 
+    3860           2 :     if ((resp_text == NULL) || (service_id == NULL) || (service_opt == NULL))
+    3861             :         return DLT_RETURN_ERROR;
+    3862             : 
+    3863             :     /* ascii type, syntax is 'get_log_info, ..' */
+    3864             :     /* check target id */
+    3865             :     strncpy(get_log_info_tag, "get_log_info", strlen("get_log_info") + 1);
+    3866           2 :     ret = memcmp((void *)resp_text, (void *)get_log_info_tag, sizeof(get_log_info_tag) - 1);
+    3867             : 
+    3868           2 :     if (ret == 0) {
+    3869           2 :         *service_id = DLT_SERVICE_ID_GET_LOG_INFO;
+    3870             :         /* reading the response mode from the resp_text. eg. option 7*/
+    3871           2 :         service_opt_str[0] = *(resp_text + GET_LOG_INFO_LENGTH + 1);
+    3872           2 :         service_opt_str[1] = *(resp_text + GET_LOG_INFO_LENGTH + 2);
+    3873           2 :         service_opt_str[2] = 0;
+    3874           2 :         *service_opt = (uint8_t) atoi(service_opt_str);
+    3875             :     }
+    3876             : 
+    3877             :     return ret;
+    3878             : }
+    3879             : 
+    3880          14 : int16_t dlt_getloginfo_conv_ascii_to_uint16_t(char *rp, int *rp_count)
+    3881             : {
+    3882          14 :     char num_work[5] = { 0 };
+    3883             :     char *endptr;
+    3884             : 
+    3885          14 :     if ((rp == NULL) || (rp_count == NULL))
+    3886             :         return -1;
+    3887             : 
+    3888             :     /* ------------------------------------------------------
+    3889             :      *  from: [89 13 ] -> to: ['+0x'1389\0] -> to num
+    3890             :      *  ------------------------------------------------------ */
+    3891          14 :     num_work[0] = *(rp + *rp_count + 3);
+    3892          14 :     num_work[1] = *(rp + *rp_count + 4);
+    3893          14 :     num_work[2] = *(rp + *rp_count + 0);
+    3894          14 :     num_work[3] = *(rp + *rp_count + 1);
+    3895             :     num_work[4] = 0;
+    3896          14 :     *rp_count += 6;
+    3897             : 
+    3898          14 :     return (uint16_t)strtol(num_work, &endptr, 16);
+    3899             : }
+    3900             : 
+    3901          12 : int16_t dlt_getloginfo_conv_ascii_to_int16_t(char *rp, int *rp_count)
+    3902             : {
+    3903          12 :     char num_work[3] = { 0 };
+    3904             :     char *endptr;
+    3905             : 
+    3906          12 :     if ((rp == NULL) || (rp_count == NULL))
+    3907             :         return -1;
+    3908             : 
+    3909             :     /* ------------------------------------------------------
+    3910             :      *  from: [89 ] -> to: ['0x'89\0] -> to num
+    3911             :      *  ------------------------------------------------------ */
+    3912          12 :     num_work[0] = *(rp + *rp_count + 0);
+    3913          12 :     num_work[1] = *(rp + *rp_count + 1);
+    3914             :     num_work[2] = 0;
+    3915          12 :     *rp_count += 3;
+    3916             : 
+    3917          12 :     return (signed char)strtol(num_work, &endptr, 16);
+    3918             : }
+    3919             : 
+    3920          11 : void dlt_getloginfo_conv_ascii_to_string(char *rp, int *rp_count, char *wp, int len)
+    3921             : {
+    3922          11 :     if ((rp == NULL ) || (rp_count == NULL ) || (wp == NULL ))
+    3923             :         return;
+    3924             :     /* ------------------------------------------------------
+    3925             :      *  from: [72 65 6d 6f ] -> to: [0x72,0x65,0x6d,0x6f,0x00]
+    3926             :      *  ------------------------------------------------------ */
+    3927             : 
+    3928          11 :     int count = dlt_getloginfo_conv_ascii_to_id(rp, rp_count, wp, len);
+    3929          11 :     *(wp + count) = '\0';
+    3930             : 
+    3931          11 :     return;
+    3932             : }
+    3933             : 
+    3934          20 : int dlt_getloginfo_conv_ascii_to_id(char *rp, int *rp_count, char *wp, int len)
+    3935             : {
+    3936          20 :     char number16[3] = { 0 };
+    3937             :     char *endptr;
+    3938             :     int count;
+    3939             : 
+    3940          20 :     if ((rp == NULL) || (rp_count == NULL) || (wp == NULL))
+    3941             :         return 0;
+    3942             : 
+    3943             :     /* ------------------------------------------------------
+    3944             :      *  from: [72 65 6d 6f ] -> to: [0x72,0x65,0x6d,0x6f]
+    3945             :      *  ------------------------------------------------------ */
+    3946         289 :     for (count = 0; count < len; count++) {
+    3947         269 :         number16[0] = *(rp + *rp_count + 0);
+    3948         269 :         number16[1] = *(rp + *rp_count + 1);
+    3949         269 :         *(wp + count) = (char) strtol(number16, &endptr, 16);
+    3950         269 :         *rp_count += 3;
+    3951             :     }
+    3952             : 
+    3953             :     return count;
+    3954             : }
+    3955             : 
+    3956           0 : void dlt_hex_ascii_to_binary(const char *ptr, uint8_t *binary, int *size)
+    3957             : {
+    3958           0 :     char ch = *ptr;
+    3959             :     int pos = 0;
+    3960           0 :     binary[pos] = 0;
+    3961             :     int first = 1;
+    3962             :     int found;
+    3963             : 
+    3964             :     for (;;) {
+    3965           0 :         if (ch == 0) {
+    3966           0 :             *size = pos;
+    3967           0 :             return;
+    3968             :         }
+    3969             : 
+    3970             :         found = 0;
+    3971             : 
+    3972           0 :         if ((ch >= '0') && (ch <= '9')) {
+    3973           0 :             binary[pos] = (uint8_t) ((binary[pos] << 4) + (ch - '0'));
+    3974             :             found = 1;
+    3975             :         }
+    3976           0 :         else if ((ch >= 'A') && (ch <= 'F'))
+    3977             :         {
+    3978           0 :             binary[pos] = (uint8_t) ((binary[pos] << 4) + (ch - 'A' + 10));
+    3979             :             found = 1;
+    3980             :         }
+    3981           0 :         else if ((ch >= 'a') && (ch <= 'f'))
+    3982             :         {
+    3983           0 :             binary[pos] = (uint8_t) ((binary[pos] << 4) + (ch - 'a' + 10));
+    3984             :             found = 1;
+    3985             :         }
+    3986             : 
+    3987             :         if (found) {
+    3988           0 :             if (first) {
+    3989             :                 first = 0;
+    3990             :             }
+    3991             :             else {
+    3992             :                 first = 1;
+    3993           0 :                 pos++;
+    3994             : 
+    3995           0 :                 if (pos >= *size)
+    3996             :                     return;
+    3997             : 
+    3998           0 :                 binary[pos] = 0;
+    3999             :             }
+    4000             :         }
+    4001             : 
+    4002           0 :         ch = *(++ptr);
+    4003             :     }
+    4004             : }
+    4005             : 
+    4006           3 : DltReturnValue dlt_file_quick_parsing(DltFile *file, const char *filename,
+    4007             :                                       int type, int verbose)
+    4008             : {
+    4009           3 :     PRINT_FUNCTION_VERBOSE(verbose);
+    4010             :     int ret = DLT_RETURN_OK;
+    4011           3 :     char text[DLT_CONVERT_TEXTBUFSIZE] = { 0 };
+    4012             : 
+    4013           3 :     if ((file == NULL) || (filename == NULL))
+    4014             :         return DLT_RETURN_WRONG_PARAMETER;
+    4015             : 
+    4016           1 :     FILE *output = fopen(filename, "w+");
+    4017             : 
+    4018           1 :     if (output == NULL) {
+    4019           0 :         dlt_vlog(LOG_ERR, "Cannot open output file %s for parsing\n", filename);
+    4020           0 :         return DLT_RETURN_ERROR;
+    4021             :     }
+    4022             : 
+    4023         106 :     while (ret >= DLT_RETURN_OK && file->file_position < file->file_length) {
+    4024             :         /* get file position at start of DLT message */
+    4025         105 :         if (verbose)
+    4026           0 :             dlt_vlog(LOG_DEBUG, "Position in file: %" PRIu64 "\n", file->file_position);
+    4027             : 
+    4028             :         /* read all header and payload */
+    4029         105 :         ret = dlt_file_read_header(file, verbose);
+    4030             : 
+    4031         105 :         if (ret < DLT_RETURN_OK)
+    4032             :             break;
+    4033             : 
+    4034         105 :         ret = dlt_file_read_header_extended(file, verbose);
+    4035             : 
+    4036         105 :         if (ret < DLT_RETURN_OK)
+    4037             :             break;
+    4038             : 
+    4039         105 :         ret = dlt_file_read_data(file, verbose);
+    4040             : 
+    4041         105 :         if (ret < DLT_RETURN_OK)
+    4042             :             break;
+    4043             : 
+    4044         105 :         if (file->filter) {
+    4045             :             /* check the filters if message is used */
+    4046           0 :             ret = dlt_message_filter_check(&(file->msg), file->filter, verbose);
+    4047             : 
+    4048           0 :             if (ret != DLT_RETURN_TRUE)
+    4049           0 :                 continue;
+    4050             :         }
+    4051             : 
+    4052         105 :         ret = dlt_message_header(&(file->msg), text,
+    4053             :                                  DLT_CONVERT_TEXTBUFSIZE, verbose);
+    4054             : 
+    4055         105 :         if (ret < DLT_RETURN_OK)
+    4056             :             break;
+    4057             : 
+    4058             :         fprintf(output, "%s", text);
+    4059             : 
+    4060         105 :         ret = dlt_message_payload(&(file->msg), text,
+    4061             :                                   DLT_CONVERT_TEXTBUFSIZE, type, verbose);
+    4062             : 
+    4063         105 :         if (ret < DLT_RETURN_OK)
+    4064             :             break;
+    4065             : 
+    4066             :         fprintf(output, "[%s]\n", text);
+    4067             : 
+    4068             :         /* store index pointer to message position in DLT file */
+    4069         105 :         file->counter++;
+    4070         105 :         file->position = file->counter_total - 1;
+    4071             :         /* increase total message counter */
+    4072         105 :         file->counter_total++;
+    4073             :         /* store position to next message */
+    4074         105 :         file->file_position = ftell(file->handle);
+    4075             :     } /* while() */
+    4076             : 
+    4077           1 :     fclose(output);
+    4078           1 :     return ret;
+    4079             : }
+    4080             : 
+    4081             : 
+    4082           0 : int dlt_execute_command(char *filename, char *command, ...)
+    4083             : {
+    4084             :     va_list val;
+    4085             :     int argc;
+    4086             :     char **args = NULL;
+    4087           0 :     int ret = 0;
+    4088             : 
+    4089           0 :     if (command == NULL)
+    4090             :         return -1;
+    4091             : 
+    4092             :     /* Determine number of variadic arguments */
+    4093           0 :     va_start(val, command);
+    4094             : 
+    4095           0 :     for (argc = 2; va_arg(val, char *) != NULL; argc++);
+    4096             : 
+    4097           0 :     va_end(val);
+    4098             : 
+    4099             :     /* Allocate args, put references to command */
+    4100           0 :     args = (char **) malloc( (uint32_t) argc * sizeof(char*));
+    4101           0 :     args[0] = command;
+    4102             : 
+    4103           0 :     va_start(val, command);
+    4104             : 
+    4105           0 :     for (int i = 0; args[i] != NULL; i++)
+    4106           0 :         args[i + 1] = va_arg(val, char *);
+    4107             : 
+    4108           0 :     va_end(val);
+    4109             : 
+    4110             :     /* Run command in child process */
+    4111           0 :     pid_t pid = fork();
+    4112             : 
+    4113           0 :     if (pid == 0) { /* child process */
+    4114             : 
+    4115             :         /* Redirect output if required */
+    4116           0 :         if (filename != NULL) {
+    4117             :             int fd = open(filename, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+    4118             : 
+    4119           0 :             if (fd < 0)
+    4120           0 :                 err(-1, "%s failed on open()", __func__);
+    4121             : 
+    4122           0 :             if (dup2(fd, STDOUT_FILENO) == -1) {
+    4123           0 :                 close(fd);
+    4124           0 :                 err(-1, "%s failed on dup2()", __func__);
+    4125             :             }
+    4126             : 
+    4127           0 :             close(fd);
+    4128             :         }
+    4129             : 
+    4130             :         /* Run command */
+    4131           0 :         execvp(command, (char **)args);
+    4132             :     }
+    4133           0 :     else if (pid == -1) /* error in fork */
+    4134             :     {
+    4135           0 :         ret = -1;
+    4136             :     }
+    4137             :     else /* parent */
+    4138             :     {
+    4139           0 :         if (wait(&ret) == -1) {
+    4140           0 :             err(-1, "%s failed on wait()", __func__);
+    4141             :         }
+    4142             :     }
+    4143             : 
+    4144           0 :     free(args);
+    4145           0 :     return ret;
+    4146             : }
+    4147             : 
+    4148           5 : char *get_filename_ext(const char *filename)
+    4149             : {
+    4150           5 :     if (filename == NULL) {
+    4151           0 :         fprintf(stderr, "ERROR: %s: invalid arguments\n", __FUNCTION__);
+    4152           0 :         return "";
+    4153             :     }
+    4154             : 
+    4155           5 :     char *dot = strrchr(filename, '.');
+    4156           5 :     return (!dot || dot == filename) ? NULL : dot;
+    4157             : }
+    4158             : 
+    4159           6 : bool dlt_extract_base_name_without_ext(const char* const abs_file_name, char* base_name, long base_name_len) {
+    4160           6 :     if (abs_file_name == NULL || base_name == NULL) return false;
+    4161             : 
+    4162           6 :     const char* last_separator = strrchr(abs_file_name, '.');
+    4163           6 :     if (!last_separator) return false;
+    4164           5 :     long length = last_separator - abs_file_name;
+    4165           5 :     length = length > base_name_len ? base_name_len : length;
+    4166             : 
+    4167           5 :     strncpy(base_name, abs_file_name, length);
+    4168           5 :     base_name[length] = '\0';
+    4169           5 :     return true;
+    4170             : }
+    4171             : 
+    4172             : #ifdef DLT_TRACE_LOAD_CTRL_ENABLE
+    4173             : static int32_t dlt_output_soft_limit_over_warning(
+    4174             :     DltTraceLoadSettings* const tl_settings,
+    4175             :     DltLogInternal log_internal,
+    4176             :     void *const log_params)
+    4177             : {
+    4178             :     char local_str[255];
+    4179             : 
+    4180             :     if (!tl_settings || !tl_settings->tl_stat.is_over_soft_limit || tl_settings->tl_stat.slot_left_soft_limit_warn)
+    4181             :     {
+    4182             :         /* No need to output warning message */
+    4183             :         return 0;
+    4184             :     }
+    4185             : 
+    4186             :     /* Calculate extra trace load which was over limit */
+    4187             :     const uint64_t dropped_message_load
+    4188             :         = (tl_settings->tl_stat.hard_limit_over_bytes * DLT_TIMESTAMP_RESOLUTION)
+    4189             :           / TIMESTAMP_BASED_WINDOW_SIZE;
+    4190             :     const uint64_t curr_trace_load = tl_settings->tl_stat.avg_trace_load + dropped_message_load;
+    4191             :     if (curr_trace_load <= tl_settings->soft_limit) {
+    4192             :         /* No need to output warning message */
+    4193             :         return 0;
+    4194             :     }
+    4195             : 
+    4196             :     /* Warning for exceeded soft limit */
+    4197             :     if (tl_settings->ctid[0] == 0) {
+    4198             :         snprintf(local_str, sizeof(local_str),
+    4199             :                  "Trace load exceeded trace soft limit on apid %.4s "
+    4200             :                  "(soft limit: %u bytes/sec, current: %lu bytes/sec)",
+    4201             :                  tl_settings->apid,
+    4202             :                  tl_settings->soft_limit,
+    4203             :                  curr_trace_load);
+    4204             :     } else {
+    4205             :         snprintf(local_str, sizeof(local_str),
+    4206             :                  "Trace load exceeded trace soft limit on apid %.4s, ctid %.4s "
+    4207             :                  "(soft limit: %u bytes/sec, current: %lu bytes/sec)",
+    4208             :                  tl_settings->apid,
+    4209             :                  tl_settings->ctid,
+    4210             :                  tl_settings->soft_limit,
+    4211             :                  curr_trace_load);
+    4212             :     }
+    4213             : 
+    4214             :     // must be signed int for error return value
+    4215             :     int32_t sent_size = log_internal(DLT_LOG_WARN, local_str, log_params);
+    4216             :     if (sent_size < DLT_RETURN_OK)
+    4217             :     {
+    4218             :         /* Output warning message via other route for safety */
+    4219             :         dlt_log(DLT_LOG_WARN, local_str);
+    4220             :         sent_size = 0;
+    4221             :     }
+    4222             : 
+    4223             :     /* Turn off the flag after sending warning message */
+    4224             :     tl_settings->tl_stat.is_over_soft_limit = false;
+    4225             :     tl_settings->tl_stat.slot_left_soft_limit_warn = DLT_SOFT_LIMIT_WARN_FREQUENCY;
+    4226             : 
+    4227             :     return sent_size;
+    4228             : }
+    4229             : 
+    4230             : static int32_t dlt_output_hard_limit_warning(
+    4231             :     DltTraceLoadSettings* const tl_settings,
+    4232             :     DltLogInternal log_internal,
+    4233             :     void *const log_params)
+    4234             : {
+    4235             :     char local_str[255];
+    4236             :     if (!tl_settings || !tl_settings->tl_stat.is_over_hard_limit || tl_settings->tl_stat.slot_left_hard_limit_warn)
+    4237             :     {
+    4238             :         /* No need to output warning message */
+    4239             :         return 0;
+    4240             :     }
+    4241             : 
+    4242             :     /* Calculate extra trace load which was over limit */
+    4243             :     const uint64_t dropped_message_load
+    4244             :         = (tl_settings->tl_stat.hard_limit_over_bytes * DLT_TIMESTAMP_RESOLUTION)
+    4245             :           / TIMESTAMP_BASED_WINDOW_SIZE;
+    4246             :     const uint64_t curr_trace_load = tl_settings->tl_stat.avg_trace_load + dropped_message_load;
+    4247             :     if (curr_trace_load <= tl_settings->hard_limit) {
+    4248             :         /* No need to output warning message */
+    4249             :         return 0;
+    4250             :     }
+    4251             : 
+    4252             :     if (tl_settings->ctid[0] == 0) {
+    4253             :         snprintf(local_str, sizeof(local_str),
+    4254             :                  "Trace load exceeded trace hard limit on apid %.4s "
+    4255             :                  "(hard limit: %u bytes/sec, current: %lu bytes/sec) %u messages discarded. ",
+    4256             :                  tl_settings->apid,
+    4257             :                  tl_settings->hard_limit,
+    4258             :                  curr_trace_load,
+    4259             :                  tl_settings->tl_stat.hard_limit_over_counter);
+    4260             :     } else {
+    4261             :         snprintf(local_str, sizeof(local_str),
+    4262             :                  "Trace load exceeded trace hard limit on apid %.4s, ctid %.4s."
+    4263             :                  "(hard limit: %u bytes/sec, current: %lu bytes/sec) %u messages discarded.",
+    4264             :                  tl_settings->apid,
+    4265             :                  tl_settings->ctid,
+    4266             :                  tl_settings->hard_limit,
+    4267             :                  curr_trace_load,
+    4268             :                  tl_settings->tl_stat.hard_limit_over_counter);
+    4269             :     }
+    4270             : 
+    4271             :     // must be signed int for error return
+    4272             :     int32_t sent_size = log_internal(DLT_LOG_WARN, local_str, log_params);
+    4273             :     if (sent_size < DLT_RETURN_OK)
+    4274             :     {
+    4275             :         /* Output warning message via other route for safety */
+    4276             :         dlt_log(DLT_LOG_WARN, local_str);
+    4277             :         sent_size = 0;
+    4278             :     }
+    4279             : 
+    4280             :     /* Turn off the flag after sending warning message */
+    4281             :     tl_settings->tl_stat.is_over_hard_limit = false;
+    4282             :     tl_settings->tl_stat.hard_limit_over_counter = 0;
+    4283             :     tl_settings->tl_stat.hard_limit_over_bytes = 0;
+    4284             :     tl_settings->tl_stat.slot_left_hard_limit_warn = DLT_HARD_LIMIT_WARN_FREQUENCY;
+    4285             : 
+    4286             :     return sent_size;
+    4287             : }
+    4288             : 
+    4289             : static bool dlt_user_cleanup_window(DltTraceLoadStat *const tl_stat)
+    4290             : {
+    4291             :     if (!tl_stat)
+    4292             :     {
+    4293             :         return false;
+    4294             :     }
+    4295             : 
+    4296             :     uint32_t elapsed_slots  = 0;
+    4297             :     /* check if overflow of timestamp happened, after ~119 hours */
+    4298             :     if (tl_stat->curr_abs_slot < tl_stat->last_abs_slot) {
+    4299             :         /* calculate where the next slot starts according to the last slot
+    4300             :          * This works because the value after the uint32 rollover equals is equal to the remainder that did not fit
+    4301             :          * into uint32 before. Therefore, we always have slots that are DLT_TIMESTAMP_RESOLUTION long
+    4302             :          * */
+    4303             :         const uint32_t next_slot_start =
+    4304             :             DLT_TIMESTAMP_RESOLUTION + tl_stat->last_abs_slot;
+    4305             : 
+    4306             :         /* Check if we are already in the next slot */
+    4307             :         if (next_slot_start <= tl_stat->curr_abs_slot) {
+    4308             :             /* Calculate relative amount of elapsed slots */
+    4309             :             elapsed_slots = (tl_stat->curr_abs_slot - next_slot_start) / DLT_TIMESTAMP_RESOLUTION + 1;
+    4310             :         }
+    4311             :         /* else we are not in the next slot yet */
+    4312             :     } else {
+    4313             :         /* no rollover, get difference between slots to get amount of elapsed slots  */
+    4314             :         elapsed_slots = (tl_stat->curr_abs_slot - tl_stat->last_abs_slot);
+    4315             :     }
+    4316             : 
+    4317             :     if (!elapsed_slots)
+    4318             :     {
+    4319             :         /* Same slot can be still used. No need to cleanup slot */
+    4320             :         return false;
+    4321             :     }
+    4322             : 
+    4323             :     /* Slot-Based Count down for next warning messages */
+    4324             :     tl_stat->slot_left_soft_limit_warn = (tl_stat->slot_left_soft_limit_warn > elapsed_slots) ?
+    4325             :                                                                                               (tl_stat->slot_left_soft_limit_warn - elapsed_slots) : 0;
+    4326             : 
+    4327             :     tl_stat->slot_left_hard_limit_warn = (tl_stat->slot_left_hard_limit_warn > elapsed_slots) ?
+    4328             :                                                                                               (tl_stat->slot_left_hard_limit_warn - elapsed_slots) : 0;
+    4329             : 
+    4330             :     /* Clear whole window when time elapsed longer than window size from last message */
+    4331             :     if (elapsed_slots >= DLT_TRACE_LOAD_WINDOW_SIZE)
+    4332             :     {
+    4333             :         tl_stat->total_bytes_of_window = 0;
+    4334             :         memset(tl_stat->window, 0, sizeof(tl_stat->window));
+    4335             :         return true;
+    4336             :     }
+    4337             : 
+    4338             :     /* Clear skipped no data slots */
+    4339             :     uint32_t temp_slot = tl_stat->last_slot;
+    4340             :     while (temp_slot != tl_stat->curr_slot)
+    4341             :     {
+    4342             :         temp_slot++;
+    4343             :         temp_slot %= DLT_TRACE_LOAD_WINDOW_SIZE;
+    4344             :         tl_stat->total_bytes_of_window -= tl_stat->window[temp_slot];
+    4345             :         tl_stat->window[temp_slot] = 0;
+    4346             :     }
+    4347             : 
+    4348             :     return true;
+    4349             : }
+    4350             : 
+    4351             : static int32_t dlt_switch_slot_if_needed(
+    4352             :     DltTraceLoadSettings* const tl_settings,
+    4353             :     DltLogInternal log_internal,
+    4354             :     void* const log_internal_params,
+    4355             :     const uint32_t timestamp)
+    4356             : {
+    4357             :     if (!tl_settings)
+    4358             :     {
+    4359             :         return 0;
+    4360             :     }
+    4361             : 
+    4362             :     /* Get new window slot No. */
+    4363             :     tl_settings->tl_stat.curr_abs_slot = timestamp / DLT_TRACE_LOAD_WINDOW_RESOLUTION;
+    4364             :     tl_settings->tl_stat.curr_slot = tl_settings->tl_stat.curr_abs_slot % DLT_TRACE_LOAD_WINDOW_SIZE;
+    4365             : 
+    4366             :     /* Cleanup window */
+    4367             :     if (!dlt_user_cleanup_window(&tl_settings->tl_stat))
+    4368             :     {
+    4369             :         /* No need to switch slot because same slot can be still used */
+    4370             :         return 0;
+    4371             :     }
+    4372             : 
+    4373             :     /* If slot is switched and trace load has been over soft/hard limit
+    4374             :      * in previous slot, warning messages may be sent.
+    4375             :      * The warning messages will be also counted as trace load.
+    4376             :      */
+    4377             :     const int32_t sent_warn_msg_bytes =
+    4378             :         dlt_output_soft_limit_over_warning(tl_settings, log_internal, log_internal_params) +
+    4379             :         dlt_output_hard_limit_warning(tl_settings, log_internal, log_internal_params);
+    4380             :     return sent_warn_msg_bytes;
+    4381             : }
+    4382             : 
+    4383             : static void dlt_record_trace_load(DltTraceLoadStat *const tl_stat, const int32_t size)
+    4384             : {
+    4385             :     if (!tl_stat)
+    4386             :     {
+    4387             :         return;
+    4388             :     }
+    4389             : 
+    4390             :     /* Record trace load to current slot by message size of
+    4391             :      * original message and warning message if it was sent
+    4392             :      */
+    4393             :     tl_stat->window[tl_stat->curr_slot] += size;
+    4394             :     tl_stat->total_bytes_of_window += size;
+    4395             : 
+    4396             :     /* Keep the latest time information */
+    4397             :     tl_stat->last_abs_slot = tl_stat->curr_abs_slot;
+    4398             :     tl_stat->last_slot = tl_stat->curr_slot;
+    4399             : 
+    4400             :     /* Calculate average trace load [bytes/sec] in window
+    4401             :      * The division is necessary to normalize the average to bytes per second even if
+    4402             :      * the slot size is not equal to 1s
+    4403             :      * */
+    4404             :     tl_stat->avg_trace_load
+    4405             :         = (tl_stat->total_bytes_of_window * DLT_TIMESTAMP_RESOLUTION) / TIMESTAMP_BASED_WINDOW_SIZE;
+    4406             : }
+    4407             : 
+    4408             : static inline bool dlt_is_over_trace_load_soft_limit(DltTraceLoadSettings* const tl_settings)
+    4409             : {
+    4410             :     if (tl_settings
+    4411             :         && (tl_settings->tl_stat.avg_trace_load > tl_settings->soft_limit || tl_settings->soft_limit == 0))
+    4412             :     {
+    4413             :         /* Mark as soft limit over */
+    4414             :         tl_settings->tl_stat.is_over_soft_limit = true;
+    4415             :         return true;
+    4416             :     }
+    4417             : 
+    4418             :     return false;
+    4419             : }
+    4420             : 
+    4421             : static inline bool dlt_is_over_trace_load_hard_limit(
+    4422             :     DltTraceLoadSettings* const tl_settings, const int size)
+    4423             : {
+    4424             :     if (tl_settings
+    4425             :         && (tl_settings->tl_stat.avg_trace_load > tl_settings->hard_limit
+    4426             :             || tl_settings->hard_limit == 0))
+    4427             :     {
+    4428             :         /* Mark as limit over */
+    4429             :         tl_settings->tl_stat.is_over_hard_limit = true;
+    4430             :         tl_settings->tl_stat.hard_limit_over_counter++;
+    4431             :         tl_settings->tl_stat.hard_limit_over_bytes += size;
+    4432             : 
+    4433             :         /* Delete size of limit over message from window */
+    4434             :         tl_settings->tl_stat.window[tl_settings->tl_stat.curr_slot] -= size;
+    4435             :         tl_settings->tl_stat.total_bytes_of_window -= size;
+    4436             :         return true;
+    4437             :     }
+    4438             : 
+    4439             :     return false;
+    4440             : }
+    4441             : 
+    4442             : bool dlt_check_trace_load(
+    4443             :     DltTraceLoadSettings * const tl_settings,
+    4444             :     const int32_t log_level,
+    4445             :     const uint32_t timestamp,
+    4446             :     const int32_t size,
+    4447             :     DltLogInternal internal_dlt_log,
+    4448             :     void* const internal_dlt_log_params)
+    4449             : {
+    4450             :     /* Unconditionally allow message which has log level: Debug/Verbose to be output */
+    4451             :     if (log_level == DLT_LOG_DEBUG || log_level == DLT_LOG_VERBOSE)
+    4452             :     {
+    4453             :         return true;
+    4454             :     }
+    4455             : 
+    4456             :     if (size < 0)
+    4457             :     {
+    4458             :         dlt_vlog(LOG_ERR, "Invalid size: %d", size);
+    4459             :         return false;
+    4460             :     }
+    4461             : 
+    4462             :     /* Switch window slot according to timestamp
+    4463             :      * If warning messages for hard/soft limit over are sent,
+    4464             :      * the message size will be returned.
+    4465             :      */
+    4466             :     const int32_t sent_warn_msg_bytes = dlt_switch_slot_if_needed(
+    4467             :         tl_settings, internal_dlt_log, internal_dlt_log_params, timestamp);
+    4468             : 
+    4469             :     /* Record trace load */
+    4470             :     dlt_record_trace_load(&tl_settings->tl_stat, size + sent_warn_msg_bytes);
+    4471             : 
+    4472             :     /* Check if trace load is over the soft limit.
+    4473             :      * Even if trace load is over the soft limit, message will not be discarded.
+    4474             :      * Only the warning message will be output
+    4475             :      */
+    4476             :     dlt_is_over_trace_load_soft_limit(tl_settings);
+    4477             : 
+    4478             :     /* Check if trace load is over hard limit.
+    4479             :      * If trace load is over the limit, message will be discarded.
+    4480             :      */
+    4481             :     const bool allow_output = !dlt_is_over_trace_load_hard_limit(tl_settings, size);
+    4482             : 
+    4483             :     return allow_output;
+    4484             : }
+    4485             : 
+    4486             : DltTraceLoadSettings*
+    4487             : dlt_find_runtime_trace_load_settings(DltTraceLoadSettings *settings, uint32_t settings_count, const char* apid, const char* ctid) {
+    4488             :     if ((apid == NULL) || (strlen(apid) == 0))
+    4489             :         return NULL;
+    4490             : 
+    4491             :     DltTraceLoadSettings* app_level = NULL;
+    4492             :     size_t ctid_len = (ctid != NULL) ? strlen(ctid) : 0;
+    4493             : 
+    4494             :     for (uint32_t i = 0; i < settings_count; ++i) {
+    4495             :         if (strncmp(apid, settings->apid, DLT_ID_SIZE) != 0) {
+    4496             :             if (app_level == NULL)
+    4497             :                 continue;
+    4498             :             // settings are sorted.
+    4499             :             // If we found a configuration entry which matches the app id already
+    4500             :             // we can exit here because no more entries with the app id will follow anymore.
+    4501             :             break;
+    4502             :         }
+    4503             : 
+    4504             :         if (settings[i].ctid[0] == '\0') {
+    4505             :             app_level = &settings[i];
+    4506             :             if (ctid_len == 0)
+    4507             :                 return &settings[i];
+    4508             :             continue;
+    4509             :         }
+    4510             : 
+    4511             :         if ((ctid_len > 0) && (strncmp(ctid, settings[i].ctid, DLT_ID_SIZE) == 0)) {
+    4512             :             return &settings[i];
+    4513             :         }
+    4514             :     }
+    4515             : 
+    4516             :     return app_level;
+    4517             : }
+    4518             : 
+    4519             : #endif
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/dlt_config_file_parser.c.func-sort-c.html b/dlt_lcov_report/shared/dlt_config_file_parser.c.func-sort-c.html new file mode 100644 index 000000000..46ffd7b64 --- /dev/null +++ b/dlt_lcov_report/shared/dlt_config_file_parser.c.func-sort-c.html @@ -0,0 +1,132 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared/dlt_config_file_parser.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - shared - dlt_config_file_parser.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:14217083.5 %
Date:2024-12-05 09:07:13Functions:1515100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_config_file_check_section_name_exists4
dlt_config_file_get_num_sections14
dlt_config_file_init14
dlt_config_file_read_file14
dlt_config_file_release14
dlt_config_file_get_section_name40
dlt_config_file_get_section_name_from_string40
dlt_config_file_is_section_name40
dlt_config_file_set_section40
dlt_config_file_get_key_value339
dlt_config_file_set_section_data339
dlt_config_file_read_line379
dlt_config_file_trim_line379
dlt_config_file_get_value536
dlt_config_file_find_section540
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/dlt_config_file_parser.c.func.html b/dlt_lcov_report/shared/dlt_config_file_parser.c.func.html new file mode 100644 index 000000000..1c5deecb7 --- /dev/null +++ b/dlt_lcov_report/shared/dlt_config_file_parser.c.func.html @@ -0,0 +1,132 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared/dlt_config_file_parser.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - shared - dlt_config_file_parser.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:14217083.5 %
Date:2024-12-05 09:07:13Functions:1515100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_config_file_check_section_name_exists4
dlt_config_file_find_section540
dlt_config_file_get_key_value339
dlt_config_file_get_num_sections14
dlt_config_file_get_section_name40
dlt_config_file_get_section_name_from_string40
dlt_config_file_get_value536
dlt_config_file_init14
dlt_config_file_is_section_name40
dlt_config_file_read_file14
dlt_config_file_read_line379
dlt_config_file_release14
dlt_config_file_set_section40
dlt_config_file_set_section_data339
dlt_config_file_trim_line379
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/dlt_config_file_parser.c.gcov.html b/dlt_lcov_report/shared/dlt_config_file_parser.c.gcov.html new file mode 100644 index 000000000..988515502 --- /dev/null +++ b/dlt_lcov_report/shared/dlt_config_file_parser.c.gcov.html @@ -0,0 +1,645 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared/dlt_config_file_parser.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - shared - dlt_config_file_parser.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:14217083.5 %
Date:2024-12-05 09:07:13Functions:1515100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2015, Advanced Driver Information Technology
+       5             :  * This code is developed by Advanced Driver Information Technology.
+       6             :  * Copyright of Advanced Driver Information Technology, Bosch and DENSO.
+       7             :  *
+       8             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       9             :  *
+      10             :  * This Source Code Form is subject to the terms of the
+      11             :  * Mozilla Public License (MPL), v. 2.0.
+      12             :  * If a copy of the MPL was not distributed with this file,
+      13             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      14             :  *
+      15             :  * For further information see http://www.covesa.org/.
+      16             :  */
+      17             : 
+      18             : /*!
+      19             :  * \author
+      20             :  * Christoph Lipka <clipka@jp.adit-jv.com>
+      21             :  *
+      22             :  * \copyright Copyright © 2015 Advanced Driver Information Technology. \n
+      23             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      24             :  *
+      25             :  * \file dlt_config_file_parser.c
+      26             :  */
+      27             : 
+      28             : #include "dlt_config_file_parser.h"
+      29             : #include <stdlib.h>
+      30             : #include <stdio.h>
+      31             : #include <string.h>
+      32             : #include <ctype.h>
+      33             : #include <syslog.h>
+      34             : #include "dlt_common.h"
+      35             : #include "dlt_log.h"
+      36             : #include "dlt-daemon_cfg.h"
+      37             : 
+      38             : /* internal defines */
+      39             : #define DLT_CONFIG_FILE_NEW_SECTION 0x0a
+      40             : #define DLT_CONFIG_FILE_NEW_DATA    0x0b
+      41             : 
+      42             : 
+      43             : /* internal helper functions */
+      44             : 
+      45             : /**
+      46             :  * dlt_config_file_trim_line
+      47             :  *
+      48             :  * Trim all whitespace from a string
+      49             :  *
+      50             :  * @param line  String to remove whitespace from
+      51             :  */
+      52         379 : static void dlt_config_file_trim_line(char *line)
+      53             : {
+      54         379 :     if (line == NULL)
+      55             :         return;
+      56             : 
+      57             :     char *i = line;
+      58             :     char *j = line;
+      59             : 
+      60        6683 :     while (*j != '\0') {
+      61        6304 :         *i = *j++;
+      62             : 
+      63        6304 :         if (!isspace(*i))
+      64        5925 :             i++;
+      65             :     }
+      66             : 
+      67         379 :     *i = '\0';
+      68             : }
+      69             : 
+      70             : /**
+      71             :  * dlt_config_file_ignore_line
+      72             :  *
+      73             :  * Check if a line has to be ignored, because it contains a comment or is empty
+      74             :  *
+      75             :  * @param line  Line of configuration file
+      76             :  * @return 0 if ignore, -1 do not ignore
+      77             :  */
+      78             : static int dlt_config_file_ignore_line(char *line)
+      79             : {
+      80         406 :     if ((line[0] == '#') || (line[0] == ';') || (line[0] == '\n') ||
+      81             :         (line[0] == '\0'))
+      82             :         return 0; /* ignore */
+      83             :     else
+      84             :         return -1; /* do not ignore */
+      85             : }
+      86             : 
+      87             : /**
+      88             :  * dlt_config_file_is_section_name
+      89             :  *
+      90             :  * Check if section name already used
+      91             :  *
+      92             :  * @param file  DltConfigFile
+      93             :  * @param name  Name of section
+      94             :  * @return 0, section name not used, -1 section name already used
+      95             :  */
+      96          40 : static int dlt_config_file_is_section_name(DltConfigFile *file, char *name)
+      97             : {
+      98             :     int i = 0;
+      99             : 
+     100          40 :     if ((file == NULL) || (name == NULL))
+     101             :         return -1;
+     102             : 
+     103         179 :     for (i = 0; i < file->num_sections; i++) {
+     104         139 :         DltConfigFileSection *s = &file->sections[i];
+     105             : 
+     106         139 :         if (strncmp(s->name, name, DLT_CONFIG_FILE_ENTRY_MAX_LEN) == 0)
+     107             :             return -1;
+     108             :     }
+     109             : 
+     110             :     return 0; /* section name not used */
+     111             : }
+     112             : 
+     113             : /**
+     114             :  * dlt_config_file_set_section
+     115             :  *
+     116             :  * Store section in internal data structure
+     117             :  *
+     118             :  * @param file  DltConfigFile
+     119             :  * @param name  Name of section
+     120             :  * @return 0 on success, else -1
+     121             :  */
+     122          40 : static int dlt_config_file_set_section(DltConfigFile *file, char *name)
+     123             : {
+     124          40 :     int section = file->num_sections;
+     125             : 
+     126             :     /* check if adding another section would exceed max number of sections */
+     127          40 :     if (section >= DLT_CONFIG_FILE_SECTIONS_MAX) {
+     128           0 :         dlt_log(LOG_WARNING, "Cannot store more sections\n");
+     129           0 :         return -1; /* reached max number of sections */
+     130             :     }
+     131             : 
+     132             :     /* do not store section with same name again */
+     133          40 :     if (dlt_config_file_is_section_name(file, name) != 0) {
+     134           0 :         dlt_log(LOG_WARNING, "Cannot store section name again\n");
+     135           0 :         return -1;
+     136             :     }
+     137             : 
+     138          40 :     DltConfigFileSection *s = &file->sections[section];
+     139             : 
+     140             :     /* alloc data for entries */
+     141          40 :     s->name = calloc(sizeof(char), DLT_CONFIG_FILE_ENTRY_MAX_LEN + 1);
+     142             : 
+     143          40 :     if (s->name == NULL) {
+     144           0 :         dlt_log(LOG_ERR, "Cannot allocate memory for internal data structure\n");
+     145           0 :         return -1;
+     146             :     }
+     147             : 
+     148          40 :     s->keys = calloc(sizeof(char), DLT_CONFIG_FILE_ENTRY_MAX_LEN * DLT_CONFIG_FILE_KEYS_MAX + 1);
+     149             : 
+     150          40 :     if (s->keys == NULL) {
+     151           0 :         free(s->name);
+     152           0 :         s->name = NULL;
+     153           0 :         dlt_log(LOG_ERR, "Cannot allocate memory for internal data structure\n");
+     154           0 :         return -1;
+     155             :     }
+     156             : 
+     157             :     strncpy(file->sections[section].name, name, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
+     158          40 :     file->num_sections += 1;
+     159          40 :     return 0;
+     160             : }
+     161             : 
+     162             : /**
+     163             :  * dlt_config_file_set_section_data
+     164             :  *
+     165             :  * Store data pair of a section
+     166             :  *
+     167             :  * @param file DltConfigFile
+     168             :  * @param str1 string used for key
+     169             :  * @param str2 string used for value
+     170             :  * @return 0 on success, else -1
+     171             :  */
+     172         339 : static int dlt_config_file_set_section_data(DltConfigFile *file, char *str1, char *str2)
+     173             : {
+     174             :     DltConfigKeyData **tmp = NULL;
+     175             : 
+     176         339 :     if ((file == NULL) || (str1 == NULL) || (str2 == NULL))
+     177             :         return -1;
+     178             : 
+     179         339 :     DltConfigFileSection *s = &file->sections[file->num_sections - 1];
+     180         339 :     int key_number = s->num_entries;
+     181             : 
+     182         339 :     if (key_number + 1 >= DLT_CONFIG_FILE_KEYS_MAX) {
+     183           0 :         dlt_log(LOG_WARNING, "Cannot store more keys in section\n");
+     184           0 :         return -1; /* reached max number of keys per section */
+     185             :     }
+     186             : 
+     187             :     /* copy data into structure */
+     188         339 :     strncpy(&s->keys[key_number * DLT_CONFIG_FILE_ENTRY_MAX_LEN], str1, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
+     189             : 
+     190         339 :     if (s->list == NULL) {
+     191             :         /* creating a list if it doesnt exists */
+     192          40 :         s->list = malloc(sizeof(DltConfigKeyData));
+     193             : 
+     194          40 :         if (s->list == NULL) {
+     195           0 :             dlt_log(LOG_WARNING, "Could not allocate initial memory to list \n");
+     196           0 :             return -1;
+     197             :         }
+     198             : 
+     199          40 :         tmp = &s->list;
+     200             :     }
+     201             :     else {
+     202         299 :         tmp = &s->list;
+     203             : 
+     204        1589 :         while (*(tmp) != NULL)
+     205        1290 :             tmp = &(*tmp)->next;
+     206             : 
+     207             :         /* Adding new entry to the list */
+     208         299 :         *tmp = malloc(sizeof(DltConfigKeyData));
+     209             : 
+     210         299 :         if (*tmp == NULL) {
+     211           0 :             dlt_log(LOG_WARNING, "Could not allocate memory to list \n");
+     212           0 :             return -1;
+     213             :         }
+     214             :     }
+     215             : 
+     216         339 :     (*tmp)->key = strdup(str1);
+     217         339 :     (*tmp)->data = strdup(str2);
+     218         339 :     (*tmp)->next = NULL;
+     219             : 
+     220         339 :     s->num_entries += 1;
+     221             : 
+     222         339 :     return 0;
+     223             : }
+     224             : 
+     225             : /**
+     226             :  * dlt_config_file_has_section
+     227             :  *
+     228             :  * Check if a certain line in config file is a section header
+     229             :  *
+     230             :  * @param line  Line in configuration file
+     231             :  * @return 0 if section header, else -1
+     232             :  */
+     233             : static int dlt_config_file_line_has_section(char *line)
+     234             : {
+     235             :     (void)line; /* avoid compiler warnings */
+     236             : 
+     237         379 :     if (line[0] == '[') /* section found */
+     238             :         return 0;
+     239             :     else
+     240             :         return -1;
+     241             : }
+     242             : 
+     243             : /**
+     244             :  * dlt_config_file_get_section_name_from_string
+     245             :  *
+     246             :  * Extract section name from line
+     247             :  *
+     248             :  * @param line  Line in configuration file containing a section header
+     249             :  * @param name  Section name
+     250             :  * @return 0 on success, else -1
+     251             :  */
+     252          40 : static int dlt_config_file_get_section_name_from_string(char *line, char *name)
+     253             : {
+     254             :     int i = 0;
+     255             :     int j = 0;
+     256             : 
+     257          40 :     if ((line == NULL) || (name == NULL))
+     258             :         return -1;
+     259             : 
+     260         386 :     for (i = 0; i < DLT_CONFIG_FILE_ENTRY_MAX_LEN; i++) {
+     261         386 :         if ((line[i] == '[') || isspace(line[i]))
+     262          40 :             continue;
+     263         346 :         else if ((line[i] == ']') || (line[i] == '\n') || (line[i] == '\0'))
+     264             :             break;
+     265             :         else
+     266         306 :             name[j++] = line[i];
+     267             :     }
+     268             : 
+     269             :     return 0;
+     270             : }
+     271             : 
+     272             : /**
+     273             :  * dlt_config_file_get_key_value
+     274             :  *
+     275             :  * Get key and value from a line of configuration file
+     276             :  *
+     277             :  * @param line      Line on configuration file
+     278             :  * @param[out] str1 String to be used as key
+     279             :  * @param[out] str2 String to be used as value
+     280             :  * @return 0 on success, else -1
+     281             :  */
+     282         339 : static int dlt_config_file_get_key_value(char *line, char *str1, char *str2)
+     283             : {
+     284             :     char *delimiter = "=";
+     285             :     char *ptr;
+     286             :     char *save_ptr;
+     287             : 
+     288         339 :     if ((line == NULL) || (str1 == NULL) || (str2 == NULL))
+     289             :         return -1;
+     290             : 
+     291         339 :     ptr = strtok_r(line, delimiter, &save_ptr);
+     292             : 
+     293         339 :     if (ptr != NULL) { /* get key */
+     294             :         strncpy(str1, ptr, DLT_CONFIG_FILE_ENTRY_MAX_LEN - 1);
+     295         339 :         str1[DLT_CONFIG_FILE_ENTRY_MAX_LEN - 1] = '\0';
+     296             :     } else {
+     297             :         return -1;
+     298             :     }
+     299             : 
+     300         339 :     ptr = strtok_r(NULL, delimiter, &save_ptr);
+     301             : 
+     302         339 :     if (ptr != NULL) {
+     303             :         strncpy(str2, ptr, DLT_CONFIG_FILE_ENTRY_MAX_LEN - 1);
+     304         339 :         str2[DLT_CONFIG_FILE_ENTRY_MAX_LEN - 1] = '\0';
+     305             :     } else {
+     306             :         return -1;
+     307             :     }
+     308             : 
+     309         339 :     return 0;
+     310             : }
+     311             : 
+     312             : /**
+     313             :  * dlt_config_file_read_line
+     314             :  *
+     315             :  * Read line from configuration file
+     316             :  *
+     317             :  * @param       line Line from configuration file
+     318             :  * @param[out]  str1 String contains section header or key
+     319             :  * @param[out]  str2 String contains value or is empty
+     320             :  * @return 0 on success, else -1
+     321             :  */
+     322         379 : static int dlt_config_file_read_line(char *line, char *str1, char *str2)
+     323             : {
+     324         379 :     if ((line == NULL) || (str1 == NULL) || (str2 == NULL))
+     325             :         return -1;
+     326             : 
+     327             :     /* reset values to zero */
+     328             :     memset(str1, 0, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
+     329             :     memset(str2, 0, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
+     330             : 
+     331             :     /* check if line contains a section */
+     332             :     if ((dlt_config_file_line_has_section(line)) == 0) {
+     333             :         /* retrieve section name */
+     334          40 :         if (dlt_config_file_get_section_name_from_string(line, str1) != 0)
+     335             :             return -1;
+     336             : 
+     337          40 :         return DLT_CONFIG_FILE_NEW_SECTION;
+     338             :     }
+     339             : 
+     340             :     /* copy strings as key value pair into str1, str2 */
+     341         339 :     if (dlt_config_file_get_key_value(line, str1, str2) != 0)
+     342           0 :         return -1;
+     343             : 
+     344             :     return DLT_CONFIG_FILE_NEW_DATA;
+     345             : }
+     346             : 
+     347             : /**
+     348             :  * dlt_config_file_read_file
+     349             :  *
+     350             :  * Read configuration file line by line and fill internal structures
+     351             :  *
+     352             :  * @param file DltConfigFile
+     353             :  * @param hdl  FILE handle of opened configuration file
+     354             :  */
+     355          14 : static void dlt_config_file_read_file(DltConfigFile *file, FILE *hdl)
+     356             : {
+     357             :     int ret = 0;
+     358          14 :     char line[DLT_CONFIG_FILE_LINE_MAX_LEN] = { '\0' };
+     359          14 :     char str1[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = { '\0' };
+     360          14 :     char str2[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = { '\0' };
+     361             :     int line_number = 0;
+     362             :     int is_section_valid = -1; /* to check if section name is given twice or invalid */
+     363             : 
+     364             :     /* read configuration file line by line */
+     365         434 :     while (fgets(line, DLT_CONFIG_FILE_LINE_MAX_LEN, hdl) != NULL) {
+     366         406 :         line_number++;
+     367             : 
+     368             :         /* ignore empty and comment lines */
+     369          27 :         if (dlt_config_file_ignore_line(line) == 0)
+     370          27 :             continue;
+     371             : 
+     372             :         /* trim line end */
+     373         379 :         dlt_config_file_trim_line(line);
+     374             : 
+     375             :         /* parse content of line */
+     376         379 :         ret = dlt_config_file_read_line(line, str1, str2);
+     377             : 
+     378         379 :         switch (ret) {
+     379          40 :         case DLT_CONFIG_FILE_NEW_SECTION:     /* store str1 as new section */
+     380             :             is_section_valid = -1;
+     381             : 
+     382          40 :             if ((ret = dlt_config_file_set_section(file, str1)) == 0)
+     383             :                 is_section_valid = 0;
+     384             : 
+     385             :             break;
+     386         339 :         case DLT_CONFIG_FILE_NEW_DATA:     /* store str1 and str2 as new data for section */
+     387             : 
+     388         339 :             if (is_section_valid == 0)
+     389         339 :                 dlt_config_file_set_section_data(file, str1, str2);
+     390             : 
+     391             :             break;
+     392           0 :         default:     /* something is wrong with the line */
+     393           0 :             dlt_vlog(LOG_WARNING, "Line (%d) \"%s\" is invalid\n", line_number,
+     394             :                      line);
+     395             :         }
+     396             :     }
+     397          14 : }
+     398             : 
+     399             : /**
+     400             :  * dlt_config_file_find_section
+     401             :  *
+     402             :  * Find a section
+     403             :  *
+     404             :  * @param file      DltConfigFile
+     405             :  * @param section   Name of section
+     406             :  * @return number of section on success, else -1
+     407             :  */
+     408         540 : static int dlt_config_file_find_section(const DltConfigFile *file,
+     409             :                                         const char *section)
+     410             : {
+     411             :     int i = 0;
+     412             : 
+     413         540 :     if ((file == NULL) || (section == NULL) || (file->num_sections <= 0)) {
+     414           0 :         dlt_log(LOG_WARNING, "Section cannot be found due to invalid parameters\n");
+     415           0 :         return -1;
+     416             :     }
+     417             : 
+     418        2490 :     for (i = 0; i < file->num_sections; i++) {
+     419        2486 :         DltConfigFileSection *s = &file->sections[i];
+     420             : 
+     421        2486 :         if (strncmp(s->name, section, DLT_CONFIG_FILE_ENTRY_MAX_LEN) == 0)
+     422         536 :             return i;
+     423             :     }
+     424             : 
+     425             :     return -1;
+     426             : }
+     427             : 
+     428             : /************************** interface implementation ***************************/
+     429          14 : DltConfigFile *dlt_config_file_init(char *file_name)
+     430             : {
+     431             :     DltConfigFile *file;
+     432             :     FILE *hdl = NULL;
+     433             : 
+     434          14 :     if ((file_name == NULL) || (strlen(file_name) >= DLT_PATH_MAX)) {
+     435           0 :         dlt_log(LOG_ERR, "Given configuration file invalid\n");
+     436           0 :         return NULL;
+     437             :     }
+     438             : 
+     439          14 :     file = calloc(sizeof(DltConfigFile), 1);
+     440             : 
+     441          14 :     if (file == NULL) {
+     442           0 :         dlt_log(LOG_ERR, "Setup internal data structure to parse config file failed\n");
+     443           0 :         return NULL;
+     444             :     }
+     445             : 
+     446          14 :     file->sections = calloc(sizeof(DltConfigFileSection), DLT_CONFIG_FILE_SECTIONS_MAX);
+     447             : 
+     448             :     /* open file */
+     449          14 :     if ((hdl = fopen(file_name, "r")) == NULL) {
+     450           0 :         dlt_log(LOG_ERR, "Cannot open configuration file\n");
+     451           0 :         free(file);
+     452           0 :         return NULL;
+     453             :     }
+     454             : 
+     455          14 :     dlt_config_file_read_file(file, hdl);
+     456             : 
+     457             :     /* all information stored internally */
+     458          14 :     fclose(hdl);
+     459             : 
+     460          14 :     return file;
+     461             : }
+     462             : 
+     463          14 : void dlt_config_file_release(DltConfigFile *file)
+     464             : {
+     465             :     int i = 0;
+     466             : 
+     467          14 :     if (file != NULL) {
+     468          14 :         int max = file->num_sections;
+     469             : 
+     470          54 :         for (i = 0; i < max; i++) {
+     471          40 :             DltConfigFileSection *s = &file->sections[i];
+     472          40 :             DltConfigKeyData *node = file->sections[i].list;
+     473          40 :             free(s->name);
+     474             : 
+     475          40 :             if (s->keys != NULL)
+     476          40 :                 free(s->keys);
+     477             : 
+     478         379 :             while (node) {
+     479             :                 DltConfigKeyData *tmp = node;
+     480         339 :                 node = node->next;
+     481         339 :                 free(tmp->key);
+     482         339 :                 free(tmp->data);
+     483         339 :                 free(tmp);
+     484             :             }
+     485             :         }
+     486             : 
+     487          14 :         free(file->sections);
+     488          14 :         free(file);
+     489             :     }
+     490          14 : }
+     491             : 
+     492          40 : int dlt_config_file_get_section_name(const DltConfigFile *file,
+     493             :                                      int num,
+     494             :                                      char *name)
+     495             : {
+     496          40 :     if ((file == NULL) || (name == NULL) || (num < 0) || (num >= file->num_sections))
+     497             :         return -1;
+     498             : 
+     499          40 :     strncpy(name, (file->sections + num)->name, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
+     500          40 :     name[DLT_CONFIG_FILE_ENTRY_MAX_LEN - 1] = '\0';
+     501             : 
+     502          40 :     return 0;
+     503             : }
+     504             : 
+     505          14 : int dlt_config_file_get_num_sections(const DltConfigFile *file, int *num)
+     506             : {
+     507          14 :     if ((file == NULL) || (file->num_sections < 0))
+     508             :         return -1;
+     509             : 
+     510             :     /*
+     511             :      * Note: Since General section could be used in configuration file,
+     512             :      * this number could be also containing General section.
+     513             :      */
+     514          14 :     *num = file->num_sections;
+     515             : 
+     516          14 :     return 0;
+     517             : }
+     518             : 
+     519         536 : int dlt_config_file_get_value(const DltConfigFile *file,
+     520             :                               const char *section,
+     521             :                               const char *key, char *value)
+     522             : {
+     523             :     DltConfigFileSection *s = NULL;
+     524             :     DltConfigKeyData **tmp = NULL;
+     525             :     int num_section = 0;
+     526             : 
+     527         536 :     if ((file == NULL) || (section == NULL) || (key == NULL) || (value == NULL))
+     528             :         return -1;
+     529             : 
+     530             :     /* clean value */
+     531             :     memset(value, 0, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
+     532             : 
+     533         536 :     num_section = dlt_config_file_find_section(file, section);
+     534             : 
+     535         536 :     if (num_section == -1)
+     536             :         return -1;
+     537             : 
+     538         536 :     s = (file->sections + num_section);
+     539             : 
+     540         536 :     tmp = &s->list;
+     541             : 
+     542        3465 :     while (*(tmp) != NULL) {
+     543        3264 :         if (strncmp((*tmp)->key, key, DLT_CONFIG_FILE_ENTRY_MAX_LEN) == 0) {
+     544         335 :             strncpy(value, (*tmp)->data, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
+     545         335 :             return 0;
+     546             :         }
+     547             :         else { /* not found yet see list for more */
+     548        2929 :             tmp = &(*tmp)->next;
+     549             :         }
+     550             :     }
+     551             : 
+     552         201 :     dlt_vlog(LOG_WARNING, "Entry does not exist in section: %s\n", key);
+     553         201 :     return -1;
+     554             : }
+     555             : 
+     556           4 : int dlt_config_file_check_section_name_exists(const DltConfigFile *file,
+     557             :                                              const char *name)
+     558             : {
+     559             :     int ret = 0;
+     560             : 
+     561           4 :     if ((file == NULL) || (file->num_sections <= 0) || (name == NULL))
+     562             :         return -1;
+     563             : 
+     564           4 :     ret = dlt_config_file_find_section(file, name);
+     565           4 :     if (ret == -1)
+     566           4 :         return ret;
+     567             : 
+     568             :     return 0;
+     569             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/dlt_log.c.func-sort-c.html b/dlt_lcov_report/shared/dlt_log.c.func-sort-c.html new file mode 100644 index 000000000..0e4c59f46 --- /dev/null +++ b/dlt_lcov_report/shared/dlt_log.c.func-sort-c.html @@ -0,0 +1,132 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared/dlt_log.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - shared - dlt_log.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:11513088.5 %
Date:2024-12-05 09:07:13Functions:1515100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_log_free_single_logfile2
dlt_log_free_multiple_logfiles3
dlt_log_init_multiple_logfiles4
dlt_log_init_single_logfile4
dlt_log_init12
dlt_log_multiple_files_write12
dlt_log_free15
dlt_log_set_filename17
dlt_log_set_level19
dlt_log_init_multiple_logfiles_support26
dlt_is_log_in_multiple_files_active37
dlt_user_printf2852
dlt_vnlog16780
dlt_log23464
dlt_vlog37361
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/dlt_log.c.func.html b/dlt_lcov_report/shared/dlt_log.c.func.html new file mode 100644 index 000000000..ce77490fe --- /dev/null +++ b/dlt_lcov_report/shared/dlt_log.c.func.html @@ -0,0 +1,132 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared/dlt_log.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - shared - dlt_log.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:11513088.5 %
Date:2024-12-05 09:07:13Functions:1515100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_is_log_in_multiple_files_active37
dlt_log23464
dlt_log_free15
dlt_log_free_multiple_logfiles3
dlt_log_free_single_logfile2
dlt_log_init12
dlt_log_init_multiple_logfiles4
dlt_log_init_multiple_logfiles_support26
dlt_log_init_single_logfile4
dlt_log_multiple_files_write12
dlt_log_set_filename17
dlt_log_set_level19
dlt_user_printf2852
dlt_vlog37361
dlt_vnlog16780
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/dlt_log.c.gcov.html b/dlt_lcov_report/shared/dlt_log.c.gcov.html new file mode 100644 index 000000000..40c5aa27c --- /dev/null +++ b/dlt_lcov_report/shared/dlt_log.c.gcov.html @@ -0,0 +1,430 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared/dlt_log.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - shared - dlt_log.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:11513088.5 %
Date:2024-12-05 09:07:13Functions:1515100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2024, Mercedes Benz Tech Innovation GmbH
+       5             :  *
+       6             :  * This file is part of GENIVI Project DLT - Diagnostic Log and Trace.
+       7             :  *
+       8             :  * This Source Code Form is subject to the terms of the
+       9             :  * Mozilla Public License (MPL), v. 2.0.
+      10             :  * If a copy of the MPL was not distributed with this file,
+      11             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      12             :  *
+      13             :  * For further information see https://www.covesa.global/.
+      14             :  */
+      15             : 
+      16             : /*!
+      17             :  * \author
+      18             :  * Daniel Weber <daniel.w.weber@mercedes-benz.com>
+      19             :  *
+      20             :  * \copyright Copyright © 2024 Mercedes Benz Tech Innovation GmbH. \n
+      21             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      22             :  *
+      23             :  * \file dlt_log.c
+      24             :  */
+      25             : 
+      26             : #include "dlt_log.h"
+      27             : #include "dlt_common.h"
+      28             : #include "dlt_multiple_files.h"
+      29             : #include <syslog.h>
+      30             : #include <errno.h>
+      31             : #include <libgen.h>   /* dirname */
+      32             : #include <limits.h>   /* for NAME_MAX */
+      33             : #include <string.h>   /* for strlen() */
+      34             : #include <stdlib.h>   /* for calloc(), free() */
+      35             : #include <stdarg.h>   /* va_list, va_start */
+      36             : 
+      37             : /* internal logging parameters */
+      38             : static int logging_level = LOG_INFO;
+      39             : static char logging_filename[NAME_MAX + 1] = "";
+      40             : DltLoggingMode logging_mode = DLT_LOG_TO_STDERR;
+      41             : FILE *logging_handle = NULL;
+      42             : 
+      43             : //use ohandle as an indicator that multiple files logging is active
+      44             : MultipleFilesRingBuffer multiple_files_ring_buffer = {
+      45             :         .directory={0},
+      46             :         .filename={0},
+      47             :         .fileSize=0,
+      48             :         .maxSize=0,
+      49             :         .filenameTimestampBased=false,
+      50             :         .filenameBase={0},
+      51             :         .filenameExt={0},
+      52             :         .ohandle=-1};
+      53             : 
+      54             : 
+      55          17 : void dlt_log_set_filename(const char *filename)
+      56             : {
+      57             :     /* check nullpointer */
+      58          17 :     if (filename == NULL) {
+      59           1 :         dlt_log(LOG_WARNING, "Wrong parameter: filename is NULL\n");
+      60           1 :         return;
+      61             :     }
+      62             : 
+      63             :     strncpy(logging_filename, filename, NAME_MAX);
+      64          16 :     logging_filename[NAME_MAX] = 0;
+      65             : }
+      66             : 
+      67          19 : void dlt_log_set_level(int level)
+      68             : {
+      69          19 :     if ((level < 0) || (level > LOG_DEBUG)) {
+      70           0 :         if (logging_level < LOG_WARNING)
+      71           0 :             logging_level = LOG_WARNING;
+      72             : 
+      73           0 :         dlt_vlog(LOG_WARNING, "Wrong parameter for level: %d\n", level);
+      74             :     }
+      75             :     else {
+      76          19 :         logging_level = level;
+      77             :     }
+      78          19 : }
+      79             : 
+      80          12 : void dlt_log_init(int mode)
+      81             : {
+      82          12 :     dlt_log_init_multiple_logfiles_support((DltLoggingMode)mode, false, 0, 0);
+      83          12 : }
+      84             : 
+      85             : 
+      86          26 : DltReturnValue dlt_log_init_multiple_logfiles_support(const DltLoggingMode mode, const bool enable_multiple_logfiles,
+      87             :                                                       const int logging_file_size, const int logging_files_max_size)
+      88             : {
+      89          26 :     if ((mode < DLT_LOG_TO_CONSOLE) || (mode > DLT_LOG_DROPPED)) {
+      90           0 :         dlt_vlog(LOG_WARNING, "Wrong parameter for mode: %d\n", mode);
+      91           0 :         return DLT_RETURN_WRONG_PARAMETER;
+      92             :     }
+      93             : 
+      94          26 :     logging_mode = mode;
+      95             : 
+      96          26 :     if (logging_mode != DLT_LOG_TO_FILE) {
+      97             :         return DLT_RETURN_OK;
+      98             :     }
+      99             : 
+     100             :     DltReturnValue result;
+     101           7 :     if (enable_multiple_logfiles) {
+     102           4 :         dlt_user_printf("configure dlt logging using file limits\n");
+     103           4 :         result = dlt_log_init_multiple_logfiles(logging_file_size, logging_files_max_size);
+     104           4 :         if (result != DLT_RETURN_OK) {
+     105           1 :             dlt_user_printf("dlt logging for limits fails with error code=%d, use logging without limits as fallback\n", result);
+     106           1 :             result = dlt_log_init_single_logfile();
+     107             :         }
+     108             :     } else {
+     109           3 :         dlt_user_printf("configure dlt logging without file limits\n");
+     110           3 :         result = dlt_log_init_single_logfile();
+     111             :     }
+     112             : 
+     113             :     return result;
+     114             : }
+     115             : 
+     116           4 : DltReturnValue dlt_log_init_single_logfile()
+     117             : {
+     118             :     /* internal logging to file */
+     119           4 :     errno = 0;
+     120           4 :     logging_handle = fopen(logging_filename, "a");
+     121             : 
+     122           4 :     if (logging_handle == NULL) {
+     123           0 :         dlt_user_printf("Internal log file %s cannot be opened, error: %s\n", logging_filename, strerror(errno));
+     124           0 :         return DLT_RETURN_ERROR;
+     125             :     }
+     126             :     return DLT_RETURN_OK;
+     127             : }
+     128             : 
+     129           4 : DltReturnValue dlt_log_init_multiple_logfiles(const int logging_file_size, const int logging_files_max_size)
+     130             : {
+     131             :     char path_logging_filename[PATH_MAX + 1];
+     132             :     strncpy(path_logging_filename, logging_filename, PATH_MAX);
+     133           4 :     path_logging_filename[PATH_MAX] = 0;
+     134             : 
+     135           4 :     const char *directory = dirname(path_logging_filename);
+     136           4 :     if (directory[0]) {
+     137             :         char basename_logging_filename[NAME_MAX + 1];
+     138             :         strncpy(basename_logging_filename, logging_filename, NAME_MAX);
+     139           4 :         basename_logging_filename[NAME_MAX] = 0;
+     140             : 
+     141           4 :         const char *file_name = basename(basename_logging_filename);
+     142             :         char filename_base[NAME_MAX];
+     143           4 :         if (!dlt_extract_base_name_without_ext(file_name, filename_base, sizeof(filename_base))) return DLT_RETURN_ERROR;
+     144             : 
+     145           3 :         const char *filename_ext = get_filename_ext(file_name);
+     146           3 :         if (!filename_ext) return DLT_RETURN_ERROR;
+     147             : 
+     148           3 :         DltReturnValue result = multiple_files_buffer_init(
+     149             :                 &multiple_files_ring_buffer,
+     150             :                 directory,
+     151             :                 logging_file_size,
+     152             :                 logging_files_max_size,
+     153             :                 false,
+     154             :                 true,
+     155             :                 filename_base,
+     156             :                 filename_ext);
+     157             : 
+     158           3 :         return result;
+     159             :     }
+     160             : 
+     161             :     return DLT_RETURN_ERROR;
+     162             : }
+     163             : 
+     164        2852 : int dlt_user_printf(const char *format, ...)
+     165             : {
+     166        2852 :     if (format == NULL) return -1;
+     167             : 
+     168             :     va_list args;
+     169        2852 :     va_start(args, format);
+     170             : 
+     171             :     int ret = 0;
+     172             : 
+     173        2852 :     switch (logging_mode) {
+     174           8 :         case DLT_LOG_TO_CONSOLE:
+     175             :         case DLT_LOG_TO_SYSLOG:
+     176             :         case DLT_LOG_TO_FILE:
+     177             :         case DLT_LOG_DROPPED:
+     178             :         default:
+     179           8 :             ret = vfprintf(stdout, format, args);
+     180           8 :             break;
+     181        2844 :         case DLT_LOG_TO_STDERR:
+     182        2844 :             ret = vfprintf(stderr, format, args);
+     183        2844 :             break;
+     184             :     }
+     185             : 
+     186        2852 :     va_end(args);
+     187             : 
+     188        2852 :     return ret;
+     189             : }
+     190             : 
+     191       23464 : DltReturnValue dlt_log(int prio, const char *s)
+     192             : {
+     193             :     static const char asSeverity[LOG_DEBUG +
+     194             :                                  2][11] =
+     195             :             { "EMERGENCY", "ALERT    ", "CRITICAL ", "ERROR    ", "WARNING  ", "NOTICE   ", "INFO     ", "DEBUG    ",
+     196             :               "         " };
+     197             :     static const char sFormatString[] = "[%5u.%06u]~DLT~%5d~%s~%s";
+     198             :     struct timespec sTimeSpec;
+     199             : 
+     200       23464 :     if (s == NULL)
+     201             :         return DLT_RETURN_WRONG_PARAMETER;
+     202             : 
+     203       23463 :     if (logging_level < prio)
+     204             :         return DLT_RETURN_OK;
+     205             : 
+     206       22547 :     if ((prio < 0) || (prio > LOG_DEBUG))
+     207             :         prio = LOG_DEBUG + 1;
+     208             : 
+     209       22547 :     clock_gettime(CLOCK_MONOTONIC, &sTimeSpec);
+     210             : 
+     211       22547 :     switch (logging_mode) {
+     212         525 :         case DLT_LOG_TO_CONSOLE:
+     213             :             /* log to stdout */
+     214        1050 :             fprintf(stdout, sFormatString,
+     215         525 :                     (unsigned int)sTimeSpec.tv_sec,
+     216         525 :                     (unsigned int)(sTimeSpec.tv_nsec / 1000),
+     217             :                     getpid(),
+     218         525 :                     asSeverity[prio],
+     219             :                     s);
+     220         525 :             fflush(stdout);
+     221         525 :             break;
+     222       21985 :         case DLT_LOG_TO_STDERR:
+     223             :             /* log to stderr */
+     224       43970 :             fprintf(stderr, sFormatString,
+     225       21985 :                     (unsigned int)sTimeSpec.tv_sec,
+     226       21985 :                     (unsigned int)(sTimeSpec.tv_nsec / 1000),
+     227             :                     getpid(),
+     228       21985 :                     asSeverity[prio],
+     229             :                     s);
+     230             :             break;
+     231           0 :         case DLT_LOG_TO_SYSLOG:
+     232             :             /* log to syslog */
+     233             : #if !defined (__WIN32__) && !defined(_MSC_VER)
+     234           0 :             openlog("DLT", LOG_PID, LOG_DAEMON);
+     235           0 :             syslog(prio,
+     236             :                    sFormatString,
+     237           0 :                    (unsigned int)sTimeSpec.tv_sec,
+     238           0 :                    (unsigned int)(sTimeSpec.tv_nsec / 1000),
+     239             :                    getpid(),
+     240           0 :                    asSeverity[prio],
+     241             :                    s);
+     242           0 :             closelog();
+     243             : #endif
+     244           0 :             break;
+     245          32 :         case DLT_LOG_TO_FILE:
+     246             :             /* log to file */
+     247             : 
+     248          32 :             if (dlt_is_log_in_multiple_files_active()) {
+     249          24 :                 dlt_log_multiple_files_write(sFormatString, (unsigned int)sTimeSpec.tv_sec,
+     250          12 :                                              (unsigned int)(sTimeSpec.tv_nsec / 1000), getpid(), asSeverity[prio], s);
+     251             :             }
+     252          20 :             else if (logging_handle) {
+     253          40 :                 fprintf(logging_handle, sFormatString, (unsigned int)sTimeSpec.tv_sec,
+     254          20 :                         (unsigned int)(sTimeSpec.tv_nsec / 1000), getpid(), asSeverity[prio], s);
+     255          20 :                 fflush(logging_handle);
+     256             :             }
+     257             : 
+     258             :             break;
+     259             :         case DLT_LOG_DROPPED:
+     260             :         default:
+     261             :             break;
+     262             :     }
+     263             : 
+     264             :     return DLT_RETURN_OK;
+     265             : }
+     266             : 
+     267       37361 : DltReturnValue dlt_vlog(int prio, const char *format, ...)
+     268             : {
+     269       37361 :     char outputString[2048] = { 0 }; /* TODO: what is a reasonable string length here? */
+     270             : 
+     271             :     va_list args;
+     272             : 
+     273       37361 :     if (format == NULL)
+     274             :         return DLT_RETURN_WRONG_PARAMETER;
+     275             : 
+     276       37361 :     if (logging_level < prio)
+     277             :         return DLT_RETURN_OK;
+     278             : 
+     279        5693 :     va_start(args, format);
+     280             :     vsnprintf(outputString, 2047, format, args);
+     281        5693 :     va_end(args);
+     282             : 
+     283        5693 :     dlt_log(prio, outputString);
+     284             : 
+     285        5693 :     return DLT_RETURN_OK;
+     286             : }
+     287             : 
+     288       16780 : DltReturnValue dlt_vnlog(int prio, size_t size, const char *format, ...)
+     289             : {
+     290             :     char *outputString = NULL;
+     291             : 
+     292             :     va_list args;
+     293             : 
+     294       16780 :     if (format == NULL)
+     295             :         return DLT_RETURN_WRONG_PARAMETER;
+     296             : 
+     297       16780 :     if ((logging_level < prio) || (size == 0))
+     298             :         return DLT_RETURN_OK;
+     299             : 
+     300       16780 :     if ((outputString = (char *)calloc(size + 1, sizeof(char))) == NULL)
+     301             :         return DLT_RETURN_ERROR;
+     302             : 
+     303       16780 :     va_start(args, format);
+     304             :     vsnprintf(outputString, size, format, args);
+     305       16780 :     va_end(args);
+     306             : 
+     307       16780 :     dlt_log(prio, outputString);
+     308             : 
+     309       16780 :     free(outputString);
+     310             :     outputString = NULL;
+     311             : 
+     312       16780 :     return DLT_RETURN_OK;
+     313             : }
+     314             : 
+     315          12 : void dlt_log_multiple_files_write(const char* format, ...)
+     316             : {
+     317          12 :     char output_string[2048] = { 0 };
+     318             :     va_list args;
+     319          12 :     va_start (args, format);
+     320             :     vsnprintf(output_string, 2047, format, args);
+     321          12 :     va_end (args);
+     322          12 :     multiple_files_buffer_write(&multiple_files_ring_buffer, (unsigned char*)output_string, strlen(output_string));
+     323          12 : }
+     324             : 
+     325          15 : void dlt_log_free(void)
+     326             : {
+     327          15 :     if (logging_mode == DLT_LOG_TO_FILE) {
+     328           5 :         if (dlt_is_log_in_multiple_files_active()) {
+     329           3 :             dlt_log_free_multiple_logfiles();
+     330             :         } else {
+     331           2 :             dlt_log_free_single_logfile();
+     332             :         }
+     333             :     }
+     334          15 : }
+     335             : 
+     336           2 : void dlt_log_free_single_logfile()
+     337             : {
+     338           2 :     if (logging_handle != NULL) {
+     339           2 :         fclose(logging_handle);
+     340             :     }
+     341           2 : }
+     342             : 
+     343           3 : void dlt_log_free_multiple_logfiles()
+     344             : {
+     345           3 :     if (DLT_RETURN_ERROR == multiple_files_buffer_free(&multiple_files_ring_buffer)) return;
+     346             : 
+     347             :     // reset indicator of multiple files usage
+     348           3 :     multiple_files_ring_buffer.ohandle = -1;
+     349             : }
+     350             : 
+     351          37 : bool dlt_is_log_in_multiple_files_active()
+     352             : {
+     353          37 :     return multiple_files_ring_buffer.ohandle > -1;
+     354             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/dlt_multiple_files.c.func-sort-c.html b/dlt_lcov_report/shared/dlt_multiple_files.c.func-sort-c.html new file mode 100644 index 000000000..14edc5a19 --- /dev/null +++ b/dlt_lcov_report/shared/dlt_multiple_files.c.func-sort-c.html @@ -0,0 +1,124 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared/dlt_multiple_files.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - shared - dlt_multiple_files.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:13319368.9 %
Date:2024-12-05 09:07:13Functions:1313100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
multiple_files_buffer_free3
multiple_files_buffer_init3
multiple_files_buffer_open_file_for_append3
multiple_files_buffer_create_new_file9
multiple_files_buffer_delete_oldest_file9
multiple_files_buffer_file_name9
multiple_files_buffer_check_size12
multiple_files_buffer_rotate_file12
multiple_files_buffer_storage_dir_info12
multiple_files_buffer_write12
multiple_files_buffer_write_chunk12
multiple_files_buffer_get_total_size21
multiple_files_buffer_get_idx_of_log_file53
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/dlt_multiple_files.c.func.html b/dlt_lcov_report/shared/dlt_multiple_files.c.func.html new file mode 100644 index 000000000..29397ee5e --- /dev/null +++ b/dlt_lcov_report/shared/dlt_multiple_files.c.func.html @@ -0,0 +1,124 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared/dlt_multiple_files.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - shared - dlt_multiple_files.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:13319368.9 %
Date:2024-12-05 09:07:13Functions:1313100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
multiple_files_buffer_check_size12
multiple_files_buffer_create_new_file9
multiple_files_buffer_delete_oldest_file9
multiple_files_buffer_file_name9
multiple_files_buffer_free3
multiple_files_buffer_get_idx_of_log_file53
multiple_files_buffer_get_total_size21
multiple_files_buffer_init3
multiple_files_buffer_open_file_for_append3
multiple_files_buffer_rotate_file12
multiple_files_buffer_storage_dir_info12
multiple_files_buffer_write12
multiple_files_buffer_write_chunk12
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/dlt_multiple_files.c.gcov.html b/dlt_lcov_report/shared/dlt_multiple_files.c.gcov.html new file mode 100644 index 000000000..7967ff914 --- /dev/null +++ b/dlt_lcov_report/shared/dlt_multiple_files.c.gcov.html @@ -0,0 +1,575 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared/dlt_multiple_files.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - shared - dlt_multiple_files.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:13319368.9 %
Date:2024-12-05 09:07:13Functions:1313100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2022, Daimler TSS GmbH
+       5             :  *
+       6             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       7             :  *
+       8             :  * This Source Code Form is subject to the terms of the
+       9             :  * Mozilla Public License (MPL), v. 2.0.
+      10             :  * If a copy of the MPL was not distributed with this file,
+      11             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      12             :  *
+      13             :  * For further information see https://www.covesa.global/.
+      14             :  */
+      15             : 
+      16             : /*!
+      17             :  * \author
+      18             :  * Oleg Tropmann <oleg.tropmann@daimler.com>
+      19             :  * Daniel Weber <daniel.w.weber@daimler.com>
+      20             :  *
+      21             :  * \copyright Copyright © 2022 Daimler TSS GmbH. \n
+      22             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      23             :  *
+      24             :  * \file dlt_daemon_log.c
+      25             :  */
+      26             : 
+      27             : #include <stdio.h>
+      28             : #include <stdlib.h>
+      29             : #include <string.h>
+      30             : #include <time.h>
+      31             : #include <sys/types.h>
+      32             : #include <sys/stat.h>
+      33             : #include <fcntl.h>
+      34             : #include <unistd.h>
+      35             : #include <dirent.h>
+      36             : #include <syslog.h>
+      37             : #include <errno.h>
+      38             : #include <stdarg.h>
+      39             : 
+      40             : #include "dlt_multiple_files.h"
+      41             : #include "dlt_common.h"
+      42             : #include "dlt_log.h"
+      43             : 
+      44          12 : unsigned int multiple_files_buffer_storage_dir_info(const char *path, const char *file_name,
+      45             :                                                     char *newest, char *oldest)
+      46             : {
+      47             :     int i = 0;
+      48             :     unsigned int num_log_files = 0;
+      49          12 :     struct dirent **files = { 0 };
+      50             :     char *tmp_old = NULL;
+      51             :     char *tmp_new = NULL;
+      52             : 
+      53          12 :     if ((path == NULL) || (file_name == NULL) || (newest == NULL) || (oldest == NULL)) {
+      54           0 :         fprintf(stderr, "multiple_files_buffer_storage_dir_info: Invalid parameter(s)");
+      55           0 :         return 0;
+      56             :     }
+      57             : 
+      58          12 :     const int file_cnt = scandir(path, &files, NULL, alphasort);
+      59          12 :     if (file_cnt <= 0) return 0;
+      60             : 
+      61         434 :     for (i = 0; i < file_cnt; i++) {
+      62             :         int len = 0;
+      63         422 :         len = strlen(file_name);
+      64             : 
+      65         422 :         if ((strncmp(files[i]->d_name, file_name, len) == 0) &&
+      66         110 :             (files[i]->d_name[len] == MULTIPLE_FILES_FILENAME_INDEX_DELIM[0])) {
+      67          48 :             num_log_files++;
+      68             : 
+      69          48 :             if ((tmp_old == NULL) || (strlen(tmp_old) >= strlen(files[i]->d_name))) {
+      70          48 :                 if (tmp_old == NULL) {
+      71             :                     tmp_old = files[i]->d_name;
+      72          36 :                 } else if (strlen(tmp_old) > strlen(files[i]->d_name)) {
+      73             :                     /* when file name is smaller, it is older */
+      74             :                     tmp_old = files[i]->d_name;
+      75          20 :                 } else if (strcmp(tmp_old, files[i]->d_name) > 0) {
+      76             :                     /* filename length is equal, do a string compare */
+      77             :                     tmp_old = files[i]->d_name;
+      78             :                 }
+      79             :             }
+      80             : 
+      81          48 :             if ((tmp_new == NULL) || (strlen(tmp_new) <= strlen(files[i]->d_name))) {
+      82          32 :                 if (tmp_new == NULL) {
+      83             :                     tmp_new = files[i]->d_name;
+      84          20 :                 } else if (strlen(tmp_new) < strlen(files[i]->d_name)) {
+      85             :                     /* when file name is longer, it is younger */
+      86             :                     tmp_new = files[i]->d_name;
+      87          20 :                 } else if (strcmp(tmp_new, files[i]->d_name) < 0) {
+      88             :                     tmp_new = files[i]->d_name;
+      89             :                 }
+      90             :             }
+      91             :         }
+      92             :     }
+      93             : 
+      94          12 :     if (num_log_files > 0) {
+      95          12 :         if ((tmp_old != NULL) && (strlen(tmp_old) < NAME_MAX)) {
+      96             :             strncpy(oldest, tmp_old, NAME_MAX);
+      97          12 :             oldest[NAME_MAX] = '\0';
+      98           0 :         } else if ((tmp_old != NULL) && (strlen(tmp_old) >=  NAME_MAX)) {
+      99             :             printf("length mismatch of file %s\n", tmp_old);
+     100             :         }
+     101             : 
+     102          12 :         if ((tmp_new != NULL) && (strlen(tmp_new) < NAME_MAX)) {
+     103             :             strncpy(newest, tmp_new, NAME_MAX);
+     104          12 :             newest[NAME_MAX] = '\0';
+     105           0 :         } else if ((tmp_new != NULL) && (strlen(tmp_new) >=  NAME_MAX)) {
+     106             :             printf("length mismatch of file %s\n", tmp_new);
+     107             :         }
+     108             :     }
+     109             : 
+     110             :     /* free scandir result */
+     111         434 :     for (i = 0; i < file_cnt; i++) free(files[i]);
+     112             : 
+     113          12 :     free(files);
+     114             : 
+     115          12 :     return num_log_files;
+     116             : }
+     117             : 
+     118           9 : void multiple_files_buffer_file_name(MultipleFilesRingBuffer *files_buffer, const size_t length, const unsigned int idx)
+     119             : {
+     120             :     char file_index[11]; /* UINT_MAX = 4294967295 -> 10 digits */
+     121             :     snprintf(file_index, sizeof(file_index), "%010u", idx);
+     122             : 
+     123             :     /* create log file name */
+     124           9 :     char* file_name = files_buffer->filename;
+     125             :     memset(file_name, 0, length * sizeof(char));
+     126             : 
+     127           9 :     const size_t size = length - strlen(file_name) - 1;
+     128           9 :     strncat(file_name, files_buffer->filenameBase, size);
+     129             :     strncat(file_name, MULTIPLE_FILES_FILENAME_INDEX_DELIM, size);
+     130             :     strncat(file_name, file_index, size);
+     131           9 :     strncat(file_name, files_buffer->filenameExt, size);
+     132           9 : }
+     133             : 
+     134          53 : unsigned int multiple_files_buffer_get_idx_of_log_file(char *file)
+     135             : {
+     136          53 :     if ((file == NULL) || (file[0] == '\0')) return 0;
+     137             : 
+     138          53 :     const char d[2] = MULTIPLE_FILES_FILENAME_INDEX_DELIM;
+     139             :     char *token;
+     140             : 
+     141          53 :     token = strtok(file, d);
+     142             :     /* we are interested in 2. token because of log file name */
+     143          53 :     token = strtok(NULL, d);
+     144             : 
+     145          53 :     return token != NULL ? strtol(token, NULL, 10) : 0;
+     146             : }
+     147             : 
+     148           9 : DltReturnValue multiple_files_buffer_create_new_file(MultipleFilesRingBuffer *files_buffer)
+     149             : {
+     150           9 :     if (files_buffer == NULL) {
+     151           0 :         fprintf(stderr, "multiple files buffer not set\n");
+     152           0 :         return DLT_RETURN_ERROR;
+     153             :     }
+     154             : 
+     155             :     time_t t;
+     156             :     struct tm tmp;
+     157             :     char file_path[PATH_MAX + 1];
+     158             :     unsigned int idx = 0;
+     159             :     int ret = 0;
+     160             : 
+     161             :     /* set filename */
+     162           9 :     if (files_buffer->filenameTimestampBased) {
+     163             :         /* timestamp format: "yyyymmdd_hhmmss" */
+     164             :         char timestamp[16];
+     165           0 :         t = time(NULL);
+     166           0 :         tzset();
+     167           0 :         localtime_r(&t, &tmp);
+     168             : 
+     169           0 :         strftime(timestamp, sizeof(timestamp), "%Y%m%d_%H%M%S", &tmp);
+     170             : 
+     171           0 :         ret = snprintf(files_buffer->filename, sizeof(files_buffer->filename), "%s%s%s%s",
+     172           0 :                        files_buffer->filenameBase,
+     173             :                        MULTIPLE_FILES_FILENAME_TIMESTAMP_DELIM, timestamp,
+     174           0 :                        files_buffer->filenameExt);
+     175             : 
+     176           0 :         if ((ret < 0) || ((size_t)ret >= (int)sizeof(files_buffer->filename))) {
+     177           0 :             fprintf(stderr, "filename cannot be concatenated\n");
+     178           0 :             return DLT_RETURN_ERROR;
+     179             :         }
+     180             : 
+     181             :         ret = snprintf(file_path, sizeof(file_path), "%s/%s",
+     182           0 :                        files_buffer->directory, files_buffer->filename);
+     183             : 
+     184           0 :         if ((ret < 0) || ((size_t)ret >= (int)sizeof(file_path))) {
+     185           0 :             fprintf(stderr, "file path cannot be concatenated\n");
+     186           0 :             return DLT_RETURN_ERROR;
+     187             :         }
+     188             :     }
+     189             :     else {
+     190           9 :         char newest[NAME_MAX + 1] = { 0 };
+     191           9 :         char oldest[NAME_MAX + 1] = { 0 };
+     192             :         /* targeting newest file, ignoring number of files in dir returned */
+     193           9 :         if (0 == multiple_files_buffer_storage_dir_info(files_buffer->directory,
+     194           9 :                                                         files_buffer->filenameBase,
+     195             :                                                         newest,
+     196             :                                                         oldest)) {
+     197             :             printf("No multiple files found\n");
+     198             :         }
+     199             : 
+     200           9 :         idx = multiple_files_buffer_get_idx_of_log_file(newest) + 1;
+     201             : 
+     202           9 :         multiple_files_buffer_file_name(files_buffer, sizeof(files_buffer->filename), idx);
+     203             :         ret = snprintf(file_path, sizeof(file_path), "%s/%s",
+     204           9 :                        files_buffer->directory, files_buffer->filename);
+     205             : 
+     206           9 :         if ((ret < 0) || (ret >= NAME_MAX)) {
+     207           0 :             fprintf(stderr, "filename cannot be concatenated\n");
+     208           0 :             return DLT_RETURN_ERROR;
+     209             :         }
+     210             :     }
+     211             : 
+     212             :     /* open DLT output file */
+     213           9 :     errno = 0;
+     214           9 :     files_buffer->ohandle = open(file_path, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR |
+     215             :                                                                 S_IRGRP | S_IROTH); /* mode: wb */
+     216             : 
+     217           9 :     if (files_buffer->ohandle == -1) {
+     218             :         /* file cannot be opened */
+     219           0 :         fprintf(stderr, "file %s cannot be created, error: %s\n", file_path, strerror(errno));
+     220           0 :         return DLT_RETURN_ERROR;
+     221             :     }
+     222             : 
+     223             :     return DLT_RETURN_OK;
+     224             : }
+     225             : 
+     226          21 : ssize_t multiple_files_buffer_get_total_size(const MultipleFilesRingBuffer *files_buffer)
+     227             : {
+     228          21 :     if (files_buffer == NULL) {
+     229           0 :         fprintf(stderr, "multiple files buffer not set\n");
+     230           0 :         return -1;
+     231             :     }
+     232             : 
+     233             :     struct dirent *dp;
+     234             :     char filename[PATH_MAX + 1];
+     235             :     ssize_t size = 0;
+     236             :     struct stat status;
+     237             : 
+     238             :     /* go through all dlt files in directory */
+     239          21 :     DIR *dir = opendir(files_buffer->directory);
+     240          21 :     if (!dir) {
+     241           0 :         fprintf(stderr, "directory %s cannot be opened, error=%s\n", files_buffer->directory, strerror(errno));
+     242           0 :         return -1;
+     243             :     }
+     244             : 
+     245         779 :     while ((dp = readdir(dir)) != NULL) {
+     246             :         // consider files matching with a specific base name and a particular extension
+     247         758 :         if (strstr(dp->d_name, files_buffer->filenameBase)  && strstr(dp->d_name, files_buffer->filenameExt)) {
+     248             :             int res = snprintf(filename, sizeof(filename), "%s/%s", files_buffer->directory, dp->d_name);
+     249             : 
+     250             :             /* if the total length of the string is greater than the buffer, silently forget it. */
+     251             :             /* snprintf: a return value of size  or more means that the output was truncated */
+     252             :             /*           if an output error is encountered, a negative value is returned. */
+     253          80 :             if (((unsigned int)res < sizeof(filename)) && (res > 0)) {
+     254          80 :                 errno = 0;
+     255          80 :                 if (0 == stat(filename, &status))
+     256          80 :                     size += status.st_size;
+     257             :                 else
+     258           0 :                     fprintf(stderr, "file %s cannot be stat-ed, error=%s\n", filename, strerror(errno));
+     259             :             }
+     260             :         }
+     261             :     }
+     262             : 
+     263          21 :     closedir(dir);
+     264             : 
+     265             :     /* return size */
+     266          21 :     return size;
+     267             : }
+     268             : 
+     269           9 : int multiple_files_buffer_delete_oldest_file(MultipleFilesRingBuffer *files_buffer)
+     270             : {
+     271           9 :     if (files_buffer == NULL) {
+     272           0 :         fprintf(stderr, "multiple files buffer not set\n");
+     273           0 :         return -1;  /* ERROR */
+     274             :     }
+     275             : 
+     276             :     struct dirent *dp;
+     277             :     char filename[PATH_MAX + 1];
+     278             :     char filename_oldest[PATH_MAX + 1];
+     279             :     unsigned long size_oldest = 0;
+     280             :     struct stat status;
+     281             :     time_t time_oldest = 0;
+     282             :     int index_oldest = INT_MAX;
+     283             : 
+     284           9 :     filename[0] = 0;
+     285           9 :     filename_oldest[0] = 0;
+     286             : 
+     287             :     /* go through all dlt files in directory */
+     288           9 :     DIR *dir = opendir(files_buffer->directory);
+     289             : 
+     290           9 :     if(!dir)
+     291             :         return -1;
+     292             : 
+     293         345 :     while ((dp = readdir(dir)) != NULL) {
+     294         336 :         if (strstr(dp->d_name, files_buffer->filenameBase) && strstr(dp->d_name, files_buffer->filenameExt)) {
+     295             :             int res = snprintf(filename, sizeof(filename), "%s/%s", files_buffer->directory, dp->d_name);
+     296             : 
+     297             :             /* if the total length of the string is greater than the buffer, silently forget it. */
+     298             :             /* snprintf: a return value of size  or more means that the output was truncated */
+     299             :             /*           if an output error is encountered, a negative value is returned. */
+     300          44 :             if (((unsigned int) res >= sizeof(filename)) || (res <= 0)) {
+     301             :                 printf("Filename for delete oldest too long. Skip file.\n");
+     302           0 :                 continue;
+     303             :             }
+     304             : 
+     305          44 :             if (files_buffer->filenameTimestampBased) {
+     306           0 :                 errno = 0;
+     307           0 :                 if (0 == stat(filename, &status)) {
+     308           0 :                     if ((time_oldest == 0) || (status.st_mtime < time_oldest)) {
+     309           0 :                         time_oldest = status.st_mtime;
+     310           0 :                         size_oldest = status.st_size;
+     311             :                         strncpy(filename_oldest, filename, PATH_MAX);
+     312           0 :                         filename_oldest[PATH_MAX] = 0;
+     313             :                     }
+     314             :                 } else {
+     315           0 :                     printf("Old file %s cannot be stat-ed, error=%s\n", filename, strerror(errno));
+     316             :                 }
+     317             :             } else {
+     318             :                 //index based
+     319          44 :                 const int index = multiple_files_buffer_get_idx_of_log_file(filename);
+     320          44 :                 if (index < index_oldest) {
+     321             :                     index_oldest = index;
+     322             :                     snprintf(filename, sizeof(filename), "%s/%s", files_buffer->directory, dp->d_name);
+     323             :                     strncpy(filename_oldest, filename, PATH_MAX);
+     324          18 :                     filename_oldest[PATH_MAX] = 0;
+     325             :                 }
+     326             :             }
+     327             :         }
+     328             :     }
+     329             : 
+     330           9 :     closedir(dir);
+     331             : 
+     332             :     /* delete file */
+     333           9 :     if (filename_oldest[0]) {
+     334           9 :         if (remove(filename_oldest)) {
+     335           0 :             fprintf(stderr, "Remove file %s failed! error=%s\n", filename_oldest, strerror(errno));
+     336           0 :             return -1; /* ERROR */
+     337             :         }
+     338             :     } else {
+     339           0 :         fprintf(stderr, "No file to be removed!\n");
+     340           0 :         return -1; /* ERROR */
+     341             :     }
+     342             : 
+     343             :     /* return size of deleted file*/
+     344           9 :     return size_oldest;
+     345             : }
+     346             : 
+     347          12 : DltReturnValue multiple_files_buffer_check_size(MultipleFilesRingBuffer *files_buffer)
+     348             : {
+     349          12 :     if (files_buffer == NULL) {
+     350           0 :         fprintf(stderr, "multiple files buffer not set\n");
+     351           0 :         return DLT_RETURN_ERROR;
+     352             :     }
+     353             : 
+     354             :     struct stat status;
+     355             : 
+     356             :     /* check for existence of buffer files directory */
+     357          12 :     errno = 0;
+     358          12 :     if (stat(files_buffer->directory, &status) == -1) {
+     359           0 :         fprintf(stderr, "Buffer files directory: %s doesn't exist, error=%s\n", files_buffer->directory, strerror(errno));
+     360           0 :         return DLT_RETURN_ERROR;
+     361             :     }
+     362             :     /* check for accessibility of buffer files directory */
+     363          12 :     else if (access(files_buffer->directory, W_OK) != 0) {
+     364           0 :         fprintf(stderr, "Buffer files directory: %s doesn't have the write access \n", files_buffer->directory);
+     365           0 :         return DLT_RETURN_ERROR;
+     366             :     }
+     367             : 
+     368             :     ssize_t total_size = 0;
+     369             :     /* check size of complete buffer file */
+     370          21 :     while ((total_size = multiple_files_buffer_get_total_size(files_buffer)) > (files_buffer->maxSize - files_buffer->fileSize)) {
+     371             :         /* remove the oldest files as long as new file will not fit in completely into complete multiple files buffer */
+     372           9 :         if (multiple_files_buffer_delete_oldest_file(files_buffer) < 0) return DLT_RETURN_ERROR;
+     373             :     }
+     374             : 
+     375          12 :     return total_size == -1 ? DLT_RETURN_ERROR : DLT_RETURN_OK;
+     376             : }
+     377             : 
+     378           3 : DltReturnValue multiple_files_buffer_open_file_for_append(MultipleFilesRingBuffer *files_buffer) {
+     379           3 :     if (files_buffer == NULL || files_buffer->filenameTimestampBased) return DLT_RETURN_ERROR;
+     380             : 
+     381           3 :     char newest[NAME_MAX + 1] = {0};
+     382           3 :     char oldest[NAME_MAX + 1] = {0};
+     383             :     /* targeting the newest file, ignoring number of files in dir returned */
+     384             : 
+     385           3 :     if (0 == multiple_files_buffer_storage_dir_info(files_buffer->directory,
+     386           3 :                                                    files_buffer->filenameBase, newest, oldest) ) {
+     387             :         // no file for appending found. Create a new one
+     388             :         printf("No multiple files for appending found. Create a new one\n");
+     389           0 :         return multiple_files_buffer_create_new_file(files_buffer);
+     390             :     }
+     391             : 
+     392             :     char file_path[PATH_MAX + 1];
+     393             :     int ret = snprintf(file_path, sizeof(file_path), "%s/%s",
+     394             :                          files_buffer->directory, newest);
+     395             : 
+     396           3 :     if ((ret < 0) || (ret >= NAME_MAX)) {
+     397           0 :         fprintf(stderr, "filename cannot be concatenated\n");
+     398           0 :         return DLT_RETURN_ERROR;
+     399             :     }
+     400             : 
+     401             :     /* open DLT output file */
+     402           3 :     errno = 0;
+     403           3 :     files_buffer->ohandle = open(file_path, O_WRONLY | O_APPEND); /* mode: wb */
+     404             : 
+     405           3 :     return files_buffer->ohandle == -1 ? DLT_RETURN_ERROR : DLT_RETURN_OK;
+     406             : }
+     407             : 
+     408           3 : DltReturnValue multiple_files_buffer_init(MultipleFilesRingBuffer *files_buffer,
+     409             :                                           const char *directory,
+     410             :                                           const int file_size,
+     411             :                                           const int max_size,
+     412             :                                           const bool filename_timestamp_based,
+     413             :                                           const bool append,
+     414             :                                           const char *filename_base,
+     415             :                                           const char *filename_ext)
+     416             : {
+     417           3 :     if (files_buffer == NULL) {
+     418           0 :         fprintf(stderr, "multiple files buffer not set\n");
+     419           0 :         return DLT_RETURN_ERROR;
+     420             :     }
+     421             : 
+     422             :     /* init parameters */
+     423           3 :     strncpy(files_buffer->directory, directory, NAME_MAX);
+     424           3 :     files_buffer->directory[NAME_MAX] = 0;
+     425           3 :     files_buffer->fileSize = file_size;
+     426           3 :     files_buffer->maxSize = max_size;
+     427           3 :     files_buffer->filenameTimestampBased = filename_timestamp_based;
+     428           3 :     strncpy(files_buffer->filenameBase, filename_base, NAME_MAX);
+     429           3 :     files_buffer->filenameBase[NAME_MAX] = 0;
+     430           3 :     strncpy(files_buffer->filenameExt, filename_ext, NAME_MAX);
+     431           3 :     files_buffer->filenameExt[NAME_MAX] = 0;
+     432             : 
+     433           3 :     if (DLT_RETURN_ERROR == multiple_files_buffer_check_size(files_buffer)) return DLT_RETURN_ERROR;
+     434             : 
+     435           3 :     return (!files_buffer->filenameTimestampBased && append)
+     436           3 :         ? multiple_files_buffer_open_file_for_append(files_buffer)
+     437           3 :         : multiple_files_buffer_create_new_file(files_buffer);
+     438             : }
+     439             : 
+     440          12 : void multiple_files_buffer_rotate_file(MultipleFilesRingBuffer *files_buffer, const int size)
+     441             : {
+     442             :     /* check file size here */
+     443          12 :     if ((lseek(files_buffer->ohandle, 0, SEEK_CUR) + size) < files_buffer->fileSize) return;
+     444             : 
+     445             :     /* close old file */
+     446           9 :     close(files_buffer->ohandle);
+     447           9 :     files_buffer->ohandle = -1;
+     448             : 
+     449             :     /* check complete files size, remove old logs if needed */
+     450           9 :     if (DLT_RETURN_ERROR == multiple_files_buffer_check_size(files_buffer)) return;
+     451             : 
+     452             :     /* create new file */
+     453           9 :     multiple_files_buffer_create_new_file(files_buffer);
+     454             : }
+     455             : 
+     456          12 : DltReturnValue multiple_files_buffer_write_chunk(const MultipleFilesRingBuffer *files_buffer,
+     457             :                                                  const unsigned char *data,
+     458             :                                                  const int size)
+     459             : {
+     460          12 :     if (files_buffer == NULL) {
+     461           0 :         fprintf(stderr, "multiple files buffer not set\n");
+     462           0 :         return DLT_RETURN_ERROR;
+     463             :     }
+     464             : 
+     465          12 :     if (data && (files_buffer->ohandle >= 0)) {
+     466          12 :         if (write(files_buffer->ohandle, data, size) != size) {
+     467           0 :             fprintf(stderr, "file write failed!\n");
+     468           0 :             return DLT_RETURN_ERROR;
+     469             :         }
+     470             :     }
+     471             :     return DLT_RETURN_OK;
+     472             : }
+     473             : 
+     474          12 : DltReturnValue multiple_files_buffer_write(MultipleFilesRingBuffer *files_buffer,
+     475             :                                            const unsigned char *data,
+     476             :                                            const int size)
+     477             : {
+     478          12 :     if (files_buffer->ohandle < 0) return DLT_RETURN_ERROR;
+     479             : 
+     480          12 :     multiple_files_buffer_rotate_file(files_buffer, size);
+     481             : 
+     482             :     /* write data into log file */
+     483          12 :     return multiple_files_buffer_write_chunk(files_buffer, data, size);
+     484             : }
+     485             : 
+     486           3 : DltReturnValue multiple_files_buffer_free(const MultipleFilesRingBuffer *files_buffer)
+     487             : {
+     488           3 :     if (files_buffer == NULL) {
+     489           0 :         fprintf(stderr, "multiple files buffer not set\n");
+     490           0 :         return DLT_RETURN_ERROR;
+     491             :     }
+     492             : 
+     493           3 :     if (files_buffer->ohandle < 0) return DLT_RETURN_ERROR;
+     494             : 
+     495             :     /* close last used log file */
+     496           3 :     close(files_buffer->ohandle);
+     497             : 
+     498           3 :     return DLT_RETURN_OK;
+     499             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/dlt_offline_trace.c.func-sort-c.html b/dlt_lcov_report/shared/dlt_offline_trace.c.func-sort-c.html new file mode 100644 index 000000000..99b28bcd4 --- /dev/null +++ b/dlt_lcov_report/shared/dlt_offline_trace.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared/dlt_offline_trace.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - shared - dlt_offline_trace.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:060.0 %
Date:2024-12-05 09:07:13Functions:010.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_offline_trace_write0
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/dlt_offline_trace.c.func.html b/dlt_lcov_report/shared/dlt_offline_trace.c.func.html new file mode 100644 index 000000000..7ca51db79 --- /dev/null +++ b/dlt_lcov_report/shared/dlt_offline_trace.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared/dlt_offline_trace.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - shared - dlt_offline_trace.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:060.0 %
Date:2024-12-05 09:07:13Functions:010.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_offline_trace_write0
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/dlt_offline_trace.c.gcov.html b/dlt_lcov_report/shared/dlt_offline_trace.c.gcov.html new file mode 100644 index 000000000..52df780c6 --- /dev/null +++ b/dlt_lcov_report/shared/dlt_offline_trace.c.gcov.html @@ -0,0 +1,164 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared/dlt_offline_trace.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - shared - dlt_offline_trace.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:060.0 %
Date:2024-12-05 09:07:13Functions:010.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2011-2015, BMW AG
+       5             :  *
+       6             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       7             :  *
+       8             :  * This Source Code Form is subject to the terms of the
+       9             :  * Mozilla Public License (MPL), v. 2.0.
+      10             :  * If a copy of the MPL was not distributed with this file,
+      11             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      12             :  *
+      13             :  * For further information see http://www.covesa.org/.
+      14             :  */
+      15             : 
+      16             : /*!
+      17             :  * \author Alexander Wenzel <alexander.aw.wenzel@bmw.de>
+      18             :  *
+      19             :  * \copyright Copyright © 2011-2015 BMW AG. \n
+      20             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      21             :  *
+      22             :  * \file dlt_offline_trace.c
+      23             :  */
+      24             : 
+      25             : /*******************************************************************************
+      26             : **                                                                            **
+      27             : **  SRC-MODULE: dlt_offline_trace.c                                           **
+      28             : **                                                                            **
+      29             : **  TARGET    : linux                                                         **
+      30             : **                                                                            **
+      31             : **  PROJECT   : DLT                                                           **
+      32             : **                                                                            **
+      33             : **  AUTHOR    : Alexander Wenzel Alexander.AW.Wenzel@bmw.de                   **
+      34             : **                                                                            **
+      35             : **  PURPOSE   :                                                               **
+      36             : **                                                                            **
+      37             : **  REMARKS   :                                                               **
+      38             : **                                                                            **
+      39             : **  PLATFORM DEPENDANT [yes/no]: yes                                          **
+      40             : **                                                                            **
+      41             : **  TO BE CHANGED BY USER [yes/no]: no                                        **
+      42             : **                                                                            **
+      43             : *******************************************************************************/
+      44             : 
+      45             : /*******************************************************************************
+      46             : **                      Author Identity                                       **
+      47             : ********************************************************************************
+      48             : **                                                                            **
+      49             : ** Initials     Name                       Company                            **
+      50             : ** --------     -------------------------  ---------------------------------- **
+      51             : **  aw          Alexander Wenzel           BMW                                **
+      52             : *******************************************************************************/
+      53             : 
+      54             : #include <stdio.h>
+      55             : #include <stdlib.h>
+      56             : #include <string.h>
+      57             : #include <time.h>
+      58             : #include <sys/types.h>
+      59             : #include <sys/stat.h>
+      60             : #include <fcntl.h>
+      61             : #include <unistd.h>
+      62             : #include <dirent.h>
+      63             : #include <syslog.h>
+      64             : #include <errno.h>
+      65             : 
+      66             : #include <dlt_offline_trace.h>
+      67             : #include <dlt_multiple_files.h>
+      68             : 
+      69           0 : DltReturnValue dlt_offline_trace_write(MultipleFilesRingBuffer *trace,
+      70             :                                        const unsigned char *data1,
+      71             :                                        const int size1,
+      72             :                                        const unsigned char *data2,
+      73             :                                        const int size2,
+      74             :                                        const unsigned char *data3,
+      75             :                                        const int size3)
+      76             : {
+      77             : 
+      78           0 :     if (trace->ohandle < 0) return DLT_RETURN_ERROR;
+      79             : 
+      80           0 :     multiple_files_buffer_rotate_file(trace, size1 + size2 + size3);
+      81             : 
+      82             :     /* write data into log file */
+      83           0 :     if (multiple_files_buffer_write_chunk(trace, data1, size1) != DLT_RETURN_OK) return DLT_RETURN_ERROR;
+      84           0 :     if (multiple_files_buffer_write_chunk(trace, data2, size2) != DLT_RETURN_OK) return DLT_RETURN_ERROR;
+      85           0 :     if (multiple_files_buffer_write_chunk(trace, data3, size3) != DLT_RETURN_OK) return DLT_RETURN_ERROR;
+      86             : 
+      87             :     return DLT_RETURN_OK;
+      88             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/dlt_protocol.c.func-sort-c.html b/dlt_lcov_report/shared/dlt_protocol.c.func-sort-c.html new file mode 100644 index 000000000..294a8f21d --- /dev/null +++ b/dlt_lcov_report/shared/dlt_protocol.c.func-sort-c.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared/dlt_protocol.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - shared - dlt_protocol.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:6785.7 %
Date:2024-12-05 09:07:13Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_get_service_name11
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/dlt_protocol.c.func.html b/dlt_lcov_report/shared/dlt_protocol.c.func.html new file mode 100644 index 000000000..94dabdd55 --- /dev/null +++ b/dlt_lcov_report/shared/dlt_protocol.c.func.html @@ -0,0 +1,76 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared/dlt_protocol.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - shared - dlt_protocol.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:6785.7 %
Date:2024-12-05 09:07:13Functions:11100.0 %
+
+ +
+ + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_get_service_name11
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/dlt_protocol.c.gcov.html b/dlt_lcov_report/shared/dlt_protocol.c.gcov.html new file mode 100644 index 000000000..506ef93b8 --- /dev/null +++ b/dlt_lcov_report/shared/dlt_protocol.c.gcov.html @@ -0,0 +1,158 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared/dlt_protocol.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - shared - dlt_protocol.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:6785.7 %
Date:2024-12-05 09:07:13Functions:11100.0 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2016 Advanced Driver Information Technology.
+       5             :  * This code is developed by Advanced Driver Information Technology.
+       6             :  * Copyright of Advanced Driver Information Technology, Bosch and DENSO.
+       7             :  *
+       8             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       9             :  *
+      10             :  * This Source Code Form is subject to the terms of the
+      11             :  * Mozilla Public License (MPL), v. 2.0.
+      12             :  * If a copy of the MPL was not distributed with this file,
+      13             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      14             :  *
+      15             :  * For further information see http://www.covesa.org/.
+      16             :  */
+      17             : 
+      18             : /*!
+      19             :  * \author
+      20             :  * Christoph Lipka <clipka@jp.adit-jv.com>
+      21             :  *
+      22             :  * \copyright Copyright © 2016 Advanced Driver Information Technology. \n
+      23             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      24             :  *
+      25             :  * \file dlt_protocol.c
+      26             :  */
+      27             : 
+      28             : #include "dlt_protocol.h"
+      29             : 
+      30             : const char *const dlt_service_names[] = {
+      31             :     "DLT_SERVICE_ID",
+      32             :     "DLT_SERVICE_ID_SET_LOG_LEVEL",
+      33             :     "DLT_SERVICE_ID_SET_TRACE_STATUS",
+      34             :     "DLT_SERVICE_ID_GET_LOG_INFO",
+      35             :     "DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL",
+      36             :     "DLT_SERVICE_ID_STORE_CONFIG",
+      37             :     "DLT_SERVICE_ID_RESET_TO_FACTORY_DEFAULT",
+      38             :     "DLT_SERVICE_ID_SET_COM_INTERFACE_STATUS",
+      39             :     "DLT_SERVICE_ID_SET_COM_INTERFACE_MAX_BANDWIDTH",
+      40             :     "DLT_SERVICE_ID_SET_VERBOSE_MODE",
+      41             :     "DLT_SERVICE_ID_SET_MESSAGE_FILTERING",
+      42             :     "DLT_SERVICE_ID_SET_TIMING_PACKETS",
+      43             :     "DLT_SERVICE_ID_GET_LOCAL_TIME",
+      44             :     "DLT_SERVICE_ID_USE_ECU_ID",
+      45             :     "DLT_SERVICE_ID_USE_SESSION_ID",
+      46             :     "DLT_SERVICE_ID_USE_TIMESTAMP",
+      47             :     "DLT_SERVICE_ID_USE_EXTENDED_HEADER",
+      48             :     "DLT_SERVICE_ID_SET_DEFAULT_LOG_LEVEL",
+      49             :     "DLT_SERVICE_ID_SET_DEFAULT_TRACE_STATUS",
+      50             :     "DLT_SERVICE_ID_GET_SOFTWARE_VERSION",
+      51             :     "DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW"
+      52             : };
+      53             : const char *const dlt_user_service_names[] = {
+      54             :     "DLT_USER_SERVICE_ID",
+      55             :     "DLT_SERVICE_ID_UNREGISTER_CONTEXT",
+      56             :     "DLT_SERVICE_ID_CONNECTION_INFO",
+      57             :     "DLT_SERVICE_ID_TIMEZONE",
+      58             :     "DLT_SERVICE_ID_MARKER",
+      59             :     "DLT_SERVICE_ID_OFFLINE_LOGSTORAGE",
+      60             :     "DLT_SERVICE_ID_PASSIVE_NODE_CONNECT",
+      61             :     "DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS",
+      62             :     "DLT_SERVICE_ID_SET_ALL_LOG_LEVEL",
+      63             :     "DLT_SERVICE_ID_SET_ALL_TRACE_STATUS",
+      64             :     "DLT_SERVICE_ID_UNDEFINED", /* 0xF0A is not defined */
+      65             :     "DLT_SERVICE_ID_RESERVED",
+      66             :     "DLT_SERVICE_ID_RESERVED",
+      67             :     "DLT_SERVICE_ID_RESERVED",
+      68             :     "DLT_SERVICE_ID_RESERVED"
+      69             : };
+      70             : 
+      71          11 : const char *dlt_get_service_name(unsigned int id)
+      72             : {
+      73          11 :     if (id == DLT_SERVICE_ID_CALLSW_CINJECTION)
+      74             :         return "DLT_SERVICE_ID_CALLSW_CINJECTION";
+      75          11 :     else if ((id == DLT_SERVICE_ID) || (id >= DLT_USER_SERVICE_ID_LAST_ENTRY) ||
+      76          11 :              ((id >= DLT_SERVICE_ID_LAST_ENTRY) && (id <= DLT_USER_SERVICE_ID)))
+      77             :         return "UNDEFINED";
+      78          11 :     else if ((id > DLT_SERVICE_ID) && (id < DLT_SERVICE_ID_LAST_ENTRY))
+      79          11 :         return dlt_service_names[id];
+      80             :     else /* user services */
+      81           0 :         return dlt_user_service_names[id & 0xFF];
+      82             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/dlt_user_shared.c.func-sort-c.html b/dlt_lcov_report/shared/dlt_user_shared.c.func-sort-c.html new file mode 100644 index 000000000..950052dec --- /dev/null +++ b/dlt_lcov_report/shared/dlt_user_shared.c.func-sort-c.html @@ -0,0 +1,96 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared/dlt_user_shared.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - shared - dlt_user_shared.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:425477.8 %
Date:2024-12-05 09:07:13Functions:5683.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_user_log_out3_with_timeout0
dlt_user_log_out2_with_timeout51
dlt_user_log_out2432
dlt_user_log_out36375
dlt_user_set_userheader6809
dlt_user_check_userheader11831
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/dlt_user_shared.c.func.html b/dlt_lcov_report/shared/dlt_user_shared.c.func.html new file mode 100644 index 000000000..bc483488b --- /dev/null +++ b/dlt_lcov_report/shared/dlt_user_shared.c.func.html @@ -0,0 +1,96 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared/dlt_user_shared.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - shared - dlt_user_shared.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:425477.8 %
Date:2024-12-05 09:07:13Functions:5683.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_user_check_userheader11831
dlt_user_log_out2432
dlt_user_log_out2_with_timeout51
dlt_user_log_out36375
dlt_user_log_out3_with_timeout0
dlt_user_set_userheader6809
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/dlt_user_shared.c.gcov.html b/dlt_lcov_report/shared/dlt_user_shared.c.gcov.html new file mode 100644 index 000000000..3a6b78bed --- /dev/null +++ b/dlt_lcov_report/shared/dlt_user_shared.c.gcov.html @@ -0,0 +1,299 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared/dlt_user_shared.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - shared - dlt_user_shared.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:425477.8 %
Date:2024-12-05 09:07:13Functions:5683.3 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2011-2015, BMW AG
+       5             :  *
+       6             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       7             :  *
+       8             :  * This Source Code Form is subject to the terms of the
+       9             :  * Mozilla Public License (MPL), v. 2.0.
+      10             :  * If a copy of the MPL was not distributed with this file,
+      11             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      12             :  *
+      13             :  * For further information see http://www.covesa.org/.
+      14             :  */
+      15             : 
+      16             : /*!
+      17             :  * \author Alexander Wenzel <alexander.aw.wenzel@bmw.de>
+      18             :  *
+      19             :  * \copyright Copyright © 2011-2015 BMW AG. \n
+      20             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      21             :  *
+      22             :  * \file dlt_user_shared.c
+      23             :  */
+      24             : 
+      25             : 
+      26             : /*******************************************************************************
+      27             : **                                                                            **
+      28             : **  SRC-MODULE: dlt_user_shared.c                                             **
+      29             : **                                                                            **
+      30             : **  TARGET    : linux                                                         **
+      31             : **                                                                            **
+      32             : **  PROJECT   : DLT                                                           **
+      33             : **                                                                            **
+      34             : **  AUTHOR    : Alexander Wenzel Alexander.AW.Wenzel@bmw.de                   **
+      35             : **              Markus Klein                                                  **
+      36             : **                                                                            **
+      37             : **  PURPOSE   :                                                               **
+      38             : **                                                                            **
+      39             : **  REMARKS   :                                                               **
+      40             : **                                                                            **
+      41             : **  PLATFORM DEPENDANT [yes/no]: yes                                          **
+      42             : **                                                                            **
+      43             : **  TO BE CHANGED BY USER [yes/no]: no                                        **
+      44             : **                                                                            **
+      45             : *******************************************************************************/
+      46             : 
+      47             : /*******************************************************************************
+      48             : **                      Author Identity                                       **
+      49             : ********************************************************************************
+      50             : **                                                                            **
+      51             : ** Initials     Name                       Company                            **
+      52             : ** --------     -------------------------  ---------------------------------- **
+      53             : **  aw          Alexander Wenzel           BMW                                **
+      54             : **  mk          Markus Klein               Fraunhofer ESK                     **
+      55             : *******************************************************************************/
+      56             : 
+      57             : /*******************************************************************************
+      58             : **                      Revision Control History                              **
+      59             : *******************************************************************************/
+      60             : 
+      61             : /*
+      62             :  * $LastChangedRevision: 1670 $
+      63             :  * $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
+      64             :  * $LastChangedBy$
+      65             :  * Initials    Date         Comment
+      66             :  * aw          13.01.2010   initial
+      67             :  */
+      68             : 
+      69             : #include <sys/stat.h>
+      70             : #include <fcntl.h>
+      71             : #include <errno.h>
+      72             : 
+      73             : #include <sys/uio.h> /* writev() */
+      74             : #include <sys/time.h> /* timeval */
+      75             : 
+      76             : #include "dlt_user_shared.h"
+      77             : #include "dlt_user_shared_cfg.h"
+      78             : 
+      79        6809 : DltReturnValue dlt_user_set_userheader(DltUserHeader *userheader, uint32_t mtype)
+      80             : {
+      81        6809 :     if (userheader == 0)
+      82             :         return DLT_RETURN_ERROR;
+      83             : 
+      84        6809 :     if (mtype <= 0)
+      85             :         return DLT_RETURN_ERROR;
+      86             : 
+      87        6809 :     userheader->pattern[0] = 'D';
+      88        6809 :     userheader->pattern[1] = 'U';
+      89        6809 :     userheader->pattern[2] = 'H';
+      90        6809 :     userheader->pattern[3] = 1;
+      91        6809 :     userheader->message = mtype;
+      92             : 
+      93        6809 :     return DLT_RETURN_OK;
+      94             : }
+      95             : 
+      96       11831 : int dlt_user_check_userheader(DltUserHeader *userheader)
+      97             : {
+      98       11831 :     if (userheader == 0)
+      99             :         return -1;
+     100             : 
+     101       23662 :     return (userheader->pattern[0] == 'D') &&
+     102       11831 :            (userheader->pattern[1] == 'U') &&
+     103       23662 :            (userheader->pattern[2] == 'H') &&
+     104       11831 :            (userheader->pattern[3] == 1);
+     105             : }
+     106             : 
+     107         432 : DltReturnValue dlt_user_log_out2(int handle, void *ptr1, size_t len1, void *ptr2, size_t len2)
+     108             : {
+     109             :     struct iovec iov[2];
+     110             :     uint32_t bytes_written;
+     111             : 
+     112         432 :     if (handle < 0)
+     113             :         /* Invalid handle */
+     114             :         return DLT_RETURN_ERROR;
+     115             : 
+     116          94 :     iov[0].iov_base = ptr1;
+     117          94 :     iov[0].iov_len = len1;
+     118          94 :     iov[1].iov_base = ptr2;
+     119          94 :     iov[1].iov_len = len2;
+     120             : 
+     121          94 :     bytes_written = (uint32_t) writev(handle, iov, 2);
+     122             : 
+     123          94 :     if (bytes_written != (len1 + len2))
+     124           0 :         return DLT_RETURN_ERROR;
+     125             : 
+     126             :     return DLT_RETURN_OK;
+     127             : }
+     128             : 
+     129          51 : DltReturnValue dlt_user_log_out2_with_timeout(int handle, void *ptr1, size_t len1, void *ptr2, size_t len2)
+     130             : {
+     131          51 :     if (handle < 0)
+     132             :         /* Invalid handle */
+     133             :         return DLT_RETURN_ERROR;
+     134             : 
+     135             :     fd_set fds;
+     136         867 :     FD_ZERO(&fds);
+     137          51 :     FD_SET(handle, &fds);
+     138             : 
+     139          51 :     struct timeval tv = { DLT_WRITEV_TIMEOUT_SEC, DLT_WRITEV_TIMEOUT_USEC };
+     140          51 :     if (select(handle+1, NULL, &fds, NULL, &tv) < 0) {
+     141             :         return DLT_RETURN_ERROR;
+     142             :     }
+     143             : 
+     144          51 :     if (FD_ISSET(handle, &fds)) {
+     145          51 :         return dlt_user_log_out2(handle, ptr1, len1, ptr2, len2);
+     146             :     } else {
+     147             :         return DLT_RETURN_ERROR;
+     148             :     }
+     149             : }
+     150             : 
+     151        6375 : DltReturnValue dlt_user_log_out3(int handle, void *ptr1, size_t len1, void *ptr2, size_t len2, void *ptr3, size_t len3)
+     152             : {
+     153             :     struct iovec iov[3];
+     154             :     uint32_t bytes_written;
+     155             : 
+     156        6375 :     if (handle < 0)
+     157             :         /* Invalid handle */
+     158             :         return DLT_RETURN_ERROR;
+     159             : 
+     160        5856 :     iov[0].iov_base = ptr1;
+     161        5856 :     iov[0].iov_len = len1;
+     162        5856 :     iov[1].iov_base = ptr2;
+     163        5856 :     iov[1].iov_len = len2;
+     164        5856 :     iov[2].iov_base = ptr3;
+     165        5856 :     iov[2].iov_len = len3;
+     166             : 
+     167        5856 :     bytes_written = (uint32_t) writev(handle, iov, 3);
+     168             : 
+     169        5856 :     if (bytes_written != (len1 + len2 + len3)) {
+     170           2 :         switch (errno) {
+     171             :         case ETIMEDOUT:
+     172             :         {
+     173             :             return DLT_RETURN_PIPE_ERROR;     /* ETIMEDOUT - connect timeout */
+     174             :             break;
+     175             :         }
+     176             :         case EBADF:
+     177             :         {
+     178             :             return DLT_RETURN_PIPE_ERROR;     /* EBADF - handle not open */
+     179             :             break;
+     180             :         }
+     181             :         case EPIPE:
+     182             :         {
+     183             :             return DLT_RETURN_PIPE_ERROR;     /* EPIPE - pipe error */
+     184             :             break;
+     185             :         }
+     186           0 :         case EAGAIN:
+     187             :         {
+     188           0 :             return DLT_RETURN_PIPE_FULL;     /* EAGAIN - data could not be written */
+     189             :             break;
+     190             :         }
+     191             :         default:
+     192             :         {
+     193             :             break;
+     194             :         }
+     195             :         }
+     196             : 
+     197           0 :         return DLT_RETURN_ERROR;
+     198             :     }
+     199             : 
+     200             :     return DLT_RETURN_OK;
+     201             : }
+     202             : 
+     203           0 : DltReturnValue dlt_user_log_out3_with_timeout(int handle, void *ptr1, size_t len1, void *ptr2, size_t len2, void *ptr3, size_t len3)
+     204             : {
+     205           0 :     if (handle < 0)
+     206             :         /* Invalid handle */
+     207             :         return DLT_RETURN_ERROR;
+     208             : 
+     209             :     fd_set fds;
+     210           0 :     FD_ZERO(&fds);
+     211           0 :     FD_SET(handle, &fds);
+     212             : 
+     213           0 :     struct timeval tv = { DLT_WRITEV_TIMEOUT_SEC, DLT_WRITEV_TIMEOUT_USEC };
+     214           0 :     if (select(handle+1, NULL, &fds, NULL, &tv) < 0) {
+     215             :         return DLT_RETURN_ERROR;
+     216             :     }
+     217             : 
+     218           0 :     if (FD_ISSET(handle, &fds)) {
+     219           0 :         return dlt_user_log_out3(handle, ptr1, len1, ptr2, len2, ptr3, len3);
+     220             :     } else {
+     221             :         return DLT_RETURN_ERROR;
+     222             :     }
+     223             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/index-sort-f.html b/dlt_lcov_report/shared/index-sort-f.html new file mode 100644 index 000000000..6a6dce71d --- /dev/null +++ b/dlt_lcov_report/shared/index-sort-f.html @@ -0,0 +1,153 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - sharedHitTotalCoverage
Test:dlt_final_coverage.infoLines:1443218566.0 %
Date:2024-12-05 09:07:13Functions:13014689.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_offline_trace.c +
0.0%
+
0.0 %0 / 60.0 %0 / 1
dlt_user_shared.c +
77.8%77.8%
+
77.8 %42 / 5483.3 %5 / 6
dlt_common.c +
61.8%61.8%
+
61.8 %1005 / 162585.3 %81 / 95
dlt_protocol.c +
85.7%85.7%
+
85.7 %6 / 7100.0 %1 / 1
dlt_multiple_files.c +
68.9%68.9%
+
68.9 %133 / 193100.0 %13 / 13
dlt_config_file_parser.c +
83.5%83.5%
+
83.5 %142 / 170100.0 %15 / 15
dlt_log.c +
88.5%88.5%
+
88.5 %115 / 130100.0 %15 / 15
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/index-sort-l.html b/dlt_lcov_report/shared/index-sort-l.html new file mode 100644 index 000000000..0a01292a6 --- /dev/null +++ b/dlt_lcov_report/shared/index-sort-l.html @@ -0,0 +1,153 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - sharedHitTotalCoverage
Test:dlt_final_coverage.infoLines:1443218566.0 %
Date:2024-12-05 09:07:13Functions:13014689.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_offline_trace.c +
0.0%
+
0.0 %0 / 60.0 %0 / 1
dlt_common.c +
61.8%61.8%
+
61.8 %1005 / 162585.3 %81 / 95
dlt_multiple_files.c +
68.9%68.9%
+
68.9 %133 / 193100.0 %13 / 13
dlt_user_shared.c +
77.8%77.8%
+
77.8 %42 / 5483.3 %5 / 6
dlt_config_file_parser.c +
83.5%83.5%
+
83.5 %142 / 170100.0 %15 / 15
dlt_protocol.c +
85.7%85.7%
+
85.7 %6 / 7100.0 %1 / 1
dlt_log.c +
88.5%88.5%
+
88.5 %115 / 130100.0 %15 / 15
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/index.html b/dlt_lcov_report/shared/index.html new file mode 100644 index 000000000..047e23268 --- /dev/null +++ b/dlt_lcov_report/shared/index.html @@ -0,0 +1,153 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - sharedHitTotalCoverage
Test:dlt_final_coverage.infoLines:1443218566.0 %
Date:2024-12-05 09:07:13Functions:13014689.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_common.c +
61.8%61.8%
+
61.8 %1005 / 162585.3 %81 / 95
dlt_config_file_parser.c +
83.5%83.5%
+
83.5 %142 / 170100.0 %15 / 15
dlt_log.c +
88.5%88.5%
+
88.5 %115 / 130100.0 %15 / 15
dlt_multiple_files.c +
68.9%68.9%
+
68.9 %133 / 193100.0 %13 / 13
dlt_offline_trace.c +
0.0%
+
0.0 %0 / 60.0 %0 / 1
dlt_protocol.c +
85.7%85.7%
+
85.7 %6 / 7100.0 %1 / 1
dlt_user_shared.c +
77.8%77.8%
+
77.8 %42 / 5483.3 %5 / 6
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/snow.png b/dlt_lcov_report/snow.png new file mode 100644 index 0000000000000000000000000000000000000000..2cdae107fceec6e7f02ac7acb4a34a82a540caa5 GIT binary patch literal 141 zcmeAS@N?(olHy`uVBq!ia0vp^j3CU&3?x-=hn)ga>?NMQuI!iC1^MM!lvI6;R0X`wF|Ns97GD8ntt^-nBo-U3d c6}OTTfNUlP#;5A{K>8RwUHx3vIVCg!071?oo&W#< literal 0 HcmV?d00001 diff --git a/dlt_lcov_report/updown.png b/dlt_lcov_report/updown.png new file mode 100644 index 0000000000000000000000000000000000000000..aa56a238b3e6c435265250f9266cd1b8caba0f20 GIT binary patch literal 117 zcmeAS@N?(olHy`uVBq!ia0vp^AT}Qd8;}%R+`Ae`*?77*hG?8mPH5^{)z4*}Q$iB}huR`+ literal 0 HcmV?d00001 diff --git a/googletest b/googletest deleted file mode 160000 index b796f7d44..000000000 --- a/googletest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b796f7d44681514f58a683a3a71ff17c94edb0c1