From 122d1b42231796b47ff52166d548d5ea337091d7 Mon Sep 17 00:00:00 2001 From: github-actions Date: Wed, 29 Nov 2023 14:15:49 +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 | 1037 ++ .../console/dlt-convert.c.func-sort-c.html | 84 + .../console/dlt-convert.c.func.html | 84 + .../console/dlt-convert.c.gcov.html | 608 + .../console/dlt-receive.c.func-sort-c.html | 100 + .../console/dlt-receive.c.func.html | 100 + .../console/dlt-receive.c.gcov.html | 796 + 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 | 676 + .../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 | 4061 +++++ .../dlt_daemon_client.c.func-sort-c.html | 204 + .../daemon/dlt_daemon_client.c.func.html | 204 + .../daemon/dlt_daemon_client.c.gcov.html | 2882 ++++ .../dlt_daemon_common.c.func-sort-c.html | 200 + .../daemon/dlt_daemon_common.c.func.html | 200 + .../daemon/dlt_daemon_common.c.gcov.html | 1915 +++ .../dlt_daemon_connection.c.func-sort-c.html | 104 + .../daemon/dlt_daemon_connection.c.func.html | 104 + .../daemon/dlt_daemon_connection.c.gcov.html | 516 + ...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 | 604 + ...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 | 307 + .../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 | 261 + 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 | 12562 ++++++++++++++++ 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 | 1861 +++ 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 | 1477 ++ .../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 | 140 + .../lib/dlt_filetransfer.c.func.html | 140 + .../lib/dlt_filetransfer.c.gcov.html | 822 + .../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 | 5271 +++++++ 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 | 280 + .../dlt_offline_logstorage.c.func.html | 280 + .../dlt_offline_logstorage.c.gcov.html | 2716 ++++ ...ine_logstorage_behavior.c.func-sort-c.html | 152 + ...lt_offline_logstorage_behavior.c.func.html | 152 + ...lt_offline_logstorage_behavior.c.gcov.html | 1672 ++ .../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 | 512 + dlt_lcov_report/shared/dlt_common.c.func.html | 512 + dlt_lcov_report/shared/dlt_common.c.gcov.html | 4522 ++++++ .../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 | 644 + .../dlt_multiple_files.c.func-sort-c.html | 124 + .../shared/dlt_multiple_files.c.func.html | 124 + .../shared/dlt_multiple_files.c.gcov.html | 574 + .../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 | 143 + dlt_lcov_report/shared/index-sort-l.html | 143 + dlt_lcov_report/shared/index.html | 143 + dlt_lcov_report/snow.png | Bin 0 -> 141 bytes dlt_lcov_report/updown.png | Bin 0 -> 117 bytes googletest | 1 - 118 files changed, 62093 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_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:14621069.5 %
Date:2023-11-29 14:15:44Functions: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..b0cad2cf4 --- /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:14621069.5 %
Date:2023-11-29 14:15:44Functions: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..889f92e60 --- /dev/null +++ b/dlt_lcov_report/console/dlt-control-common.c.gcov.html @@ -0,0 +1,1037 @@ + + + + + + + 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:14621069.5 %
Date:2023-11-29 14:15:44Functions: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          16 :             if (fgets(line, value_length - 1, pFile) != NULL) {
+     207          14 :                 if (strncmp(line, config_id, strlen(config_id)) == 0) {
+     208           3 :                     pch = strtok(line, " =\r\n");
+     209           3 :                     token[0] = 0;
+     210           3 :                     value[0] = 0;
+     211             : 
+     212           6 :                     while (pch != NULL) {
+     213           6 :                         if (token[0] == 0) {
+     214             :                             strncpy(token, pch, sizeof(token) - 1);
+     215           3 :                             token[sizeof(token) - 1] = 0;
+     216             :                         }
+     217             :                         else {
+     218             :                             strncpy(value, pch, sizeof(value) - 1);
+     219           3 :                             value[sizeof(value) - 1] = 0;
+     220           3 :                             break;
+     221             :                         }
+     222             : 
+     223           3 :                         pch = strtok(NULL, " =\r\n");
+     224             :                     }
+     225             : 
+     226           3 :                     if (token[0] && value[0]) {
+     227           3 :                         if (strcmp(token, config_id) == 0) {
+     228           3 :                             *(config_data) = (char *)
+     229           3 :                                 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             :     /* Waiting for thread to complete */
+     667           2 :     pthread_join(daemon_connect_thread, NULL);
+     668             :     /* Closing the socket */
+     669           2 :     return dlt_client_cleanup(&g_client, get_verbosity());
+     670             : }
+     671             : 
+     672             : 
+     673             : #ifdef EXTENDED_FILTERING /* EXTENDED_FILTERING */
+     674             : #   if defined(__linux__) || defined(__ANDROID_API__)
+     675             : DltReturnValue dlt_json_filter_load(DltFilter *filter, const char *filename, int verbose)
+     676             : {
+     677             :     if ((filter == NULL) || (filename == NULL))
+     678             :         return DLT_RETURN_WRONG_PARAMETER;
+     679             : 
+     680             :     if(verbose)
+     681             :         pr_verbose("dlt_json_filter_load()\n");
+     682             : 
+     683             :     FILE *handle;
+     684             :     char buffer[JSON_FILTER_SIZE*DLT_FILTER_MAX];
+     685             :     struct json_object *j_parsed_json;
+     686             :     struct json_object *j_app_id;
+     687             :     struct json_object *j_context_id;
+     688             :     struct json_object *j_log_level;
+     689             :     struct json_object *j_payload_min;
+     690             :     struct json_object *j_payload_max;
+     691             :     enum json_tokener_error jerr;
+     692             : 
+     693             :     char app_id[DLT_ID_SIZE + 1] = "";
+     694             :     char context_id[DLT_ID_SIZE + 1] = "";
+     695             :     int32_t log_level = 0;
+     696             :     int32_t payload_max = INT32_MAX;
+     697             :     int32_t payload_min = 0;
+     698             : 
+     699             :     handle = fopen(filename, "r");
+     700             : 
+     701             :     if (handle == NULL) {
+     702             :         pr_error("Filter file %s cannot be opened!\n", filename);
+     703             :         return DLT_RETURN_ERROR;
+     704             :     }
+     705             : 
+     706             :     if (fread(buffer, sizeof(buffer), 1, handle) != 0) {
+     707             :         if (!feof(handle)) {
+     708             :             pr_error("Filter file %s is to big for reading it with current buffer!\n", filename);
+     709             :             return DLT_RETURN_ERROR;
+     710             :         }
+     711             :     }
+     712             : 
+     713             :     j_parsed_json = json_tokener_parse_verbose(buffer, &jerr);
+     714             : 
+     715             :     if (jerr != json_tokener_success) {
+     716             :         pr_error("Faild to parse given filter %s: %s\n", filename, json_tokener_error_desc(jerr));
+     717             :         return DLT_RETURN_ERROR;
+     718             :     }
+     719             : 
+     720             :     printf("The following filter(s) are applied: \n");
+     721             :     pr_verbose("The following filter(s) are applied: \n");
+     722             :     int iterator = 0;
+     723             :     json_object_object_foreach(j_parsed_json, key, val)
+     724             :     {
+     725             :         if (iterator >= DLT_FILTER_MAX) {
+     726             :             pr_error("Maximum number (%d) of allowed filters reached, ignoring rest of filters!\n",
+     727             :                      DLT_FILTER_MAX);
+     728             :             break;
+     729             :         }
+     730             : 
+     731             :         printf("%s:\n", key);
+     732             :         pr_verbose("%s:\n", key);
+     733             : 
+     734             :         if (json_object_object_get_ex(val, "AppId", &j_app_id))
+     735             :             strncpy(app_id, json_object_get_string(j_app_id), DLT_ID_SIZE);
+     736             :         else
+     737             :             dlt_set_id(app_id, "");
+     738             : 
+     739             :         if (json_object_object_get_ex(val, "ContextId", &j_context_id))
+     740             :             strncpy(context_id, json_object_get_string(j_context_id), DLT_ID_SIZE);
+     741             :         else
+     742             :             dlt_set_id(context_id, "");
+     743             : 
+     744             :         if (json_object_object_get_ex(val, "LogLevel", &j_log_level))
+     745             :             log_level = json_object_get_int(j_log_level);
+     746             :         else
+     747             :             log_level = 0;
+     748             : 
+     749             :         if (json_object_object_get_ex(val, "PayloadMin", &j_payload_min))
+     750             :             payload_min = json_object_get_int(j_payload_min);
+     751             :         else
+     752             :             payload_min = 0;
+     753             : 
+     754             :         if (json_object_object_get_ex(val, "PayloadMax", &j_payload_max))
+     755             :             payload_max = json_object_get_int(j_payload_max);
+     756             :         else
+     757             :             payload_max = INT32_MAX;
+     758             : 
+     759             :         dlt_filter_add(filter, app_id, context_id, log_level, payload_min, payload_max, verbose);
+     760             : 
+     761             :         printf("\tAppId: %.*s\n", DLT_ID_SIZE, app_id);
+     762             :         pr_verbose("\tAppId: %.*s\n", DLT_ID_SIZE, app_id);
+     763             :         printf("\tConextId: %.*s\n", DLT_ID_SIZE, context_id);
+     764             :         pr_verbose("\tConextId: %.*s\n", DLT_ID_SIZE, context_id);
+     765             :         printf("\tLogLevel: %i\n", log_level);
+     766             :         pr_verbose("\tLogLevel: %i\n", log_level);
+     767             :         printf("\tPayloadMin: %i\n", payload_min);
+     768             :         pr_verbose("\tPayloadMin: %i\n", payload_min);
+     769             :         printf("\tPayloadMax: %i\n", payload_max);
+     770             :         pr_verbose("\tPayloadMax: %i\n", payload_max);
+     771             : 
+     772             :         iterator++;
+     773             :     }
+     774             : 
+     775             :     fclose(handle);
+     776             : 
+     777             :     return DLT_RETURN_OK;
+     778             : }
+     779             : #   endif /* __Linux__ */
+     780             : 
+     781             : #   ifdef __QNX__
+     782             : DltReturnValue dlt_json_filter_load(DltFilter *filter, const char *filename, int verbose)
+     783             : {
+     784             :     if ((filter == NULL) || (filename == NULL))
+     785             :         return DLT_RETURN_WRONG_PARAMETER;
+     786             : 
+     787             :     if(verbose)
+     788             :         pr_verbose("dlt_json_filter_load()\n");
+     789             : 
+     790             :     json_decoder_t *j_decoder = json_decoder_create();
+     791             : 
+     792             :     const char *s_app_id;
+     793             :     const char *s_context_id;
+     794             :     int32_t log_level = 0;
+     795             :     int32_t payload_max = INT32_MAX;
+     796             :     int32_t payload_min = 0;
+     797             : 
+     798             :     json_decoder_error_t ret = json_decoder_parse_file(j_decoder, filename);
+     799             : 
+     800             :     if (ret != JSON_DECODER_OK) {
+     801             :         pr_error("Faild to parse given filter %s: json_decoder_error_t is %i\n", filename, ret);
+     802             :         return DLT_RETURN_ERROR;
+     803             :     }
+     804             : 
+     805             :     json_decoder_push_object(j_decoder, NULL, true);
+     806             : 
+     807             :     int iterator = 0;
+     808             :     bool end_of_json = false;
+     809             : 
+     810             :     while (!end_of_json) {
+     811             :         if (iterator >= DLT_FILTER_MAX) {
+     812             :             pr_error("Maximum number (%d) of allowed filters reached, ignoring rest of filters!\n",
+     813             :                      DLT_FILTER_MAX);
+     814             :             break;
+     815             :         }
+     816             : 
+     817             :         if (json_decoder_next(j_decoder) == JSON_DECODER_NOT_FOUND)
+     818             :             end_of_json = true;
+     819             : 
+     820             :         json_decoder_previous(j_decoder);
+     821             : 
+     822             :         printf("%s:\n", json_decoder_name(j_decoder));
+     823             :         json_decoder_push_object(j_decoder, NULL, true);
+     824             : 
+     825             :         if (json_decoder_get_string(j_decoder, "AppId", &s_app_id, true) != JSON_DECODER_OK)
+     826             :             s_app_id = "";
+     827             : 
+     828             :         if (json_decoder_get_string(j_decoder, "ContextId", &s_context_id, true) != JSON_DECODER_OK)
+     829             :             s_context_id = "";
+     830             : 
+     831             :         if (json_decoder_get_int(j_decoder, "LogLevel", &log_level, true) != JSON_DECODER_OK)
+     832             :             log_level = 0;
+     833             : 
+     834             :         if (json_decoder_get_int(j_decoder, "PayloadMin", &payload_min, true) != JSON_DECODER_OK)
+     835             :             payload_min = 0;
+     836             : 
+     837             :         if (json_decoder_get_int(j_decoder, "PayloadMax", &payload_max, true) != JSON_DECODER_OK)
+     838             :             payload_max = INT32_MAX;
+     839             : 
+     840             :         char app_id[DLT_ID_SIZE];
+     841             :         char context_id[DLT_ID_SIZE];
+     842             :         strncpy(app_id, s_app_id, DLT_ID_SIZE);
+     843             :         strncpy(context_id, s_context_id, DLT_ID_SIZE);
+     844             : 
+     845             :         dlt_filter_add(filter, app_id, context_id, log_level, payload_min, payload_max, verbose);
+     846             : 
+     847             :         printf("\tAppId: %.*s\n", DLT_ID_SIZE, app_id);
+     848             :         printf("\tConextId: %.*s\n", DLT_ID_SIZE, context_id);
+     849             :         printf("\tLogLevel: %i\n", log_level);
+     850             :         printf("\tPayloadMin: %i\n", payload_min);
+     851             :         printf("\tPayloadMax: %i\n", payload_max);
+     852             : 
+     853             :         json_decoder_pop(j_decoder);
+     854             : 
+     855             :         iterator++;
+     856             :     }
+     857             : 
+     858             :     json_decoder_destroy(j_decoder);
+     859             : 
+     860             :     return DLT_RETURN_OK;
+     861             : }
+     862             : #   endif /* __QNX__ */
+     863             : #endif /* EXTENDED_FILTERING */
+     864             : 
+     865             : #ifdef EXTENDED_FILTERING /* EXTENDED_FILTERING */
+     866             : #   if defined(__linux__) || defined(__ANDROID_API__)
+     867             : DltReturnValue dlt_json_filter_save(DltFilter *filter, const char *filename, int verbose)
+     868             : {
+     869             :     if ((filter == NULL) || (filename == NULL))
+     870             :         return DLT_RETURN_WRONG_PARAMETER;
+     871             : 
+     872             :     if(verbose)
+     873             :         pr_verbose("dlt_json_filter_save()\n");
+     874             : 
+     875             :     struct json_object *json_filter_obj = json_object_new_object();
+     876             : 
+     877             :     for (int num = 0; num < filter->counter; num++) {
+     878             :         struct json_object *tmp_json_obj = json_object_new_object();
+     879             :         char filter_name[JSON_FILTER_NAME_SIZE];
+     880             :         sprintf(filter_name, "filter%i", num);
+     881             : 
+     882             :         if (filter->apid[num][DLT_ID_SIZE - 1] != 0)
+     883             :             json_object_object_add(tmp_json_obj, "AppId", json_object_new_string_len(filter->apid[num], DLT_ID_SIZE));
+     884             :         else
+     885             :             json_object_object_add(tmp_json_obj, "AppId", json_object_new_string(filter->apid[num]));
+     886             : 
+     887             :         if (filter->ctid[num][DLT_ID_SIZE - 1] != 0)
+     888             :             json_object_object_add(tmp_json_obj, "ContextId",
+     889             :                                    json_object_new_string_len(filter->ctid[num], DLT_ID_SIZE));
+     890             :         else
+     891             :             json_object_object_add(tmp_json_obj, "ContextId", json_object_new_string(filter->ctid[num]));
+     892             : 
+     893             :         json_object_object_add(tmp_json_obj, "LogLevel", json_object_new_int(filter->log_level[num]));
+     894             :         json_object_object_add(tmp_json_obj, "PayloadMin", json_object_new_int(filter->payload_min[num]));
+     895             :         json_object_object_add(tmp_json_obj, "PayloadMax", json_object_new_int(filter->payload_max[num]));
+     896             : 
+     897             :         json_object_object_add(json_filter_obj, filter_name, tmp_json_obj);
+     898             :     }
+     899             : 
+     900             :     printf("Saving current filter into '%s'\n", filename);
+     901             :     json_object_to_file((char*)filename, json_filter_obj);
+     902             : 
+     903             :     return DLT_RETURN_OK;
+     904             : }
+     905             : #   endif /* __Linux__ */
+     906             : 
+     907             : #   ifdef __QNX__
+     908             : DltReturnValue dlt_json_filter_save(DltFilter *filter, const char *filename, int verbose)
+     909             : {
+     910             :     if ((filter == NULL) || (filename == NULL))
+     911             :         return DLT_RETURN_WRONG_PARAMETER;
+     912             : 
+     913             :     if(verbose)
+     914             :         pr_verbose("dlt_json_filter_save()\n");
+     915             : 
+     916             :     char s_app_id[DLT_ID_SIZE + 1];
+     917             :     char s_context_id[DLT_ID_SIZE + 1];
+     918             : 
+     919             :     json_encoder_t *j_encoder = json_encoder_create();
+     920             :     json_encoder_start_object(j_encoder, NULL);
+     921             : 
+     922             :     for (int num = 0; num < filter->counter; num++) {
+     923             :         char filter_name[JSON_FILTER_NAME_SIZE];
+     924             :         sprintf(filter_name, "filter%i", num);
+     925             :         json_encoder_start_object(j_encoder, filter_name);
+     926             : 
+     927             :         strncpy(s_app_id, filter->apid[num], DLT_ID_SIZE);
+     928             : 
+     929             :         if (filter->apid[num][DLT_ID_SIZE - 1] != 0)
+     930             :             s_app_id[DLT_ID_SIZE] = '\0';
+     931             : 
+     932             :         strncpy(s_context_id, filter->ctid[num], DLT_ID_SIZE);
+     933             : 
+     934             :         if (filter->ctid[num][DLT_ID_SIZE - 1] != 0)
+     935             :             s_context_id[DLT_ID_SIZE] = '\0';
+     936             : 
+     937             :         json_encoder_add_string(j_encoder, "AppId", s_app_id);
+     938             :         json_encoder_add_string(j_encoder, "ContextId", s_context_id);
+     939             :         json_encoder_add_int(j_encoder, "LogLevel", filter->log_level[num]);
+     940             :         json_encoder_add_int(j_encoder, "PayloadMin", filter->payload_min[num]);
+     941             :         json_encoder_add_int(j_encoder, "PayloadMax", filter->payload_max[num]);
+     942             : 
+     943             :         json_encoder_end_object(j_encoder);
+     944             :     }
+     945             : 
+     946             :     json_encoder_end_object(j_encoder);
+     947             : 
+     948             :     printf("Saving current filter into '%s'\n", filename);
+     949             :     FILE *handle = fopen(filename, "w");
+     950             :     int filter_buffer_size = 100 * (filter->counter);
+     951             :     char filter_buffer[filter_buffer_size];
+     952             :     snprintf(filter_buffer, filter_buffer_size, json_encoder_buffer(j_encoder));
+     953             :     fprintf(handle, filter_buffer);
+     954             : 
+     955             :     fclose(handle);
+     956             :     json_encoder_destroy(j_encoder);
+     957             : 
+     958             :     return DLT_RETURN_OK;
+     959             : }
+     960             : #   endif /* __QNX__ */
+     961             : #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..0e39af0dd --- /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:3718420.1 %
Date:2023-11-29 14:15:44Functions:1333.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
empty_dir0
usage0
main35
+
+
+ + + +
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..cf5ad6c37 --- /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:3718420.1 %
Date:2023-11-29 14:15:44Functions:1333.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
empty_dir0
main35
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..a6c04f5a0 --- /dev/null +++ b/dlt_lcov_report/console/dlt-convert.c.gcov.html @@ -0,0 +1,608 @@ + + + + + + + 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:3718420.1 %
Date:2023-11-29 14:15:44Functions: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             : 
+     140           0 :     if (stat(dir, &st) == 0) {
+     141           0 :         if (S_ISDIR(st.st_mode)) {
+     142           0 :             n = (uint32_t) scandir(dir, &files, NULL, alphasort);
+     143             : 
+     144             :             /* Do not include /. and /.. */
+     145           0 :             if (n < 2)
+     146           0 :                 fprintf(stderr, "ERROR: Failed to scan %s with error %s\n",
+     147           0 :                         dir, strerror(errno));
+     148           0 :             else if (n == 2)
+     149             :                 printf("%s is already empty\n", dir);
+     150             :             else {
+     151           0 :                 for (i = 2; i < n; i++) {
+     152             :                     memset(tmp_filename, 0, FILENAME_SIZE);
+     153           0 :                     snprintf(tmp_filename, FILENAME_SIZE, "%s%s", dir, files[i]->d_name);
+     154             : 
+     155           0 :                     if (remove(tmp_filename) != 0)
+     156           0 :                         fprintf(stderr, "ERROR: Failed to delete %s with error %s\n",
+     157           0 :                                 tmp_filename, strerror(errno));
+     158             :                 }
+     159           0 :                 if (files) {
+     160           0 :                     for (i = 0; i < n ; i++)
+     161           0 :                         if (files[i]) {
+     162           0 :                             free(files[i]);
+     163           0 :                             files[i] = NULL;
+     164             :                         }
+     165           0 :                     free(files);
+     166             :                     files = NULL;
+     167             :                 }
+     168             :             }
+     169             :         }
+     170             :         else
+     171           0 :             fprintf(stderr, "ERROR: %s is not a directory\n", dir);
+     172             :     }
+     173             :     else
+     174           0 :         fprintf(stderr, "ERROR: Failed to stat %s with error %s\n", dir, strerror(errno));
+     175           0 : }
+     176             : 
+     177             : /**
+     178             :  * Main function of tool.
+     179             :  */
+     180          35 : int main(int argc, char *argv[])
+     181             : {
+     182             :     int vflag = 0;
+     183             :     int cflag = 0;
+     184             :     int aflag = 0;
+     185             :     int sflag = 0;
+     186             :     int xflag = 0;
+     187             :     int mflag = 0;
+     188             :     int wflag = 0;
+     189             :     int tflag = 0;
+     190             :     char *fvalue = 0;
+     191             :     char *bvalue = 0;
+     192             :     char *evalue = 0;
+     193             :     char *ovalue = 0;
+     194             : 
+     195             :     int index;
+     196             :     int c;
+     197             : 
+     198             :     DltFile file;
+     199             :     DltFilter filter;
+     200             : 
+     201             :     int ohandle = -1;
+     202             : 
+     203             :     int num, begin, end;
+     204             : 
+     205          35 :     char text[DLT_CONVERT_TEXTBUFSIZE] = { 0 };
+     206             : 
+     207             :     /* For handling compressed files */
+     208          35 :     char tmp_filename[FILENAME_SIZE] = { 0 };
+     209             :     struct stat st;
+     210             :     memset(&st, 0, sizeof(struct stat));
+     211          35 :     struct dirent **files = { 0 };
+     212             :     int n = 0;
+     213             :     int i = 0;
+     214             : 
+     215             :     struct iovec iov[2];
+     216             :     int bytes_written = 0;
+     217             :     int syserr = 0;
+     218             : 
+     219          35 :     opterr = 0;
+     220             : 
+     221          70 :     while ((c = getopt (argc, argv, "vcashxmwtf:b:e:o:")) != -1) {
+     222          35 :         switch (c)
+     223             :         {
+     224             :         case 'v':
+     225             :         {
+     226             :             vflag = 1;
+     227             :             break;
+     228             :         }
+     229           0 :         case 'c':
+     230             :         {
+     231             :             cflag = 1;
+     232           0 :             break;
+     233             :         }
+     234          35 :         case 'a':
+     235             :         {
+     236             :             aflag = 1;
+     237          35 :             break;
+     238             :         }
+     239           0 :         case 's':
+     240             :         {
+     241             :             sflag = 1;
+     242           0 :             break;
+     243             :         }
+     244           0 :         case 'x':
+     245             :         {
+     246             :             xflag = 1;
+     247           0 :             break;
+     248             :         }
+     249           0 :         case 'm':
+     250             :         {
+     251             :             mflag = 1;
+     252           0 :             break;
+     253             :         }
+     254           0 :         case 'w':
+     255             :         {
+     256             :             wflag = 1;
+     257           0 :             break;
+     258             :         }
+     259           0 :         case 't':
+     260             :         {
+     261             :             tflag = 1;
+     262           0 :             break;
+     263             :         }
+     264           0 :         case 'h':
+     265             :         {
+     266           0 :             usage();
+     267           0 :             return -1;
+     268             :         }
+     269           0 :         case 'f':
+     270             :         {
+     271           0 :             fvalue = optarg;
+     272           0 :             break;
+     273             :         }
+     274           0 :         case 'b':
+     275             :         {
+     276           0 :             bvalue = optarg;
+     277           0 :             break;
+     278             :         }
+     279           0 :         case 'e':
+     280             :         {
+     281           0 :             evalue = optarg;
+     282           0 :             break;
+     283             :         }
+     284           0 :         case 'o':
+     285             :         {
+     286           0 :             ovalue = optarg;
+     287           0 :             break;
+     288             :         }
+     289           0 :         case '?':
+     290             :         {
+     291           0 :             if ((optopt == 'f') || (optopt == 'b') || (optopt == 'e') || (optopt == 'o'))
+     292           0 :                 fprintf (stderr, "Option -%c requires an argument.\n", optopt);
+     293           0 :             else if (isprint (optopt))
+     294           0 :                 fprintf (stderr, "Unknown option `-%c'.\n", optopt);
+     295             :             else
+     296           0 :                 fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
+     297             : 
+     298             :             /* unknown or wrong option used, show usage information and terminate */
+     299           0 :             usage();
+     300           0 :             return -1;
+     301             :         }
+     302             :         default:
+     303             :         {
+     304             :             return -1;    /*for parasoft */
+     305             :         }
+     306             :         }
+     307             :     }
+     308             : 
+     309             :     /* Initialize structure to use DLT file */
+     310          35 :     dlt_file_init(&file, vflag);
+     311             : 
+     312             :     /* first parse filter file if filter parameter is used */
+     313          35 :     if (fvalue) {
+     314           0 :         if (dlt_filter_load(&filter, fvalue, vflag) < DLT_RETURN_OK) {
+     315           0 :             dlt_file_free(&file, vflag);
+     316           0 :             return -1;
+     317             :         }
+     318             : 
+     319           0 :         dlt_file_set_filter(&file, &filter, vflag);
+     320             :     }
+     321             : 
+     322          35 :     if (ovalue) {
+     323             :         ohandle = open(ovalue, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* mode: wb */
+     324             : 
+     325           0 :         if (ohandle == -1) {
+     326           0 :             dlt_file_free(&file, vflag);
+     327           0 :             fprintf(stderr, "ERROR: Output file %s cannot be opened!\n", ovalue);
+     328           0 :             return -1;
+     329             :         }
+     330             :     }
+     331             : 
+     332          35 :     if (tflag) {
+     333             :         /* Prepare the temp dir to untar compressed files */
+     334           0 :         if (stat(DLT_CONVERT_WS, &st) == -1) {
+     335           0 :             if (mkdir(DLT_CONVERT_WS, 0700) != 0) {
+     336           0 :                 fprintf(stderr,"ERROR: Cannot create temp dir %s!\n", DLT_CONVERT_WS);
+     337           0 :                 if (ovalue)
+     338           0 :                     close(ohandle);
+     339             : 
+     340           0 :                 return -1;
+     341             :             }
+     342             :         }
+     343             :         else {
+     344           0 :             if (S_ISDIR(st.st_mode))
+     345           0 :                 empty_dir(DLT_CONVERT_WS);
+     346             :             else
+     347           0 :                 fprintf(stderr, "ERROR: %s is not a directory", DLT_CONVERT_WS);
+     348             :         }
+     349             : 
+     350           0 :         for (index = optind; index < argc; index++) {
+     351             :             /* Check extension of input file
+     352             :              * If it is a compressed file, uncompress it
+     353             :              */
+     354           0 :             if (strcmp(get_filename_ext(argv[index]), DLT_EXTENSION) != 0) {
+     355           0 :                 syserr = dlt_execute_command(NULL, "tar", "xf", argv[index], "-C", DLT_CONVERT_WS, NULL);
+     356           0 :                 if (syserr != 0)
+     357           0 :                     fprintf(stderr, "ERROR: Failed to uncompress %s to %s with error [%d]\n",
+     358           0 :                             argv[index], DLT_CONVERT_WS, WIFEXITED(syserr));
+     359             :             }
+     360             :             else {
+     361           0 :                 syserr = dlt_execute_command(NULL, "cp", argv[index], DLT_CONVERT_WS, NULL);
+     362           0 :                 if (syserr != 0)
+     363           0 :                     fprintf(stderr, "ERROR: Failed to copy %s to %s with error [%d]\n",
+     364           0 :                             argv[index], DLT_CONVERT_WS, WIFEXITED(syserr));
+     365             :             }
+     366             : 
+     367             :         }
+     368             : 
+     369           0 :         n = scandir(DLT_CONVERT_WS, &files, NULL, alphasort);
+     370           0 :         if (n == -1) {
+     371           0 :             fprintf(stderr,"ERROR: Cannot scan temp dir %s!\n", DLT_CONVERT_WS);
+     372           0 :             if (ovalue)
+     373           0 :                 close(ohandle);
+     374             : 
+     375           0 :             return -1;
+     376             :         }
+     377             : 
+     378             :         /* do not include ./ and ../ in the files */
+     379           0 :         argc = optind + (n - 2);
+     380             :     }
+     381             : 
+     382          70 :     for (index = optind; index < argc; index++) {
+     383          35 :         if (tflag) {
+     384             :             memset(tmp_filename, 0, FILENAME_SIZE);
+     385             :             snprintf(tmp_filename, FILENAME_SIZE, "%s%s",
+     386           0 :                     DLT_CONVERT_WS, files[index - optind + 2]->d_name);
+     387             : 
+     388           0 :             argv[index] = tmp_filename;
+     389             :         }
+     390             : 
+     391             :         /* load, analyze data file and create index list */
+     392          35 :         if (dlt_file_open(&file, argv[index], vflag) >= DLT_RETURN_OK) {
+     393         739 :             while (dlt_file_read(&file, vflag) >= DLT_RETURN_OK) {
+     394             :             }
+     395             :         }
+     396             : 
+     397          35 :         if (aflag || sflag || xflag || mflag || ovalue) {
+     398          35 :             if (bvalue)
+     399             :                 begin = atoi(bvalue);
+     400             :             else
+     401             :                 begin = 0;
+     402             : 
+     403          35 :             if (evalue && (wflag == 0))
+     404             :                 end = atoi(evalue);
+     405             :             else
+     406          35 :                 end = file.counter - 1;
+     407             : 
+     408          35 :             if ((begin < 0) || (begin >= file.counter)) {
+     409           0 :                 fprintf(stderr, "ERROR: Selected first message %d is out of range!\n", begin);
+     410           0 :                 if (ovalue)
+     411           0 :                     close(ohandle);
+     412             : 
+     413           0 :                 return -1;
+     414             :             }
+     415             : 
+     416          35 :             if ((end < 0) || (end >= file.counter) || (end < begin)) {
+     417           0 :                 fprintf(stderr, "ERROR: Selected end message %d is out of range!\n", end);
+     418           0 :                 if (ovalue)
+     419           0 :                     close(ohandle);
+     420             : 
+     421           0 :                 return -1;
+     422             :             }
+     423             : 
+     424         739 :             for (num = begin; num <= end; num++) {
+     425         704 :                 if (dlt_file_message(&file, num, vflag) < DLT_RETURN_OK)
+     426           0 :                     continue;
+     427             : 
+     428         704 :                 if (xflag) {
+     429             :                     printf("%d ", num);
+     430           0 :                     if (dlt_message_print_hex(&(file.msg), text, DLT_CONVERT_TEXTBUFSIZE, vflag) < DLT_RETURN_OK)
+     431           0 :                         continue;
+     432             :                 }
+     433         704 :                 else if (aflag) {
+     434             :                     printf("%d ", num);
+     435             : 
+     436         704 :                     if (dlt_message_header(&(file.msg), text, DLT_CONVERT_TEXTBUFSIZE, vflag) < DLT_RETURN_OK)
+     437           0 :                         continue;
+     438             : 
+     439             :                     printf("%s ", text);
+     440             : 
+     441         704 :                     if (dlt_message_payload(&file.msg, text, DLT_CONVERT_TEXTBUFSIZE, DLT_OUTPUT_ASCII, vflag) < DLT_RETURN_OK)
+     442           0 :                         continue;
+     443             : 
+     444             :                     printf("[%s]\n", text);
+     445             :                 }
+     446           0 :                 else if (mflag) {
+     447             :                     printf("%d ", num);
+     448           0 :                     if (dlt_message_print_mixed_plain(&(file.msg), text, DLT_CONVERT_TEXTBUFSIZE, vflag) < DLT_RETURN_OK)
+     449           0 :                         continue;
+     450             :                 }
+     451           0 :                 else if (sflag) {
+     452             :                     printf("%d ", num);
+     453             : 
+     454           0 :                     if (dlt_message_header(&(file.msg), text, DLT_CONVERT_TEXTBUFSIZE, vflag) < DLT_RETURN_OK)
+     455           0 :                         continue;
+     456             : 
+     457             :                     printf("%s \n", text);
+     458             :                 }
+     459             : 
+     460             :                 /* if file output enabled write message */
+     461         704 :                 if (ovalue) {
+     462           0 :                     iov[0].iov_base = file.msg.headerbuffer;
+     463           0 :                     iov[0].iov_len = (uint32_t) file.msg.headersize;
+     464           0 :                     iov[1].iov_base = file.msg.databuffer;
+     465           0 :                     iov[1].iov_len = (uint32_t) file.msg.datasize;
+     466             : 
+     467           0 :                     bytes_written =(int) writev(ohandle, iov, 2);
+     468             : 
+     469           0 :                     if (0 > bytes_written) {
+     470             :                         printf("in main: writev(ohandle, iov, 2); returned an error!");
+     471           0 :                         close(ohandle);
+     472           0 :                         dlt_file_free(&file, vflag);
+     473           0 :                         return -1;
+     474             :                     }
+     475             :                 }
+     476             : 
+     477             :                 /* check for new messages if follow flag set */
+     478         704 :                 if (wflag && (num == end)) {
+     479             :                     while (1) {
+     480           0 :                         while (dlt_file_read(&file, 0) >= 0){
+     481             :                         }
+     482             : 
+     483           0 :                         if (end == (file.counter - 1)) {
+     484             :                             /* Sleep if no new message was received */
+     485             :                             struct timespec req;
+     486           0 :                             req.tv_sec = 0;
+     487           0 :                             req.tv_nsec = 100000000;
+     488           0 :                             nanosleep(&req, NULL);
+     489             :                         }
+     490             :                         else {
+     491             :                             /* set new end of log file and continue reading */
+     492             :                             end = file.counter - 1;
+     493             :                             break;
+     494             :                         }
+     495             :                     }
+     496             :                 }
+     497             :             }
+     498             :         }
+     499             : 
+     500          35 :         if (cflag) {
+     501           0 :             printf("Total number of messages: %d\n", file.counter_total);
+     502             : 
+     503           0 :             if (file.filter)
+     504           0 :                 printf("Filtered number of messages: %d\n", file.counter);
+     505             :         }
+     506             :     }
+     507             : 
+     508          35 :     if (ovalue)
+     509           0 :         close(ohandle);
+     510             : 
+     511          35 :     if (tflag) {
+     512           0 :         empty_dir(DLT_CONVERT_WS);
+     513           0 :         if (files) {
+     514           0 :             for (i = 0; i < n ; i++)
+     515           0 :                 if (files[i])
+     516           0 :                     free(files[i]);
+     517             : 
+     518           0 :             free(files);
+     519             :         }
+     520           0 :         rmdir(DLT_CONVERT_WS);
+     521             :     }
+     522          35 :     if (index == optind) {
+     523             :         /* no file selected, show usage and terminate */
+     524           0 :         fprintf(stderr, "ERROR: No file selected\n");
+     525           0 :         usage();
+     526           0 :         return -1;
+     527             :     }
+     528             : 
+     529          35 :     dlt_file_free(&file, vflag);
+     530             : 
+     531          35 :     return 0;
+     532             : }
+
+
+
+ + + + +
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..7f1401e9e --- /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:8423535.7 %
Date:2023-11-29 14:15:44Functions: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..3fa3d97e4 --- /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:8423535.7 %
Date:2023-11-29 14:15:44Functions: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..e9568c965 --- /dev/null +++ b/dlt_lcov_report/console/dlt-receive.c.gcov.html @@ -0,0 +1,796 @@ + + + + + + + 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:8423535.7 %
Date:2023-11-29 14:15:44Functions: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             : 
+      87             : #include "dlt_client.h"
+      88             : #include "dlt-control-common.h"
+      89             : 
+      90             : #define DLT_RECEIVE_ECU_ID "RECV"
+      91             : 
+      92             : DltClient dltclient;
+      93             : 
+      94           1 : void signal_handler(int signal)
+      95             : {
+      96           1 :     switch (signal) {
+      97           1 :     case SIGHUP:
+      98             :     case SIGTERM:
+      99             :     case SIGINT:
+     100             :     case SIGQUIT:
+     101             :         /* stop main loop */
+     102           1 :         shutdown(dltclient.receiver.fd, SHUT_RD);
+     103           1 :         break;
+     104             :     default:
+     105             :         /* This case should never happen! */
+     106             :         break;
+     107             :     } /* switch */
+     108             : 
+     109           1 : }
+     110             : 
+     111             : /* Function prototypes */
+     112             : int dlt_receive_message_callback(DltMessage *message, void *data);
+     113             : 
+     114             : typedef struct {
+     115             :     int aflag;
+     116             :     int sflag;
+     117             :     int xflag;
+     118             :     int mflag;
+     119             :     int vflag;
+     120             :     int yflag;
+     121             :     int uflag;
+     122             :     char *ovalue;
+     123             :     char *ovaluebase; /* ovalue without ".dlt" */
+     124             :     char *fvalue;       /* filename for space separated filter file (<AppID> <ContextID>) */
+     125             :     char *jvalue;       /* filename for json filter file */
+     126             :     char *evalue;
+     127             :     int bvalue;
+     128             :     int sendSerialHeaderFlag;
+     129             :     int resyncSerialHeaderFlag;
+     130             :     int64_t climit;
+     131             :     char ecuid[4];
+     132             :     int ohandle;
+     133             :     int64_t totalbytes; /* bytes written so far into the output file, used to check the file size limit */
+     134             :     int part_num;    /* number of current output file if limit was exceeded */
+     135             :     DltFile file;
+     136             :     DltFilter filter;
+     137             :     int port;
+     138             :     char *ifaddr;
+     139             : } DltReceiveData;
+     140             : 
+     141             : /**
+     142             :  * Print usage information of tool.
+     143             :  */
+     144           0 : void usage()
+     145             : {
+     146             :     char version[255];
+     147             : 
+     148           0 :     dlt_get_version(version, 255);
+     149             : 
+     150             :     printf("Usage: dlt-receive [options] hostname/serial_device_name\n");
+     151             :     printf("Receive DLT messages from DLT daemon and print or store the messages.\n");
+     152             :     printf("Use filters to filter received messages.\n");
+     153             :     printf("%s \n", version);
+     154             :     printf("Options:\n");
+     155             :     printf("  -a            Print DLT messages; payload as ASCII\n");
+     156             :     printf("  -x            Print DLT messages; payload as hex\n");
+     157             :     printf("  -m            Print DLT messages; payload as hex and ASCII\n");
+     158             :     printf("  -s            Print DLT messages; only headers\n");
+     159             :     printf("  -v            Verbose mode\n");
+     160             :     printf("  -h            Usage\n");
+     161             :     printf("  -S            Send message with serial header (Default: Without serial header)\n");
+     162             :     printf("  -R            Enable resync serial header\n");
+     163             :     printf("  -y            Serial device mode\n");
+     164             :     printf("  -u            UDP multicast mode\n");
+     165             :     printf("  -i addr       Host interface address\n");
+     166             :     printf("  -b baudrate   Serial device baudrate (Default: 115200)\n");
+     167             :     printf("  -e ecuid      Set ECU ID (Default: RECV)\n");
+     168             :     printf("  -o filename   Output messages in new DLT file\n");
+     169             :     printf("  -c limit      Restrict file size to <limit> bytes when output to file\n");
+     170             :     printf("                When limit is reached, a new file is opened. Use K,M,G as\n");
+     171             :     printf("                suffix to specify kilo-, mega-, giga-bytes respectively\n");
+     172             :     printf("  -f filename   Enable filtering of messages with space separated list (<AppID> <ContextID>)\n");
+     173             :     printf("  -j filename   Enable filtering of messages with filter defined in json file\n");
+     174             :     printf("  -p port       Use the given port instead the default port\n");
+     175             :     printf("                Cannot be used with serial devices\n");
+     176           0 : }
+     177             : 
+     178             : 
+     179           0 : int64_t convert_arg_to_byte_size(char *arg)
+     180             : {
+     181             :     size_t i;
+     182             :     int64_t factor;
+     183             :     int64_t result;
+     184             : 
+     185             :     /* check if valid input */
+     186           0 :     for (i = 0; i < strlen(arg) - 1; ++i)
+     187           0 :         if (!isdigit(arg[i]))
+     188             :             return -2;
+     189             : 
+     190             :     /* last character */
+     191             :     factor = 1;
+     192             : 
+     193           0 :     if ((arg[strlen(arg) - 1] == 'K') || (arg[strlen(arg) - 1] == 'k'))
+     194             :         factor = 1024;
+     195             :     else if ((arg[strlen(arg) - 1] == 'M') || (arg[strlen(arg) - 1] == 'm'))
+     196             :         factor = 1024 * 1024;
+     197             :     else if ((arg[strlen(arg) - 1] == 'G') || (arg[strlen(arg) - 1] == 'g'))
+     198             :         factor = 1024 * 1024 * 1024;
+     199           0 :     else if (!isdigit(arg[strlen(arg) - 1]))
+     200             :         return -2;
+     201             : 
+     202             :     /* range checking */
+     203             :     int64_t const mult = atoll(arg);
+     204             : 
+     205           0 :     if (((INT64_MAX) / factor) < mult)
+     206             :         /* Would overflow! */
+     207             :         return -2;
+     208             : 
+     209           0 :     result = factor * mult;
+     210             : 
+     211             :     /* The result be at least the size of one message
+     212             :      * One message consists of its header + user data:
+     213             :      */
+     214             :     DltMessage msg;
+     215             :     int64_t min_size = sizeof(msg.headerbuffer);
+     216             :     min_size += 2048 /* DLT_USER_BUF_MAX_SIZE */;
+     217             : 
+     218           0 :     if (min_size > result) {
+     219           0 :         dlt_vlog(LOG_ERR,
+     220             :                  "ERROR: Specified limit: %" PRId64 "is smaller than a the size of a single message: %" PRId64 "!\n",
+     221             :                  result,
+     222             :                  min_size);
+     223             :         result = -2;
+     224             :     }
+     225             : 
+     226             :     return result;
+     227             : }
+     228             : 
+     229             : 
+     230             : /*
+     231             :  * open output file
+     232             :  */
+     233           0 : int dlt_receive_open_output_file(DltReceiveData *dltdata)
+     234             : {
+     235             :     /* if (file_already_exists) */
+     236             :     glob_t outer;
+     237             : 
+     238           0 :     if (glob(dltdata->ovalue,
+     239             : #ifndef __ANDROID_API__
+     240             :              GLOB_TILDE |
+     241             : #endif
+     242             :              GLOB_NOSORT, NULL, &outer) == 0) {
+     243           0 :         if (dltdata->vflag)
+     244           0 :             dlt_vlog(LOG_INFO, "File %s already exists, need to rename first\n", dltdata->ovalue);
+     245             : 
+     246           0 :         if (dltdata->part_num < 0) {
+     247             :             char pattern[PATH_MAX + 1];
+     248           0 :             pattern[PATH_MAX] = 0;
+     249           0 :             snprintf(pattern, PATH_MAX, "%s.*.dlt", dltdata->ovaluebase);
+     250             :             glob_t inner;
+     251             : 
+     252             :             /* sort does not help here because we have to traverse the
+     253             :              * full result in any case. Remember, a sorted list would look like:
+     254             :              * foo.1.dlt
+     255             :              * foo.10.dlt
+     256             :              * foo.1000.dlt
+     257             :              * foo.11.dlt
+     258             :              */
+     259           0 :             if (glob(pattern,
+     260             : #ifndef __ANDROID_API__
+     261             :                      GLOB_TILDE |
+     262             : #endif
+     263             :                      GLOB_NOSORT, NULL, &inner) == 0) {
+     264             :                 /* search for the highest number used */
+     265             :                 size_t i;
+     266             : 
+     267           0 :                 for (i = 0; i < inner.gl_pathc; ++i) {
+     268             :                     /* convert string that follows the period after the initial portion,
+     269             :                      * e.g. gt.gl_pathv[i] = foo.1.dlt -> atoi("1.dlt");
+     270             :                      */
+     271           0 :                     int cur = atoi(&inner.gl_pathv[i][strlen(dltdata->ovaluebase) + 1]);
+     272             : 
+     273           0 :                     if (cur > dltdata->part_num)
+     274           0 :                         dltdata->part_num = cur;
+     275             :                 }
+     276             :             }
+     277             : 
+     278           0 :             globfree(&inner);
+     279             : 
+     280           0 :             ++dltdata->part_num;
+     281             : 
+     282             :         }
+     283             : 
+     284             :         char filename[PATH_MAX + 1];
+     285           0 :         filename[PATH_MAX] = 0;
+     286             : 
+     287           0 :         snprintf(filename, PATH_MAX, "%s.%i.dlt", dltdata->ovaluebase, dltdata->part_num++);
+     288             : 
+     289           0 :         if (rename(dltdata->ovalue, filename) != 0)
+     290           0 :             dlt_vlog(LOG_ERR, "ERROR: rename %s to %s failed with error %s\n",
+     291           0 :                      dltdata->ovalue, filename, strerror(errno));
+     292           0 :         else if (dltdata->vflag)
+     293           0 :             dlt_vlog(LOG_INFO, "Renaming existing file from %s to %s\n",
+     294             :                      dltdata->ovalue, filename);
+     295             :     } /* if (file_already_exists) */
+     296             : 
+     297           0 :     globfree(&outer);
+     298             : 
+     299           0 :     dltdata->ohandle = open(dltdata->ovalue, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+     300           0 :     return dltdata->ohandle;
+     301             : }
+     302             : 
+     303             : 
+     304           0 : void dlt_receive_close_output_file(DltReceiveData *dltdata)
+     305             : {
+     306           0 :     if (dltdata->ohandle) {
+     307           0 :         close(dltdata->ohandle);
+     308           0 :         dltdata->ohandle = -1;
+     309             :     }
+     310           0 : }
+     311             : 
+     312             : 
+     313             : /**
+     314             :  * Main function of tool.
+     315             :  */
+     316           1 : int main(int argc, char *argv[])
+     317             : {
+     318             :     DltReceiveData dltdata;
+     319             :     memset(&dltdata, 0, sizeof(dltdata));
+     320             :     int c;
+     321             :     int index;
+     322             : 
+     323             :     /* Initialize dltdata */
+     324           1 :     dltdata.climit = -1; /* default: -1 = unlimited */
+     325           1 :     dltdata.ohandle = -1;
+     326           1 :     dltdata.part_num = -1;
+     327           1 :     dltdata.port = 3490;
+     328             : 
+     329             :     /* Config signal handler */
+     330             :     struct sigaction act;
+     331             : 
+     332             :     /* Initialize signal handler struct */
+     333             :     memset(&act, 0, sizeof(act));
+     334           1 :     act.sa_handler = signal_handler;
+     335           1 :     sigemptyset(&act.sa_mask);
+     336           1 :     sigaction(SIGHUP, &act, 0);
+     337           1 :     sigaction(SIGTERM, &act, 0);
+     338           1 :     sigaction(SIGINT, &act, 0);
+     339           1 :     sigaction(SIGQUIT, &act, 0);
+     340             : 
+     341             :     /* Fetch command line arguments */
+     342           1 :     opterr = 0;
+     343             : 
+     344           2 :     while ((c = getopt (argc, argv, "vashSRyuxmf:j:o:e:b:c:p:i:")) != -1)
+     345           1 :         switch (c) {
+     346           0 :         case 'v':
+     347             :         {
+     348           0 :             dltdata.vflag = 1;
+     349           0 :             break;
+     350             :         }
+     351           0 :         case 'a':
+     352             :         {
+     353           0 :             dltdata.aflag = 1;
+     354           0 :             break;
+     355             :         }
+     356           0 :         case 's':
+     357             :         {
+     358           0 :             dltdata.sflag = 1;
+     359           0 :             break;
+     360             :         }
+     361           0 :         case 'x':
+     362             :         {
+     363           0 :             dltdata.xflag = 1;
+     364           0 :             break;
+     365             :         }
+     366           0 :         case 'm':
+     367             :         {
+     368           0 :             dltdata.mflag = 1;
+     369           0 :             break;
+     370             :         }
+     371           0 :         case 'h':
+     372             :         {
+     373           0 :             usage();
+     374           0 :             return -1;
+     375             :         }
+     376           0 :         case 'S':
+     377             :         {
+     378           0 :             dltdata.sendSerialHeaderFlag = 1;
+     379           0 :             break;
+     380             :         }
+     381           0 :         case 'R':
+     382             :         {
+     383           0 :             dltdata.resyncSerialHeaderFlag = 1;
+     384           0 :             break;
+     385             :         }
+     386           0 :         case 'y':
+     387             :         {
+     388           0 :             dltdata.yflag = 1;
+     389           0 :             break;
+     390             :         }
+     391           0 :         case 'u':
+     392             :         {
+     393           0 :             dltdata.uflag = 1;
+     394           0 :             break;
+     395             :         }
+     396           0 :         case 'i':
+     397             :         {
+     398           0 :             dltdata.ifaddr = optarg;
+     399           0 :             break;
+     400             :         }
+     401           0 :         case 'f':
+     402             :         {
+     403           0 :             dltdata.fvalue = optarg;
+     404           0 :             break;
+     405             :         }
+     406           0 :         case 'j':
+     407             :         {
+     408             :             #ifdef EXTENDED_FILTERING
+     409             :             dltdata.jvalue = optarg;
+     410             :             break;
+     411             :             #else
+     412           0 :             fprintf (stderr,
+     413             :                      "Extended filtering is not supported. Please build with the corresponding cmake option to use it.\n");
+     414           0 :             return -1;
+     415             :             #endif
+     416             :         }
+     417           1 :         case 'o':
+     418             :         {
+     419           1 :             dltdata.ovalue = optarg;
+     420           1 :             size_t to_copy = strlen(dltdata.ovalue);
+     421             : 
+     422           1 :             if (strcmp(&dltdata.ovalue[to_copy - 4], ".dlt") == 0)
+     423             :                 to_copy = to_copy - 4;
+     424             : 
+     425           1 :             dltdata.ovaluebase = (char *)calloc(1, to_copy + 1);
+     426             : 
+     427           1 :             if (dltdata.ovaluebase == NULL) {
+     428           0 :                 fprintf (stderr, "Memory allocation failed.\n");
+     429           0 :                 return -1;
+     430             :             }
+     431             : 
+     432           1 :             dltdata.ovaluebase[to_copy] = '\0';
+     433           1 :             memcpy(dltdata.ovaluebase, dltdata.ovalue, to_copy);
+     434             :             break;
+     435             :         }
+     436           0 :         case 'e':
+     437             :         {
+     438           0 :             dltdata.evalue = optarg;
+     439           0 :             break;
+     440             :         }
+     441           0 :         case 'b':
+     442             :         {
+     443           0 :             dltdata.bvalue = atoi(optarg);
+     444           0 :             break;
+     445             :         }
+     446           0 :         case 'p':
+     447             :         {
+     448           0 :             dltdata.port = atoi(optarg);
+     449           0 :             break;
+     450             :         }
+     451             : 
+     452           0 :         case 'c':
+     453             :         {
+     454           0 :             dltdata.climit = convert_arg_to_byte_size(optarg);
+     455             : 
+     456           0 :             if (dltdata.climit < -1) {
+     457           0 :                 fprintf (stderr, "Invalid argument for option -c.\n");
+     458             :                 /* unknown or wrong option used, show usage information and terminate */
+     459           0 :                 usage();
+     460           0 :                 return -1;
+     461             :             }
+     462             : 
+     463             :             break;
+     464             :         }
+     465           0 :         case '?':
+     466             :         {
+     467           0 :             if ((optopt == 'o') || (optopt == 'f') || (optopt == 'c'))
+     468           0 :                 fprintf (stderr, "Option -%c requires an argument.\n", optopt);
+     469           0 :             else if (isprint (optopt))
+     470           0 :                 fprintf (stderr, "Unknown option `-%c'.\n", optopt);
+     471             :             else
+     472           0 :                 fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
+     473             : 
+     474             :             /* unknown or wrong option used, show usage information and terminate */
+     475           0 :             usage();
+     476           0 :             return -1;
+     477             :         }
+     478           0 :         default:
+     479             :         {
+     480           0 :             abort ();
+     481             :             return -1;    /*for parasoft */
+     482             :         }
+     483             :         }
+     484             : 
+     485             :     /* Initialize DLT Client */
+     486           1 :     dlt_client_init(&dltclient, dltdata.vflag);
+     487             : 
+     488             :     /* Register callback to be called when message was received */
+     489           1 :     dlt_client_register_message_callback(dlt_receive_message_callback);
+     490             : 
+     491             :     /* Setup DLT Client structure */
+     492           1 :     if(dltdata.uflag) {
+     493           0 :         dltclient.mode = DLT_CLIENT_MODE_UDP_MULTICAST;
+     494             :     }
+     495             :     else {
+     496           1 :         dltclient.mode = dltdata.yflag;
+     497             :     }
+     498             : 
+     499           1 :     if (dltclient.mode == DLT_CLIENT_MODE_TCP || dltclient.mode == DLT_CLIENT_MODE_UDP_MULTICAST) {
+     500           1 :         dltclient.port = dltdata.port;
+     501             : 
+     502             :         unsigned int servIPLength = 1; // Counting the terminating 0 byte
+     503           2 :         for (index = optind; index < argc; index++) {
+     504           1 :             servIPLength += strlen(argv[index]);
+     505           1 :             if (index > optind) {
+     506           0 :                 servIPLength++; // For the comma delimiter
+     507             :             }
+     508             :         }
+     509           1 :         if (servIPLength > 1) {
+     510           1 :             char* servIPString = malloc(servIPLength);
+     511           1 :             strcpy(servIPString, argv[optind]);
+     512             : 
+     513           1 :             for (index = optind + 1; index < argc; index++) {
+     514             :                 strcat(servIPString, ",");
+     515           0 :                 strcat(servIPString, argv[index]);
+     516             :             }
+     517             : 
+     518           1 :             int retval = dlt_client_set_server_ip(&dltclient, servIPString);
+     519           1 :             free(servIPString);
+     520             : 
+     521           1 :             if (retval == -1) {
+     522           0 :                 fprintf(stderr, "set server ip didn't succeed\n");
+     523           0 :                 return -1;
+     524             :             }
+     525             :         }
+     526             : 
+     527           1 :         if (dltclient.servIP == 0) {
+     528             :             /* no hostname selected, show usage and terminate */
+     529           0 :             fprintf(stderr, "ERROR: No hostname selected\n");
+     530           0 :             usage();
+     531           0 :             dlt_client_cleanup(&dltclient, dltdata.vflag);
+     532           0 :             return -1;
+     533             :         }
+     534             : 
+     535           1 :         if (dltdata.ifaddr != 0) {
+     536           0 :             if (dlt_client_set_host_if_address(&dltclient, dltdata.ifaddr) != DLT_RETURN_OK) {
+     537           0 :                 fprintf(stderr, "set host interface address didn't succeed\n");
+     538           0 :                 return -1;
+     539             :             }
+     540             :         }
+     541             :     }
+     542             :     else {
+     543           0 :         for (index = optind; index < argc; index++)
+     544           0 :             if (dlt_client_set_serial_device(&dltclient, argv[index]) == -1) {
+     545           0 :                 fprintf(stderr, "set serial device didn't succeed\n");
+     546           0 :                 return -1;
+     547             :             }
+     548             : 
+     549           0 :         if (dltclient.serialDevice == 0) {
+     550             :             /* no serial device name selected, show usage and terminate */
+     551           0 :             fprintf(stderr, "ERROR: No serial device name specified\n");
+     552           0 :             usage();
+     553           0 :             return -1;
+     554             :         }
+     555             : 
+     556           0 :         dlt_client_setbaudrate(&dltclient, dltdata.bvalue);
+     557             :     }
+     558             : 
+     559             :     /* Update the send and resync serial header flags based on command line option */
+     560           1 :     dltclient.send_serial_header = dltdata.sendSerialHeaderFlag;
+     561           1 :     dltclient.resync_serial_header = dltdata.resyncSerialHeaderFlag;
+     562             : 
+     563             :     /* initialise structure to use DLT file */
+     564           1 :     dlt_file_init(&(dltdata.file), dltdata.vflag);
+     565             : 
+     566             :     /* first parse filter file if filter parameter is used */
+     567           1 :     dlt_filter_init(&(dltdata.filter), dltdata.vflag);
+     568             : 
+     569           1 :     if (dltdata.fvalue) {
+     570           0 :         if (dlt_filter_load(&(dltdata.filter), dltdata.fvalue, dltdata.vflag) < DLT_RETURN_OK) {
+     571           0 :             dlt_file_free(&(dltdata.file), dltdata.vflag);
+     572           0 :             return -1;
+     573             :         }
+     574             : 
+     575           0 :         dlt_file_set_filter(&(dltdata.file), &(dltdata.filter), dltdata.vflag);
+     576             :     }
+     577             : 
+     578             :     #ifdef EXTENDED_FILTERING
+     579             : 
+     580             :     if (dltdata.jvalue) {
+     581             :         if (dlt_json_filter_load(&(dltdata.filter), dltdata.jvalue, dltdata.vflag) < DLT_RETURN_OK) {
+     582             :             dlt_file_free(&(dltdata.file), dltdata.vflag);
+     583             :             return -1;
+     584             :         }
+     585             : 
+     586             :         dlt_file_set_filter(&(dltdata.file), &(dltdata.filter), dltdata.vflag);
+     587             :     }
+     588             : 
+     589             :     #endif
+     590             : 
+     591             :     /* open DLT output file */
+     592           1 :     if (dltdata.ovalue) {
+     593           1 :         if (dltdata.climit > -1) {
+     594           0 :             dlt_vlog(LOG_INFO, "Using file size limit of %" PRId64 "bytes\n",
+     595             :                      dltdata.climit);
+     596           0 :             dltdata.ohandle = dlt_receive_open_output_file(&dltdata);
+     597             :         }
+     598             :         else { /* in case no limit for the output file is given, we simply overwrite any existing file */
+     599           1 :             dltdata.ohandle = open(dltdata.ovalue, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+     600             :         }
+     601             : 
+     602           1 :         if (dltdata.ohandle == -1) {
+     603           0 :             dlt_file_free(&(dltdata.file), dltdata.vflag);
+     604           0 :             fprintf(stderr, "ERROR: Output file %s cannot be opened!\n", dltdata.ovalue);
+     605           0 :             return -1;
+     606             :         }
+     607             :     }
+     608             : 
+     609           1 :     if (dltdata.evalue)
+     610           0 :         dlt_set_id(dltdata.ecuid, dltdata.evalue);
+     611             :     else
+     612           1 :         dlt_set_id(dltdata.ecuid, DLT_RECEIVE_ECU_ID);
+     613             : 
+     614             :     /* Connect to TCP socket or open serial device */
+     615           1 :     if (dlt_client_connect(&dltclient, dltdata.vflag) != DLT_RETURN_ERROR) {
+     616             : 
+     617             :         /* Dlt Client Main Loop */
+     618           1 :         dlt_client_main_loop(&dltclient, &dltdata, dltdata.vflag);
+     619             : 
+     620             :         /* Dlt Client Cleanup */
+     621           1 :         dlt_client_cleanup(&dltclient, dltdata.vflag);
+     622             :     }
+     623             : 
+     624             :     /* dlt-receive cleanup */
+     625           1 :     if (dltdata.ovalue)
+     626           1 :         close(dltdata.ohandle);
+     627             : 
+     628           1 :     free(dltdata.ovaluebase);
+     629             : 
+     630           1 :     dlt_file_free(&(dltdata.file), dltdata.vflag);
+     631             : 
+     632           1 :     dlt_filter_free(&(dltdata.filter), dltdata.vflag);
+     633             : 
+     634           1 :     return 0;
+     635             : }
+     636             : 
+     637         206 : int dlt_receive_message_callback(DltMessage *message, void *data)
+     638             : {
+     639             :     DltReceiveData *dltdata;
+     640             :     static char text[DLT_RECEIVE_BUFSIZE];
+     641             : 
+     642             :     struct iovec iov[2];
+     643             :     int bytes_written;
+     644             : 
+     645         206 :     if ((message == 0) || (data == 0))
+     646             :         return -1;
+     647             : 
+     648             :     dltdata = (DltReceiveData *)data;
+     649             : 
+     650             :     /* prepare storage header */
+     651         206 :     if (DLT_IS_HTYP_WEID(message->standardheader->htyp))
+     652         206 :         dlt_set_storageheader(message->storageheader, message->headerextra.ecu);
+     653             :     else
+     654           0 :         dlt_set_storageheader(message->storageheader, dltdata->ecuid);
+     655             : 
+     656         206 :     if (((dltdata->fvalue || dltdata->jvalue) == 0) ||
+     657           0 :         (dlt_message_filter_check(message, &(dltdata->filter), dltdata->vflag) == DLT_RETURN_TRUE)) {
+     658             :         /* if no filter set or filter is matching display message */
+     659         206 :         if (dltdata->xflag) {
+     660           0 :             dlt_message_print_hex(message, text, DLT_RECEIVE_BUFSIZE, dltdata->vflag);
+     661             :         }
+     662         206 :         else if (dltdata->aflag)
+     663             :         {
+     664             : 
+     665           0 :             dlt_message_header(message, text, DLT_RECEIVE_BUFSIZE, dltdata->vflag);
+     666             : 
+     667             :             printf("%s ", text);
+     668             : 
+     669           0 :             dlt_message_payload(message, text, DLT_RECEIVE_BUFSIZE, DLT_OUTPUT_ASCII, dltdata->vflag);
+     670             : 
+     671             :             printf("[%s]\n", text);
+     672             :         }
+     673         206 :         else if (dltdata->mflag)
+     674             :         {
+     675           0 :             dlt_message_print_mixed_plain(message, text, DLT_RECEIVE_BUFSIZE, dltdata->vflag);
+     676             :         }
+     677         206 :         else if (dltdata->sflag)
+     678             :         {
+     679             : 
+     680           0 :             dlt_message_header(message, text, DLT_RECEIVE_BUFSIZE, dltdata->vflag);
+     681             : 
+     682             :             printf("%s \n", text);
+     683             :         }
+     684             : 
+     685             :         /* if file output enabled write message */
+     686         206 :         if (dltdata->ovalue) {
+     687         206 :             iov[0].iov_base = message->headerbuffer;
+     688         206 :             iov[0].iov_len = (uint32_t)message->headersize;
+     689         206 :             iov[1].iov_base = message->databuffer;
+     690         206 :             iov[1].iov_len = (uint32_t)message->datasize;
+     691             : 
+     692         206 :             if (dltdata->climit > -1) {
+     693           0 :                 uint32_t bytes_to_write = message->headersize + message->datasize;
+     694             : 
+     695           0 :                 if ((bytes_to_write + dltdata->totalbytes > dltdata->climit)) {
+     696             :                     dlt_receive_close_output_file(dltdata);
+     697             : 
+     698           0 :                     if (dlt_receive_open_output_file(dltdata) < 0) {
+     699             :                         printf(
+     700             :                             "ERROR: dlt_receive_message_callback: Unable to open log when maximum filesize was reached!\n");
+     701           0 :                         return -1;
+     702             :                     }
+     703             : 
+     704           0 :                     dltdata->totalbytes = 0;
+     705             :                 }
+     706             :             }
+     707             : 
+     708         206 :             bytes_written = (int)writev(dltdata->ohandle, iov, 2);
+     709             : 
+     710         206 :             dltdata->totalbytes += bytes_written;
+     711             : 
+     712         206 :             if (0 > bytes_written) {
+     713             :                 printf("dlt_receive_message_callback: writev(dltdata->ohandle, iov, 2); returned an error!");
+     714           0 :                 return -1;
+     715             :             }
+     716             :         }
+     717             :     }
+     718             : 
+     719             :     return 0;
+     720             : }
+
+
+
+ + + + +
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..80795c593 --- /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:26762942.4 %
Date:2023-11-29 14:15:44Functions:222975.9 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt-convert.c +
20.1%20.1%
+
20.1 %37 / 18433.3 %1 / 3
dlt-receive.c +
35.7%35.7%
+
35.7 %84 / 23542.9 %3 / 7
dlt-control-common.c +
69.5%69.5%
+
69.5 %146 / 21094.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..98b85f1fc --- /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:26762942.4 %
Date:2023-11-29 14:15:44Functions:222975.9 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt-convert.c +
20.1%20.1%
+
20.1 %37 / 18433.3 %1 / 3
dlt-receive.c +
35.7%35.7%
+
35.7 %84 / 23542.9 %3 / 7
dlt-control-common.c +
69.5%69.5%
+
69.5 %146 / 21094.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..08ef252ee --- /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:26762942.4 %
Date:2023-11-29 14:15:44Functions:222975.9 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_control_callsw_cinjection0
dlt_daemon_control_get_default_log_level0
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_log_level0
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_software_version2
dlt_daemon_control_service_logstorage2
dlt_daemon_control_service_response2
dlt_daemon_control_get_log_info3
dlt_daemon_client_process_control7
dlt_daemon_control_message_connection_info9
dlt_daemon_process_one_s_timer11
dlt_daemon_client_send_control_message16
dlt_daemon_client_send_all_multiple214
dlt_daemon_client_send_message_to_all_client5809
dlt_daemon_client_send5881
+
+
+ + + +
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..82147a90f --- /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:21997122.6 %
Date:2023-11-29 14:15:44Functions:113333.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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

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

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_socket_close0
dlt_daemon_socket_get_send_qeue_max_size0
dlt_daemon_socket_open9
dlt_daemon_socket_send11
dlt_daemon_socket_sendreliable456
+
+
+ + + +
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..6bdd9fa69 --- /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:305752.6 %
Date:2023-11-29 14:15:44Functions:3560.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_socket_close0
dlt_daemon_socket_get_send_qeue_max_size0
dlt_daemon_socket_open9
dlt_daemon_socket_send11
dlt_daemon_socket_sendreliable456
+
+
+ + + +
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..ccccb62fb --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_socket.c.gcov.html @@ -0,0 +1,307 @@ + + + + + + + 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:305752.6 %
Date:2023-11-29 14:15:44Functions:3560.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             : #include "dlt_types.h"
+      52             : #include "dlt-daemon.h"
+      53             : #include "dlt-daemon_cfg.h"
+      54             : #include "dlt_daemon_common_cfg.h"
+      55             : 
+      56             : #include "dlt_daemon_socket.h"
+      57             : 
+      58           9 : int dlt_daemon_socket_open(int *sock, unsigned int servPort, char *ip)
+      59             : {
+      60           9 :     int yes = 1;
+      61             :     int ret_inet_pton = 1;
+      62             :     int lastErrno = 0;
+      63             : 
+      64             : #ifdef DLT_USE_IPv6
+      65             : 
+      66             :     /* create socket */
+      67           9 :     if ((*sock = socket(AF_INET6, SOCK_STREAM, 0)) == -1) {
+      68           0 :         lastErrno = errno;
+      69           0 :         dlt_vlog(LOG_ERR, "dlt_daemon_socket_open: socket() error %d: %s\n", lastErrno,
+      70             :                  strerror(lastErrno));
+      71           0 :         return -1;
+      72             :     }
+      73             : 
+      74             : #else
+      75             : 
+      76             :     if ((*sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
+      77             :         lastErrno = errno;
+      78             :         dlt_vlog(LOG_ERR, "dlt_daemon_socket_open: socket() error %d: %s\n", lastErrno,
+      79             :                  strerror(lastErrno));
+      80             :         return -1;
+      81             :     }
+      82             : 
+      83             : #endif
+      84             : 
+      85           9 :     dlt_vlog(LOG_INFO, "%s: Socket created\n", __FUNCTION__);
+      86             : 
+      87             :     /* setsockpt SO_REUSEADDR */
+      88           9 :     if (setsockopt(*sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) {
+      89           0 :         lastErrno = errno;
+      90           0 :         dlt_vlog(
+      91             :             LOG_ERR,
+      92             :             "dlt_daemon_socket_open: Setsockopt error %d in dlt_daemon_local_connection_init: %s\n",
+      93             :             lastErrno,
+      94             :             strerror(lastErrno));
+      95           0 :         return -1;
+      96             :     }
+      97             : 
+      98             :     /* bind */
+      99             : #ifdef DLT_USE_IPv6
+     100             :     struct sockaddr_in6 forced_addr;
+     101             :     memset(&forced_addr, 0, sizeof(forced_addr));
+     102           9 :     forced_addr.sin6_family = AF_INET6;
+     103           9 :     forced_addr.sin6_port = htons(servPort);
+     104             : 
+     105           9 :     if (0 == strcmp(ip, "0.0.0.0")) {
+     106           9 :         forced_addr.sin6_addr = in6addr_any;
+     107             :     } else {
+     108           0 :         ret_inet_pton = inet_pton(AF_INET6, ip, &forced_addr.sin6_addr);
+     109             :     }
+     110             : 
+     111             : #else
+     112             :     struct sockaddr_in forced_addr;
+     113             :     memset(&forced_addr, 0, sizeof(forced_addr));
+     114             :     forced_addr.sin_family = AF_INET;
+     115             :     forced_addr.sin_port = htons(servPort);
+     116             :     ret_inet_pton = inet_pton(AF_INET, ip, &forced_addr.sin_addr);
+     117             : #endif
+     118             : 
+     119             :     /* inet_pton returns 1 on success */
+     120           0 :     if (ret_inet_pton != 1) {
+     121           0 :         lastErrno = errno;
+     122           0 :         dlt_vlog(
+     123             :             LOG_WARNING,
+     124             :             "dlt_daemon_socket_open: inet_pton() error %d: %s. Cannot convert IP address: %s\n",
+     125             :             lastErrno,
+     126             :             strerror(lastErrno),
+     127             :             ip);
+     128           0 :         return -1;
+     129             :     }
+     130             : 
+     131           9 :     if (bind(*sock, (struct sockaddr *)&forced_addr, sizeof(forced_addr)) == -1) {
+     132           0 :         lastErrno = errno;     /*close() may set errno too */
+     133           0 :         close(*sock);
+     134           0 :         dlt_vlog(LOG_WARNING, "dlt_daemon_socket_open: bind() error %d: %s\n", lastErrno,
+     135             :                  strerror(lastErrno));
+     136           0 :         return -1;
+     137             :     }
+     138             : 
+     139             :     /*listen */
+     140           9 :     dlt_vlog(LOG_INFO, "%s: Listening on ip %s and port: %u\n", __FUNCTION__, ip, servPort);
+     141             : 
+     142             :     /* get socket buffer size */
+     143          18 :     dlt_vlog(LOG_INFO, "dlt_daemon_socket_open: Socket send queue size: %d\n",
+     144             :              dlt_daemon_socket_get_send_qeue_max_size(*sock));
+     145             : 
+     146           9 :     if (listen(*sock, 3) < 0) {
+     147           0 :         lastErrno = errno;
+     148           0 :         dlt_vlog(LOG_WARNING,
+     149             :                  "dlt_daemon_socket_open: listen() failed with error %d: %s\n",
+     150             :                  lastErrno,
+     151             :                  strerror(lastErrno));
+     152           0 :         return -1;
+     153             :     }
+     154             : 
+     155             :     return 0; /* OK */
+     156             : }
+     157             : 
+     158           0 : int dlt_daemon_socket_close(int sock)
+     159             : {
+     160           0 :     close(sock);
+     161             : 
+     162           0 :     return 0;
+     163             : }
+     164             : 
+     165          11 : int dlt_daemon_socket_send(int sock,
+     166             :                            void *data1,
+     167             :                            int size1,
+     168             :                            void *data2,
+     169             :                            int size2,
+     170             :                            char serialheader)
+     171             : {
+     172             :     int ret = DLT_RETURN_OK;
+     173             : 
+     174             :     /* Optional: Send serial header, if requested */
+     175          11 :     if (serialheader) {
+     176           0 :         ret = dlt_daemon_socket_sendreliable(sock,
+     177             :                                              (void *)dltSerialHeader,
+     178             :                                              sizeof(dltSerialHeader));
+     179             : 
+     180           0 :         if (ret != DLT_RETURN_OK) {
+     181             :             return ret;
+     182             :         }
+     183             :     }
+     184             : 
+     185             :     /* Send data */
+     186          11 :     if ((data1 != NULL) && (size1 > 0)) {
+     187          11 :         ret = dlt_daemon_socket_sendreliable(sock, data1, size1);
+     188             : 
+     189          11 :         if (ret != DLT_RETURN_OK) {
+     190             :             return ret;
+     191             :         }
+     192             :     }
+     193             : 
+     194          11 :     if ((data2 != NULL) && (size2 > 0)) {
+     195          11 :         ret = dlt_daemon_socket_sendreliable(sock, data2, size2);
+     196             :     }
+     197             : 
+     198             :     return ret;
+     199             : }
+     200             : 
+     201           0 : int dlt_daemon_socket_get_send_qeue_max_size(int sock)
+     202             : {
+     203           9 :     int n = 0;
+     204           9 :     socklen_t m = sizeof(n);
+     205           9 :     getsockopt(sock, SOL_SOCKET, SO_SNDBUF, (void *)&n, &m);
+     206             : 
+     207           9 :     return n;
+     208             : }
+     209             : 
+     210         456 : int dlt_daemon_socket_sendreliable(int sock, void *data_buffer, int message_size)
+     211             : {
+     212             :     int data_sent = 0;
+     213             : 
+     214         912 :     while (data_sent < message_size) {
+     215         456 :         ssize_t ret = send(sock,
+     216             :                            (uint8_t *)data_buffer + data_sent,
+     217         456 :                            message_size - data_sent,
+     218             :                            0);
+     219             : 
+     220         456 :         if (ret < 0) {
+     221           0 :             dlt_vlog(LOG_WARNING,
+     222           0 :                      "%s: socket send failed [errno: %d]!\n", __func__, errno);
+     223           0 :             return DLT_DAEMON_ERROR_SEND_FAILED;
+     224             :         } else {
+     225         456 :             data_sent += ret;
+     226             :         }
+     227             :     }
+     228             : 
+     229             :     return DLT_DAEMON_ERROR_OK;
+     230             : }
+     231             : 
+
+
+
+ + + + +
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..3afafec92 --- /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:102540.0 %
Date:2023-11-29 14:15:44Functions: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..ea2009cb0 --- /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:102540.0 %
Date:2023-11-29 14:15:44Functions: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..10a41eb21 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_unix_socket.c.gcov.html @@ -0,0 +1,261 @@ + + + + + + + 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:102540.0 %
Date:2023-11-29 14:15:44Functions: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 :     unlink(sock_path);
+     149             : 
+     150             :     /* set appropriate access permissions */
+     151           9 :     old_mask = umask(mask);
+     152             : 
+     153           9 :     if (bind(*sock, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
+     154           0 :         dlt_vlog(LOG_WARNING, "%s: bind() error (%s)\n", __func__,
+     155           0 :                  strerror(errno));
+     156           0 :         return -1;
+     157             :     }
+     158             : 
+     159           9 :     if (listen(*sock, 1) == -1) {
+     160           0 :         dlt_vlog(LOG_WARNING, "%s: listen error (%s)\n", __func__,
+     161           0 :                  strerror(errno));
+     162           0 :         return -1;
+     163             :     }
+     164             : 
+     165             :     /* restore permissions */
+     166           9 :     umask(old_mask);
+     167             : 
+     168             : #ifdef DLT_SYSTEM_SOCKET_ACTIVATION_ENABLE
+     169             :     } // end of: if (!sd_socket_open) {
+     170             : #endif
+     171             : 
+     172             : 
+     173           9 :     return 0;
+     174             : }
+     175             : 
+     176           0 : int dlt_daemon_unix_socket_close(int sock)
+     177             : {
+     178           0 :     int ret = close(sock);
+     179             : 
+     180           0 :     if (ret != 0) {
+     181           0 :         dlt_vlog(LOG_WARNING, "unix socket close failed: %s", strerror(errno));
+     182             :     }
+     183             : 
+     184           0 :     return ret;
+     185             : }
+
+
+
+ + + + +
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..af63d6e4d --- /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:1645341648.2 %
Date:2023-11-29 14:15:44Functions:10715768.2 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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 +
22.6%22.6%
+
22.6 %219 / 97133.3 %11 / 33
dlt_daemon_unix_socket.c +
40.0%40.0%
+
40.0 %10 / 2550.0 %1 / 2
dlt_daemon_socket.c +
52.6%52.6%
+
52.6 %30 / 5760.0 %3 / 5
dlt_daemon_common.c +
56.7%56.7%
+
56.7 %351 / 61971.9 %23 / 32
dlt-daemon.c +
52.9%52.9%
+
52.9 %603 / 113973.8 %31 / 42
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..8e427e29e --- /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:1645341648.2 %
Date:2023-11-29 14:15:44Functions:10715768.2 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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 +
22.6%22.6%
+
22.6 %219 / 97133.3 %11 / 33
dlt_daemon_unix_socket.c +
40.0%40.0%
+
40.0 %10 / 2550.0 %1 / 2
dlt_daemon_socket.c +
52.6%52.6%
+
52.6 %30 / 5760.0 %3 / 5
dlt-daemon.c +
52.9%52.9%
+
52.9 %603 / 113973.8 %31 / 42
dlt_daemon_common.c +
56.7%56.7%
+
56.7 %351 / 61971.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..e383b3dbc --- /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:1645341648.2 %
Date:2023-11-29 14:15:44Functions:10715768.2 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt-daemon.c +
52.9%52.9%
+
52.9 %603 / 113973.8 %31 / 42
dlt_daemon_client.c +
22.6%22.6%
+
22.6 %219 / 97133.3 %11 / 33
dlt_daemon_common.c +
56.7%56.7%
+
56.7 %351 / 61971.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.6%52.6%
+
52.6 %30 / 5760.0 %3 / 5
dlt_daemon_unix_socket.c +
40.0%40.0%
+
40.0 %10 / 2550.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..a6cffee0a --- /dev/null +++ b/dlt_lcov_report/dlt_final_coverage.info @@ -0,0 +1,12562 @@ +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,set_conf +FNDA:2,set_timeout +FNDA:2,dlt_control_callback +FNDA:2,dlt_control_listen_to_daemon +FNDA:2,dlt_control_init_connection +FNDA:2,set_resync_serial_header +FNDA:2,prepare_headers +FNDA:2,get_timeout +FNDA:2,set_send_serial_header +FNDA:2,dlt_parse_config_param +FNDA:4,get_ecuid +FNDA:2,dlt_control_init +FNDA:0,set_verbosity +FNDA:2,prepare_extra_headers +FNDA:2,dlt_control_deinit +FNDA:18,get_verbosity +FNDA:2,dlt_control_prepare_message +FNDA:2,set_ecuid +FNDA:2,dlt_control_send_message +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,16 +DA:207,14 +DA:208,3 +DA:209,3 +DA:210,3 +DA:212,6 +DA:213,6 +DA:215,3 +DA:219,3 +DA:220,3 +DA:223,3 +DA:226,3 +DA:227,3 +DA:228,3 +DA:229,3 +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:667,2 +DA:669,2 +LF:210 +LH:146 +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:180,main +FNDA:35,main +FNDA:0,usage +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: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:155,0 +DA:156,0 +DA:157,0 +DA:159,0 +DA:160,0 +DA:161,0 +DA:162,0 +DA:163,0 +DA:165,0 +DA:171,0 +DA:174,0 +DA:175,0 +DA:180,35 +DA:205,35 +DA:208,35 +DA:211,35 +DA:219,35 +DA:221,70 +DA:222,35 +DA:229,0 +DA:232,0 +DA:234,35 +DA:237,35 +DA:239,0 +DA:242,0 +DA:244,0 +DA:247,0 +DA:249,0 +DA:252,0 +DA:254,0 +DA:257,0 +DA:259,0 +DA:262,0 +DA:264,0 +DA:266,0 +DA:267,0 +DA:269,0 +DA:271,0 +DA:272,0 +DA:274,0 +DA:276,0 +DA:277,0 +DA:279,0 +DA:281,0 +DA:282,0 +DA:284,0 +DA:286,0 +DA:287,0 +DA:289,0 +DA:291,0 +DA:292,0 +DA:293,0 +DA:294,0 +DA:296,0 +DA:299,0 +DA:300,0 +DA:310,35 +DA:313,35 +DA:314,0 +DA:315,0 +DA:316,0 +DA:319,0 +DA:322,35 +DA:325,0 +DA:326,0 +DA:327,0 +DA:328,0 +DA:332,35 +DA:334,0 +DA:335,0 +DA:336,0 +DA:337,0 +DA:338,0 +DA:340,0 +DA:344,0 +DA:345,0 +DA:347,0 +DA:350,0 +DA:354,0 +DA:355,0 +DA:356,0 +DA:357,0 +DA:358,0 +DA:361,0 +DA:362,0 +DA:363,0 +DA:364,0 +DA:369,0 +DA:370,0 +DA:371,0 +DA:372,0 +DA:373,0 +DA:375,0 +DA:379,0 +DA:382,70 +DA:383,35 +DA:386,0 +DA:388,0 +DA:392,35 +DA:393,739 +DA:397,35 +DA:398,35 +DA:403,35 +DA:406,35 +DA:408,35 +DA:409,0 +DA:410,0 +DA:411,0 +DA:413,0 +DA:416,35 +DA:417,0 +DA:418,0 +DA:419,0 +DA:421,0 +DA:424,739 +DA:425,704 +DA:426,0 +DA:428,704 +DA:430,0 +DA:431,0 +DA:433,704 +DA:436,704 +DA:437,0 +DA:441,704 +DA:442,0 +DA:446,0 +DA:448,0 +DA:449,0 +DA:451,0 +DA:454,0 +DA:455,0 +DA:461,704 +DA:462,0 +DA:463,0 +DA:464,0 +DA:465,0 +DA:467,0 +DA:469,0 +DA:471,0 +DA:472,0 +DA:473,0 +DA:478,704 +DA:480,0 +DA:483,0 +DA:486,0 +DA:487,0 +DA:488,0 +DA:500,35 +DA:501,0 +DA:503,0 +DA:504,0 +DA:508,35 +DA:509,0 +DA:511,35 +DA:512,0 +DA:513,0 +DA:514,0 +DA:515,0 +DA:516,0 +DA:518,0 +DA:520,0 +DA:522,35 +DA:524,0 +DA:525,0 +DA:526,0 +DA:529,35 +DA:531,35 +LF:184 +LH:37 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/console/dlt-receive.c +FN:94,signal_handler +FN:144,usage +FN:179,convert_arg_to_byte_size +FN:233,dlt_receive_open_output_file +FN:304,dlt_receive_close_output_file +FN:316,main +FN:637,dlt_receive_message_callback +FNDA:206,dlt_receive_message_callback +FNDA:0,usage +FNDA:1,main +FNDA:1,signal_handler +FNDA:0,dlt_receive_close_output_file +FNDA:0,dlt_receive_open_output_file +FNDA:0,convert_arg_to_byte_size +FNF:7 +FNH:3 +DA:94,1 +DA:96,1 +DA:97,1 +DA:102,1 +DA:103,1 +DA:109,1 +DA:144,0 +DA:148,0 +DA:176,0 +DA:179,0 +DA:186,0 +DA:187,0 +DA:193,0 +DA:199,0 +DA:205,0 +DA:209,0 +DA:218,0 +DA:219,0 +DA:233,0 +DA:238,0 +DA:243,0 +DA:244,0 +DA:246,0 +DA:248,0 +DA:249,0 +DA:259,0 +DA:267,0 +DA:271,0 +DA:273,0 +DA:274,0 +DA:278,0 +DA:280,0 +DA:285,0 +DA:287,0 +DA:289,0 +DA:290,0 +DA:291,0 +DA:292,0 +DA:293,0 +DA:297,0 +DA:299,0 +DA:300,0 +DA:304,0 +DA:306,0 +DA:307,0 +DA:308,0 +DA:310,0 +DA:316,1 +DA:324,1 +DA:325,1 +DA:326,1 +DA:327,1 +DA:334,1 +DA:335,1 +DA:336,1 +DA:337,1 +DA:338,1 +DA:339,1 +DA:342,1 +DA:344,2 +DA:345,1 +DA:346,0 +DA:348,0 +DA:349,0 +DA:351,0 +DA:353,0 +DA:354,0 +DA:356,0 +DA:358,0 +DA:359,0 +DA:361,0 +DA:363,0 +DA:364,0 +DA:366,0 +DA:368,0 +DA:369,0 +DA:371,0 +DA:373,0 +DA:374,0 +DA:376,0 +DA:378,0 +DA:379,0 +DA:381,0 +DA:383,0 +DA:384,0 +DA:386,0 +DA:388,0 +DA:389,0 +DA:391,0 +DA:393,0 +DA:394,0 +DA:396,0 +DA:398,0 +DA:399,0 +DA:401,0 +DA:403,0 +DA:404,0 +DA:406,0 +DA:412,0 +DA:414,0 +DA:417,1 +DA:419,1 +DA:420,1 +DA:422,1 +DA:425,1 +DA:427,1 +DA:428,0 +DA:429,0 +DA:432,1 +DA:433,1 +DA:436,0 +DA:438,0 +DA:439,0 +DA:441,0 +DA:443,0 +DA:444,0 +DA:446,0 +DA:448,0 +DA:449,0 +DA:452,0 +DA:454,0 +DA:456,0 +DA:457,0 +DA:459,0 +DA:460,0 +DA:465,0 +DA:467,0 +DA:468,0 +DA:469,0 +DA:470,0 +DA:472,0 +DA:475,0 +DA:476,0 +DA:478,0 +DA:480,0 +DA:486,1 +DA:489,1 +DA:492,1 +DA:493,0 +DA:496,1 +DA:499,1 +DA:500,1 +DA:503,2 +DA:504,1 +DA:505,1 +DA:506,0 +DA:509,1 +DA:510,1 +DA:511,1 +DA:513,1 +DA:515,0 +DA:518,1 +DA:519,1 +DA:521,1 +DA:522,0 +DA:523,0 +DA:527,1 +DA:529,0 +DA:530,0 +DA:531,0 +DA:532,0 +DA:535,1 +DA:536,0 +DA:537,0 +DA:538,0 +DA:543,0 +DA:544,0 +DA:545,0 +DA:546,0 +DA:549,0 +DA:551,0 +DA:552,0 +DA:553,0 +DA:556,0 +DA:560,1 +DA:561,1 +DA:564,1 +DA:567,1 +DA:569,1 +DA:570,0 +DA:571,0 +DA:572,0 +DA:575,0 +DA:592,1 +DA:593,1 +DA:594,0 +DA:596,0 +DA:599,1 +DA:602,1 +DA:603,0 +DA:604,0 +DA:605,0 +DA:609,1 +DA:610,0 +DA:612,1 +DA:615,1 +DA:618,1 +DA:621,1 +DA:625,1 +DA:626,1 +DA:628,1 +DA:630,1 +DA:632,1 +DA:634,1 +DA:637,206 +DA:645,206 +DA:651,206 +DA:652,206 +DA:654,0 +DA:656,206 +DA:657,0 +DA:659,206 +DA:660,0 +DA:662,206 +DA:665,0 +DA:669,0 +DA:673,206 +DA:675,0 +DA:677,206 +DA:680,0 +DA:686,206 +DA:687,206 +DA:688,206 +DA:689,206 +DA:690,206 +DA:692,206 +DA:693,0 +DA:695,0 +DA:698,0 +DA:701,0 +DA:704,0 +DA:708,206 +DA:710,206 +DA:712,206 +DA:714,0 +LF:235 +LH:84 +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:0,set_handler_type +FNDA:2,prepare_message_body +FNDA:0,get_logstorage_control +FNDA:2,set_default_path +FNDA:2,dlt_logstorage_send_event +FNDA:0,dlt_logstorage_check_config_file +FNDA:2,get_default_path +FNDA:0,dlt_logstorage_get_handler_fd +FNDA:4,get_handler_type +FNDA:0,dlt_logstorage_check_directory_permission +FNDA:0,dlt_logstorage_get_handler_cb +FNDA:2,set_default_event_type +FNDA:0,dlt_logstorage_deinit_handler +FNDA:6,get_default_event_type +FNDA:0,dlt_logstorage_init_handler +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:538,sd_notify +FN:556,main +FNDA:2,parse_args +FNDA:0,dlt_logstorage_must_exit +FNDA:0,dlt_logstorage_ctrl_setup_event_loop +FNDA:0,dlt_logstorage_exit +FNDA:0,catch_signal +FNDA:0,dlt_logstorage_ctrl_execute_event_loop +FNDA:2,main +FNDA:0,usage +FNDA:2,analyze_response +FNDA:0,dlt_logstorage_ctrl_add_event +FNDA:0,sd_notify +FNDA:2,dlt_logstorage_ctrl_single_request +FNDA:0,install_signal_handler +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:463,0 +DA:465,0 +DA:466,0 +DA:468,0 +DA:470,0 +DA:471,0 +DA:473,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:484,0 +DA:486,0 +DA:487,0 +DA:488,0 +DA:491,0 +DA:492,0 +DA:493,0 +DA:494,0 +DA:495,0 +DA:496,0 +DA:497,0 +DA:498,0 +DA:500,2 +DA:501,2 +DA:502,2 +DA:504,0 +DA:505,0 +DA:506,0 +DA:507,0 +DA:508,0 +DA:510,0 +DA:511,0 +DA:513,0 +DA:515,0 +DA:516,0 +DA:517,0 +DA:518,0 +DA:519,0 +DA:524,4 +DA:525,2 +DA:526,0 +DA:527,0 +DA:531,2 +DA:532,0 +DA:538,0 +DA:543,0 +DA:556,2 +DA:560,2 +DA:561,2 +DA:562,2 +DA:565,2 +DA:570,2 +DA:571,2 +DA:573,2 +DA:575,2 +DA:576,0 +DA:579,0 +DA:583,0 +DA:588,0 +DA:589,0 +DA:590,0 +DA:594,0 +DA:595,0 +DA:598,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_store_dev_info +FNDA:0,logstorage_delete_dev_info +FNDA:0,logstorage_find_dev_info +FNDA:0,print_list +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:177,usage +FN:218,option_handling +FN:347,option_file_parser +FN:1033,dlt_mkdir_recursive +FN:1082,dlt_daemon_create_pipes_dir +FN:1125,main +FN:1359,dlt_daemon_local_init_p1 +FN:1420,dlt_daemon_local_init_p2 +FN:1522,dlt_daemon_init_serial +FN:1580,dlt_daemon_init_fifo +FN:1754,dlt_daemon_initialize_control_socket +FN:1801,dlt_daemon_local_connection_init +FN:1917,file_read_everything +FN:1971,file_read_field +FN:2027,dlt_daemon_local_ecu_version_init +FN:2056,dlt_daemon_local_cleanup +FN:2110,dlt_daemon_exit_trigger +FN:2134,dlt_daemon_signal_handler +FN:2183,dlt_daemon_daemonize +FN:2253,dlt_daemon_log_internal +FN:2330,dlt_daemon_check_numeric_setting +FN:2346,dlt_daemon_process_client_connect +FN:2456,dlt_daemon_process_client_messages +FN:2533,dlt_daemon_process_client_messages_serial +FN:2602,dlt_daemon_process_control_connect +FN:2698,dlt_daemon_process_control_messages +FN:2766,dlt_daemon_process_user_message_not_sup +FN:2807,dlt_daemon_process_user_messages +FN:2887,dlt_daemon_process_user_message_overflow +FN:2925,dlt_daemon_send_message_overflow +FN:2945,dlt_daemon_process_user_message_register_application +FN:3063,dlt_daemon_process_user_message_register_context +FN:3271,dlt_daemon_process_user_message_unregister_application +FN:3369,dlt_daemon_process_user_message_unregister_context +FN:3447,dlt_daemon_process_user_message_log +FN:3578,enforce_context_ll_and_ts_keep_message +FN:3603,dlt_daemon_process_user_message_set_app_ll_ts +FN:3679,dlt_daemon_process_user_message_log_mode +FN:3712,dlt_daemon_process_user_message_marker +FN:3742,dlt_daemon_send_ringbuffer_to_client +FN:3846,create_timer_fd +FN:3938,dlt_daemon_close_socket +FNDA:9,dlt_daemon_signal_handler +FNDA:38,dlt_daemon_process_user_message_register_context +FNDA:5,dlt_daemon_close_socket +FNDA:7,dlt_daemon_process_user_message_register_application +FNDA:9,main +FNDA:5809,dlt_daemon_process_user_message_log +FNDA:4,dlt_daemon_process_client_connect +FNDA:2,dlt_daemon_send_ringbuffer_to_client +FNDA:0,file_read_field +FNDA:0,dlt_daemon_process_user_message_not_sup +FNDA:0,enforce_context_ll_and_ts_keep_message +FNDA:9,option_handling +FNDA:9,dlt_daemon_init_serial +FNDA:2,dlt_daemon_process_control_connect +FNDA:9,dlt_daemon_create_pipes_dir +FNDA:9,option_file_parser +FNDA:9,dlt_mkdir_recursive +FNDA:9,dlt_daemon_init_fifo +FNDA:9,dlt_daemon_initialize_control_socket +FNDA:9,dlt_daemon_local_connection_init +FNDA:0,dlt_daemon_send_message_overflow +FNDA:4,dlt_daemon_process_control_messages +FNDA:0,dlt_daemon_process_user_message_overflow +FNDA:0,dlt_daemon_process_user_message_log_mode +FNDA:6,dlt_daemon_process_user_message_unregister_application +FNDA:0,usage +FNDA:9,dlt_daemon_local_init_p1 +FNDA:9,dlt_daemon_local_init_p2 +FNDA:0,file_read_everything +FNDA:0,dlt_daemon_process_client_messages_serial +FNDA:10,create_timer_fd +FNDA:2,dlt_daemon_daemonize +FNDA:0,dlt_daemon_process_user_message_marker +FNDA:9,dlt_daemon_local_cleanup +FNDA:9,dlt_daemon_exit_trigger +FNDA:1282,dlt_daemon_process_user_messages +FNDA:37,dlt_daemon_process_user_message_unregister_context +FNDA:40,dlt_daemon_log_internal +FNDA:3,dlt_daemon_check_numeric_setting +FNDA:9,dlt_daemon_local_ecu_version_init +FNDA:0,dlt_daemon_process_user_message_set_app_ll_ts +FNDA:8,dlt_daemon_process_client_messages +FNF:42 +FNH:31 +DA:177,0 +DA:180,0 +DA:213,0 +DA:218,9 +DA:226,9 +DA:227,0 +DA:228,0 +DA:235,9 +DA:238,9 +DA:245,9 +DA:253,19 +DA:254,10 +DA:255,2 +DA:257,2 +DA:258,2 +DA:260,7 +DA:262,7 +DA:273,0 +DA:275,0 +DA:276,0 +DA:287,1 +DA:289,1 +DA:291,1 +DA:292,0 +DA:293,0 +DA:298,0 +DA:300,0 +DA:301,0 +DA:303,0 +DA:305,0 +DA:310,0 +DA:311,0 +DA:312,0 +DA:314,0 +DA:317,0 +DA:318,0 +DA:320,0 +DA:322,0 +DA:323,0 +DA:330,9 +DA:332,9 +DA:340,9 +DA:347,9 +DA:348,9 +DA:350,9 +DA:351,9 +DA:352,9 +DA:358,9 +DA:359,9 +DA:360,9 +DA:361,9 +DA:362,9 +DA:363,9 +DA:364,9 +DA:365,9 +DA:372,9 +DA:377,9 +DA:378,0 +DA:381,9 +DA:382,9 +DA:383,9 +DA:385,9 +DA:386,9 +DA:387,9 +DA:388,9 +DA:389,9 +DA:390,9 +DA:391,9 +DA:392,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:401,9 +DA:402,9 +DA:404,9 +DA:415,9 +DA:417,9 +DA:418,9 +DA:421,9 +DA:422,9 +DA:423,9 +DA:424,9 +DA:430,9 +DA:431,9 +DA:434,9 +DA:435,7 +DA:440,9 +DA:442,9 +DA:445,116 +DA:446,51 +DA:447,51 +DA:448,51 +DA:450,95 +DA:451,88 +DA:454,88 +DA:455,44 +DA:456,44 +DA:459,44 +DA:460,44 +DA:461,44 +DA:464,44 +DA:467,51 +DA:469,44 +DA:470,0 +DA:473,44 +DA:475,0 +DA:478,44 +DA:480,0 +DA:483,44 +DA:485,0 +DA:488,44 +DA:490,0 +DA:493,44 +DA:495,1 +DA:498,43 +DA:500,0 +DA:503,43 +DA:505,0 +DA:508,43 +DA:510,0 +DA:513,43 +DA:515,0 +DA:518,43 +DA:520,0 +DA:521,0 +DA:524,43 +DA:526,0 +DA:527,0 +DA:530,43 +DA:532,1 +DA:533,1 +DA:536,42 +DA:538,0 +DA:539,0 +DA:542,42 +DA:544,1 +DA:547,41 +DA:549,1 +DA:552,40 +DA:557,1 +DA:560,39 +DA:562,0 +DA:564,39 +DA:566,0 +DA:568,39 +DA:570,0 +DA:572,39 +DA:574,1 +DA:577,38 +DA:579,1 +DA:583,37 +DA:585,1 +DA:589,36 +DA:591,1 +DA:595,35 +DA:597,1 +DA:600,34 +DA:602,0 +DA:605,0 +DA:608,34 +DA:610,0 +DA:613,34 +DA:615,0 +DA:618,34 +DA:620,0 +DA:623,34 +DA:625,0 +DA:628,34 +DA:633,0 +DA:636,34 +DA:640,0 +DA:643,34 +DA:645,0 +DA:648,34 +DA:650,6 +DA:652,28 +DA:654,6 +DA:658,22 +DA:661,6 +DA:662,6 +DA:664,16 +DA:667,0 +DA:668,0 +DA:670,16 +DA:672,0 +DA:673,0 +DA:674,16 +DA:675,6 +DA:677,10 +DA:679,0 +DA:680,0 +DA:681,0 +DA:684,10 +DA:695,2 +DA:697,1 +DA:700,1 +DA:711,0 +DA:715,0 +DA:716,0 +DA:720,0 +DA:727,0 +DA:731,0 +DA:732,0 +DA:736,0 +DA:743,0 +DA:747,0 +DA:748,0 +DA:752,0 +DA:759,0 +DA:761,0 +DA:768,0 +DA:771,0 +DA:801,0 +DA:806,0 +DA:808,0 +DA:809,0 +DA:811,0 +DA:812,0 +DA:813,0 +DA:814,0 +DA:817,0 +DA:820,0 +DA:823,0 +DA:825,0 +DA:826,0 +DA:828,0 +DA:829,0 +DA:830,0 +DA:831,0 +DA:834,0 +DA:837,0 +DA:839,0 +DA:844,0 +DA:847,0 +DA:848,0 +DA:851,0 +DA:860,7 +DA:863,2 +DA:1033,9 +DA:1042,9 +DA:1044,9 +DA:1045,0 +DA:1047,9 +DA:1049,36 +DA:1050,27 +DA:1051,0 +DA:1053,0 +DA:1054,0 +DA:1062,0 +DA:1067,9 +DA:1068,9 +DA:1075,9 +DA:1078,9 +DA:1082,9 +DA:1086,9 +DA:1087,0 +DA:1088,0 +DA:1092,9 +DA:1095,9 +DA:1096,0 +DA:1101,0 +DA:1105,9 +DA:1109,9 +DA:1110,0 +DA:1113,0 +DA:1115,0 +DA:1125,9 +DA:1137,9 +DA:1138,0 +DA:1139,0 +DA:1141,0 +DA:1145,9 +DA:1146,0 +DA:1147,0 +DA:1149,0 +DA:1153,9 +DA:1154,9 +DA:1156,9 +DA:1157,9 +DA:1161,9 +DA:1162,0 +DA:1179,9 +DA:1181,9 +DA:1183,9 +DA:1188,9 +DA:1189,0 +DA:1190,0 +DA:1202,9 +DA:1203,0 +DA:1204,0 +DA:1209,9 +DA:1211,0 +DA:1212,0 +DA:1216,9 +DA:1217,0 +DA:1218,0 +DA:1223,9 +DA:1224,0 +DA:1225,0 +DA:1232,9 +DA:1235,9 +DA:1236,0 +DA:1237,0 +DA:1251,9 +DA:1252,6 +DA:1257,0 +DA:1280,9 +DA:1283,9 +DA:1284,9 +DA:1285,0 +DA:1288,9 +DA:1289,1 +DA:1290,0 +DA:1291,0 +DA:1295,1 +DA:1304,9 +DA:1305,0 +DA:1307,9 +DA:1309,9 +DA:1318,9 +DA:1319,0 +DA:1320,0 +DA:1322,0 +DA:1324,9 +DA:1330,1331 +DA:1331,1322 +DA:1335,9 +DA:1337,9 +DA:1339,9 +DA:1341,9 +DA:1347,9 +DA:1349,9 +DA:1351,9 +DA:1353,9 +DA:1355,9 +DA:1359,9 +DA:1361,9 +DA:1364,9 +DA:1365,0 +DA:1366,0 +DA:1388,9 +DA:1394,9 +DA:1395,2 +DA:1398,9 +DA:1400,9 +DA:1401,0 +DA:1403,0 +DA:1404,0 +DA:1407,9 +DA:1409,9 +DA:1410,9 +DA:1411,9 +DA:1412,9 +DA:1417,9 +DA:1420,9 +DA:1422,9 +DA:1424,9 +DA:1425,0 +DA:1426,0 +DA:1430,9 +DA:1431,9 +DA:1435,0 +DA:1436,0 +DA:1440,9 +DA:1441,0 +DA:1442,0 +DA:1443,0 +DA:1446,0 +DA:1450,0 +DA:1451,0 +DA:1456,9 +DA:1457,6 +DA:1459,6 +DA:1460,0 +DA:1461,0 +DA:1468,9 +DA:1469,1 +DA:1471,8 +DA:1474,9 +DA:1495,9 +DA:1496,0 +DA:1497,0 +DA:1501,9 +DA:1502,0 +DA:1505,9 +DA:1506,9 +DA:1508,9 +DA:1509,0 +DA:1510,0 +DA:1513,9 +DA:1517,9 +DA:1519,9 +DA:1522,9 +DA:1528,9 +DA:1531,0 +DA:1533,0 +DA:1534,0 +DA:1537,0 +DA:1538,0 +DA:1541,0 +DA:1544,0 +DA:1545,0 +DA:1547,0 +DA:1549,0 +DA:1550,0 +DA:1551,0 +DA:1553,0 +DA:1554,0 +DA:1556,0 +DA:1559,0 +DA:1560,0 +DA:1563,0 +DA:1564,0 +DA:1567,0 +DA:1568,0 +DA:1569,0 +DA:1572,0 +DA:1580,9 +DA:1587,9 +DA:1590,9 +DA:1591,9 +DA:1593,9 +DA:1595,9 +DA:1596,0 +DA:1597,0 +DA:1598,0 +DA:1602,9 +DA:1603,0 +DA:1604,0 +DA:1606,0 +DA:1607,0 +DA:1609,0 +DA:1610,0 +DA:1614,0 +DA:1616,0 +DA:1621,0 +DA:1629,9 +DA:1630,0 +DA:1631,0 +DA:1632,0 +DA:1639,9 +DA:1641,0 +DA:1642,0 +DA:1646,9 +DA:1647,0 +DA:1649,9 +DA:1656,9 +DA:1754,9 +DA:1759,9 +DA:1761,9 +DA:1762,0 +DA:1763,0 +DA:1782,9 +DA:1783,9 +DA:1787,9 +DA:1788,9 +DA:1793,0 +DA:1801,9 +DA:1805,9 +DA:1807,9 +DA:1809,9 +DA:1810,0 +DA:1811,0 +DA:1814,9 +DA:1825,9 +DA:1826,0 +DA:1827,0 +DA:1840,9 +DA:1842,9 +DA:1844,9 +DA:1845,9 +DA:1850,0 +DA:1851,0 +DA:1855,0 +DA:1856,0 +DA:1861,0 +DA:1863,0 +DA:1864,0 +DA:1869,0 +DA:1875,0 +DA:1878,0 +DA:1881,0 +DA:1882,0 +DA:1883,0 +DA:1903,9 +DA:1904,0 +DA:1905,0 +DA:1909,9 +DA:1910,0 +DA:1911,0 +DA:1917,0 +DA:1919,0 +DA:1924,0 +DA:1925,0 +DA:1926,0 +DA:1927,0 +DA:1928,0 +DA:1929,0 +DA:1933,0 +DA:1934,0 +DA:1935,0 +DA:1936,0 +DA:1937,0 +DA:1940,0 +DA:1941,0 +DA:1942,0 +DA:1943,0 +DA:1944,0 +DA:1948,0 +DA:1949,0 +DA:1951,0 +DA:1952,0 +DA:1953,0 +DA:1954,0 +DA:1955,0 +DA:1958,0 +DA:1959,0 +DA:1960,0 +DA:1961,0 +DA:1962,0 +DA:1966,0 +DA:1968,0 +DA:1971,0 +DA:1973,0 +DA:1978,0 +DA:1982,0 +DA:1983,0 +DA:1987,0 +DA:1995,0 +DA:1996,0 +DA:1997,0 +DA:2001,0 +DA:2002,0 +DA:2003,0 +DA:2009,0 +DA:2012,0 +DA:2013,0 +DA:2017,0 +DA:2018,0 +DA:2022,0 +DA:2024,0 +DA:2027,9 +DA:2031,9 +DA:2034,9 +DA:2037,9 +DA:2039,9 +DA:2041,9 +DA:2042,9 +DA:2045,0 +DA:2046,0 +DA:2048,0 +DA:2051,0 +DA:2053,0 +DA:2056,9 +DA:2058,9 +DA:2060,9 +DA:2061,0 +DA:2062,0 +DA:2066,9 +DA:2068,9 +DA:2071,9 +DA:2072,0 +DA:2075,9 +DA:2079,9 +DA:2092,9 +DA:2094,6 +DA:2098,6 +DA:2101,9 +DA:2102,9 +DA:2104,9 +DA:2107,9 +DA:2110,9 +DA:2113,9 +DA:2116,9 +DA:2119,9 +DA:2120,9 +DA:2121,0 +DA:2125,9 +DA:2132,9 +DA:2134,9 +DA:2136,9 +DA:2138,9 +DA:2139,9 +DA:2145,9 +DA:2147,9 +DA:2148,9 +DA:2157,9 +DA:2183,2 +DA:2188,2 +DA:2190,2 +DA:2193,2 +DA:2195,4 +DA:2196,0 +DA:2197,0 +DA:2200,4 +DA:2201,2 +DA:2208,2 +DA:2209,0 +DA:2210,0 +DA:2216,2 +DA:2218,2 +DA:2219,0 +DA:2222,2 +DA:2223,0 +DA:2225,2 +DA:2228,0 +DA:2229,0 +DA:2233,2 +DA:2236,2 +DA:2237,0 +DA:2240,2 +DA:2241,2 +DA:2242,2 +DA:2243,2 +DA:2245,2 +DA:2253,40 +DA:2255,40 +DA:2262,40 +DA:2265,40 +DA:2266,40 +DA:2269,40 +DA:2270,40 +DA:2272,40 +DA:2276,40 +DA:2281,40 +DA:2282,40 +DA:2283,40 +DA:2286,40 +DA:2287,40 +DA:2288,40 +DA:2289,40 +DA:2291,40 +DA:2292,40 +DA:2293,40 +DA:2296,40 +DA:2297,40 +DA:2298,40 +DA:2300,40 +DA:2301,40 +DA:2303,40 +DA:2304,0 +DA:2305,0 +DA:2310,40 +DA:2311,40 +DA:2312,40 +DA:2313,40 +DA:2314,40 +DA:2317,40 +DA:2319,40 +DA:2322,40 +DA:2323,40 +DA:2325,40 +DA:2327,40 +DA:2330,3 +DA:2333,3 +DA:2334,3 +DA:2335,3 +DA:2336,3 +DA:2337,3 +DA:2338,0 +DA:2341,0 +DA:2346,4 +DA:2355,4 +DA:2357,4 +DA:2359,4 +DA:2360,0 +DA:2363,0 +DA:2367,4 +DA:2369,4 +DA:2370,0 +DA:2372,0 +DA:2373,0 +DA:2379,4 +DA:2380,4 +DA:2384,4 +DA:2385,4 +DA:2387,4 +DA:2392,0 +DA:2394,4 +DA:2399,0 +DA:2400,0 +DA:2401,0 +DA:2405,4 +DA:2413,4 +DA:2415,0 +DA:2420,0 +DA:2421,0 +DA:2427,4 +DA:2431,4 +DA:2433,4 +DA:2435,4 +DA:2436,2 +DA:2437,0 +DA:2439,2 +DA:2441,2 +DA:2442,0 +DA:2443,0 +DA:2445,0 +DA:2449,2 +DA:2450,2 +DA:2456,8 +DA:2464,8 +DA:2466,8 +DA:2467,0 +DA:2470,0 +DA:2473,8 +DA:2475,8 +DA:2476,0 +DA:2480,0 +DA:2484,13 +DA:2485,13 +DA:2486,13 +DA:2488,13 +DA:2490,5 +DA:2491,5 +DA:2492,5 +DA:2498,5 +DA:2499,5 +DA:2502,5 +DA:2505,5 +DA:2506,0 +DA:2508,5 +DA:2509,0 +DA:2511,0 +DA:2515,8 +DA:2516,0 +DA:2518,0 +DA:2521,8 +DA:2525,1 +DA:2533,0 +DA:2540,0 +DA:2542,0 +DA:2543,0 +DA:2546,0 +DA:2549,0 +DA:2550,0 +DA:2553,0 +DA:2557,0 +DA:2558,0 +DA:2559,0 +DA:2561,0 +DA:2563,0 +DA:2564,0 +DA:2570,0 +DA:2571,0 +DA:2575,0 +DA:2576,0 +DA:2579,0 +DA:2582,0 +DA:2583,0 +DA:2585,0 +DA:2586,0 +DA:2588,0 +DA:2592,0 +DA:2593,0 +DA:2596,0 +DA:2602,2 +DA:2612,2 +DA:2614,2 +DA:2615,0 +DA:2618,0 +DA:2622,2 +DA:2624,2 +DA:2625,0 +DA:2626,0 +DA:2632,2 +DA:2633,2 +DA:2635,2 +DA:2640,0 +DA:2642,0 +DA:2645,2 +DA:2646,0 +DA:2698,4 +DA:2706,4 +DA:2708,4 +DA:2709,0 +DA:2712,0 +DA:2715,4 +DA:2716,2 +DA:2723,2 +DA:2727,4 +DA:2729,4 +DA:2730,4 +DA:2732,4 +DA:2734,2 +DA:2735,2 +DA:2736,2 +DA:2741,2 +DA:2742,2 +DA:2745,2 +DA:2748,2 +DA:2749,0 +DA:2751,2 +DA:2752,0 +DA:2754,0 +DA:2758,2 +DA:2759,0 +DA:2760,0 +DA:2766,0 +DA:2771,0 +DA:2775,0 +DA:2777,0 +DA:2781,0 +DA:2782,0 +DA:2785,0 +DA:2807,1282 +DA:2818,1282 +DA:2820,1282 +DA:2821,0 +DA:2824,0 +DA:2827,1282 +DA:2829,1282 +DA:2830,0 +DA:2834,0 +DA:2836,1282 +DA:2837,0 +DA:2839,0 +DA:2843,7179 +DA:2847,5897 +DA:2849,5897 +DA:2850,0 +DA:2852,0 +DA:2853,0 +DA:2857,5897 +DA:2861,5897 +DA:2862,0 +DA:2864,5897 +DA:2867,5897 +DA:2869,5897 +DA:2877,1282 +DA:2878,0 +DA:2881,0 +DA:2887,0 +DA:2895,0 +DA:2897,0 +DA:2898,0 +DA:2900,0 +DA:2903,0 +DA:2912,0 +DA:2920,0 +DA:2925,0 +DA:2928,0 +DA:2930,0 +DA:2931,0 +DA:2932,0 +DA:2936,0 +DA:2937,0 +DA:2940,0 +DA:2945,7 +DA:2955,7 +DA:2960,7 +DA:2962,7 +DA:2963,0 +DA:2965,0 +DA:2969,7 +DA:2975,7 +DA:2980,7 +DA:2984,7 +DA:2987,7 +DA:2989,7 +DA:2991,0 +DA:2995,7 +DA:2997,7 +DA:2998,0 +DA:3009,7 +DA:3011,7 +DA:3014,7 +DA:3015,0 +DA:3016,0 +DA:3019,7 +DA:3021,7 +DA:3022,0 +DA:3024,7 +DA:3025,0 +DA:3027,7 +DA:3036,7 +DA:3038,7 +DA:3039,0 +DA:3041,0 +DA:3043,7 +DA:3045,7 +DA:3047,7 +DA:3050,7 +DA:3053,7 +DA:3057,7 +DA:3063,38 +DA:3071,38 +DA:3079,38 +DA:3081,38 +DA:3082,0 +DA:3084,0 +DA:3088,38 +DA:3093,38 +DA:3098,38 +DA:3102,38 +DA:3105,38 +DA:3107,38 +DA:3108,0 +DA:3113,38 +DA:3115,38 +DA:3116,0 +DA:3127,38 +DA:3129,38 +DA:3132,38 +DA:3133,0 +DA:3134,0 +DA:3137,38 +DA:3139,38 +DA:3142,38 +DA:3143,0 +DA:3149,0 +DA:3153,38 +DA:3154,38 +DA:3157,0 +DA:3164,38 +DA:3165,38 +DA:3168,0 +DA:3174,38 +DA:3177,38 +DA:3178,38 +DA:3185,38 +DA:3186,0 +DA:3189,0 +DA:3192,38 +DA:3194,38 +DA:3197,38 +DA:3198,38 +DA:3201,38 +DA:3202,0 +DA:3204,38 +DA:3207,38 +DA:3209,33 +DA:3210,33 +DA:3211,33 +DA:3215,5 +DA:3218,38 +DA:3220,0 +DA:3221,0 +DA:3222,0 +DA:3225,0 +DA:3227,0 +DA:3228,0 +DA:3229,0 +DA:3232,0 +DA:3233,0 +DA:3234,0 +DA:3237,0 +DA:3238,0 +DA:3239,0 +DA:3244,0 +DA:3245,0 +DA:3246,0 +DA:3247,0 +DA:3248,0 +DA:3250,0 +DA:3252,0 +DA:3255,38 +DA:3256,38 +DA:3258,38 +DA:3259,0 +DA:3263,0 +DA:3271,6 +DA:3283,6 +DA:3285,6 +DA:3286,0 +DA:3289,0 +DA:3292,6 +DA:3299,6 +DA:3301,6 +DA:3304,6 +DA:3308,6 +DA:3313,6 +DA:3317,6 +DA:3318,0 +DA:3320,6 +DA:3321,0 +DA:3323,0 +DA:3325,0 +DA:3329,0 +DA:3331,0 +DA:3332,0 +DA:3334,0 +DA:3340,6 +DA:3344,0 +DA:3346,0 +DA:3348,0 +DA:3351,6 +DA:3357,6 +DA:3361,6 +DA:3369,37 +DA:3378,37 +DA:3380,37 +DA:3381,0 +DA:3385,0 +DA:3388,37 +DA:3395,37 +DA:3398,37 +DA:3405,37 +DA:3407,37 +DA:3408,0 +DA:3413,0 +DA:3416,37 +DA:3424,37 +DA:3425,0 +DA:3430,37 +DA:3435,37 +DA:3436,0 +DA:3447,5809 +DA:3455,5809 +DA:3457,5809 +DA:3458,0 +DA:3459,0 +DA:3513,5809 +DA:3514,5809 +DA:3515,5809 +DA:3519,5809 +DA:3520,0 +DA:3528,0 +DA:3530,0 +DA:3538,0 +DA:3541,0 +DA:3550,0 +DA:3557,0 +DA:3558,5809 +DA:3561,5809 +DA:3562,5809 +DA:3565,5809 +DA:3568,5809 +DA:3569,0 +DA:3570,0 +DA:3578,0 +DA:3584,5809 +DA:3585,0 +DA:3589,0 +DA:3600,0 +DA:3603,0 +DA:3616,0 +DA:3618,0 +DA:3619,0 +DA:3622,0 +DA:3625,0 +DA:3627,0 +DA:3632,0 +DA:3639,0 +DA:3641,0 +DA:3646,0 +DA:3650,0 +DA:3651,0 +DA:3653,0 +DA:3654,0 +DA:3656,0 +DA:3657,0 +DA:3658,0 +DA:3660,0 +DA:3661,0 +DA:3664,0 +DA:3665,0 +DA:3668,0 +DA:3669,0 +DA:3679,0 +DA:3687,0 +DA:3689,0 +DA:3690,0 +DA:3691,0 +DA:3696,0 +DA:3704,0 +DA:3707,0 +DA:3709,0 +DA:3712,0 +DA:3719,0 +DA:3721,0 +DA:3722,0 +DA:3724,0 +DA:3729,0 +DA:3737,0 +DA:3739,0 +DA:3742,2 +DA:3751,2 +DA:3753,2 +DA:3754,0 +DA:3755,0 +DA:3758,2 +DA:3759,0 +DA:3760,0 +DA:3771,4 +DA:3783,4 +DA:3784,4 +DA:3786,0 +DA:3788,4 +DA:3790,4 +DA:3791,0 +DA:3793,4 +DA:3794,2 +DA:3795,2 +DA:3846,10 +DA:3854,10 +DA:3855,0 +DA:3856,0 +DA:3859,10 +DA:3861,10 +DA:3862,0 +DA:3863,0 +DA:3866,10 +DA:3868,0 +DA:3874,10 +DA:3876,10 +DA:3877,0 +DA:3878,0 +DA:3880,10 +DA:3881,10 +DA:3882,10 +DA:3883,10 +DA:3885,10 +DA:3886,0 +DA:3887,0 +DA:3930,10 +DA:3934,10 +DA:3938,5 +DA:3940,5 +DA:3942,5 +DA:3944,5 +DA:3945,0 +DA:3946,0 +DA:3950,5 +DA:3954,5 +DA:3956,3 +DA:3957,3 +DA:3962,3 +DA:3963,3 +DA:3966,5 +DA:3973,5 +DA:3977,5 +DA:3978,5 +DA:3980,5 +LF:1139 +LH:603 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/daemon/dlt_daemon_client.c +FN:103,dlt_daemon_client_send_all_multiple +FN:163,dlt_daemon_client_send +FN:315,dlt_daemon_client_send_message_to_all_client +FN:389,dlt_daemon_client_send_control_message +FN:473,dlt_daemon_client_process_control +FN:735,dlt_daemon_control_get_software_version +FN:796,dlt_daemon_control_get_default_log_level +FN:851,dlt_daemon_control_get_log_info +FN:1219,dlt_daemon_control_message_buffer_overflow +FN:1280,dlt_daemon_control_service_response +FN:1326,dlt_daemon_control_message_unregister_context +FN:1381,dlt_daemon_control_message_connection_info +FN:1434,dlt_daemon_control_message_timezone +FN:1489,dlt_daemon_control_message_marker +FN:1535,dlt_daemon_control_callsw_cinjection +FN:1660,dlt_daemon_send_log_level +FN:1686,dlt_daemon_find_multiple_context_and_send_log_level +FN:1734,dlt_daemon_control_set_log_level +FN:1833,dlt_daemon_send_trace_status +FN:1859,dlt_daemon_find_multiple_context_and_send_trace_status +FN:1907,dlt_daemon_control_set_trace_status +FN:2005,dlt_daemon_control_set_default_log_level +FN:2042,dlt_daemon_control_set_all_log_level +FN:2083,dlt_daemon_control_set_default_trace_status +FN:2121,dlt_daemon_control_set_all_trace_status +FN:2161,dlt_daemon_control_set_timing_packets +FN:2190,dlt_daemon_control_message_time +FN:2264,dlt_daemon_process_one_s_timer +FN:2309,dlt_daemon_process_sixty_s_timer +FN:2400,dlt_daemon_process_systemd_timer +FN:2416,dlt_daemon_control_service_logstorage +FN:2653,dlt_daemon_control_passive_node_connect +FN:2710,dlt_daemon_control_passive_node_connect_status +FNDA:2,dlt_daemon_control_service_logstorage +FNDA:0,dlt_daemon_control_set_all_log_level +FNDA:0,dlt_daemon_control_get_default_log_level +FNDA:0,dlt_daemon_process_systemd_timer +FNDA:0,dlt_daemon_control_message_unregister_context +FNDA:0,dlt_daemon_control_set_default_log_level +FNDA:11,dlt_daemon_process_one_s_timer +FNDA:9,dlt_daemon_control_message_connection_info +FNDA:5881,dlt_daemon_client_send +FNDA:0,dlt_daemon_control_message_timezone +FNDA:3,dlt_daemon_control_get_log_info +FNDA:5809,dlt_daemon_client_send_message_to_all_client +FNDA:0,dlt_daemon_control_message_marker +FNDA:0,dlt_daemon_control_set_log_level +FNDA:214,dlt_daemon_client_send_all_multiple +FNDA:0,dlt_daemon_control_set_default_trace_status +FNDA:0,dlt_daemon_send_log_level +FNDA:2,dlt_daemon_control_service_response +FNDA:0,dlt_daemon_send_trace_status +FNDA:2,dlt_daemon_control_get_software_version +FNDA:0,dlt_daemon_control_set_trace_status +FNDA:0,dlt_daemon_find_multiple_context_and_send_trace_status +FNDA:0,dlt_daemon_control_message_buffer_overflow +FNDA:16,dlt_daemon_client_send_control_message +FNDA:0,dlt_daemon_control_message_time +FNDA:0,dlt_daemon_control_set_timing_packets +FNDA:0,dlt_daemon_control_passive_node_connect_status +FNDA:0,dlt_daemon_control_passive_node_connect +FNDA:0,dlt_daemon_find_multiple_context_and_send_log_level +FNDA:0,dlt_daemon_process_sixty_s_timer +FNDA:0,dlt_daemon_control_callsw_cinjection +FNDA:7,dlt_daemon_client_process_control +FNDA:0,dlt_daemon_control_set_all_trace_status +FNF:33 +FNH:11 +DA:80,0 +DA:103,214 +DA:118,214 +DA:120,214 +DA:121,0 +DA:122,0 +DA:125,1286 +DA:127,1072 +DA:128,1072 +DA:130,1072 +DA:131,1072 +DA:132,856 +DA:133,856 +DA:136,216 +DA:143,216 +DA:144,0 +DA:145,0 +DA:151,216 +DA:152,0 +DA:163,5881 +DA:178,5881 +DA:179,0 +DA:180,0 +DA:183,5881 +DA:185,11 +DA:186,0 +DA:187,0 +DA:188,0 +DA:189,0 +DA:190,0 +DA:193,11 +DA:194,11 +DA:195,11 +DA:196,0 +DA:197,0 +DA:201,11 +DA:208,5870 +DA:209,5866 +DA:210,0 +DA:211,0 +DA:215,0 +DA:216,0 +DA:217,0 +DA:227,5866 +DA:228,5839 +DA:239,5870 +DA:254,5870 +DA:256,415 +DA:257,214 +DA:265,214 +DA:273,5870 +DA:274,5866 +DA:276,5455 +DA:278,5455 +DA:279,5455 +DA:280,0 +DA:283,5455 +DA:284,0 +DA:285,0 +DA:286,0 +DA:288,0 +DA:291,415 +DA:292,0 +DA:293,0 +DA:294,0 +DA:295,0 +DA:298,0 +DA:300,0 +DA:304,0 +DA:305,0 +DA:315,5809 +DA:322,5809 +DA:324,5809 +DA:325,0 +DA:326,0 +DA:330,5809 +DA:331,0 +DA:334,0 +DA:337,0 +DA:338,0 +DA:340,0 +DA:344,0 +DA:345,0 +DA:349,5809 +DA:350,5809 +DA:352,0 +DA:355,5809 +DA:356,0 +DA:358,0 +DA:359,0 +DA:363,5809 +DA:364,0 +DA:365,0 +DA:367,0 +DA:368,5809 +DA:369,0 +DA:370,0 +DA:372,0 +DA:373,5809 +DA:374,0 +DA:375,0 +DA:377,0 +DA:381,5809 +DA:382,5809 +DA:384,5809 +DA:385,5809 +DA:389,16 +DA:400,16 +DA:402,16 +DA:406,16 +DA:408,16 +DA:412,16 +DA:413,16 +DA:419,16 +DA:422,16 +DA:426,16 +DA:428,16 +DA:431,16 +DA:432,16 +DA:433,16 +DA:434,16 +DA:436,16 +DA:438,16 +DA:439,16 +DA:441,0 +DA:443,16 +DA:444,16 +DA:446,0 +DA:449,16 +DA:450,16 +DA:452,16 +DA:454,16 +DA:455,0 +DA:456,0 +DA:459,16 +DA:461,16 +DA:462,16 +DA:464,16 +DA:465,16 +DA:466,0 +DA:467,0 +DA:473,7 +DA:482,7 +DA:484,7 +DA:487,7 +DA:490,7 +DA:493,7 +DA:494,0 +DA:495,0 +DA:502,7 +DA:503,7 +DA:505,7 +DA:507,7 +DA:508,0 +DA:510,0 +DA:511,0 +DA:513,0 +DA:515,0 +DA:516,0 +DA:518,3 +DA:520,3 +DA:521,3 +DA:523,0 +DA:525,0 +DA:526,0 +DA:528,0 +DA:530,0 +DA:531,0 +DA:532,0 +DA:537,0 +DA:544,0 +DA:553,0 +DA:559,0 +DA:561,0 +DA:562,0 +DA:563,0 +DA:568,0 +DA:569,0 +DA:571,0 +DA:573,0 +DA:579,0 +DA:581,0 +DA:583,0 +DA:589,0 +DA:591,0 +DA:593,0 +DA:599,0 +DA:601,0 +DA:603,0 +DA:609,0 +DA:611,0 +DA:613,0 +DA:614,0 +DA:616,0 +DA:619,0 +DA:620,0 +DA:622,0 +DA:624,0 +DA:630,0 +DA:632,0 +DA:634,0 +DA:640,0 +DA:642,0 +DA:644,0 +DA:650,0 +DA:652,0 +DA:654,0 +DA:660,0 +DA:662,0 +DA:664,0 +DA:665,0 +DA:667,0 +DA:669,0 +DA:670,0 +DA:672,2 +DA:674,2 +DA:675,2 +DA:677,0 +DA:679,0 +DA:681,0 +DA:683,2 +DA:685,2 +DA:686,2 +DA:688,0 +DA:690,0 +DA:695,0 +DA:697,0 +DA:699,0 +DA:703,0 +DA:705,0 +DA:707,0 +DA:708,0 +DA:710,0 +DA:712,0 +DA:713,0 +DA:715,0 +DA:717,0 +DA:723,0 +DA:729,0 +DA:735,2 +DA:741,2 +DA:743,2 +DA:744,0 +DA:747,2 +DA:748,0 +DA:754,0 +DA:758,2 +DA:761,2 +DA:763,2 +DA:764,0 +DA:765,0 +DA:768,2 +DA:769,2 +DA:770,2 +DA:773,2 +DA:774,0 +DA:780,0 +DA:784,2 +DA:785,2 +DA:786,2 +DA:787,2 +DA:790,2 +DA:793,2 +DA:796,0 +DA:801,0 +DA:803,0 +DA:804,0 +DA:807,0 +DA:808,0 +DA:814,0 +DA:817,0 +DA:819,0 +DA:820,0 +DA:821,0 +DA:824,0 +DA:825,0 +DA:826,0 +DA:829,0 +DA:830,0 +DA:836,0 +DA:840,0 +DA:841,0 +DA:842,0 +DA:845,0 +DA:848,0 +DA:851,3 +DA:863,3 +DA:882,3 +DA:884,3 +DA:885,0 +DA:887,3 +DA:890,3 +DA:892,3 +DA:896,3 +DA:899,3 +DA:900,0 +DA:906,0 +DA:910,3 +DA:911,0 +DA:917,0 +DA:920,3 +DA:921,0 +DA:922,0 +DA:926,0 +DA:929,0 +DA:930,0 +DA:932,0 +DA:936,0 +DA:939,0 +DA:949,3 +DA:950,3 +DA:961,3 +DA:965,3 +DA:966,3 +DA:968,3 +DA:969,3 +DA:971,3 +DA:974,3 +DA:975,3 +DA:976,0 +DA:979,0 +DA:980,0 +DA:982,0 +DA:983,0 +DA:988,0 +DA:992,0 +DA:993,0 +DA:996,0 +DA:998,0 +DA:1000,0 +DA:1001,0 +DA:1003,0 +DA:1004,0 +DA:1010,0 +DA:1011,0 +DA:1013,0 +DA:1014,0 +DA:1019,3 +DA:1020,0 +DA:1022,0 +DA:1023,0 +DA:1024,0 +DA:1027,3 +DA:1028,0 +DA:1030,0 +DA:1031,0 +DA:1036,3 +DA:1037,0 +DA:1042,3 +DA:1043,3 +DA:1045,3 +DA:1046,0 +DA:1052,0 +DA:1059,3 +DA:1063,3 +DA:1065,3 +DA:1068,3 +DA:1070,3 +DA:1071,0 +DA:1078,0 +DA:1079,0 +DA:1080,0 +DA:1083,0 +DA:1084,0 +DA:1090,0 +DA:1095,0 +DA:1099,0 +DA:1100,0 +DA:1102,0 +DA:1103,0 +DA:1110,0 +DA:1111,0 +DA:1113,0 +DA:1115,0 +DA:1116,0 +DA:1122,0 +DA:1127,0 +DA:1128,0 +DA:1129,0 +DA:1134,0 +DA:1135,0 +DA:1136,0 +DA:1138,0 +DA:1139,0 +DA:1147,0 +DA:1148,0 +DA:1149,0 +DA:1150,0 +DA:1154,0 +DA:1155,0 +DA:1156,0 +DA:1157,0 +DA:1161,0 +DA:1162,0 +DA:1163,0 +DA:1164,0 +DA:1165,0 +DA:1166,0 +DA:1167,0 +DA:1168,0 +DA:1171,0 +DA:1172,0 +DA:1173,0 +DA:1189,0 +DA:1190,0 +DA:1191,0 +DA:1192,0 +DA:1193,0 +DA:1194,0 +DA:1195,0 +DA:1196,0 +DA:1199,0 +DA:1200,0 +DA:1201,0 +DA:1210,3 +DA:1213,3 +DA:1216,3 +DA:1219,0 +DA:1230,0 +DA:1232,0 +DA:1236,0 +DA:1237,0 +DA:1243,0 +DA:1247,0 +DA:1249,0 +DA:1250,0 +DA:1251,0 +DA:1254,0 +DA:1255,0 +DA:1256,0 +DA:1259,0 +DA:1263,0 +DA:1264,0 +DA:1265,0 +DA:1266,0 +DA:1269,0 +DA:1270,0 +DA:1271,0 +DA:1275,0 +DA:1277,0 +DA:1280,2 +DA:1290,2 +DA:1292,2 +DA:1293,0 +DA:1296,2 +DA:1300,2 +DA:1302,2 +DA:1303,0 +DA:1304,0 +DA:1307,2 +DA:1308,2 +DA:1309,2 +DA:1312,2 +DA:1316,2 +DA:1317,2 +DA:1320,2 +DA:1323,2 +DA:1326,0 +DA:1337,0 +DA:1339,0 +DA:1343,0 +DA:1347,0 +DA:1349,0 +DA:1350,0 +DA:1351,0 +DA:1354,0 +DA:1355,0 +DA:1356,0 +DA:1359,0 +DA:1363,0 +DA:1364,0 +DA:1365,0 +DA:1366,0 +DA:1367,0 +DA:1370,0 +DA:1371,0 +DA:1372,0 +DA:1376,0 +DA:1378,0 +DA:1381,9 +DA:1391,9 +DA:1393,9 +DA:1397,9 +DA:1401,9 +DA:1403,9 +DA:1404,0 +DA:1405,0 +DA:1408,9 +DA:1409,9 +DA:1410,9 +DA:1413,9 +DA:1417,9 +DA:1418,9 +DA:1419,9 +DA:1420,9 +DA:1423,9 +DA:1424,0 +DA:1425,0 +DA:1429,9 +DA:1431,9 +DA:1434,0 +DA:1439,0 +DA:1441,0 +DA:1445,0 +DA:1449,0 +DA:1451,0 +DA:1452,0 +DA:1453,0 +DA:1456,0 +DA:1457,0 +DA:1458,0 +DA:1461,0 +DA:1465,0 +DA:1466,0 +DA:1468,0 +DA:1470,0 +DA:1471,0 +DA:1473,0 +DA:1475,0 +DA:1478,0 +DA:1479,0 +DA:1480,0 +DA:1484,0 +DA:1486,0 +DA:1489,0 +DA:1494,0 +DA:1496,0 +DA:1500,0 +DA:1504,0 +DA:1506,0 +DA:1507,0 +DA:1508,0 +DA:1511,0 +DA:1512,0 +DA:1513,0 +DA:1516,0 +DA:1520,0 +DA:1521,0 +DA:1524,0 +DA:1525,0 +DA:1526,0 +DA:1530,0 +DA:1532,0 +DA:1535,0 +DA:1554,0 +DA:1556,0 +DA:1557,0 +DA:1559,0 +DA:1562,0 +DA:1563,0 +DA:1566,0 +DA:1567,0 +DA:1568,0 +DA:1572,0 +DA:1577,0 +DA:1578,0 +DA:1582,0 +DA:1583,0 +DA:1584,0 +DA:1588,0 +DA:1589,0 +DA:1593,0 +DA:1596,0 +DA:1599,0 +DA:1601,0 +DA:1602,0 +DA:1606,0 +DA:1607,0 +DA:1608,0 +DA:1611,0 +DA:1613,0 +DA:1614,0 +DA:1615,0 +DA:1618,0 +DA:1620,0 +DA:1621,0 +DA:1622,0 +DA:1625,0 +DA:1626,0 +DA:1632,0 +DA:1636,0 +DA:1637,0 +DA:1639,0 +DA:1640,0 +DA:1643,0 +DA:1646,0 +DA:1649,0 +DA:1655,0 +DA:1660,0 +DA:1667,0 +DA:1672,0 +DA:1673,0 +DA:1675,0 +DA:1676,0 +DA:1677,0 +DA:1680,0 +DA:1681,0 +DA:1682,0 +DA:1684,0 +DA:1686,0 +DA:1695,0 +DA:1699,0 +DA:1703,0 +DA:1704,0 +DA:1705,0 +DA:1708,0 +DA:1710,0 +DA:1713,0 +DA:1714,0 +DA:1716,0 +DA:1717,0 +DA:1718,0 +DA:1720,0 +DA:1722,0 +DA:1724,0 +DA:1725,0 +DA:1726,0 +DA:1729,0 +DA:1734,0 +DA:1740,0 +DA:1742,0 +DA:1743,0 +DA:1749,0 +DA:1750,0 +DA:1752,0 +DA:1755,0 +DA:1757,0 +DA:1758,0 +DA:1760,0 +DA:1761,0 +DA:1762,0 +DA:1763,0 +DA:1765,0 +DA:1766,0 +DA:1771,0 +DA:1772,0 +DA:1775,0 +DA:1777,0 +DA:1782,0 +DA:1783,0 +DA:1786,0 +DA:1788,0 +DA:1794,0 +DA:1797,0 +DA:1799,0 +DA:1805,0 +DA:1809,0 +DA:1812,0 +DA:1816,0 +DA:1817,0 +DA:1820,0 +DA:1822,0 +DA:1833,0 +DA:1840,0 +DA:1845,0 +DA:1846,0 +DA:1848,0 +DA:1849,0 +DA:1850,0 +DA:1853,0 +DA:1854,0 +DA:1855,0 +DA:1857,0 +DA:1859,0 +DA:1868,0 +DA:1872,0 +DA:1876,0 +DA:1877,0 +DA:1878,0 +DA:1881,0 +DA:1883,0 +DA:1886,0 +DA:1887,0 +DA:1889,0 +DA:1890,0 +DA:1891,0 +DA:1893,0 +DA:1895,0 +DA:1897,0 +DA:1898,0 +DA:1899,0 +DA:1902,0 +DA:1907,0 +DA:1913,0 +DA:1915,0 +DA:1916,0 +DA:1922,0 +DA:1923,0 +DA:1925,0 +DA:1928,0 +DA:1930,0 +DA:1931,0 +DA:1933,0 +DA:1934,0 +DA:1935,0 +DA:1936,0 +DA:1938,0 +DA:1939,0 +DA:1944,0 +DA:1945,0 +DA:1948,0 +DA:1951,0 +DA:1956,0 +DA:1957,0 +DA:1960,0 +DA:1962,0 +DA:1968,0 +DA:1971,0 +DA:1973,0 +DA:1979,0 +DA:1983,0 +DA:1986,0 +DA:1987,0 +DA:1990,0 +DA:1992,0 +DA:1995,0 +DA:2005,0 +DA:2011,0 +DA:2016,0 +DA:2019,0 +DA:2022,0 +DA:2025,0 +DA:2026,0 +DA:2027,0 +DA:2028,0 +DA:2030,0 +DA:2033,0 +DA:2035,0 +DA:2038,0 +DA:2042,0 +DA:2048,0 +DA:2054,0 +DA:2055,0 +DA:2056,0 +DA:2059,0 +DA:2062,0 +DA:2065,0 +DA:2066,0 +DA:2069,0 +DA:2072,0 +DA:2076,0 +DA:2079,0 +DA:2083,0 +DA:2089,0 +DA:2095,0 +DA:2098,0 +DA:2101,0 +DA:2104,0 +DA:2106,0 +DA:2107,0 +DA:2109,0 +DA:2112,0 +DA:2114,0 +DA:2117,0 +DA:2121,0 +DA:2127,0 +DA:2133,0 +DA:2134,0 +DA:2135,0 +DA:2138,0 +DA:2141,0 +DA:2144,0 +DA:2145,0 +DA:2146,0 +DA:2147,0 +DA:2149,0 +DA:2152,0 +DA:2154,0 +DA:2157,0 +DA:2161,0 +DA:2167,0 +DA:2172,0 +DA:2175,0 +DA:2178,0 +DA:2180,0 +DA:2181,0 +DA:2183,0 +DA:2186,0 +DA:2190,0 +DA:2195,0 +DA:2197,0 +DA:2198,0 +DA:2201,0 +DA:2207,0 +DA:2208,0 +DA:2211,0 +DA:2212,0 +DA:2218,0 +DA:2221,0 +DA:2222,0 +DA:2224,0 +DA:2227,0 +DA:2228,0 +DA:2229,0 +DA:2230,0 +DA:2232,0 +DA:2233,0 +DA:2234,0 +DA:2237,0 +DA:2238,0 +DA:2240,0 +DA:2242,0 +DA:2243,0 +DA:2246,0 +DA:2248,0 +DA:2251,0 +DA:2254,0 +DA:2258,0 +DA:2261,0 +DA:2264,11 +DA:2269,11 +DA:2272,11 +DA:2274,11 +DA:2275,0 +DA:2276,0 +DA:2279,11 +DA:2281,11 +DA:2282,0 +DA:2283,0 +DA:2288,11 +DA:2290,0 +DA:2293,0 +DA:2297,11 +DA:2298,0 +DA:2299,0 +DA:2304,11 +DA:2306,11 +DA:2309,0 +DA:2314,0 +DA:2317,0 +DA:2319,0 +DA:2320,0 +DA:2321,0 +DA:2324,0 +DA:2326,0 +DA:2327,0 +DA:2328,0 +DA:2333,0 +DA:2334,0 +DA:2339,0 +DA:2341,0 +DA:2346,0 +DA:2347,0 +DA:2349,0 +DA:2355,0 +DA:2357,0 +DA:2400,0 +DA:2410,0 +DA:2412,0 +DA:2416,2 +DA:2431,2 +DA:2434,2 +DA:2437,2 +DA:2439,2 +DA:2440,0 +DA:2443,0 +DA:2446,2 +DA:2447,0 +DA:2454,0 +DA:2456,0 +DA:2459,2 +DA:2462,2 +DA:2464,2 +DA:2465,0 +DA:2466,0 +DA:2467,0 +DA:2468,0 +DA:2475,0 +DA:2478,0 +DA:2482,4 +DA:2483,2 +DA:2486,2 +DA:2487,0 +DA:2489,0 +DA:2491,0 +DA:2492,0 +DA:2498,0 +DA:2500,0 +DA:2502,0 +DA:2506,0 +DA:2507,0 +DA:2508,0 +DA:2509,0 +DA:2514,2 +DA:2515,2 +DA:2516,0 +DA:2520,2 +DA:2521,2 +DA:2525,0 +DA:2526,0 +DA:2532,0 +DA:2533,0 +DA:2537,2 +DA:2539,2 +DA:2540,0 +DA:2542,0 +DA:2543,0 +DA:2549,0 +DA:2551,0 +DA:2553,0 +DA:2559,0 +DA:2562,0 +DA:2570,0 +DA:2572,0 +DA:2576,0 +DA:2583,2 +DA:2586,0 +DA:2593,0 +DA:2596,0 +DA:2605,2 +DA:2609,2 +DA:2611,4 +DA:2612,2 +DA:2614,2 +DA:2617,2 +DA:2622,0 +DA:2624,0 +DA:2628,2 +DA:2629,2 +DA:2636,0 +DA:2644,0 +DA:2653,0 +DA:2659,0 +DA:2664,0 +DA:2665,0 +DA:2669,0 +DA:2670,0 +DA:2674,0 +DA:2682,0 +DA:2685,0 +DA:2688,0 +DA:2690,0 +DA:2692,0 +DA:2693,0 +DA:2695,0 +DA:2702,0 +DA:2710,0 +DA:2720,0 +DA:2722,0 +DA:2723,0 +DA:2725,0 +DA:2729,0 +DA:2730,0 +DA:2734,0 +DA:2742,0 +DA:2746,0 +DA:2748,0 +DA:2749,0 +DA:2751,0 +DA:2752,0 +DA:2754,0 +DA:2755,0 +DA:2756,0 +DA:2759,0 +DA:2762,0 +DA:2764,0 +DA:2766,0 +DA:2768,0 +DA:2769,0 +DA:2770,0 +DA:2772,0 +DA:2775,0 +DA:2777,0 +DA:2778,0 +DA:2779,0 +DA:2788,0 +DA:2790,0 +DA:2793,0 +DA:2794,0 +DA:2797,0 +DA:2805,0 +LF:971 +LH:219 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/daemon/dlt_daemon_common.c +FN:91,dlt_daemon_cmp_apid +FN:102,dlt_daemon_cmp_apid_ctid +FN:123,dlt_daemon_find_users_list +FN:229,dlt_daemon_init_runtime_configuration +FN:286,dlt_daemon_init +FN:338,dlt_daemon_free +FN:376,dlt_daemon_init_user_information +FN:422,dlt_daemon_applications_invalidate_fd +FN:448,dlt_daemon_applications_clear +FN:484,dlt_daemon_application_reset_user_handle +FN:511,dlt_daemon_application_add +FN:679,dlt_daemon_application_del +FN:724,dlt_daemon_application_find +FN:758,dlt_daemon_applications_load +FN:850,dlt_daemon_applications_save +FN:899,dlt_daemon_context_add +FN:1118,dlt_daemon_context_del +FN:1171,dlt_daemon_context_find +FN:1208,dlt_daemon_contexts_invalidate_fd +FN:1234,dlt_daemon_contexts_clear +FN:1268,dlt_daemon_contexts_load +FN:1378,dlt_daemon_contexts_save +FN:1432,dlt_daemon_configuration_save +FN:1453,dlt_daemon_configuration_load +FN:1520,dlt_daemon_user_send_log_level +FN:1581,dlt_daemon_user_send_log_state +FN:1610,dlt_daemon_control_reset_to_factory_default +FN:1660,dlt_daemon_user_send_default_update +FN:1694,dlt_daemon_user_send_all_log_level_update +FN:1750,dlt_daemon_user_send_all_trace_status_update +FN:1786,dlt_daemon_user_send_all_log_state +FN:1815,dlt_daemon_change_state +FNDA:472,dlt_daemon_find_users_list +FNDA:41,dlt_daemon_context_add +FNDA:0,dlt_daemon_configuration_save +FNDA:0,dlt_daemon_user_send_all_log_level_update +FNDA:149,dlt_daemon_application_find +FNDA:18,dlt_daemon_init_user_information +FNDA:0,dlt_daemon_control_reset_to_factory_default +FNDA:16,dlt_daemon_change_state +FNDA:41,dlt_daemon_user_send_log_level +FNDA:0,dlt_daemon_contexts_save +FNDA:0,dlt_daemon_cmp_apid +FNDA:9,dlt_daemon_user_send_log_state +FNDA:15,dlt_daemon_contexts_invalidate_fd +FNDA:5,dlt_daemon_user_send_all_log_state +FNDA:0,dlt_daemon_contexts_load +FNDA:0,dlt_daemon_user_send_default_update +FNDA:10,dlt_daemon_application_add +FNDA:15,dlt_daemon_applications_invalidate_fd +FNDA:10,dlt_daemon_applications_clear +FNDA:37,dlt_daemon_context_del +FNDA:9,dlt_daemon_init_runtime_configuration +FNDA:15,dlt_daemon_application_reset_user_handle +FNDA:17,dlt_daemon_init +FNDA:0,dlt_daemon_user_send_all_trace_status_update +FNDA:156,dlt_daemon_context_find +FNDA:9,dlt_daemon_free +FNDA:10,dlt_daemon_contexts_clear +FNDA:471,dlt_daemon_cmp_apid_ctid +FNDA:9,dlt_daemon_configuration_load +FNDA:9,dlt_daemon_applications_load +FNDA:6,dlt_daemon_application_del +FNDA:0,dlt_daemon_applications_save +FNF:32 +FNH:23 +DA:91,0 +DA:93,132 +DA:99,132 +DA:102,471 +DA:104,471 +DA:111,471 +DA:113,471 +DA:115,471 +DA:116,471 +DA:123,472 +DA:127,472 +DA:131,472 +DA:132,0 +DA:133,0 +DA:136,474 +DA:137,442 +DA:138,440 +DA:140,32 +DA:141,32 +DA:229,9 +DA:231,9 +DA:234,9 +DA:238,9 +DA:240,9 +DA:246,9 +DA:247,0 +DA:248,0 +DA:251,9 +DA:252,9 +DA:255,9 +DA:259,9 +DA:260,0 +DA:261,0 +DA:264,9 +DA:265,9 +DA:268,9 +DA:272,9 +DA:273,0 +DA:274,0 +DA:277,9 +DA:278,9 +DA:281,9 +DA:283,9 +DA:286,17 +DA:296,17 +DA:298,17 +DA:301,17 +DA:302,17 +DA:304,17 +DA:305,17 +DA:306,17 +DA:308,17 +DA:310,17 +DA:312,17 +DA:314,17 +DA:316,17 +DA:317,17 +DA:319,17 +DA:322,17 +DA:325,17 +DA:331,17 +DA:335,17 +DA:338,9 +DA:343,9 +DA:345,9 +DA:349,19 +DA:350,10 +DA:352,10 +DA:354,10 +DA:355,10 +DA:359,9 +DA:367,9 +DA:368,9 +DA:371,9 +DA:373,9 +DA:376,18 +DA:384,18 +DA:386,18 +DA:389,18 +DA:391,17 +DA:393,17 +DA:394,0 +DA:395,0 +DA:398,17 +DA:399,17 +DA:402,1 +DA:405,1 +DA:407,1 +DA:408,0 +DA:409,0 +DA:412,1 +DA:413,1 +DA:415,2 +DA:416,1 +DA:422,15 +DA:430,15 +DA:432,15 +DA:435,15 +DA:437,15 +DA:438,26 +DA:439,11 +DA:440,0 +DA:448,10 +DA:453,10 +DA:455,10 +DA:458,10 +DA:460,10 +DA:463,11 +DA:464,1 +DA:471,1 +DA:472,1 +DA:475,10 +DA:476,7 +DA:478,10 +DA:479,10 +DA:481,10 +DA:484,15 +DA:492,15 +DA:495,6 +DA:496,6 +DA:497,6 +DA:498,0 +DA:499,0 +DA:500,0 +DA:504,6 +DA:505,6 +DA:507,6 +DA:508,6 +DA:511,10 +DA:530,10 +DA:533,10 +DA:535,10 +DA:538,10 +DA:539,10 +DA:540,10 +DA:542,10 +DA:549,10 +DA:551,10 +DA:552,10 +DA:554,10 +DA:555,10 +DA:557,0 +DA:558,0 +DA:559,0 +DA:560,0 +DA:563,0 +DA:564,0 +DA:565,0 +DA:566,0 +DA:569,0 +DA:571,0 +DA:572,0 +DA:576,10 +DA:578,10 +DA:579,10 +DA:580,10 +DA:581,10 +DA:582,10 +DA:583,10 +DA:588,0 +DA:591,0 +DA:599,10 +DA:600,0 +DA:601,0 +DA:604,10 +DA:605,10 +DA:607,10 +DA:608,10 +DA:610,0 +DA:611,0 +DA:612,0 +DA:616,10 +DA:617,9 +DA:618,9 +DA:622,10 +DA:642,9 +DA:643,0 +DA:644,0 +DA:652,9 +DA:653,9 +DA:655,9 +DA:656,9 +DA:657,9 +DA:661,10 +DA:662,10 +DA:663,10 +DA:668,10 +DA:679,6 +DA:687,6 +DA:689,6 +DA:692,6 +DA:694,6 +DA:697,6 +DA:698,6 +DA:701,6 +DA:702,6 +DA:703,6 +DA:706,6 +DA:709,6 +DA:710,6 +DA:711,6 +DA:714,6 +DA:718,6 +DA:724,149 +DA:732,149 +DA:734,149 +DA:735,149 +DA:738,149 +DA:740,149 +DA:744,132 +DA:745,132 +DA:746,132 +DA:750,132 +DA:751,132 +DA:752,132 +DA:753,132 +DA:758,9 +DA:766,9 +DA:768,9 +DA:771,9 +DA:773,9 +DA:774,9 +DA:778,9 +DA:780,9 +DA:783,0 +DA:790,0 +DA:793,0 +DA:794,0 +DA:797,0 +DA:798,0 +DA:799,0 +DA:801,0 +DA:803,0 +DA:804,0 +DA:807,0 +DA:810,0 +DA:811,0 +DA:815,0 +DA:817,0 +DA:819,0 +DA:820,0 +DA:821,0 +DA:823,0 +DA:826,0 +DA:831,0 +DA:833,0 +DA:837,0 +DA:838,0 +DA:845,0 +DA:847,0 +DA:850,0 +DA:858,0 +DA:860,0 +DA:865,0 +DA:867,0 +DA:870,0 +DA:871,0 +DA:873,0 +DA:874,0 +DA:875,0 +DA:877,0 +DA:878,0 +DA:887,0 +DA:890,0 +DA:899,41 +DA:916,41 +DA:918,41 +DA:919,41 +DA:922,41 +DA:925,41 +DA:928,41 +DA:930,41 +DA:933,41 +DA:934,10 +DA:936,10 +DA:941,41 +DA:943,41 +DA:947,41 +DA:949,41 +DA:950,41 +DA:952,41 +DA:953,41 +DA:955,0 +DA:956,0 +DA:957,0 +DA:958,0 +DA:961,0 +DA:962,0 +DA:963,0 +DA:964,0 +DA:967,0 +DA:969,0 +DA:970,0 +DA:974,41 +DA:977,41 +DA:978,41 +DA:980,41 +DA:985,41 +DA:986,0 +DA:987,0 +DA:990,41 +DA:991,41 +DA:993,41 +DA:994,41 +DA:1028,41 +DA:1032,0 +DA:1036,0 +DA:1039,0 +DA:1050,41 +DA:1051,0 +DA:1052,41 +DA:1053,41 +DA:1056,41 +DA:1057,41 +DA:1062,41 +DA:1063,0 +DA:1065,41 +DA:1068,41 +DA:1069,41 +DA:1070,41 +DA:1075,41 +DA:1118,37 +DA:1127,37 +DA:1129,37 +DA:1132,37 +DA:1134,37 +DA:1137,37 +DA:1138,37 +DA:1144,37 +DA:1145,37 +DA:1146,37 +DA:1149,37 +DA:1152,37 +DA:1153,37 +DA:1154,37 +DA:1157,37 +DA:1161,37 +DA:1164,37 +DA:1165,37 +DA:1171,156 +DA:1180,156 +DA:1182,156 +DA:1183,156 +DA:1186,156 +DA:1188,156 +DA:1192,112 +DA:1193,112 +DA:1194,112 +DA:1198,112 +DA:1199,112 +DA:1201,112 +DA:1202,112 +DA:1203,112 +DA:1208,15 +DA:1216,15 +DA:1218,15 +DA:1221,15 +DA:1223,15 +DA:1224,39 +DA:1225,24 +DA:1226,0 +DA:1234,10 +DA:1239,10 +DA:1241,10 +DA:1244,10 +DA:1246,10 +DA:1249,11 +DA:1250,1 +DA:1251,1 +DA:1252,1 +DA:1255,10 +DA:1256,7 +DA:1257,7 +DA:1260,11 +DA:1261,1 +DA:1263,10 +DA:1265,10 +DA:1268,0 +DA:1277,0 +DA:1279,0 +DA:1282,0 +DA:1284,0 +DA:1285,0 +DA:1288,0 +DA:1290,0 +DA:1293,0 +DA:1300,0 +DA:1303,0 +DA:1304,0 +DA:1307,0 +DA:1308,0 +DA:1309,0 +DA:1311,0 +DA:1313,0 +DA:1314,0 +DA:1317,0 +DA:1320,0 +DA:1321,0 +DA:1325,0 +DA:1327,0 +DA:1329,0 +DA:1330,0 +DA:1331,0 +DA:1333,0 +DA:1334,0 +DA:1335,0 +DA:1337,0 +DA:1338,0 +DA:1339,0 +DA:1341,0 +DA:1342,0 +DA:1343,0 +DA:1345,0 +DA:1349,0 +DA:1352,0 +DA:1353,0 +DA:1357,0 +DA:1359,0 +DA:1362,0 +DA:1363,0 +DA:1373,0 +DA:1375,0 +DA:1378,0 +DA:1386,0 +DA:1388,0 +DA:1391,0 +DA:1393,0 +DA:1399,0 +DA:1400,0 +DA:1402,0 +DA:1403,0 +DA:1404,0 +DA:1405,0 +DA:1407,0 +DA:1408,0 +DA:1409,0 +DA:1410,0 +DA:1411,0 +DA:1414,0 +DA:1415,0 +DA:1416,0 +DA:1419,0 +DA:1422,0 +DA:1432,0 +DA:1436,0 +DA:1438,0 +DA:1441,0 +DA:1443,0 +DA:1445,0 +DA:1447,0 +DA:1453,9 +DA:1455,9 +DA:1464,9 +DA:1466,9 +DA:1468,9 +DA:1471,18 +DA:1472,9 +DA:1473,9 +DA:1474,9 +DA:1476,18 +DA:1477,9 +DA:1480,9 +DA:1482,9 +DA:1486,0 +DA:1487,0 +DA:1490,9 +DA:1493,9 +DA:1495,0 +DA:1496,0 +DA:1497,0 +DA:1501,0 +DA:1511,9 +DA:1514,0 +DA:1520,41 +DA:1527,41 +DA:1529,41 +DA:1530,0 +DA:1531,0 +DA:1534,41 +DA:1535,0 +DA:1536,0 +DA:1539,41 +DA:1540,34 +DA:1541,32 +DA:1544,9 +DA:1545,9 +DA:1547,41 +DA:1548,41 +DA:1550,41 +DA:1552,41 +DA:1553,41 +DA:1554,41 +DA:1555,41 +DA:1556,41 +DA:1561,41 +DA:1562,41 +DA:1566,41 +DA:1567,0 +DA:1569,0 +DA:1571,0 +DA:1572,0 +DA:1573,0 +DA:1574,0 +DA:1578,41 +DA:1581,9 +DA:1587,9 +DA:1589,9 +DA:1592,9 +DA:1595,9 +DA:1598,9 +DA:1602,9 +DA:1603,0 +DA:1604,0 +DA:1607,9 +DA:1610,0 +DA:1620,0 +DA:1622,0 +DA:1623,0 +DA:1624,0 +DA:1627,0 +DA:1628,0 +DA:1629,0 +DA:1633,0 +DA:1635,0 +DA:1637,0 +DA:1638,0 +DA:1641,0 +DA:1643,0 +DA:1645,0 +DA:1646,0 +DA:1649,0 +DA:1650,0 +DA:1651,0 +DA:1657,0 +DA:1660,0 +DA:1666,0 +DA:1668,0 +DA:1669,0 +DA:1670,0 +DA:1673,0 +DA:1675,0 +DA:1678,0 +DA:1679,0 +DA:1681,0 +DA:1682,0 +DA:1683,0 +DA:1684,0 +DA:1685,0 +DA:1688,0 +DA:1694,0 +DA:1704,0 +DA:1706,0 +DA:1709,0 +DA:1711,0 +DA:1714,0 +DA:1715,0 +DA:1717,0 +DA:1718,0 +DA:1719,0 +DA:1721,0 +DA:1732,0 +DA:1733,0 +DA:1737,0 +DA:1740,0 +DA:1742,0 +DA:1743,0 +DA:1744,0 +DA:1750,0 +DA:1756,0 +DA:1758,0 +DA:1761,0 +DA:1763,0 +DA:1766,0 +DA:1768,0 +DA:1769,0 +DA:1771,0 +DA:1772,0 +DA:1773,0 +DA:1775,0 +DA:1776,0 +DA:1778,0 +DA:1779,0 +DA:1780,0 +DA:1786,5 +DA:1792,5 +DA:1794,5 +DA:1795,0 +DA:1796,0 +DA:1799,5 +DA:1801,5 +DA:1804,7 +DA:1805,2 +DA:1807,2 +DA:1808,2 +DA:1809,2 +DA:1810,0 +DA:1815,16 +DA:1817,16 +DA:1818,0 +DA:1819,0 +DA:1820,0 +DA:1821,0 +DA:1822,12 +DA:1823,12 +DA:1824,12 +DA:1825,12 +DA:1826,0 +DA:1827,0 +DA:1828,0 +DA:1829,0 +DA:1830,2 +DA:1831,2 +DA:1832,2 +DA:1833,2 +DA:1834,2 +DA:1835,2 +DA:1836,2 +DA:1837,2 +DA:1839,16 +LF:619 +LH:351 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/daemon/dlt_daemon_connection.c +FN:68,dlt_connection_send +FN:110,dlt_connection_send_multiple +FN:148,dlt_connection_get_next +FN:156,dlt_connection_destroy_receiver +FN:192,dlt_connection_get_receiver +FN:279,dlt_connection_get_callback +FN:344,dlt_connection_destroy +FN:367,dlt_connection_create +FNDA:48,dlt_connection_get_receiver +FNDA:47,dlt_connection_create +FNDA:48,dlt_connection_destroy +FNDA:49,dlt_connection_destroy_receiver +FNDA:1314,dlt_connection_get_callback +FNDA:219,dlt_connection_send_multiple +FNDA:436,dlt_connection_send +FNDA:2,dlt_connection_get_next +FNF:8 +FNH:8 +DA:68,436 +DA:75,436 +DA:76,436 +DA:78,436 +DA:79,1 +DA:81,1 +DA:82,1 +DA:86,434 +DA:87,434 +DA:90,434 +DA:110,219 +DA:119,219 +DA:122,218 +DA:123,1 +DA:127,218 +DA:128,218 +DA:130,218 +DA:131,214 +DA:148,2 +DA:150,3 +DA:151,1 +DA:153,2 +DA:156,49 +DA:158,49 +DA:161,49 +DA:165,9 +DA:166,9 +DA:167,9 +DA:168,9 +DA:169,9 +DA:170,36 +DA:171,36 +DA:172,36 +DA:173,36 +DA:174,36 +DA:192,48 +DA:200,48 +DA:201,25 +DA:208,25 +DA:210,25 +DA:211,25 +DA:214,1 +DA:215,1 +DA:217,1 +DA:218,1 +DA:221,9 +DA:222,9 +DA:226,9 +DA:227,9 +DA:230,0 +DA:234,9 +DA:235,9 +DA:242,10 +DA:251,10 +DA:253,10 +DA:254,10 +DA:257,3 +DA:259,3 +DA:260,3 +DA:265,48 +DA:279,1314 +DA:284,1314 +DA:285,1314 +DA:287,1314 +DA:291,8 +DA:293,8 +DA:294,0 +DA:296,0 +DA:302,1282 +DA:304,1282 +DA:305,11 +DA:307,11 +DA:308,0 +DA:310,0 +DA:316,2 +DA:318,2 +DA:319,4 +DA:321,4 +DA:322,3 +DA:324,3 +DA:325,0 +DA:327,0 +DA:328,0 +DA:332,1314 +DA:344,48 +DA:346,48 +DA:347,48 +DA:348,48 +DA:349,48 +DA:350,48 +DA:367,47 +DA:375,47 +DA:379,47 +DA:387,47 +DA:389,47 +DA:390,0 +DA:391,0 +DA:396,47 +DA:398,47 +DA:399,0 +DA:401,0 +DA:402,0 +DA:406,47 +DA:407,47 +DA:416,47 +DA:417,20 +DA:420,20 +DA:421,1 +DA:422,1 +DA:427,46 +DA:429,46 +DA:431,10 +DA:433,46 +DA:434,46 +DA:439,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:77,dlt_daemon_prepare_event_handling +FN:109,dlt_event_handler_enable_fd +FN:142,dlt_event_handler_disable_fd +FN:182,dlt_daemon_handle_event +FN:279,dlt_event_handler_find_connection +FN:302,dlt_daemon_remove_connection +FN:342,dlt_event_handler_cleanup_connections +FN:367,dlt_daemon_add_connection +FN:392,dlt_connection_check_activate +FN:453,dlt_event_handler_register_connection +FN:494,dlt_event_handler_unregister_connection +FNDA:7,dlt_event_handler_disable_fd +FNDA:49,dlt_event_handler_register_connection +FNDA:47,dlt_daemon_remove_connection +FNDA:16,dlt_daemon_prepare_event_handling +FNDA:49,dlt_event_handler_enable_fd +FNDA:1122,dlt_event_handler_find_connection +FNDA:1324,dlt_daemon_handle_event +FNDA:57,dlt_connection_check_activate +FNDA:10,dlt_event_handler_cleanup_connections +FNDA:7,dlt_event_handler_unregister_connection +FNDA:6,dlt_daemon_add_connection +FNF:11 +FNH:11 +DA:64,293 +DA:65,293 +DA:66,293 +DA:67,7 +DA:77,16 +DA:81,16 +DA:84,15 +DA:86,15 +DA:87,0 +DA:88,0 +DA:91,255 +DA:92,240 +DA:94,15 +DA:95,15 +DA:97,15 +DA:109,49 +DA:111,49 +DA:112,2 +DA:113,2 +DA:114,2 +DA:116,2 +DA:117,0 +DA:119,0 +DA:122,2 +DA:123,2 +DA:125,2 +DA:126,0 +DA:129,49 +DA:130,49 +DA:131,49 +DA:142,7 +DA:146,7 +DA:148,36 +DA:149,29 +DA:151,7 +DA:152,7 +DA:155,29 +DA:156,22 +DA:159,7 +DA:160,0 +DA:161,0 +DA:162,0 +DA:168,7 +DA:182,1324 +DA:190,1324 +DA:193,1323 +DA:195,1323 +DA:199,9 +DA:202,1 +DA:203,0 +DA:205,9 +DA:208,6813 +DA:213,5499 +DA:214,4183 +DA:216,1316 +DA:218,1316 +DA:219,1316 +DA:220,1316 +DA:223,0 +DA:224,0 +DA:228,1316 +DA:231,2 +DA:236,2 +DA:238,0 +DA:242,2 +DA:246,1314 +DA:248,1314 +DA:249,0 +DA:251,0 +DA:255,1314 +DA:259,0 +DA:261,0 +DA:279,1122 +DA:281,2443 +DA:283,4823 +DA:284,4775 +DA:285,1074 +DA:286,2380 +DA:302,47 +DA:305,47 +DA:308,47 +DA:312,70 +DA:314,23 +DA:317,47 +DA:319,0 +DA:320,0 +DA:322,47 +DA:324,41 +DA:327,6 +DA:331,47 +DA:333,47 +DA:342,10 +DA:346,10 +DA:350,50 +DA:352,40 +DA:354,49 +DA:355,39 +DA:357,10 +DA:367,6 +DA:371,50 +DA:373,143 +DA:374,93 +DA:376,50 +DA:377,6 +DA:392,57 +DA:396,57 +DA:397,1 +DA:398,1 +DA:401,56 +DA:402,7 +DA:404,7 +DA:405,7 +DA:407,7 +DA:409,7 +DA:410,0 +DA:412,7 +DA:416,49 +DA:418,49 +DA:419,49 +DA:421,49 +DA:422,49 +DA:425,49 +DA:429,0 +DA:430,0 +DA:431,0 +DA:453,49 +DA:458,49 +DA:459,1 +DA:460,1 +DA:463,4 +DA:465,48 +DA:467,4 +DA:470,48 +DA:472,48 +DA:473,48 +DA:475,48 +DA:494,7 +DA:498,7 +DA:504,2 +DA:506,7 +DA:507,1 +DA:508,1 +DA:511,6 +DA:513,3 +DA:515,3 +DA:516,0 +DA:517,0 +DA:521,6 +DA:524,0 +DA:527,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_daemon_logstorage_update_passive_node_context +FNDA:5,dlt_daemon_logstorage_get_device +FNDA:2,dlt_daemon_logstorage_reset_application_loglevel +FNDA:0,dlt_logstorage_split_ctid +FNDA:37,dlt_logstorage_update_context_loglevel +FNDA:4,dlt_logstorage_update_all_contexts +FNDA:42,dlt_logstorage_split_key +FNDA:34,dlt_logstorage_split_multi +FNDA:35,dlt_daemon_logstorage_get_loglevel +FNDA:8,dlt_daemon_logstorage_setup_internal_storage +FNDA:0,dlt_daemon_logstorage_force_reset_level +FNDA:5841,dlt_daemon_logstorage_write +FNDA:1,dlt_logstorage_split_ecuid_apid +FNDA:1,dlt_logstorage_split_apid +FNDA:0,dlt_logstorage_split_ecuid +FNDA:10,dlt_daemon_logstorage_update_application_loglevel +FNDA:2,dlt_daemon_logstorage_send_log_level +FNDA:4,dlt_daemon_logstorage_sync_cache +FNDA:1,dlt_logstorage_split_apid_ctid +FNDA:38,dlt_logstorage_update_context +FNDA:10,dlt_daemon_logstorage_set_logstorage_cache_size +FNDA:8,dlt_daemon_logstorage_cleanup +FNDA:1,dlt_daemon_logstorage_reset_log_level +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:58,dlt_daemon_socket_open +FN:158,dlt_daemon_socket_close +FN:165,dlt_daemon_socket_send +FN:201,dlt_daemon_socket_get_send_qeue_max_size +FN:210,dlt_daemon_socket_sendreliable +FNDA:0,dlt_daemon_socket_get_send_qeue_max_size +FNDA:9,dlt_daemon_socket_open +FNDA:456,dlt_daemon_socket_sendreliable +FNDA:0,dlt_daemon_socket_close +FNDA:11,dlt_daemon_socket_send +FNF:5 +FNH:3 +DA:58,9 +DA:60,9 +DA:67,9 +DA:68,0 +DA:69,0 +DA:71,0 +DA:85,9 +DA:88,9 +DA:89,0 +DA:90,0 +DA:95,0 +DA:102,9 +DA:103,9 +DA:105,9 +DA:106,9 +DA:108,0 +DA:120,0 +DA:121,0 +DA:122,0 +DA:128,0 +DA:131,9 +DA:132,0 +DA:133,0 +DA:134,0 +DA:136,0 +DA:140,9 +DA:143,18 +DA:146,9 +DA:147,0 +DA:148,0 +DA:152,0 +DA:158,0 +DA:160,0 +DA:162,0 +DA:165,11 +DA:175,11 +DA:176,0 +DA:180,0 +DA:186,11 +DA:187,11 +DA:189,11 +DA:194,11 +DA:195,11 +DA:201,0 +DA:203,9 +DA:204,9 +DA:205,9 +DA:207,9 +DA:210,456 +DA:214,912 +DA:215,456 +DA:217,456 +DA:220,456 +DA:221,0 +DA:222,0 +DA:223,0 +DA:225,456 +LF:57 +LH:30 +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:176,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:151,9 +DA:153,9 +DA:154,0 +DA:155,0 +DA:156,0 +DA:159,9 +DA:160,0 +DA:161,0 +DA:162,0 +DA:166,9 +DA:173,9 +DA:176,0 +DA:178,0 +DA:180,0 +DA:181,0 +DA:184,0 +LF:25 +LH:10 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/gateway/dlt_gateway.c +FN:57,dlt_gateway_check_ip +FN:94,dlt_gateway_check_port +FN:132,dlt_gateway_check_ecu +FN:155,dlt_gateway_check_connect_trigger +FN:186,dlt_gateway_check_timeout +FN:210,dlt_gateway_check_interval +FN:233,dlt_gateway_check_send_serial +FN:252,dlt_gateway_allocate_control_messages +FN:290,dlt_gateway_check_control_messages +FN:357,dlt_gateway_check_periodic_control_messages +FN:537,dlt_gateway_check_general_param +FN:561,dlt_gateway_check_param +FN:585,dlt_gateway_store_connection +FN:656,dlt_gateway_configure +FN:830,dlt_gateway_init +FN:864,dlt_gateway_deinit +FN:903,dlt_gateway_add_to_event_loop +FN:960,dlt_gateway_establish_connections +FN:1055,dlt_gateway_get_connection_receiver +FN:1084,dlt_gateway_parse_get_log_info +FN:1210,dlt_gateway_parse_get_default_log_level +FN:1259,dlt_gateway_control_service_logstorage +FN:1286,dlt_gateway_process_passive_node_messages +FN:1499,dlt_gateway_process_gateway_timer +FN:1536,dlt_gateway_forward_control_message +FN:1614,dlt_gateway_process_on_demand_request +FN:1682,dlt_gateway_send_control_message +FN:1761,dlt_gateway_get_connection +FNDA:5,dlt_gateway_process_passive_node_messages +FNDA:0,dlt_gateway_check_interval +FNDA:2,dlt_gateway_check_periodic_control_messages +FNDA:10,dlt_gateway_deinit +FNDA:7,dlt_gateway_check_ip +FNDA:5,dlt_gateway_configure +FNDA:0,dlt_gateway_check_general_param +FNDA:6,dlt_gateway_check_control_messages +FNDA:7,dlt_gateway_check_connect_trigger +FNDA:3,dlt_gateway_add_to_event_loop +FNDA:3,dlt_gateway_process_on_demand_request +FNDA:6,dlt_gateway_check_ecu +FNDA:12,dlt_gateway_send_control_message +FNDA:9,dlt_gateway_check_port +FNDA:0,dlt_gateway_parse_get_default_log_level +FNDA:6,dlt_gateway_get_connection_receiver +FNDA:7,dlt_gateway_check_timeout +FNDA:6,dlt_gateway_check_send_serial +FNDA:7,dlt_gateway_store_connection +FNDA:0,dlt_gateway_get_connection +FNDA:4,dlt_gateway_init +FNDA:32,dlt_gateway_check_param +FNDA:3,dlt_gateway_parse_get_log_info +FNDA:17,dlt_gateway_allocate_control_messages +FNDA:2,dlt_gateway_process_gateway_timer +FNDA:6,dlt_gateway_establish_connections +FNDA:0,dlt_gateway_forward_control_message +FNDA:1,dlt_gateway_control_service_logstorage +FNF:28 +FNH:23 +DA:57,7 +DA:62,7 +DA:63,1 +DA:64,1 +DA:67,6 +DA:70,6 +DA:71,6 +DA:73,6 +DA:74,0 +DA:75,0 +DA:81,0 +DA:84,0 +DA:94,9 +DA:99,9 +DA:100,1 +DA:101,1 +DA:104,8 +DA:105,8 +DA:106,8 +DA:107,8 +DA:108,0 +DA:109,0 +DA:113,8 +DA:115,6 +DA:116,6 +DA:119,2 +DA:122,2 +DA:132,6 +DA:135,6 +DA:136,1 +DA:137,1 +DA:140,5 +DA:142,5 +DA:143,0 +DA:155,7 +DA:158,7 +DA:159,1 +DA:160,1 +DA:163,6 +DA:164,5 +DA:166,1 +DA:168,0 +DA:171,1 +DA:172,1 +DA:173,1 +DA:186,7 +DA:189,7 +DA:190,1 +DA:191,1 +DA:194,6 +DA:197,6 +DA:198,5 +DA:210,0 +DA:213,0 +DA:214,0 +DA:215,0 +DA:218,0 +DA:220,0 +DA:221,0 +DA:233,6 +DA:236,6 +DA:237,1 +DA:238,1 +DA:241,5 +DA:243,5 +DA:252,17 +DA:254,17 +DA:255,1 +DA:256,1 +DA:259,16 +DA:260,7 +DA:262,7 +DA:263,0 +DA:265,0 +DA:269,9 +DA:271,9 +DA:272,0 +DA:274,0 +DA:277,9 +DA:290,6 +DA:295,6 +DA:298,6 +DA:299,1 +DA:300,1 +DA:303,5 +DA:307,5 +DA:309,18 +DA:310,13 +DA:311,0 +DA:313,0 +DA:316,13 +DA:317,13 +DA:318,13 +DA:319,13 +DA:320,13 +DA:322,13 +DA:325,13 +DA:326,0 +DA:329,0 +DA:331,13 +DA:334,0 +DA:337,0 +DA:340,13 +DA:344,5 +DA:345,5 +DA:347,5 +DA:357,2 +DA:362,2 +DA:365,2 +DA:366,1 +DA:367,1 +DA:370,1 +DA:374,1 +DA:377,1 +DA:379,3 +DA:381,2 +DA:384,2 +DA:386,2 +DA:387,2 +DA:390,2 +DA:393,3 +DA:394,1 +DA:395,0 +DA:396,0 +DA:398,0 +DA:399,0 +DA:407,1 +DA:411,2 +DA:413,2 +DA:416,2 +DA:417,1 +DA:420,0 +DA:423,2 +DA:424,0 +DA:426,0 +DA:429,2 +DA:430,2 +DA:431,2 +DA:432,2 +DA:433,2 +DA:435,2 +DA:436,0 +DA:441,2 +DA:442,1 +DA:446,2 +DA:447,0 +DA:450,0 +DA:452,2 +DA:455,0 +DA:458,0 +DA:461,2 +DA:465,1 +DA:466,1 +DA:468,1 +DA:537,0 +DA:541,0 +DA:542,0 +DA:543,0 +DA:546,0 +DA:547,0 +DA:561,32 +DA:566,32 +DA:567,1 +DA:568,1 +DA:571,31 +DA:572,31 +DA:585,7 +DA:591,7 +DA:593,7 +DA:594,2 +DA:595,2 +DA:599,5 +DA:600,5 +DA:603,0 +DA:606,5 +DA:610,5 +DA:611,5 +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:624,5 +DA:627,0 +DA:628,0 +DA:629,0 +DA:630,0 +DA:631,0 +DA:632,0 +DA:633,0 +DA:634,0 +DA:638,5 +DA:639,5 +DA:640,0 +DA:642,0 +DA:656,5 +DA:661,5 +DA:663,5 +DA:665,5 +DA:666,1 +DA:667,1 +DA:671,4 +DA:672,4 +DA:677,4 +DA:678,4 +DA:679,0 +DA:680,0 +DA:681,0 +DA:684,4 +DA:685,4 +DA:690,4 +DA:691,4 +DA:700,0 +DA:703,4 +DA:706,4 +DA:707,0 +DA:708,0 +DA:709,0 +DA:712,8 +DA:717,4 +DA:718,4 +DA:723,4 +DA:724,4 +DA:726,4 +DA:727,4 +DA:728,0 +DA:729,0 +DA:732,4 +DA:734,0 +DA:735,0 +DA:737,0 +DA:740,0 +DA:742,0 +DA:745,0 +DA:747,0 +DA:749,0 +DA:752,0 +DA:756,0 +DA:758,0 +DA:759,0 +DA:765,36 +DA:766,32 +DA:768,32 +DA:771,32 +DA:773,4 +DA:776,4 +DA:778,28 +DA:780,0 +DA:784,0 +DA:788,28 +DA:790,28 +DA:791,0 +DA:797,4 +DA:801,4 +DA:802,0 +DA:808,4 +DA:810,4 +DA:811,0 +DA:816,4 +DA:817,4 +DA:818,4 +DA:820,4 +DA:821,4 +DA:826,4 +DA:827,4 +DA:830,4 +DA:832,4 +DA:834,4 +DA:835,1 +DA:836,1 +DA:839,3 +DA:843,3 +DA:844,3 +DA:846,3 +DA:847,3 +DA:849,0 +DA:850,0 +DA:859,3 +DA:861,3 +DA:864,10 +DA:869,10 +DA:870,0 +DA:871,0 +DA:874,10 +DA:876,12 +DA:877,2 +DA:878,2 +DA:879,2 +DA:880,2 +DA:881,2 +DA:882,2 +DA:884,6 +DA:885,4 +DA:886,4 +DA:887,4 +DA:891,10 +DA:892,10 +DA:903,3 +DA:910,3 +DA:911,0 +DA:912,0 +DA:916,3 +DA:917,3 +DA:918,3 +DA:919,3 +DA:922,3 +DA:927,0 +DA:928,0 +DA:932,3 +DA:934,9 +DA:935,6 +DA:937,6 +DA:941,6 +DA:945,6 +DA:946,0 +DA:947,0 +DA:948,0 +DA:950,6 +DA:954,3 +DA:955,3 +DA:957,3 +DA:960,6 +DA:967,6 +DA:969,6 +DA:970,1 +DA:971,1 +DA:974,10 +DA:975,5 +DA:978,5 +DA:979,0 +DA:980,0 +DA:983,5 +DA:984,5 +DA:986,5 +DA:988,5 +DA:990,3 +DA:991,0 +DA:992,0 +DA:996,2 +DA:999,2 +DA:1001,2 +DA:1002,0 +DA:1003,0 +DA:1004,0 +DA:1009,2 +DA:1010,2 +DA:1014,0 +DA:1015,0 +DA:1018,0 +DA:1023,0 +DA:1024,0 +DA:1028,0 +DA:1030,0 +DA:1031,0 +DA:1033,0 +DA:1037,0 +DA:1040,0 +DA:1044,0 +DA:1045,0 +DA:1047,0 +DA:1048,0 +DA:1055,6 +DA:1059,6 +DA:1060,1 +DA:1061,1 +DA:1064,6 +DA:1065,5 +DA:1067,5 +DA:1068,4 +DA:1084,3 +DA:1090,3 +DA:1097,3 +DA:1099,3 +DA:1100,1 +DA:1101,1 +DA:1104,2 +DA:1108,1 +DA:1110,0 +DA:1111,0 +DA:1112,0 +DA:1116,0 +DA:1117,0 +DA:1118,0 +DA:1123,1 +DA:1127,0 +DA:1128,0 +DA:1132,1 +DA:1134,1 +DA:1135,0 +DA:1137,0 +DA:1140,1 +DA:1141,0 +DA:1142,0 +DA:1143,0 +DA:1146,1 +DA:1147,0 +DA:1148,0 +DA:1149,0 +DA:1152,2 +DA:1153,1 +DA:1156,1 +DA:1163,0 +DA:1166,0 +DA:1167,0 +DA:1170,2 +DA:1171,1 +DA:1174,1 +DA:1177,1 +DA:1178,1 +DA:1184,0 +DA:1188,0 +DA:1189,0 +DA:1195,1 +DA:1197,1 +DA:1210,0 +DA:1219,0 +DA:1221,0 +DA:1222,0 +DA:1223,0 +DA:1226,0 +DA:1228,0 +DA:1229,0 +DA:1233,0 +DA:1235,0 +DA:1239,0 +DA:1240,0 +DA:1243,0 +DA:1246,0 +DA:1248,0 +DA:1259,1 +DA:1266,1 +DA:1267,1 +DA:1269,1 +DA:1272,0 +DA:1273,0 +DA:1275,0 +DA:1277,0 +DA:1286,5 +DA:1294,5 +DA:1297,5 +DA:1298,1 +DA:1299,1 +DA:1302,4 +DA:1311,4 +DA:1312,4 +DA:1317,4 +DA:1318,0 +DA:1319,0 +DA:1323,4 +DA:1324,0 +DA:1326,0 +DA:1330,4 +DA:1332,1 +DA:1333,0 +DA:1334,0 +DA:1337,1 +DA:1339,1 +DA:1340,1 +DA:1341,1 +DA:1342,1 +DA:1345,0 +DA:1347,0 +DA:1350,0 +DA:1353,1 +DA:1356,15 +DA:1357,15 +DA:1358,15 +DA:1360,15 +DA:1367,12 +DA:1370,12 +DA:1372,12 +DA:1380,12 +DA:1381,12 +DA:1384,12 +DA:1385,1 +DA:1386,1 +DA:1387,1 +DA:1390,1 +DA:1392,1 +DA:1395,1 +DA:1400,1 +DA:1401,1 +DA:1404,0 +DA:1407,11 +DA:1409,0 +DA:1415,0 +DA:1420,12 +DA:1422,0 +DA:1423,0 +DA:1426,12 +DA:1432,12 +DA:1433,12 +DA:1437,0 +DA:1445,0 +DA:1446,0 +DA:1448,0 +DA:1452,0 +DA:1454,0 +DA:1463,12 +DA:1464,0 +DA:1465,0 +DA:1466,0 +DA:1467,0 +DA:1470,0 +DA:1471,0 +DA:1474,12 +DA:1475,12 +DA:1476,12 +DA:1479,0 +DA:1480,0 +DA:1484,3 +DA:1485,0 +DA:1487,3 +DA:1489,0 +DA:1490,0 +DA:1493,3 +DA:1494,0 +DA:1499,2 +DA:1504,2 +DA:1507,2 +DA:1509,2 +DA:1510,1 +DA:1513,1 +DA:1516,1 +DA:1518,1 +DA:1519,1 +DA:1522,1 +DA:1527,1 +DA:1531,1 +DA:1533,1 +DA:1536,0 +DA:1548,0 +DA:1550,0 +DA:1551,0 +DA:1552,0 +DA:1555,0 +DA:1556,0 +DA:1565,0 +DA:1566,0 +DA:1567,0 +DA:1570,0 +DA:1571,0 +DA:1572,0 +DA:1575,0 +DA:1576,0 +DA:1581,0 +DA:1582,0 +DA:1583,0 +DA:1587,0 +DA:1589,0 +DA:1592,0 +DA:1593,0 +DA:1594,0 +DA:1597,0 +DA:1599,0 +DA:1600,0 +DA:1601,0 +DA:1605,0 +DA:1606,0 +DA:1608,0 +DA:1611,0 +DA:1614,3 +DA:1623,3 +DA:1625,3 +DA:1626,1 +DA:1627,1 +DA:1631,2 +DA:1632,2 +DA:1638,2 +DA:1639,0 +DA:1640,0 +DA:1643,2 +DA:1645,2 +DA:1646,1 +DA:1648,0 +DA:1649,0 +DA:1650,0 +DA:1654,1 +DA:1655,1 +DA:1659,1 +DA:1662,0 +DA:1665,0 +DA:1666,0 +DA:1668,0 +DA:1671,0 +DA:1675,0 +DA:1676,0 +DA:1682,12 +DA:1689,12 +DA:1691,12 +DA:1692,1 +DA:1695,1 +DA:1699,11 +DA:1704,11 +DA:1705,0 +DA:1708,0 +DA:1710,0 +DA:1715,11 +DA:1716,0 +DA:1721,0 +DA:1722,0 +DA:1723,0 +DA:1727,11 +DA:1728,4 +DA:1729,4 +DA:1731,1 +DA:1732,1 +DA:1734,4 +DA:1735,4 +DA:1737,2 +DA:1739,2 +DA:1740,1 +DA:1743,1 +DA:1747,1 +DA:1748,1 +DA:1749,1 +DA:1750,1 +DA:1752,0 +DA:1753,0 +DA:1758,0 +DA:1761,0 +DA:1768,0 +DA:1770,0 +DA:1771,0 +DA:1772,0 +DA:1775,0 +DA:1776,0 +DA:1778,0 +DA:1779,0 +DA:1782,0 +DA:1784,0 +LF:637 +LH:387 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/lib/dlt_client.c +FN:103,dlt_client_register_message_callback +FN:108,dlt_client_register_fetch_next_message_callback +FN:113,dlt_client_init_port +FN:139,dlt_client_init +FN:172,dlt_client_connect +FN:477,dlt_client_cleanup +FN:517,dlt_client_main_loop +FN:584,dlt_client_send_message_to_socket +FN:626,dlt_client_send_ctrl_msg +FN:780,dlt_client_send_inject_msg +FN:815,dlt_client_send_log_level +FN:847,dlt_client_get_log_info +FN:878,dlt_client_get_default_log_level +FN:906,dlt_client_get_software_version +FN:930,dlt_client_send_trace_status +FN:957,dlt_client_send_default_log_level +FN:982,dlt_client_send_all_log_level +FN:1007,dlt_client_send_default_trace_status +FN:1032,dlt_client_send_all_trace_status +FN:1064,dlt_client_send_timing_pakets +FN:1088,dlt_client_send_store_config +FN:1101,dlt_client_send_reset_to_factory_default +FN:1114,dlt_client_setbaudrate +FN:1124,dlt_client_set_mode +FN:1134,dlt_client_set_server_ip +FN:1146,dlt_client_set_host_if_address +FN:1158,dlt_client_set_serial_device +FN:1170,dlt_client_set_socket_path +FN:1187,dlt_client_free_calloc_failed_get_log_info +FN:1219,dlt_client_parse_get_log_info_resp_text +FN:1371,dlt_client_cleanup_get_log_info +FNDA:0,dlt_client_send_store_config +FNDA:1,dlt_client_get_default_log_level +FNDA:0,dlt_client_send_timing_pakets +FNDA:3,dlt_client_init +FNDA:0,dlt_client_set_host_if_address +FNDA:10,dlt_client_send_ctrl_msg +FNDA:4,dlt_client_get_log_info +FNDA:0,dlt_client_send_all_log_level +FNDA:8,dlt_client_init_port +FNDA:0,dlt_client_setbaudrate +FNDA:0,dlt_client_send_inject_msg +FNDA:0,dlt_client_send_trace_status +FNDA:6,dlt_client_set_server_ip +FNDA:0,dlt_client_set_mode +FNDA:9,dlt_client_connect +FNDA:2,dlt_client_parse_get_log_info_resp_text +FNDA:0,dlt_client_set_serial_device +FNDA:3,dlt_client_register_message_callback +FNDA:3,dlt_client_main_loop +FNDA:0,dlt_client_send_all_trace_status +FNDA:0,dlt_client_register_fetch_next_message_callback +FNDA:2,dlt_client_cleanup_get_log_info +FNDA:4,dlt_client_get_software_version +FNDA:5,dlt_client_cleanup +FNDA:2,dlt_client_send_message_to_socket +FNDA:0,dlt_client_send_default_trace_status +FNDA:0,dlt_client_send_default_log_level +FNDA:1,dlt_client_send_log_level +FNDA:0,dlt_client_set_socket_path +FNDA:0,dlt_client_send_reset_to_factory_default +FNDA:0,dlt_client_free_calloc_failed_get_log_info +FNF:31 +FNH:15 +DA:103,3 +DA:105,3 +DA:106,3 +DA:108,0 +DA:110,0 +DA:111,0 +DA:113,8 +DA:115,8 +DA:116,0 +DA:121,8 +DA:124,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:136,8 +DA:139,3 +DA:147,3 +DA:149,3 +DA:152,0 +DA:153,0 +DA:157,0 +DA:160,0 +DA:164,3 +DA:165,0 +DA:169,3 +DA:172,9 +DA:174,9 +DA:175,9 +DA:185,9 +DA:189,9 +DA:191,9 +DA:194,9 +DA:195,7 +DA:196,7 +DA:198,7 +DA:199,0 +DA:203,3 +DA:206,11 +DA:207,8 +DA:208,0 +DA:211,0 +DA:212,0 +DA:216,8 +DA:218,0 +DA:220,0 +DA:221,0 +DA:222,0 +DA:225,8 +DA:226,8 +DA:227,8 +DA:228,8 +DA:230,8 +DA:231,0 +DA:233,0 +DA:234,0 +DA:236,16 +DA:237,8 +DA:239,8 +DA:240,4 +DA:241,4 +DA:242,4 +DA:243,0 +DA:246,0 +DA:247,0 +DA:252,4 +DA:253,4 +DA:257,0 +DA:258,0 +DA:259,0 +DA:264,0 +DA:265,0 +DA:272,7 +DA:274,7 +DA:275,3 +DA:279,3 +DA:282,4 +DA:283,1 +DA:291,6 +DA:292,0 +DA:294,0 +DA:296,0 +DA:297,0 +DA:301,0 +DA:304,0 +DA:307,0 +DA:308,0 +DA:312,0 +DA:313,0 +DA:321,0 +DA:322,0 +DA:326,0 +DA:328,0 +DA:331,0 +DA:332,0 +DA:340,2 +DA:342,2 +DA:343,0 +DA:346,0 +DA:348,0 +DA:352,2 +DA:353,2 +DA:355,2 +DA:358,0 +DA:361,0 +DA:363,0 +DA:366,2 +DA:367,0 +DA:372,0 +DA:378,0 +DA:380,0 +DA:382,0 +DA:385,0 +DA:387,0 +DA:391,0 +DA:393,0 +DA:396,0 +DA:398,0 +DA:401,0 +DA:402,0 +DA:404,0 +DA:407,0 +DA:409,0 +DA:412,0 +DA:414,0 +DA:417,0 +DA:418,0 +DA:420,0 +DA:422,0 +DA:424,0 +DA:428,0 +DA:431,0 +DA:432,0 +DA:434,0 +DA:435,0 +DA:436,0 +DA:438,0 +DA:443,0 +DA:446,0 +DA:448,0 +DA:451,0 +DA:453,0 +DA:455,0 +DA:460,0 +DA:461,0 +DA:466,0 +DA:469,6 +DA:470,0 +DA:471,0 +DA:477,5 +DA:481,5 +DA:482,0 +DA:484,5 +DA:487,5 +DA:488,5 +DA:490,5 +DA:491,0 +DA:495,5 +DA:496,0 +DA:497,0 +DA:500,5 +DA:501,3 +DA:502,3 +DA:505,5 +DA:506,2 +DA:507,2 +DA:510,5 +DA:511,0 +DA:512,0 +DA:517,3 +DA:522,3 +DA:525,3 +DA:529,415 +DA:531,415 +DA:533,415 +DA:535,3 +DA:538,3 +DA:541,620 +DA:542,620 +DA:544,620 +DA:547,208 +DA:548,208 +DA:550,208 +DA:551,0 +DA:552,0 +DA:556,0 +DA:557,0 +DA:560,208 +DA:561,208 +DA:564,0 +DA:565,0 +DA:569,412 +DA:571,0 +DA:572,0 +DA:574,412 +DA:575,0 +DA:578,0 +DA:579,0 +DA:584,2 +DA:588,2 +DA:589,2 +DA:591,0 +DA:592,0 +DA:595,2 +DA:597,0 +DA:599,0 +DA:601,0 +DA:602,0 +DA:603,0 +DA:607,4 +DA:609,2 +DA:610,2 +DA:612,0 +DA:613,0 +DA:616,2 +DA:617,2 +DA:619,0 +DA:620,0 +DA:626,10 +DA:635,10 +DA:639,10 +DA:643,10 +DA:645,10 +DA:646,0 +DA:647,0 +DA:650,10 +DA:651,10 +DA:652,10 +DA:655,10 +DA:656,0 +DA:657,0 +DA:661,10 +DA:664,10 +DA:666,10 +DA:667,0 +DA:668,0 +DA:672,10 +DA:673,10 +DA:679,10 +DA:682,10 +DA:684,10 +DA:687,10 +DA:688,0 +DA:689,0 +DA:693,10 +DA:695,10 +DA:696,10 +DA:698,10 +DA:700,10 +DA:702,19 +DA:703,19 +DA:706,10 +DA:709,10 +DA:711,10 +DA:713,10 +DA:714,0 +DA:718,0 +DA:720,0 +DA:723,10 +DA:726,10 +DA:728,10 +DA:730,0 +DA:731,0 +DA:733,0 +DA:734,0 +DA:735,0 +DA:738,10 +DA:739,10 +DA:741,10 +DA:742,0 +DA:743,0 +DA:744,0 +DA:747,10 +DA:749,10 +DA:750,0 +DA:751,0 +DA:752,0 +DA:755,10 +DA:756,10 +DA:758,10 +DA:765,0 +DA:767,0 +DA:768,0 +DA:769,0 +DA:774,10 +DA:775,0 +DA:780,0 +DA:790,0 +DA:792,0 +DA:798,0 +DA:800,0 +DA:803,0 +DA:805,0 +DA:806,0 +DA:809,0 +DA:811,0 +DA:815,1 +DA:820,1 +DA:823,1 +DA:825,1 +DA:828,1 +DA:829,1 +DA:830,1 +DA:831,1 +DA:832,1 +DA:835,1 +DA:842,1 +DA:844,1 +DA:847,4 +DA:852,4 +DA:855,4 +DA:857,4 +DA:860,4 +DA:861,4 +DA:862,4 +DA:863,4 +DA:864,4 +DA:867,4 +DA:873,4 +DA:875,4 +DA:878,1 +DA:883,1 +DA:887,1 +DA:889,1 +DA:892,1 +DA:895,1 +DA:901,1 +DA:903,1 +DA:906,4 +DA:911,4 +DA:914,4 +DA:916,4 +DA:919,4 +DA:925,4 +DA:927,4 +DA:930,0 +DA:934,0 +DA:936,0 +DA:939,0 +DA:940,0 +DA:941,0 +DA:942,0 +DA:943,0 +DA:946,0 +DA:948,0 +DA:949,0 +DA:952,0 +DA:954,0 +DA:957,0 +DA:961,0 +DA:963,0 +DA:966,0 +DA:967,0 +DA:968,0 +DA:971,0 +DA:973,0 +DA:974,0 +DA:977,0 +DA:979,0 +DA:982,0 +DA:986,0 +DA:988,0 +DA:991,0 +DA:992,0 +DA:993,0 +DA:996,0 +DA:998,0 +DA:999,0 +DA:1002,0 +DA:1004,0 +DA:1007,0 +DA:1011,0 +DA:1013,0 +DA:1016,0 +DA:1017,0 +DA:1018,0 +DA:1021,0 +DA:1023,0 +DA:1024,0 +DA:1027,0 +DA:1029,0 +DA:1032,0 +DA:1036,0 +DA:1037,0 +DA:1038,0 +DA:1041,0 +DA:1043,0 +DA:1044,0 +DA:1045,0 +DA:1048,0 +DA:1049,0 +DA:1050,0 +DA:1053,0 +DA:1055,0 +DA:1056,0 +DA:1059,0 +DA:1061,0 +DA:1064,0 +DA:1068,0 +DA:1070,0 +DA:1073,0 +DA:1074,0 +DA:1077,0 +DA:1079,0 +DA:1080,0 +DA:1083,0 +DA:1085,0 +DA:1088,0 +DA:1092,0 +DA:1095,0 +DA:1096,0 +DA:1101,0 +DA:1105,0 +DA:1108,0 +DA:1109,0 +DA:1114,0 +DA:1116,0 +DA:1119,0 +DA:1121,0 +DA:1124,0 +DA:1126,0 +DA:1129,0 +DA:1130,0 +DA:1134,6 +DA:1136,6 +DA:1138,6 +DA:1139,0 +DA:1140,0 +DA:1146,0 +DA:1148,0 +DA:1150,0 +DA:1151,0 +DA:1152,0 +DA:1158,0 +DA:1160,0 +DA:1162,0 +DA:1163,0 +DA:1164,0 +DA:1170,0 +DA:1172,0 +DA:1174,0 +DA:1175,0 +DA:1176,0 +DA:1187,0 +DA:1195,0 +DA:1196,0 +DA:1198,0 +DA:1199,0 +DA:1201,0 +DA:1202,0 +DA:1205,0 +DA:1206,0 +DA:1208,0 +DA:1209,0 +DA:1212,0 +DA:1213,0 +DA:1214,0 +DA:1216,0 +DA:1219,2 +DA:1227,2 +DA:1229,2 +DA:1253,2 +DA:1257,2 +DA:1259,0 +DA:1260,0 +DA:1264,0 +DA:1265,0 +DA:1270,0 +DA:1275,0 +DA:1279,2 +DA:1282,2 +DA:1285,2 +DA:1286,0 +DA:1287,0 +DA:1288,0 +DA:1291,5 +DA:1292,3 +DA:1294,3 +DA:1297,3 +DA:1300,3 +DA:1303,3 +DA:1304,0 +DA:1306,0 +DA:1307,0 +DA:1310,9 +DA:1311,6 +DA:1313,6 +DA:1315,6 +DA:1319,6 +DA:1320,6 +DA:1324,6 +DA:1325,6 +DA:1329,6 +DA:1330,6 +DA:1332,6 +DA:1333,6 +DA:1335,6 +DA:1336,0 +DA:1337,0 +DA:1338,0 +DA:1341,6 +DA:1349,3 +DA:1350,3 +DA:1352,3 +DA:1353,3 +DA:1355,3 +DA:1356,0 +DA:1357,0 +DA:1358,0 +DA:1361,3 +DA:1371,2 +DA:1377,2 +DA:1380,5 +DA:1381,3 +DA:1383,9 +DA:1384,6 +DA:1385,6 +DA:1388,3 +DA:1390,3 +DA:1394,2 +DA:1397,2 +DA:1400,2 +LF:528 +LH:234 +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_increase_ll_set +FNDA:0,dlt_env_extract_ll_set +FNDA:0,dlt_env_extract_ll +FNDA:0,dlt_env_ll_item_get_matching_prio +FNDA:0,dlt_env_extract_id +FNDA:0,dlt_env_helper_to_lower +FNDA:0,dlt_env_init_ll_set +FNDA:205,dlt_env_adjust_ll_from_env +FNDA:5250,dlt_env_free_ll_set +FNDA:0,dlt_env_ids_match +FNDA:0,dlt_env_extract_ll_item +FNDA:0,dlt_env_extract_symbolic_ll +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,5250 +DA:309,5250 +DA:313,5250 +DA:314,0 +DA:315,0 +DA:318,5250 +DA:319,5250 +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:195,isFile +FN:205,doTimeout +FN:217,checkUserBufferForFreeSpace +FN:235,doRemoveFile +FN:240,dlt_user_log_file_errorMessage +FN:305,dlt_user_log_file_infoAbout +FN:368,dlt_user_log_file_complete +FN:403,dlt_user_log_file_packagesCount +FN:453,dlt_user_log_file_header_alias +FN:515,dlt_user_log_file_header +FN:575,dlt_user_log_file_data +FN:711,dlt_user_log_file_end +FNDA:0,checkUserBufferForFreeSpace +FNDA:0,getFileCreationDate2 +FNDA:0,dlt_user_log_file_data +FNDA:0,getFileSerialNumber +FNDA:0,doRemoveFile +FNDA:0,stringHash +FNDA:0,dlt_user_log_file_complete +FNDA:0,isFile +FNDA:0,doTimeout +FNDA:0,dlt_user_log_file_end +FNDA:0,getFilesize +FNDA:0,dlt_user_log_file_packagesCount +FNDA:0,dlt_user_log_file_infoAbout +FNDA:0,dlt_user_log_file_header +FNDA:0,getFileCreationDate +FNDA:0,dlt_user_log_file_errorMessage +FNDA:0,dlt_user_log_file_header_alias +FNF:17 +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:182,0 +DA:185,0 +DA:186,0 +DA:187,0 +DA:188,0 +DA:195,0 +DA:198,0 +DA:205,0 +DA:208,0 +DA:209,0 +DA:210,0 +DA:211,0 +DA:217,0 +DA:221,0 +DA:223,0 +DA:224,0 +DA:235,0 +DA:237,0 +DA:240,0 +DA:243,0 +DA:244,0 +DA:245,0 +DA:247,0 +DA:248,0 +DA:253,0 +DA:255,0 +DA:256,0 +DA:262,0 +DA:263,0 +DA:265,0 +DA:266,0 +DA:272,0 +DA:274,0 +DA:287,0 +DA:295,0 +DA:305,0 +DA:308,0 +DA:311,0 +DA:313,0 +DA:314,0 +DA:320,0 +DA:322,0 +DA:323,0 +DA:329,0 +DA:330,0 +DA:332,0 +DA:333,0 +DA:339,0 +DA:351,0 +DA:352,0 +DA:368,0 +DA:373,0 +DA:374,0 +DA:375,0 +DA:378,0 +DA:382,0 +DA:387,0 +DA:388,0 +DA:403,0 +DA:408,0 +DA:411,0 +DA:413,0 +DA:414,0 +DA:419,0 +DA:422,0 +DA:425,0 +DA:427,0 +DA:430,0 +DA:434,0 +DA:439,0 +DA:453,0 +DA:456,0 +DA:459,0 +DA:461,0 +DA:462,0 +DA:466,0 +DA:469,0 +DA:471,0 +DA:472,0 +DA:478,0 +DA:479,0 +DA:481,0 +DA:482,0 +DA:488,0 +DA:499,0 +DA:501,0 +DA:502,0 +DA:515,0 +DA:518,0 +DA:521,0 +DA:523,0 +DA:524,0 +DA:530,0 +DA:532,0 +DA:533,0 +DA:539,0 +DA:540,0 +DA:542,0 +DA:543,0 +DA:549,0 +DA:562,0 +DA:563,0 +DA:575,0 +DA:584,0 +DA:586,0 +DA:588,0 +DA:589,0 +DA:590,0 +DA:593,0 +DA:595,0 +DA:596,0 +DA:597,0 +DA:606,0 +DA:607,0 +DA:612,0 +DA:617,0 +DA:618,0 +DA:625,0 +DA:626,0 +DA:632,0 +DA:634,0 +DA:635,0 +DA:638,0 +DA:639,0 +DA:642,0 +DA:650,0 +DA:654,0 +DA:657,0 +DA:658,0 +DA:659,0 +DA:661,0 +DA:669,0 +DA:671,0 +DA:672,0 +DA:675,0 +DA:676,0 +DA:679,0 +DA:687,0 +DA:688,0 +DA:690,0 +DA:694,0 +DA:696,0 +DA:698,0 +DA:699,0 +DA:711,0 +DA:714,0 +DA:717,0 +DA:719,0 +DA:720,0 +DA:723,0 +DA:726,0 +DA:732,0 +DA:733,0 +DA:734,0 +DA:737,0 +DA:741,0 +DA:743,0 +DA:744,0 +LF:190 +LH:0 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/lib/dlt_user.c +FN:163,dlt_lock_mutex +FN:173,dlt_unlock_mutex +FN:229,dlt_user_check_library_version +FN:390,dlt_initialize_fifo_connection +FN:458,dlt_init +FN:562,dlt_get_appid +FN:573,dlt_init_file +FN:612,dlt_set_filesize_max +FN:634,dlt_init_message_queue +FN:706,dlt_init_common +FN:910,dlt_user_atexit_handler +FN:938,dlt_user_atexit_blow_out_user_buffer +FN:1001,dlt_free +FN:1195,dlt_check_library_version +FN:1200,dlt_register_app +FN:1277,dlt_register_context +FN:1304,dlt_register_context_ll_ts_llccb +FN:1507,dlt_register_context_ll_ts +FN:1522,dlt_register_context_llccb +FN:1553,dlt_unregister_app_util +FN:1591,dlt_unregister_app +FN:1596,dlt_unregister_app_flush_buffered_logs +FN:1618,dlt_unregister_context +FN:1680,dlt_set_application_ll_ts_limit +FN:1730,dlt_get_log_state +FN:1735,dlt_set_log_mode +FN:1758,dlt_set_resend_timeout_atexit +FN:1774,dlt_user_log_write_start_init +FN:1800,dlt_user_log_write_start +FN:1805,dlt_user_log_write_start_id +FN:1813,dlt_user_log_write_start_internal +FN:1876,dlt_user_log_write_start_w_given_buffer +FN:1911,dlt_user_log_write_finish +FN:1925,dlt_user_log_write_finish_w_given_buffer +FN:1937,dlt_user_log_write_raw_internal +FN:2017,dlt_user_log_write_raw +FN:2022,dlt_user_log_write_raw_formatted +FN:2027,dlt_user_log_write_raw_attr +FN:2032,dlt_user_log_write_raw_formatted_attr +FN:2038,dlt_user_log_write_generic_attr +FN:2111,dlt_user_log_write_generic_formatted +FN:2155,dlt_user_log_write_float32 +FN:2164,dlt_user_log_write_float64 +FN:2173,dlt_user_log_write_float32_attr +FN:2183,dlt_user_log_write_float64_attr +FN:2193,dlt_user_log_write_uint +FN:2234,dlt_user_log_write_uint8 +FN:2240,dlt_user_log_write_uint16 +FN:2246,dlt_user_log_write_uint32 +FN:2252,dlt_user_log_write_uint64 +FN:2258,dlt_user_log_write_uint_attr +FN:2299,dlt_user_log_write_uint8_attr +FN:2306,dlt_user_log_write_uint16_attr +FN:2313,dlt_user_log_write_uint32_attr +FN:2320,dlt_user_log_write_uint64_attr +FN:2327,dlt_user_log_write_uint8_formatted +FN:2333,dlt_user_log_write_uint16_formatted +FN:2339,dlt_user_log_write_uint32_formatted +FN:2345,dlt_user_log_write_uint64_formatted +FN:2351,dlt_user_log_write_ptr +FN:2379,dlt_user_log_write_int +FN:2420,dlt_user_log_write_int8 +FN:2426,dlt_user_log_write_int16 +FN:2432,dlt_user_log_write_int32 +FN:2438,dlt_user_log_write_int64 +FN:2444,dlt_user_log_write_int_attr +FN:2485,dlt_user_log_write_int8_attr +FN:2492,dlt_user_log_write_int16_attr +FN:2499,dlt_user_log_write_int32_attr +FN:2506,dlt_user_log_write_int64_attr +FN:2513,dlt_user_log_write_bool +FN:2519,dlt_user_log_write_bool_attr +FN:2526,dlt_user_log_write_string +FN:2531,dlt_user_log_write_string_attr +FN:2536,dlt_user_log_write_sized_string +FN:2541,dlt_user_log_write_sized_string_attr +FN:2546,dlt_user_log_write_constant_string +FN:2552,dlt_user_log_write_constant_string_attr +FN:2558,dlt_user_log_write_sized_constant_string +FN:2564,dlt_user_log_write_sized_constant_string_attr +FN:2570,dlt_user_log_write_utf8_string +FN:2575,dlt_user_log_write_utf8_string_attr +FN:2580,dlt_user_log_write_sized_utf8_string +FN:2585,dlt_user_log_write_sized_utf8_string_attr +FN:2590,dlt_user_log_write_constant_utf8_string +FN:2596,dlt_user_log_write_constant_utf8_string_attr +FN:2602,dlt_user_log_write_sized_constant_utf8_string +FN:2608,dlt_user_log_write_sized_constant_utf8_string_attr +FN:2614,dlt_user_log_write_sized_string_utils_attr +FN:2769,dlt_user_log_write_string_utils_attr +FN:2778,dlt_register_injection_callback_with_id +FN:2869,dlt_register_injection_callback +FN:2880,dlt_register_log_level_changed_callback +FN:2920,check_buffer +FN:2932,dlt_user_trace_network_segmented_start +FN:3029,dlt_user_trace_network_segmented_segment +FN:3112,dlt_user_trace_network_segmented_end +FN:3168,dlt_user_trace_network_segmented_thread +FN:3235,dlt_user_trace_network_segmented_thread_segmenter +FN:3272,dlt_user_trace_network_segmented +FN:3360,dlt_user_trace_network +FN:3370,dlt_user_trace_network_truncated +FN:3522,dlt_log_string +FN:3543,dlt_log_string_int +FN:3565,dlt_log_string_uint +FN:3587,dlt_log_int +FN:3607,dlt_log_uint +FN:3627,dlt_log_raw +FN:3651,dlt_log_marker +FN:3663,dlt_verbose_mode +FN:3678,dlt_nonverbose_mode +FN:3693,dlt_use_extended_header_for_non_verbose +FN:3708,dlt_with_session_id +FN:3723,dlt_with_timestamp +FN:3738,dlt_with_ecu_id +FN:3753,dlt_enable_local_print +FN:3767,dlt_disable_local_print +FN:3782,dlt_user_cleanup_handler +FN:3795,dlt_user_housekeeperthread_function +FN:3872,dlt_user_log_init +FN:3895,dlt_user_log_send_log +FN:4178,dlt_user_log_send_register_application +FN:4221,dlt_user_log_send_unregister_application +FN:4257,dlt_user_log_send_register_context +FN:4316,dlt_user_log_send_unregister_context +FN:4361,dlt_send_app_ll_ts_limit +FN:4408,dlt_user_log_send_log_mode +FN:4445,dlt_user_log_send_marker +FN:4473,dlt_user_print_msg +FN:4510,dlt_user_log_check_user_message +FN:4783,dlt_user_log_resend_buffer +FN:4877,dlt_user_log_reattach_to_daemon +FN:4957,dlt_user_log_send_overflow +FN:4978,dlt_user_check_buffer +FN:5010,dlt_start_threads +FN:5091,dlt_stop_threads +FN:5163,dlt_fork_child_fork_handler +FN:5170,dlt_user_log_out_error_handling +FNDA:7,dlt_user_log_write_float64 +FNDA:7,dlt_user_log_write_constant_string +FNDA:42,dlt_user_log_write_int32 +FNDA:0,dlt_user_log_write_finish_w_given_buffer +FNDA:6008,dlt_user_log_write_finish +FNDA:181,dlt_unregister_app_util +FNDA:18,dlt_log_string +FNDA:4,dlt_user_log_write_uint64 +FNDA:4,dlt_set_log_mode +FNDA:10500,dlt_user_cleanup_handler +FNDA:176,dlt_register_app +FNDA:22,dlt_log_uint +FNDA:204,dlt_unregister_context +FNDA:7,dlt_user_log_write_float64_attr +FNDA:28,dlt_user_log_write_uint64_formatted +FNDA:0,dlt_set_application_ll_ts_limit +FNDA:3,dlt_user_log_write_raw_attr +FNDA:7,dlt_check_library_version +FNDA:5,dlt_user_log_write_constant_string_attr +FNDA:0,dlt_user_log_write_ptr +FNDA:0,dlt_enable_local_print +FNDA:5250,dlt_stop_threads +FNDA:5,dlt_user_log_write_sized_constant_utf8_string +FNDA:37,dlt_user_log_write_int +FNDA:6411,dlt_user_log_init +FNDA:0,dlt_register_context_llccb +FNDA:4969513,dlt_init +FNDA:4,dlt_user_log_write_uint16 +FNDA:0,check_buffer +FNDA:0,dlt_set_resend_timeout_atexit +FNDA:5,dlt_user_log_write_constant_utf8_string +FNDA:0,dlt_set_filesize_max +FNDA:8,dlt_user_log_write_sized_utf8_string +FNDA:7,dlt_user_log_write_uint64_attr +FNDA:0,dlt_get_appid +FNDA:0,dlt_user_log_send_overflow +FNDA:7,dlt_user_log_write_float32_attr +FNDA:28,dlt_user_log_write_uint16_formatted +FNDA:6,dlt_user_log_write_int16 +FNDA:2,dlt_user_log_write_sized_string +FNDA:0,dlt_init_message_queue +FNDA:38,dlt_user_log_write_raw_internal +FNDA:25,dlt_log_string_int +FNDA:19,dlt_user_log_write_raw_formatted +FNDA:11,dlt_log_raw +FNDA:0,dlt_init_file +FNDA:7,dlt_user_log_write_int64_attr +FNDA:4,dlt_user_log_write_uint8 +FNDA:11580,dlt_user_log_write_uint32 +FNDA:6,dlt_user_log_write_int8 +FNDA:216,dlt_register_context_ll_ts_llccb +FNDA:216,dlt_register_context_ll_ts +FNDA:3,dlt_user_log_write_sized_constant_string_attr +FNDA:0,dlt_user_trace_network_segmented_end +FNDA:0,dlt_send_app_ll_ts_limit +FNDA:0,dlt_fork_child_fork_handler +FNDA:0,dlt_register_injection_callback_with_id +FNDA:7,dlt_user_log_write_uint_attr +FNDA:0,dlt_with_timestamp +FNDA:23289,dlt_free +FNDA:1,dlt_log_marker +FNDA:25,dlt_log_string_uint +FNDA:167,dlt_unregister_app +FNDA:0,dlt_user_log_write_start_w_given_buffer +FNDA:0,dlt_user_check_buffer +FNDA:5834,dlt_user_log_resend_buffer +FNDA:1,dlt_user_log_send_marker +FNDA:10500,dlt_user_trace_network_segmented_thread +FNDA:0,dlt_disable_local_print +FNDA:22,dlt_log_int +FNDA:0,dlt_with_session_id +FNDA:1,dlt_user_log_write_sized_constant_string +FNDA:11721,dlt_user_log_write_string_utils_attr +FNDA:0,dlt_user_trace_network_segmented_thread_segmenter +FNDA:8,dlt_user_atexit_handler +FNDA:0,dlt_user_trace_network_segmented_start +FNDA:5251,dlt_init_common +FNDA:7,dlt_user_log_write_int8_attr +FNDA:7,dlt_user_log_write_utf8_string_attr +FNDA:35,dlt_user_log_write_uint +FNDA:18,dlt_user_log_write_uint32_attr +FNDA:7,dlt_user_log_write_string_attr +FNDA:14,dlt_user_log_write_int32_attr +FNDA:0,dlt_with_ecu_id +FNDA:112,dlt_user_log_write_generic_formatted +FNDA:10500,dlt_user_housekeeperthread_function +FNDA:10500,dlt_lock_mutex +FNDA:3,dlt_user_log_write_raw_formatted_attr +FNDA:11760,dlt_user_log_write_generic_attr +FNDA:121,dlt_user_log_reattach_to_daemon +FNDA:6059,dlt_user_log_write_start_internal +FNDA:28,dlt_user_log_write_uint8_formatted +FNDA:1,dlt_get_log_state +FNDA:7,dlt_user_trace_network_segmented +FNDA:5926,dlt_user_log_write_start +FNDA:21,dlt_user_log_write_utf8_string +FNDA:23,dlt_user_log_write_start_id +FNDA:28,dlt_user_log_write_uint32_formatted +FNDA:7,dlt_user_log_write_uint8_attr +FNDA:10,dlt_nonverbose_mode +FNDA:3,dlt_user_log_write_bool +FNDA:7,dlt_unregister_app_flush_buffered_logs +FNDA:5250,dlt_start_threads +FNDA:6008,dlt_user_log_send_log +FNDA:7,dlt_user_log_write_int_attr +FNDA:0,dlt_register_injection_callback +FNDA:7,dlt_user_log_write_float32 +FNDA:6,dlt_user_log_write_sized_string_attr +FNDA:7,dlt_user_log_write_uint16_attr +FNDA:5250,dlt_initialize_fifo_connection +FNDA:6,dlt_user_log_write_int64 +FNDA:7,dlt_user_atexit_blow_out_user_buffer +FNDA:2,dlt_use_extended_header_for_non_verbose +FNDA:1,dlt_register_log_level_changed_callback +FNDA:0,dlt_user_trace_network_segmented_segment +FNDA:4,dlt_user_log_write_constant_utf8_string_attr +FNDA:13,dlt_user_log_write_raw +FNDA:0,dlt_user_print_msg +FNDA:7,dlt_user_log_write_sized_utf8_string_attr +FNDA:204,dlt_user_log_send_unregister_context +FNDA:4,dlt_user_log_write_sized_constant_utf8_string_attr +FNDA:10,dlt_verbose_mode +FNDA:14,dlt_user_trace_network +FNDA:859,dlt_user_log_out_error_handling +FNDA:205,dlt_user_log_send_register_context +FNDA:181,dlt_user_log_send_unregister_application +FNDA:7,dlt_user_log_write_int16_attr +FNDA:11686,dlt_user_log_write_string +FNDA:11729,dlt_user_log_write_sized_string_utils_attr +FNDA:4,dlt_user_log_send_log_mode +FNDA:5266,dlt_user_log_check_user_message +FNDA:3,dlt_user_log_write_bool_attr +FNDA:171,dlt_user_log_send_register_application +FNDA:6001,dlt_user_log_write_start_init +FNDA:7,dlt_user_check_library_version +FNDA:21,dlt_user_trace_network_truncated +FNDA:203,dlt_register_context +FNDA:15750,dlt_unlock_mutex +FNF:138 +FNH:111 +DA:163,10500 +DA:165,10500 +DA:167,10500 +DA:168,0 +DA:171,10500 +DA:173,15750 +DA:175,15750 +DA:176,15749 +DA:229,7 +DA:234,7 +DA:235,7 +DA:237,7 +DA:238,0 +DA:246,0 +DA:390,5250 +DA:397,5250 +DA:399,5250 +DA:400,0 +DA:401,0 +DA:405,5250 +DA:407,1 +DA:411,1 +DA:412,0 +DA:413,0 +DA:418,5250 +DA:421,5250 +DA:423,5250 +DA:425,5250 +DA:426,0 +DA:429,5250 +DA:431,5250 +DA:432,0 +DA:433,0 +DA:436,5250 +DA:438,5250 +DA:439,0 +DA:440,0 +DA:441,0 +DA:445,5250 +DA:447,5250 +DA:451,5243 +DA:458,4969513 +DA:461,4969513 +DA:462,1938673 +DA:464,1938673 +DA:476,3030840 +DA:481,5250 +DA:484,5250 +DA:485,0 +DA:489,5250 +DA:490,0 +DA:491,0 +DA:494,5250 +DA:495,5250 +DA:496,5250 +DA:498,5250 +DA:499,5250 +DA:525,5250 +DA:528,5250 +DA:532,0 +DA:533,0 +DA:540,5250 +DA:541,5250 +DA:543,5250 +DA:546,5250 +DA:547,0 +DA:548,0 +DA:552,5250 +DA:555,5250 +DA:556,0 +DA:562,0 +DA:564,0 +DA:566,0 +DA:568,0 +DA:569,0 +DA:573,0 +DA:576,0 +DA:588,0 +DA:592,0 +DA:597,0 +DA:600,0 +DA:603,0 +DA:604,0 +DA:605,0 +DA:606,0 +DA:612,0 +DA:614,0 +DA:616,0 +DA:618,0 +DA:621,0 +DA:622,0 +DA:625,0 +DA:627,0 +DA:630,0 +DA:634,0 +DA:636,0 +DA:638,0 +DA:639,0 +DA:641,0 +DA:642,0 +DA:647,0 +DA:651,0 +DA:652,0 +DA:653,0 +DA:654,0 +DA:660,0 +DA:664,0 +DA:665,0 +DA:666,0 +DA:668,0 +DA:669,0 +DA:672,0 +DA:678,0 +DA:679,0 +DA:680,0 +DA:681,0 +DA:685,0 +DA:687,0 +DA:689,0 +DA:690,0 +DA:691,0 +DA:694,0 +DA:695,0 +DA:696,0 +DA:703,11776 +DA:706,5251 +DA:707,0 +DA:722,5251 +DA:723,0 +DA:724,0 +DA:728,5251 +DA:730,5251 +DA:731,5251 +DA:733,5251 +DA:734,5251 +DA:736,5251 +DA:739,5251 +DA:748,5251 +DA:753,5251 +DA:755,5251 +DA:756,0 +DA:757,0 +DA:761,5251 +DA:766,5251 +DA:769,5251 +DA:772,5251 +DA:775,5251 +DA:777,5251 +DA:779,5251 +DA:781,5251 +DA:783,5251 +DA:784,0 +DA:785,0 +DA:786,0 +DA:787,0 +DA:788,0 +DA:789,0 +DA:792,5251 +DA:794,5251 +DA:795,0 +DA:796,0 +DA:802,5251 +DA:803,5251 +DA:804,5251 +DA:805,5251 +DA:808,5251 +DA:809,5251 +DA:810,5251 +DA:812,5251 +DA:813,0 +DA:815,0 +DA:816,0 +DA:823,5251 +DA:824,0 +DA:826,0 +DA:827,0 +DA:834,5251 +DA:835,0 +DA:837,0 +DA:838,0 +DA:846,5251 +DA:847,5251 +DA:849,5251 +DA:850,7 +DA:852,7 +DA:853,0 +DA:854,0 +DA:858,7 +DA:859,7 +DA:865,5251 +DA:866,5250 +DA:867,5250 +DA:869,5250 +DA:870,0 +DA:871,0 +DA:872,0 +DA:873,0 +DA:877,5251 +DA:878,5251 +DA:879,0 +DA:880,0 +DA:883,5251 +DA:887,0 +DA:888,0 +DA:889,0 +DA:892,5251 +DA:894,5251 +DA:896,5251 +DA:897,8 +DA:898,8 +DA:910,8 +DA:913,8 +DA:916,8 +DA:917,1 +DA:919,1 +DA:920,1 +DA:924,7 +DA:926,7 +DA:927,1 +DA:931,7 +DA:935,7 +DA:938,7 +DA:939,0 +DA:944,7 +DA:947,7 +DA:948,7 +DA:949,7 +DA:951,7 +DA:952,101 +DA:953,100 +DA:955,100 +DA:957,100 +DA:958,0 +DA:959,0 +DA:963,0 +DA:968,100 +DA:969,0 +DA:971,0 +DA:972,0 +DA:973,0 +DA:974,0 +DA:976,0 +DA:980,100 +DA:981,100 +DA:982,100 +DA:985,1 +DA:986,1 +DA:987,1 +DA:995,11260 +DA:996,2 +DA:997,11249 +DA:1001,23289 +DA:1002,0 +DA:1011,23289 +DA:1016,23289 +DA:1017,18039 +DA:1018,18039 +DA:1021,5250 +DA:1023,5250 +DA:1027,5250 +DA:1028,5249 +DA:1029,5249 +DA:1030,5249 +DA:1031,5249 +DA:1041,5250 +DA:1103,6 +DA:1105,6 +DA:1106,0 +DA:1108,6 +DA:1112,5250 +DA:1113,5250 +DA:1114,5250 +DA:1117,5250 +DA:1120,5250 +DA:1123,5250 +DA:1124,0 +DA:1125,5250 +DA:1127,5250 +DA:1128,10020 +DA:1129,10000 +DA:1130,1 +DA:1131,1 +DA:1134,10000 +DA:1135,1 +DA:1136,1 +DA:1139,10000 +DA:1140,1 +DA:1141,1 +DA:1144,10000 +DA:1145,0 +DA:1146,0 +DA:1149,10000 +DA:1150,10000 +DA:1153,20 +DA:1154,20 +DA:1155,20 +DA:1156,20 +DA:1159,5250 +DA:1160,5250 +DA:1164,5250 +DA:1170,5250 +DA:1171,0 +DA:1173,5250 +DA:1174,0 +DA:1176,5250 +DA:1177,5250 +DA:1178,0 +DA:1180,5250 +DA:1181,5250 +DA:1183,5250 +DA:1185,5250 +DA:1190,5250 +DA:1192,5250 +DA:1195,7 +DA:1197,7 +DA:1200,176 +DA:1201,0 +DA:1205,176 +DA:1208,176 +DA:1209,8 +DA:1210,0 +DA:1211,0 +DA:1215,176 +DA:1220,172 +DA:1221,2 +DA:1224,170 +DA:1226,2 +DA:1227,0 +DA:1230,168 +DA:1232,2 +DA:1233,0 +DA:1234,0 +DA:1237,166 +DA:1238,1 +DA:1239,1 +DA:1240,1 +DA:1245,171 +DA:1248,171 +DA:1250,171 +DA:1251,0 +DA:1253,171 +DA:1255,171 +DA:1256,171 +DA:1257,171 +DA:1259,171 +DA:1262,0 +DA:1263,0 +DA:1267,171 +DA:1269,171 +DA:1271,171 +DA:1272,7 +DA:1277,203 +DA:1280,203 +DA:1284,197 +DA:1287,197 +DA:1288,0 +DA:1289,0 +DA:1290,0 +DA:1294,197 +DA:1297,189 +DA:1304,216 +DA:1312,0 +DA:1318,216 +DA:1322,209 +DA:1325,209 +DA:1326,2 +DA:1327,2 +DA:1330,207 +DA:1331,2 +DA:1332,2 +DA:1335,205 +DA:1339,205 +DA:1344,205 +DA:1350,205 +DA:1351,21 +DA:1353,21 +DA:1354,0 +DA:1355,0 +DA:1358,21 +DA:1361,10521 +DA:1362,10500 +DA:1366,10500 +DA:1367,10500 +DA:1369,10500 +DA:1370,10500 +DA:1372,10500 +DA:1374,10500 +DA:1375,10500 +DA:1376,10500 +DA:1379,184 +DA:1386,0 +DA:1388,0 +DA:1389,0 +DA:1390,0 +DA:1391,0 +DA:1392,0 +DA:1394,0 +DA:1395,0 +DA:1396,0 +DA:1397,0 +DA:1398,0 +DA:1401,0 +DA:1402,0 +DA:1405,0 +DA:1406,0 +DA:1410,0 +DA:1411,0 +DA:1413,0 +DA:1414,0 +DA:1416,0 +DA:1418,0 +DA:1419,0 +DA:1420,0 +DA:1426,205 +DA:1429,205 +DA:1431,205 +DA:1432,0 +DA:1434,205 +DA:1436,205 +DA:1437,205 +DA:1438,205 +DA:1440,205 +DA:1441,0 +DA:1442,0 +DA:1448,205 +DA:1449,205 +DA:1451,205 +DA:1452,0 +DA:1453,0 +DA:1457,205 +DA:1458,205 +DA:1460,205 +DA:1461,0 +DA:1462,0 +DA:1467,205 +DA:1472,205 +DA:1473,0 +DA:1476,205 +DA:1478,16 +DA:1481,205 +DA:1482,15 +DA:1485,205 +DA:1486,205 +DA:1488,205 +DA:1489,205 +DA:1491,205 +DA:1493,205 +DA:1494,205 +DA:1495,205 +DA:1497,205 +DA:1498,205 +DA:1500,205 +DA:1502,205 +DA:1504,205 +DA:1507,216 +DA:1513,216 +DA:1522,0 +DA:1529,0 +DA:1533,0 +DA:1536,0 +DA:1537,0 +DA:1538,0 +DA:1539,0 +DA:1543,0 +DA:1553,181 +DA:1554,0 +DA:1558,181 +DA:1562,181 +DA:1563,0 +DA:1564,0 +DA:1568,181 +DA:1570,181 +DA:1572,181 +DA:1574,181 +DA:1575,7 +DA:1577,180 +DA:1579,180 +DA:1580,171 +DA:1583,180 +DA:1586,181 +DA:1588,181 +DA:1591,167 +DA:1593,167 +DA:1596,7 +DA:1601,7 +DA:1604,7 +DA:1605,0 +DA:1606,0 +DA:1609,7 +DA:1611,6 +DA:1612,6 +DA:1615,7 +DA:1618,204 +DA:1619,0 +DA:1624,204 +DA:1628,204 +DA:1629,204 +DA:1631,204 +DA:1635,204 +DA:1637,204 +DA:1638,204 +DA:1640,204 +DA:1642,204 +DA:1644,204 +DA:1645,204 +DA:1647,204 +DA:1648,204 +DA:1651,204 +DA:1652,204 +DA:1653,204 +DA:1656,204 +DA:1657,204 +DA:1658,204 +DA:1661,204 +DA:1663,204 +DA:1664,0 +DA:1665,0 +DA:1668,204 +DA:1669,204 +DA:1672,204 +DA:1675,204 +DA:1677,204 +DA:1680,0 +DA:1681,0 +DA:1685,0 +DA:1688,0 +DA:1689,0 +DA:1690,0 +DA:1693,0 +DA:1694,0 +DA:1695,0 +DA:1698,0 +DA:1699,0 +DA:1700,0 +DA:1701,0 +DA:1705,0 +DA:1707,0 +DA:1708,0 +DA:1709,0 +DA:1713,0 +DA:1714,0 +DA:1715,0 +DA:1717,0 +DA:1718,0 +DA:1720,0 +DA:1721,0 +DA:1724,0 +DA:1727,0 +DA:1730,1 +DA:1732,1 +DA:1735,4 +DA:1740,4 +DA:1743,4 +DA:1744,0 +DA:1745,0 +DA:1748,4 +DA:1749,0 +DA:1750,0 +DA:1751,0 +DA:1755,4 +DA:1758,0 +DA:1761,0 +DA:1764,0 +DA:1765,0 +DA:1768,0 +DA:1769,0 +DA:1774,6001 +DA:1782,6001 +DA:1785,6001 +DA:1786,6001 +DA:1787,6001 +DA:1788,6001 +DA:1789,6001 +DA:1791,6001 +DA:1800,5926 +DA:1802,6036 +DA:1805,23 +DA:1810,23 +DA:1813,6059 +DA:1822,6059 +DA:1826,6053 +DA:1834,6040 +DA:1835,39 +DA:1836,39 +DA:1839,6001 +DA:1840,6001 +DA:1842,6001 +DA:1844,0 +DA:1845,0 +DA:1849,6001 +DA:1852,6001 +DA:1853,0 +DA:1854,0 +DA:1859,6011 +DA:1860,3 +DA:1865,3 +DA:1876,0 +DA:1886,0 +DA:1890,0 +DA:1894,0 +DA:1898,0 +DA:1901,0 +DA:1902,0 +DA:1903,0 +DA:1904,0 +DA:1905,0 +DA:1911,6008 +DA:1915,6008 +DA:1918,6008 +DA:1925,0 +DA:1929,0 +DA:1932,0 +DA:1934,0 +DA:1937,38 +DA:1940,38 +DA:1944,31 +DA:1945,0 +DA:1946,0 +DA:1949,31 +DA:1950,0 +DA:1951,0 +DA:1954,31 +DA:1956,31 +DA:1957,31 +DA:1960,29 +DA:1961,29 +DA:1963,29 +DA:1964,29 +DA:1965,6 +DA:1966,6 +DA:1968,6 +DA:1970,29 +DA:1971,0 +DA:1975,29 +DA:1976,8 +DA:1977,8 +DA:1979,21 +DA:1981,4 +DA:1982,4 +DA:1985,29 +DA:1986,29 +DA:1989,29 +DA:1990,29 +DA:1992,29 +DA:1993,29 +DA:1997,6 +DA:1998,6 +DA:2002,6 +DA:2003,4 +DA:2004,4 +DA:2009,29 +DA:2010,29 +DA:2012,29 +DA:2014,29 +DA:2017,13 +DA:2019,13 +DA:2022,19 +DA:2024,19 +DA:2027,3 +DA:2029,3 +DA:2032,3 +DA:2034,3 +DA:2038,11760 +DA:2040,11760 +DA:2043,11749 +DA:2044,0 +DA:2045,0 +DA:2049,11749 +DA:2052,11751 +DA:2058,11745 +DA:2059,11745 +DA:2060,89 +DA:2061,89 +DA:2063,89 +DA:2064,89 +DA:2065,89 +DA:2066,86 +DA:2067,86 +DA:2070,89 +DA:2072,11745 +DA:2073,0 +DA:2075,11745 +DA:2076,11745 +DA:2078,11745 +DA:2082,89 +DA:2083,89 +DA:2084,89 +DA:2085,86 +DA:2086,86 +DA:2091,89 +DA:2092,64 +DA:2093,64 +DA:2095,89 +DA:2096,62 +DA:2097,62 +DA:2102,11747 +DA:2103,11747 +DA:2105,11747 +DA:2107,11747 +DA:2111,112 +DA:2113,112 +DA:2117,84 +DA:2118,0 +DA:2119,0 +DA:2122,84 +DA:2123,0 +DA:2124,0 +DA:2128,84 +DA:2131,84 +DA:2132,84 +DA:2133,84 +DA:2137,84 +DA:2138,48 +DA:2140,36 +DA:2141,24 +DA:2143,84 +DA:2144,84 +DA:2147,84 +DA:2148,84 +DA:2150,84 +DA:2152,84 +DA:2155,7 +DA:2161,7 +DA:2164,7 +DA:2170,7 +DA:2173,7 +DA:2179,7 +DA:2180,7 +DA:2183,7 +DA:2189,7 +DA:2190,7 +DA:2193,35 +DA:2195,35 +DA:2198,34 +DA:2199,0 +DA:2200,0 +DA:2214,34 +DA:2216,34 +DA:2234,4 +DA:2237,4 +DA:2240,4 +DA:2243,4 +DA:2246,11580 +DA:2249,11580 +DA:2252,4 +DA:2255,4 +DA:2258,7 +DA:2260,7 +DA:2263,7 +DA:2264,0 +DA:2265,0 +DA:2279,7 +DA:2281,7 +DA:2299,7 +DA:2302,7 +DA:2303,7 +DA:2306,7 +DA:2309,7 +DA:2310,7 +DA:2313,18 +DA:2316,18 +DA:2317,18 +DA:2320,7 +DA:2323,7 +DA:2324,7 +DA:2327,28 +DA:2330,28 +DA:2333,28 +DA:2336,28 +DA:2339,28 +DA:2342,28 +DA:2345,28 +DA:2348,28 +DA:2351,0 +DA:2353,0 +DA:2356,0 +DA:2357,0 +DA:2358,0 +DA:2367,0 +DA:2368,0 +DA:2379,37 +DA:2381,37 +DA:2384,36 +DA:2385,0 +DA:2386,0 +DA:2400,36 +DA:2402,36 +DA:2420,6 +DA:2423,6 +DA:2426,6 +DA:2429,6 +DA:2432,42 +DA:2435,42 +DA:2438,6 +DA:2441,6 +DA:2444,7 +DA:2446,7 +DA:2449,7 +DA:2450,0 +DA:2451,0 +DA:2465,7 +DA:2467,7 +DA:2485,7 +DA:2488,7 +DA:2489,7 +DA:2492,7 +DA:2495,7 +DA:2496,7 +DA:2499,14 +DA:2502,14 +DA:2503,14 +DA:2506,7 +DA:2509,7 +DA:2510,7 +DA:2513,3 +DA:2516,3 +DA:2519,3 +DA:2522,3 +DA:2523,3 +DA:2526,11686 +DA:2528,11686 +DA:2531,7 +DA:2533,7 +DA:2536,2 +DA:2538,2 +DA:2541,6 +DA:2543,6 +DA:2546,7 +DA:2549,8 +DA:2552,5 +DA:2555,7 +DA:2558,1 +DA:2561,1 +DA:2564,3 +DA:2567,3 +DA:2570,21 +DA:2572,21 +DA:2575,7 +DA:2577,7 +DA:2580,8 +DA:2582,8 +DA:2585,7 +DA:2587,7 +DA:2590,5 +DA:2593,6 +DA:2596,4 +DA:2599,4 +DA:2602,5 +DA:2605,6 +DA:2608,4 +DA:2611,4 +DA:2614,11729 +DA:2616,11729 +DA:2619,11720 +DA:2620,0 +DA:2621,0 +DA:2624,11720 +DA:2626,11720 +DA:2628,11720 +DA:2630,11720 +DA:2632,11727 +DA:2633,11720 +DA:2634,11720 +DA:2635,21 +DA:2636,21 +DA:2638,21 +DA:2647,11720 +DA:2651,21 +DA:2653,21 +DA:2655,21 +DA:2656,21 +DA:2657,21 +DA:2658,21 +DA:2659,0 +DA:2660,0 +DA:2665,21 +DA:2666,1 +DA:2667,1 +DA:2671,20 +DA:2673,20 +DA:2679,12 +DA:2682,12 +DA:2684,9 +DA:2687,6 +DA:2690,3 +DA:2694,12 +DA:2695,12 +DA:2699,11719 +DA:2700,11719 +DA:2701,11694 +DA:2702,11694 +DA:2703,11694 +DA:2704,25 +DA:2705,25 +DA:2706,25 +DA:2712,11719 +DA:2713,11719 +DA:2716,11719 +DA:2717,11719 +DA:2719,11726 +DA:2720,11719 +DA:2724,21 +DA:2725,21 +DA:2729,21 +DA:2730,15 +DA:2731,15 +DA:2736,11719 +DA:2737,11699 +DA:2740,11699 +DA:2742,11699 +DA:2743,11699 +DA:2744,11699 +DA:2746,20 +DA:2749,20 +DA:2750,20 +DA:2753,20 +DA:2754,20 +DA:2755,20 +DA:2764,11719 +DA:2766,11719 +DA:2769,11721 +DA:2771,11721 +DA:2774,11706 +DA:2775,11706 +DA:2778,0 +DA:2780,0 +DA:2787,0 +DA:2790,0 +DA:2795,0 +DA:2798,0 +DA:2800,0 +DA:2801,0 +DA:2802,0 +DA:2806,0 +DA:2809,0 +DA:2810,0 +DA:2811,0 +DA:2816,0 +DA:2823,0 +DA:2824,0 +DA:2825,0 +DA:2827,0 +DA:2828,0 +DA:2829,0 +DA:2834,0 +DA:2835,0 +DA:2837,0 +DA:2838,0 +DA:2839,0 +DA:2840,0 +DA:2843,0 +DA:2844,0 +DA:2847,0 +DA:2851,0 +DA:2853,0 +DA:2854,0 +DA:2855,0 +DA:2856,0 +DA:2859,0 +DA:2860,0 +DA:2861,0 +DA:2864,0 +DA:2866,0 +DA:2869,0 +DA:2874,0 +DA:2880,1 +DA:2885,0 +DA:2889,1 +DA:2894,1 +DA:2897,1 +DA:2899,1 +DA:2900,0 +DA:2901,0 +DA:2905,1 +DA:2908,1 +DA:2910,1 +DA:2912,1 +DA:2920,0 +DA:2923,0 +DA:2925,0 +DA:2932,0 +DA:2939,0 +DA:2944,0 +DA:2947,0 +DA:2948,0 +DA:2949,0 +DA:2952,0 +DA:2955,0 +DA:2957,0 +DA:2960,0 +DA:2961,0 +DA:2963,0 +DA:2964,0 +DA:2965,0 +DA:2969,0 +DA:2970,0 +DA:2971,0 +DA:2973,0 +DA:2974,0 +DA:2977,0 +DA:2979,0 +DA:2983,0 +DA:2985,0 +DA:2989,0 +DA:2991,0 +DA:2995,0 +DA:2997,0 +DA:3001,0 +DA:3004,0 +DA:3007,0 +DA:3009,0 +DA:3013,0 +DA:3015,0 +DA:3019,0 +DA:3023,0 +DA:3029,0 +DA:3039,0 +DA:3040,0 +DA:3041,0 +DA:3044,0 +DA:3046,0 +DA:3047,0 +DA:3048,0 +DA:3049,0 +DA:3052,0 +DA:3055,0 +DA:3056,0 +DA:3058,0 +DA:3062,0 +DA:3063,0 +DA:3065,0 +DA:3066,0 +DA:3067,0 +DA:3071,0 +DA:3072,0 +DA:3073,0 +DA:3076,0 +DA:3078,0 +DA:3082,0 +DA:3084,0 +DA:3088,0 +DA:3090,0 +DA:3094,0 +DA:3096,0 +DA:3099,0 +DA:3104,0 +DA:3108,0 +DA:3109,0 +DA:3112,0 +DA:3114,0 +DA:3117,0 +DA:3118,0 +DA:3119,0 +DA:3122,0 +DA:3125,0 +DA:3127,0 +DA:3131,0 +DA:3132,0 +DA:3134,0 +DA:3135,0 +DA:3136,0 +DA:3140,0 +DA:3141,0 +DA:3142,0 +DA:3145,0 +DA:3147,0 +DA:3151,0 +DA:3153,0 +DA:3156,0 +DA:3161,0 +DA:3168,5250 +DA:3173,5250 +DA:3174,0 +DA:3179,10500 +DA:3185,5250 +DA:3187,5607 +DA:3189,5607 +DA:3192,0 +DA:3194,0 +DA:3197,0 +DA:3198,0 +DA:3201,0 +DA:3202,0 +DA:3203,0 +DA:3204,0 +DA:3207,0 +DA:3210,0 +DA:3214,0 +DA:3215,0 +DA:3218,0 +DA:3221,0 +DA:3223,0 +DA:3224,0 +DA:3227,0 +DA:3228,0 +DA:3229,0 +DA:3235,0 +DA:3245,0 +DA:3246,0 +DA:3251,0 +DA:3254,0 +DA:3255,0 +DA:3258,0 +DA:3262,0 +DA:3263,0 +DA:3264,0 +DA:3267,0 +DA:3268,0 +DA:3269,0 +DA:3272,7 +DA:3280,7 +DA:3284,7 +DA:3285,7 +DA:3288,0 +DA:3290,0 +DA:3293,0 +DA:3295,0 +DA:3296,0 +DA:3297,0 +DA:3300,0 +DA:3302,0 +DA:3303,0 +DA:3304,0 +DA:3305,0 +DA:3309,0 +DA:3310,0 +DA:3311,0 +DA:3313,0 +DA:3317,0 +DA:3324,0 +DA:3325,0 +DA:3326,0 +DA:3327,0 +DA:3328,0 +DA:3329,0 +DA:3333,0 +DA:3334,0 +DA:3335,0 +DA:3336,0 +DA:3337,0 +DA:3339,0 +DA:3343,0 +DA:3345,0 +DA:3346,0 +DA:3348,0 +DA:3349,0 +DA:3350,0 +DA:3351,0 +DA:3352,0 +DA:3360,14 +DA:3367,14 +DA:3370,21 +DA:3379,21 +DA:3381,21 +DA:3384,15 +DA:3385,0 +DA:3386,0 +DA:3389,15 +DA:3392,15 +DA:3393,0 +DA:3397,0 +DA:3398,0 +DA:3400,0 +DA:3401,0 +DA:3402,0 +DA:3406,0 +DA:3407,0 +DA:3408,0 +DA:3410,0 +DA:3414,0 +DA:3416,0 +DA:3418,0 +DA:3422,0 +DA:3424,0 +DA:3428,0 +DA:3430,0 +DA:3437,0 +DA:3440,0 +DA:3442,0 +DA:3448,0 +DA:3450,0 +DA:3453,0 +DA:3457,0 +DA:3459,0 +DA:3463,0 +DA:3468,0 +DA:3522,18 +DA:3524,18 +DA:3527,18 +DA:3533,15 +DA:3534,11 +DA:3536,11 +DA:3543,25 +DA:3545,25 +DA:3548,25 +DA:3554,22 +DA:3555,16 +DA:3556,16 +DA:3558,16 +DA:3565,25 +DA:3567,25 +DA:3570,25 +DA:3576,22 +DA:3577,16 +DA:3578,16 +DA:3580,16 +DA:3587,22 +DA:3589,22 +DA:3592,22 +DA:3597,21 +DA:3598,15 +DA:3600,15 +DA:3601,0 +DA:3607,22 +DA:3609,22 +DA:3612,22 +DA:3617,21 +DA:3618,15 +DA:3620,15 +DA:3621,0 +DA:3627,11 +DA:3629,11 +DA:3632,11 +DA:3638,9 +DA:3639,7 +DA:3641,2 +DA:3644,5 +DA:3645,0 +DA:3651,1 +DA:3653,1 +DA:3654,0 +DA:3655,0 +DA:3656,0 +DA:3660,1 +DA:3663,10 +DA:3665,10 +DA:3666,0 +DA:3667,0 +DA:3668,0 +DA:3673,10 +DA:3675,10 +DA:3678,10 +DA:3680,10 +DA:3681,0 +DA:3682,0 +DA:3683,0 +DA:3688,10 +DA:3690,10 +DA:3693,2 +DA:3695,2 +DA:3696,0 +DA:3697,0 +DA:3698,0 +DA:3703,2 +DA:3705,2 +DA:3708,0 +DA:3710,0 +DA:3711,0 +DA:3712,0 +DA:3713,0 +DA:3718,0 +DA:3720,0 +DA:3723,0 +DA:3725,0 +DA:3726,0 +DA:3727,0 +DA:3728,0 +DA:3733,0 +DA:3735,0 +DA:3738,0 +DA:3740,0 +DA:3741,0 +DA:3742,0 +DA:3743,0 +DA:3748,0 +DA:3750,0 +DA:3753,0 +DA:3755,0 +DA:3756,0 +DA:3757,0 +DA:3758,0 +DA:3762,0 +DA:3764,0 +DA:3767,0 +DA:3769,0 +DA:3770,0 +DA:3771,0 +DA:3772,0 +DA:3776,0 +DA:3778,0 +DA:3782,10500 +DA:3788,10500 +DA:3792,10500 +DA:3793,10500 +DA:3795,5250 +DA:3819,5250 +DA:3820,0 +DA:3826,10500 +DA:3829,5250 +DA:3830,5250 +DA:3831,5250 +DA:3832,0 +DA:3837,5266 +DA:3838,5266 +DA:3840,0 +DA:3843,21 +DA:3846,21 +DA:3847,10 +DA:3862,21 +DA:3863,21 +DA:3864,21 +DA:3872,6411 +DA:3876,6411 +DA:3879,6411 +DA:3880,0 +DA:3882,0 +DA:3883,0 +DA:3884,0 +DA:3886,0 +DA:3890,6411 +DA:3891,6411 +DA:3892,6411 +DA:3895,6008 +DA:3903,6008 +DA:3904,0 +DA:3905,0 +DA:3908,6008 +DA:3909,6008 +DA:3910,5999 +DA:3911,5999 +DA:3916,5999 +DA:3919,5999 +DA:3922,5999 +DA:3924,5999 +DA:3927,5999 +DA:3928,5999 +DA:3931,5999 +DA:3932,5999 +DA:3935,5999 +DA:3936,5999 +DA:3939,5999 +DA:3940,5999 +DA:3941,5999 +DA:3944,6009 +DA:3946,5996 +DA:3949,3 +DA:3950,2 +DA:3956,5999 +DA:3959,5999 +DA:3962,5999 +DA:3963,5998 +DA:3966,1 +DA:3969,5999 +DA:3973,5999 +DA:3975,5998 +DA:3976,5998 +DA:3977,5998 +DA:3979,5998 +DA:3980,5998 +DA:3982,5998 +DA:3983,5998 +DA:3984,5998 +DA:3986,0 +DA:3988,0 +DA:3989,0 +DA:3990,0 +DA:4001,6007 +DA:4002,5996 +DA:4004,5998 +DA:4005,5998 +DA:4006,5998 +DA:4008,5998 +DA:4009,5998 +DA:4013,1 +DA:4017,5999 +DA:4019,5999 +DA:4020,0 +DA:4021,0 +DA:4024,5999 +DA:4027,5999 +DA:4029,5999 +DA:4030,0 +DA:4034,5999 +DA:4035,0 +DA:4041,0 +DA:4042,0 +DA:4047,0 +DA:4048,0 +DA:4049,0 +DA:4050,0 +DA:4051,0 +DA:4054,0 +DA:4058,0 +DA:4060,0 +DA:4061,0 +DA:4065,5999 +DA:4066,0 +DA:4067,0 +DA:4068,0 +DA:4075,5999 +DA:4076,5811 +DA:4078,5999 +DA:4106,5998 +DA:4109,5998 +DA:4110,5998 +DA:4116,5999 +DA:4117,190 +DA:4120,190 +DA:4121,190 +DA:4122,190 +DA:4124,190 +DA:4125,5999 +DA:4126,0 +DA:4128,0 +DA:4129,0 +DA:4133,0 +DA:4139,0 +DA:4142,0 +DA:4143,0 +DA:4153,0 +DA:4154,0 +DA:4156,0 +DA:4158,0 +DA:4161,0 +DA:4163,0 +DA:4165,0 +DA:4167,0 +DA:4170,0 +DA:4178,171 +DA:4185,171 +DA:4189,171 +DA:4193,171 +DA:4194,171 +DA:4196,171 +DA:4197,171 +DA:4199,0 +DA:4201,171 +DA:4204,171 +DA:4207,171 +DA:4210,171 +DA:4211,164 +DA:4215,164 +DA:4216,164 +DA:4221,181 +DA:4227,181 +DA:4231,172 +DA:4235,172 +DA:4236,172 +DA:4238,172 +DA:4241,172 +DA:4246,172 +DA:4247,166 +DA:4257,205 +DA:4263,205 +DA:4266,205 +DA:4269,205 +DA:4273,205 +DA:4277,205 +DA:4278,205 +DA:4279,205 +DA:4280,205 +DA:4282,205 +DA:4283,205 +DA:4285,205 +DA:4286,205 +DA:4288,0 +DA:4290,205 +DA:4293,205 +DA:4295,205 +DA:4301,205 +DA:4304,205 +DA:4305,167 +DA:4309,167 +DA:4310,167 +DA:4316,204 +DA:4322,204 +DA:4325,204 +DA:4328,204 +DA:4332,204 +DA:4336,204 +DA:4337,204 +DA:4338,204 +DA:4340,204 +DA:4343,204 +DA:4350,204 +DA:4351,167 +DA:4361,0 +DA:4367,0 +DA:4368,0 +DA:4369,0 +DA:4372,0 +DA:4373,0 +DA:4374,0 +DA:4377,0 +DA:4381,0 +DA:4385,0 +DA:4386,0 +DA:4387,0 +DA:4389,0 +DA:4392,0 +DA:4397,0 +DA:4398,0 +DA:4408,4 +DA:4414,4 +DA:4415,0 +DA:4416,0 +DA:4420,4 +DA:4424,4 +DA:4426,4 +DA:4429,4 +DA:4434,4 +DA:4435,4 +DA:4445,1 +DA:4451,1 +DA:4454,1 +DA:4458,1 +DA:4462,1 +DA:4463,1 +DA:4473,0 +DA:4480,0 +DA:4484,0 +DA:4485,0 +DA:4486,0 +DA:4489,0 +DA:4490,0 +DA:4492,0 +DA:4493,0 +DA:4494,0 +DA:4497,0 +DA:4501,0 +DA:4502,0 +DA:4503,0 +DA:4505,0 +DA:4507,0 +DA:4510,5266 +DA:4538,5266 +DA:4544,5266 +DA:4546,5266 +DA:4547,5266 +DA:4549,5266 +DA:4551,21 +DA:4552,9 +DA:4553,0 +DA:4554,0 +DA:4557,9 +DA:4563,21 +DA:4570,12 +DA:4573,12 +DA:4576,0 +DA:4578,0 +DA:4581,24 +DA:4582,12 +DA:4586,12 +DA:4587,0 +DA:4588,0 +DA:4591,12 +DA:4592,5 +DA:4594,5 +DA:4599,5 +DA:4602,0 +DA:4603,5 +DA:4605,5 +DA:4606,5 +DA:4607,5 +DA:4608,5 +DA:4609,5 +DA:4610,5 +DA:4612,5 +DA:4613,0 +DA:4616,5 +DA:4617,0 +DA:4618,0 +DA:4620,5 +DA:4621,5 +DA:4624,5 +DA:4625,5 +DA:4629,5 +DA:4633,5 +DA:4634,0 +DA:4636,0 +DA:4637,0 +DA:4640,5 +DA:4646,0 +DA:4649,0 +DA:4654,0 +DA:4655,0 +DA:4658,0 +DA:4660,0 +DA:4661,0 +DA:4662,0 +DA:4667,0 +DA:4669,0 +DA:4671,0 +DA:4672,0 +DA:4673,0 +DA:4674,0 +DA:4676,0 +DA:4682,0 +DA:4689,0 +DA:4694,0 +DA:4696,0 +DA:4700,0 +DA:4701,0 +DA:4702,0 +DA:4708,0 +DA:4711,0 +DA:4713,0 +DA:4716,0 +DA:4718,0 +DA:4721,0 +DA:4728,0 +DA:4732,0 +DA:4734,0 +DA:4735,0 +DA:4740,7 +DA:4743,7 +DA:4748,7 +DA:4749,7 +DA:4752,7 +DA:4758,0 +DA:4760,0 +DA:4762,0 +DA:4765,0 +DA:4774,9 +DA:4775,0 +DA:4783,5834 +DA:4784,0 +DA:4789,5834 +DA:4791,5834 +DA:4792,3 +DA:4793,3 +DA:4797,5831 +DA:4798,5831 +DA:4800,5831 +DA:4802,1 +DA:4803,1 +DA:4805,1 +DA:4806,1 +DA:4809,1 +DA:4810,1 +DA:4811,0 +DA:4814,0 +DA:4816,0 +DA:4817,0 +DA:4821,1 +DA:4824,1 +DA:4828,1 +DA:4829,0 +DA:4851,1 +DA:4855,1 +DA:4856,0 +DA:4859,1 +DA:4861,1 +DA:4862,1 +DA:4866,1 +DA:4867,1 +DA:4871,0 +DA:4877,121 +DA:4883,121 +DA:4884,111 +DA:4904,111 +DA:4905,111 +DA:4907,0 +DA:4910,0 +DA:4922,0 +DA:4925,0 +DA:4928,0 +DA:4931,0 +DA:4933,0 +DA:4935,0 +DA:4936,0 +DA:4937,0 +DA:4941,0 +DA:4943,0 +DA:4944,0 +DA:4946,0 +DA:4951,0 +DA:4953,0 +DA:4957,0 +DA:4963,0 +DA:4966,0 +DA:4970,0 +DA:4971,0 +DA:4973,0 +DA:4978,0 +DA:4979,0 +DA:4980,0 +DA:4983,0 +DA:4989,0 +DA:4990,0 +DA:4993,0 +DA:4994,0 +DA:5010,5250 +DA:5015,5250 +DA:5022,5250 +DA:5023,5250 +DA:5024,5250 +DA:5026,5250 +DA:5030,0 +DA:5031,0 +DA:5034,5250 +DA:5036,5250 +DA:5048,5250 +DA:5049,653172 +DA:5056,650463 +DA:5057,650463 +DA:5058,650463 +DA:5061,650463 +DA:5062,650463 +DA:5066,650463 +DA:5069,650463 +DA:5074,5250 +DA:5075,0 +DA:5076,0 +DA:5077,0 +DA:5082,5250 +DA:5084,0 +DA:5085,0 +DA:5091,5250 +DA:5096,5250 +DA:5099,5250 +DA:5110,5250 +DA:5111,0 +DA:5124,5250 +DA:5125,5250 +DA:5126,5250 +DA:5127,5250 +DA:5129,5250 +DA:5131,5250 +DA:5132,0 +DA:5138,5250 +DA:5139,5250 +DA:5141,5250 +DA:5142,0 +DA:5146,5250 +DA:5150,5250 +DA:5151,5250 +DA:5153,5250 +DA:5154,0 +DA:5158,5250 +DA:5161,5250 +DA:5163,0 +DA:5165,0 +DA:5166,0 +DA:5167,0 +DA:5168,0 +DA:5170,859 +DA:5172,0 +DA:5174,859 +DA:5176,859 +DA:5177,859 +DA:5178,859 +DA:5180,859 +DA:5182,859 +DA:5186,0 +DA:5187,0 +DA:5192,859 +DA:5194,859 +LF:1758 +LH:1008 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/offlinelogstorage/dlt_offline_logstorage.c +FN:44,dlt_logstorage_filter_config_free +FN:113,dlt_logstorage_list_destroy +FN:150,dlt_logstorage_list_add_config +FN:185,dlt_logstorage_list_add +FN:248,dlt_logstorage_list_find +FN:275,dlt_logstorage_count_ids +FN:305,dlt_logstorage_free +FN:332,dlt_logstorage_read_list_of_names +FN:395,dlt_logstorage_set_number +FN:420,dlt_logstorage_read_number +FN:454,dlt_logstorage_read_bool +FN:484,dlt_logstorage_get_keys_list +FN:543,dlt_logstorage_create_keys_only_ctid +FN:575,dlt_logstorage_create_keys_only_apid +FN:609,dlt_logstorage_create_keys_multi +FN:643,dlt_logstorage_create_keys_only_ecu +FN:681,dlt_logstorage_create_keys +FN:779,dlt_logstorage_prepare_table +FN:870,dlt_logstorage_validate_filter_name +FN:920,dlt_logstorage_filter_set_strategy +FN:940,dlt_logstorage_check_apids +FN:951,dlt_logstorage_check_ctids +FN:960,dlt_logstorage_set_loglevel +FN:972,dlt_logstorage_check_loglevel +FN:1012,dlt_logstorage_check_reset_loglevel +FN:1059,dlt_logstorage_check_filename +FN:1103,dlt_logstorage_check_filesize +FN:1112,dlt_logstorage_check_nofiles +FN:1121,dlt_logstorage_check_gzip_compression +FN:1135,dlt_logstorage_check_specificsize +FN:1144,dlt_logstorage_set_sync_strategy +FN:1172,dlt_logstorage_check_sync_strategy +FN:1222,dlt_logstorage_check_overwrite_strategy +FN:1254,dlt_logstorage_check_disable_network +FN:1283,dlt_logstorage_check_ecuid +FN:1523,dlt_logstorage_check_param +FN:1536,dlt_logstorage_get_filter_section_value +FN:1571,dlt_logstorage_get_filter_value +FN:1614,dlt_logstorage_setup_table +FN:1637,dlt_daemon_offline_setup_filter_properties +FN:1725,dlt_logstorage_check_maintain_logstorage_loglevel +FN:1769,dlt_logstorage_check_general_param +FN:1786,dlt_daemon_setup_general_properties +FN:1844,dlt_logstorage_store_filters +FN:1931,dlt_logstorage_load_config +FN:1986,dlt_logstorage_device_connected +FN:2029,dlt_logstorage_device_disconnected +FN:2075,dlt_logstorage_get_loglevel_by_key +FN:2136,dlt_logstorage_get_config +FN:2269,dlt_logstorage_filter +FN:2343,dlt_logstorage_write +FN:2615,dlt_logstorage_sync_caches +FNDA:36,dlt_logstorage_setup_table +FNDA:0,dlt_logstorage_check_maintain_logstorage_loglevel +FNDA:10,dlt_logstorage_load_config +FNDA:9,dlt_logstorage_read_bool +FNDA:13,dlt_logstorage_list_destroy +FNDA:40273,dlt_logstorage_list_find +FNDA:38,dlt_logstorage_check_nofiles +FNDA:0,dlt_logstorage_set_sync_strategy +FNDA:75,dlt_logstorage_filter_config_free +FNDA:468,dlt_logstorage_get_filter_value +FNDA:76,dlt_logstorage_get_keys_list +FNDA:5842,dlt_logstorage_write +FNDA:4,dlt_logstorage_create_keys_only_apid +FNDA:0,dlt_logstorage_check_reset_loglevel +FNDA:11,dlt_logstorage_store_filters +FNDA:5878,dlt_logstorage_get_config +FNDA:27,dlt_logstorage_check_sync_strategy +FNDA:5,dlt_logstorage_set_loglevel +FNDA:38,dlt_logstorage_check_apids +FNDA:76,dlt_logstorage_read_list_of_names +FNDA:4,dlt_logstorage_sync_caches +FNDA:13,dlt_logstorage_filter_set_strategy +FNDA:38,dlt_logstorage_prepare_table +FNDA:0,dlt_logstorage_create_keys_only_ecu +FNDA:0,dlt_logstorage_check_general_param +FNDA:38,dlt_logstorage_create_keys +FNDA:468,dlt_logstorage_get_filter_section_value +FNDA:8,dlt_logstorage_device_disconnected +FNDA:38,dlt_logstorage_check_loglevel +FNDA:34,dlt_logstorage_create_keys_multi +FNDA:7,dlt_logstorage_free +FNDA:26,dlt_logstorage_check_param +FNDA:12,dlt_logstorage_set_number +FNDA:39,dlt_logstorage_check_filename +FNDA:81,dlt_logstorage_read_number +FNDA:0,dlt_logstorage_create_keys_only_ctid +FNDA:39,dlt_logstorage_check_filesize +FNDA:9,dlt_logstorage_device_connected +FNDA:38,dlt_logstorage_validate_filter_name +FNDA:30,dlt_logstorage_check_overwrite_strategy +FNDA:34,dlt_logstorage_check_ecuid +FNDA:58,dlt_logstorage_list_add +FNDA:13,dlt_logstorage_count_ids +FNDA:1,dlt_logstorage_check_disable_network +FNDA:0,dlt_daemon_setup_general_properties +FNDA:38,dlt_logstorage_check_ctids +FNDA:37,dlt_logstorage_get_loglevel_by_key +FNDA:4,dlt_logstorage_check_specificsize +FNDA:59,dlt_logstorage_list_add_config +FNDA:0,dlt_logstorage_check_gzip_compression +FNDA:36,dlt_daemon_offline_setup_filter_properties +FNDA:5843,dlt_logstorage_filter +FNF:52 +FNH:44 +DA:44,75 +DA:49,75 +DA:50,72 +DA:51,72 +DA:54,75 +DA:55,72 +DA:56,72 +DA:59,75 +DA:60,70 +DA:61,70 +DA:64,75 +DA:65,27 +DA:66,27 +DA:69,75 +DA:70,64 +DA:71,64 +DA:74,75 +DA:75,17 +DA:82,75 +DA:83,23 +DA:84,23 +DA:87,75 +DA:89,113 +DA:91,38 +DA:92,38 +DA:93,38 +DA:97,38 +DA:100,75 +DA:113,13 +DA:120,52 +DA:122,39 +DA:123,39 +DA:125,39 +DA:126,39 +DA:129,39 +DA:132,39 +DA:137,39 +DA:139,39 +DA:143,39 +DA:147,13 +DA:150,59 +DA:153,59 +DA:159,59 +DA:160,54 +DA:162,59 +DA:163,54 +DA:165,59 +DA:166,52 +DA:168,59 +DA:169,48 +DA:185,58 +DA:192,209 +DA:193,151 +DA:196,58 +DA:198,58 +DA:201,58 +DA:202,58 +DA:203,58 +DA:205,0 +DA:207,0 +DA:211,58 +DA:212,58 +DA:213,58 +DA:215,58 +DA:216,0 +DA:218,0 +DA:220,0 +DA:223,58 +DA:224,0 +DA:226,0 +DA:228,0 +DA:230,0 +DA:233,58 +DA:235,58 +DA:248,40273 +DA:255,459888 +DA:256,833540 +DA:258,419615 +DA:259,419615 +DA:262,5690 +DA:263,5690 +DA:264,5690 +DA:267,419615 +DA:270,40273 +DA:275,13 +DA:278,13 +DA:286,384 +DA:287,308 +DA:288,12 +DA:290,308 +DA:305,7 +DA:307,7 +DA:308,0 +DA:309,0 +DA:312,7 +DA:313,7 +DA:332,76 +DA:340,76 +DA:341,1 +DA:342,1 +DA:346,75 +DA:347,3 +DA:348,3 +DA:351,75 +DA:353,75 +DA:354,0 +DA:356,0 +DA:360,11 +DA:363,75 +DA:365,75 +DA:366,0 +DA:367,0 +DA:370,75 +DA:371,75 +DA:375,159 +DA:376,84 +DA:377,84 +DA:379,84 +DA:381,84 +DA:382,9 +DA:384,84 +DA:386,84 +DA:387,84 +DA:395,12 +DA:397,12 +DA:398,0 +DA:399,0 +DA:402,80 +DA:404,80 +DA:420,81 +DA:426,81 +DA:429,80 +DA:430,80 +DA:433,308 +DA:434,228 +DA:435,0 +DA:436,0 +DA:439,80 +DA:441,80 +DA:454,9 +DA:457,9 +DA:460,8 +DA:461,8 +DA:462,8 +DA:463,1 +DA:464,7 +DA:465,1 +DA:466,6 +DA:467,1 +DA:484,76 +DA:488,76 +DA:491,76 +DA:494,76 +DA:496,76 +DA:499,76 +DA:501,76 +DA:502,0 +DA:503,0 +DA:506,76 +DA:509,76 +DA:510,0 +DA:511,0 +DA:514,152 +DA:516,76 +DA:517,0 +DA:518,0 +DA:521,76 +DA:523,76 +DA:524,76 +DA:527,76 +DA:529,76 +DA:543,0 +DA:546,0 +DA:549,0 +DA:557,0 +DA:558,0 +DA:559,0 +DA:561,0 +DA:562,0 +DA:575,4 +DA:578,4 +DA:581,4 +DA:589,4 +DA:590,4 +DA:592,4 +DA:594,4 +DA:595,4 +DA:609,34 +DA:612,34 +DA:615,34 +DA:623,34 +DA:624,34 +DA:627,34 +DA:628,34 +DA:629,34 +DA:631,34 +DA:632,34 +DA:643,0 +DA:645,0 +DA:650,0 +DA:651,0 +DA:681,38 +DA:688,38 +DA:689,38 +DA:690,38 +DA:691,38 +DA:694,38 +DA:698,38 +DA:699,38 +DA:700,0 +DA:701,0 +DA:702,0 +DA:703,0 +DA:706,0 +DA:709,0 +DA:710,0 +DA:713,38 +DA:714,0 +DA:715,0 +DA:719,38 +DA:720,0 +DA:721,0 +DA:725,38 +DA:726,0 +DA:727,0 +DA:728,0 +DA:731,38 +DA:734,38 +DA:737,38 +DA:738,0 +DA:739,0 +DA:740,0 +DA:744,76 +DA:745,38 +DA:747,76 +DA:748,38 +DA:750,38 +DA:751,0 +DA:752,38 +DA:753,4 +DA:755,34 +DA:757,38 +DA:759,38 +DA:764,38 +DA:765,38 +DA:767,38 +DA:779,38 +DA:783,38 +DA:785,38 +DA:790,38 +DA:791,1 +DA:792,1 +DA:795,37 +DA:801,37 +DA:802,0 +DA:803,0 +DA:807,37 +DA:812,0 +DA:813,0 +DA:814,0 +DA:816,0 +DA:819,37 +DA:820,36 +DA:822,165 +DA:823,139 +DA:829,139 +DA:834,26 +DA:835,36 +DA:836,36 +DA:838,0 +DA:841,0 +DA:843,0 +DA:845,36 +DA:846,36 +DA:847,36 +DA:849,36 +DA:850,10 +DA:852,26 +DA:856,37 +DA:858,37 +DA:870,38 +DA:878,38 +DA:881,37 +DA:884,37 +DA:887,45 +DA:888,8 +DA:894,0 +DA:898,0 +DA:899,0 +DA:905,0 +DA:909,0 +DA:910,0 +DA:920,13 +DA:923,13 +DA:927,13 +DA:929,20 +DA:930,20 +DA:931,20 +DA:934,25 +DA:935,25 +DA:936,25 +DA:940,38 +DA:943,38 +DA:944,1 +DA:945,1 +DA:948,37 +DA:951,38 +DA:954,38 +DA:957,37 +DA:960,5 +DA:963,37 +DA:964,37 +DA:965,0 +DA:966,0 +DA:967,0 +DA:972,38 +DA:977,38 +DA:985,37 +DA:988,36 +DA:992,32 +DA:996,32 +DA:1000,0 +DA:1004,0 +DA:1009,5 +DA:1012,0 +DA:1015,0 +DA:1018,0 +DA:1019,0 +DA:1020,0 +DA:1023,0 +DA:1024,0 +DA:1026,0 +DA:1028,0 +DA:1030,0 +DA:1032,0 +DA:1034,0 +DA:1036,0 +DA:1038,0 +DA:1040,0 +DA:1042,0 +DA:1044,0 +DA:1046,0 +DA:1048,0 +DA:1051,0 +DA:1052,0 +DA:1053,0 +DA:1059,39 +DA:1064,39 +DA:1065,1 +DA:1066,1 +DA:1069,38 +DA:1070,2 +DA:1071,2 +DA:1074,38 +DA:1076,38 +DA:1077,0 +DA:1079,0 +DA:1083,38 +DA:1084,37 +DA:1086,37 +DA:1087,0 +DA:1089,0 +DA:1092,37 +DA:1095,1 +DA:1097,1 +DA:1100,37 +DA:1103,39 +DA:1106,39 +DA:1109,38 +DA:1112,38 +DA:1115,38 +DA:1118,37 +DA:1121,0 +DA:1124,0 +DA:1127,0 +DA:1129,0 +DA:1130,0 +DA:1132,0 +DA:1135,4 +DA:1138,4 +DA:1141,4 +DA:1144,0 +DA:1147,0 +DA:1149,0 +DA:1151,0 +DA:1153,0 +DA:1154,0 +DA:1172,27 +DA:1175,27 +DA:1178,26 +DA:1179,1 +DA:1180,1 +DA:1184,25 +DA:1185,8 +DA:1187,25 +DA:1188,4 +DA:1190,25 +DA:1191,0 +DA:1193,25 +DA:1194,4 +DA:1196,25 +DA:1197,12 +DA:1199,25 +DA:1200,1 +DA:1202,1 +DA:1203,1 +DA:1222,30 +DA:1225,30 +DA:1228,30 +DA:1229,12 +DA:1230,18 +DA:1231,18 +DA:1233,0 +DA:1235,0 +DA:1236,0 +DA:1254,1 +DA:1257,1 +DA:1260,1 +DA:1261,1 +DA:1262,0 +DA:1263,0 +DA:1265,0 +DA:1267,0 +DA:1268,0 +DA:1283,34 +DA:1288,34 +DA:1291,33 +DA:1292,1 +DA:1293,1 +DA:1296,33 +DA:1297,33 +DA:1299,33 +DA:1302,33 +DA:1304,33 +DA:1523,26 +DA:1527,26 +DA:1530,25 +DA:1531,25 +DA:1536,468 +DA:1543,468 +DA:1546,468 +DA:1547,432 +DA:1551,432 +DA:1552,0 +DA:1555,0 +DA:1558,432 +DA:1559,125 +DA:1561,125 +DA:1571,468 +DA:1581,468 +DA:1585,468 +DA:1588,468 +DA:1592,0 +DA:1595,0 +DA:1599,0 +DA:1602,0 +DA:1607,0 +DA:1614,36 +DA:1621,36 +DA:1623,36 +DA:1625,36 +DA:1626,0 +DA:1630,36 +DA:1637,36 +DA:1642,36 +DA:1646,36 +DA:1650,36 +DA:1652,36 +DA:1654,504 +DA:1655,468 +DA:1657,468 +DA:1660,468 +DA:1661,161 +DA:1664,307 +DA:1666,307 +DA:1667,0 +DA:1668,0 +DA:1669,0 +DA:1672,0 +DA:1673,0 +DA:1674,0 +DA:1677,0 +DA:1678,0 +DA:1679,0 +DA:1682,0 +DA:1683,0 +DA:1684,0 +DA:1687,0 +DA:1688,0 +DA:1692,0 +DA:1697,36 +DA:1699,36 +DA:1700,0 +DA:1704,36 +DA:1708,36 +DA:1710,36 +DA:1725,0 +DA:1728,0 +DA:1733,0 +DA:1735,0 +DA:1737,0 +DA:1739,0 +DA:1743,0 +DA:1745,0 +DA:1746,0 +DA:1769,0 +DA:1773,0 +DA:1778,0 +DA:1780,0 +DA:1786,0 +DA:1791,0 +DA:1793,0 +DA:1798,0 +DA:1800,0 +DA:1802,0 +DA:1805,0 +DA:1807,0 +DA:1814,0 +DA:1816,0 +DA:1822,0 +DA:1825,0 +DA:1844,11 +DA:1849,11 +DA:1855,11 +DA:1856,1 +DA:1857,1 +DA:1860,10 +DA:1862,10 +DA:1863,0 +DA:1864,0 +DA:1867,10 +DA:1868,10 +DA:1870,46 +DA:1873,36 +DA:1874,0 +DA:1875,0 +DA:1876,0 +DA:1879,36 +DA:1880,0 +DA:1882,0 +DA:1883,0 +DA:1886,36 +DA:1888,36 +DA:1890,36 +DA:1893,36 +DA:1896,0 +DA:1900,0 +DA:1904,36 +DA:1908,0 +DA:1912,10 +DA:1914,10 +DA:1931,10 +DA:1933,10 +DA:1937,10 +DA:1938,9 +DA:1942,9 +DA:1943,0 +DA:1946,0 +DA:1949,9 +DA:1952,9 +DA:1954,0 +DA:1956,0 +DA:1958,9 +DA:1959,9 +DA:1961,9 +DA:1962,0 +DA:1963,0 +DA:1965,9 +DA:1967,0 +DA:1969,0 +DA:1972,9 +DA:1974,9 +DA:1986,9 +DA:1988,9 +DA:1989,1 +DA:1990,1 +DA:1993,8 +DA:1994,0 +DA:1997,0 +DA:2002,8 +DA:2003,8 +DA:2004,8 +DA:2005,8 +DA:2006,8 +DA:2007,8 +DA:2008,8 +DA:2010,8 +DA:2011,8 +DA:2013,8 +DA:2029,8 +DA:2032,8 +DA:2036,7 +DA:2037,6 +DA:2040,7 +DA:2041,7 +DA:2042,7 +DA:2043,7 +DA:2044,7 +DA:2046,39 +DA:2048,32 +DA:2049,32 +DA:2050,32 +DA:2051,32 +DA:2053,32 +DA:2054,23 +DA:2057,32 +DA:2075,37 +DA:2077,37 +DA:2083,37 +DA:2084,37 +DA:2085,36 +DA:2086,36 +DA:2089,36 +DA:2091,36 +DA:2093,0 +DA:2094,0 +DA:2096,36 +DA:2098,36 +DA:2100,36 +DA:2109,0 +DA:2112,0 +DA:2114,0 +DA:2136,5878 +DA:2143,5878 +DA:2153,5878 +DA:2154,5877 +DA:2155,5877 +DA:2169,5877 +DA:2174,5877 +DA:2176,0 +DA:2180,0 +DA:2182,0 +DA:2185,5877 +DA:2190,5877 +DA:2197,5877 +DA:2203,5877 +DA:2212,5877 +DA:2236,45812 +DA:2238,40236 +DA:2239,40236 +DA:2241,40236 +DA:2243,40236 +DA:2269,5843 +DA:2279,5843 +DA:2283,5842 +DA:2285,5842 +DA:2286,231 +DA:2289,231 +DA:2292,11228 +DA:2294,5617 +DA:2296,0 +DA:2299,0 +DA:2303,5617 +DA:2304,6 +DA:2307,6 +DA:2308,6 +DA:2312,5611 +DA:2313,5611 +DA:2315,0 +DA:2318,0 +DA:2343,5842 +DA:2353,5842 +DA:2371,5842 +DA:2372,5841 +DA:2373,5841 +DA:2374,5841 +DA:2380,5841 +DA:2383,5841 +DA:2384,5 +DA:2386,5841 +DA:2387,2 +DA:2392,5841 +DA:2393,5841 +DA:2396,5841 +DA:2397,0 +DA:2398,0 +DA:2401,5841 +DA:2402,5841 +DA:2404,5841 +DA:2408,5841 +DA:2409,5841 +DA:2411,5841 +DA:2412,231 +DA:2415,231 +DA:2419,0 +DA:2422,0 +DA:2423,0 +DA:2424,0 +DA:2431,0 +DA:2432,0 +DA:2434,0 +DA:2435,0 +DA:2436,0 +DA:2441,11224 +DA:2443,5614 +DA:2445,6 +DA:2448,6 +DA:2453,5608 +DA:2455,0 +DA:2458,0 +DA:2462,5608 +DA:2463,201 +DA:2464,201 +DA:2465,0 +DA:2468,201 +DA:2472,5608 +DA:2474,1811 +DA:2477,1811 +DA:2480,3797 +DA:2481,23940 +DA:2482,23940 +DA:2487,20143 +DA:2490,3797 +DA:2491,0 +DA:2493,0 +DA:2497,3797 +DA:2498,0 +DA:2501,3797 +DA:2504,3797 +DA:2506,3797 +DA:2507,3797 +DA:2510,3797 +DA:2511,4 +DA:2514,3793 +DA:2515,3780 +DA:2518,691 +DA:2519,0 +DA:2521,0 +DA:2527,691 +DA:2528,684 +DA:2529,684 +DA:2531,691 +DA:2532,691 +DA:2536,3793 +DA:2537,3780 +DA:2547,3780 +DA:2555,3780 +DA:2557,3089 +DA:2558,1688 +DA:2559,1672 +DA:2560,1672 +DA:2562,1688 +DA:2563,1688 +DA:2568,3780 +DA:2573,3780 +DA:2574,0 +DA:2578,0 +DA:2580,0 +DA:2584,0 +DA:2589,13 +DA:2591,13 +DA:2593,2 +DA:2594,2 +DA:2598,11 +DA:2615,4 +DA:2619,4 +DA:2622,4 +DA:2624,30 +DA:2625,26 +DA:2626,26 +DA:2628,26 +DA:2630,0 +DA:2635,26 +LF:763 +LH:535 +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:490,dlt_logstorage_open_log_output_file +FN:522,dlt_logstorage_open_log_file +FN:777,dlt_logstorage_find_dlt_header +FN:803,dlt_logstorage_find_last_dlt_header +FN:829,dlt_logstorage_write_to_log +FN:851,dlt_logstorage_check_write_ret +FN:900,dlt_logstorage_close_file +FN:928,dlt_logstorage_sync_to_file +FN:1045,dlt_logstorage_prepare_on_msg +FN:1156,dlt_logstorage_write_on_msg +FN:1210,dlt_logstorage_sync_on_msg +FN:1250,dlt_logstorage_prepare_msg_cache +FN:1368,dlt_logstorage_write_msg_cache +FN:1508,dlt_logstorage_sync_msg_cache +FNDA:147,dlt_logstorage_log_file_name +FNDA:187,dlt_logstorage_sync_to_file +FNDA:321,dlt_logstorage_sort_file_name +FNDA:3299,dlt_logstorage_sync_msg_cache +FNDA:693,dlt_logstorage_write_on_msg +FNDA:200,dlt_logstorage_check_write_ret +FNDA:3093,dlt_logstorage_write_msg_cache +FNDA:3,dlt_logstorage_rearrange_file_name +FNDA:457,dlt_logstorage_get_idx_of_log_file +FNDA:297,dlt_logstorage_concat_logfile_name +FNDA:5,dlt_logstorage_write_to_log +FNDA:198,dlt_logstorage_open_log_output_file +FNDA:3098,dlt_logstorage_prepare_msg_cache +FNDA:86,dlt_logstorage_find_last_dlt_header +FNDA:270,dlt_logstorage_find_dlt_header +FNDA:714,dlt_logstorage_sync_on_msg +FNDA:708,dlt_logstorage_prepare_on_msg +FNDA:2,dlt_logstorage_close_file +FNDA:325,dlt_logstorage_storage_dir_info +FNDA:324,dlt_logstorage_open_log_file +FNF:20 +FNH:20 +DA:47,297 +DA:49,297 +DA:50,297 +DA:52,297 +DA:53,297 +DA:56,0 +DA:59,297 +DA:60,0 +DA:62,297 +DA:85,147 +DA:92,147 +DA:95,146 +DA:96,146 +DA:98,146 +DA:105,146 +DA:109,146 +DA:110,146 +DA:114,146 +DA:115,97 +DA:116,97 +DA:117,0 +DA:119,97 +DA:120,0 +DA:130,146 +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,146 +DA:155,146 +DA:156,0 +DA:168,321 +DA:173,321 +DA:176,362 +DA:179,187 +DA:180,187 +DA:184,390 +DA:185,203 +DA:186,203 +DA:188,13 +DA:189,13 +DA:190,13 +DA:195,203 +DA:197,203 +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,457 +DA:266,457 +DA:279,456 +DA:280,456 +DA:281,456 +DA:282,456 +DA:284,456 +DA:285,0 +DA:288,456 +DA:302,325 +DA:311,325 +DA:315,325 +DA:316,325 +DA:319,325 +DA:320,325 +DA:321,324 +DA:322,324 +DA:327,324 +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,324 +DA:349,324 +DA:350,5 +DA:352,5 +DA:355,319 +DA:360,319 +DA:361,319 +DA:362,771 +DA:364,487 +DA:365,487 +DA:367,487 +DA:370,284 +DA:374,7688 +DA:375,7369 +DA:376,0 +DA:379,7369 +DA:383,7369 +DA:385,7369 +DA:387,7369 +DA:388,7369 +DA:389,1134 +DA:391,179 +DA:392,91 +DA:393,0 +DA:396,673 +DA:400,955 +DA:401,373 +DA:404,582 +DA:410,461 +DA:411,287 +DA:413,287 +DA:415,0 +DA:416,0 +DA:419,287 +DA:422,174 +DA:424,348 +DA:425,174 +DA:427,174 +DA:429,174 +DA:431,0 +DA:432,0 +DA:436,461 +DA:437,461 +DA:442,461 +DA:443,461 +DA:444,461 +DA:445,461 +DA:446,461 +DA:450,319 +DA:453,319 +DA:454,319 +DA:463,319 +DA:464,0 +DA:468,7688 +DA:469,7369 +DA:471,319 +DA:473,319 +DA:474,319 +DA:490,198 +DA:494,198 +DA:495,198 +DA:496,198 +DA:502,198 +DA:503,198 +DA:505,198 +DA:522,324 +DA:530,324 +DA:531,324 +DA:532,324 +DA:539,324 +DA:542,323 +DA:543,0 +DA:544,0 +DA:550,323 +DA:551,323 +DA:556,318 +DA:558,779 +DA:559,461 +DA:561,461 +DA:564,461 +DA:568,318 +DA:569,31 +DA:572,31 +DA:573,31 +DA:579,31 +DA:580,31 +DA:583,31 +DA:585,31 +DA:586,0 +DA:587,0 +DA:590,31 +DA:591,31 +DA:592,31 +DA:601,287 +DA:602,285 +DA:603,284 +DA:604,284 +DA:606,285 +DA:608,287 +DA:610,287 +DA:615,287 +DA:620,287 +DA:621,287 +DA:622,122 +DA:623,167 +DA:624,167 +DA:631,120 +DA:634,81 +DA:639,120 +DA:640,14 +DA:645,14 +DA:646,10 +DA:649,10 +DA:650,10 +DA:654,110 +DA:658,110 +DA:660,2 +DA:663,110 +DA:666,110 +DA:667,110 +DA:677,110 +DA:678,110 +DA:679,110 +DA:685,110 +DA:686,1 +DA:687,1 +DA:688,1 +DA:693,110 +DA:695,110 +DA:700,110 +DA:702,110 +DA:703,0 +DA:704,0 +DA:707,110 +DA:708,110 +DA:709,110 +DA:711,110 +DA:714,110 +DA:715,102 +DA:718,69 +DA:723,69 +DA:724,69 +DA:728,69 +DA:730,69 +DA:731,69 +DA:732,69 +DA:734,69 +DA:744,308 +DA:746,0 +DA:747,0 +DA:748,0 +DA:749,0 +DA:751,0 +DA:752,0 +DA:755,0 +DA:756,0 +DA:757,0 +DA:760,0 +DA:761,0 +DA:777,270 +DA:781,270 +DA:782,270 +DA:785,284 +DA:786,283 +DA:787,269 +DA:803,86 +DA:807,86 +DA:808,86 +DA:811,6016 +DA:812,5953 +DA:813,23 +DA:829,5 +DA:839,5 +DA:851,200 +DA:854,200 +DA:855,0 +DA:857,200 +DA:858,22 +DA:866,22 +DA:867,0 +DA:872,178 +DA:878,178 +DA:879,0 +DA:882,178 +DA:884,0 +DA:885,0 +DA:890,200 +DA:900,2 +DA:909,183 +DA:910,283 +DA:911,283 +DA:913,2 +DA:928,187 +DA:941,187 +DA:942,186 +DA:944,1 +DA:945,1 +DA:948,186 +DA:953,2 +DA:954,186 +DA:956,186 +DA:958,0 +DA:959,0 +DA:962,186 +DA:966,184 +DA:968,184 +DA:971,84 +DA:973,84 +DA:975,84 +DA:976,84 +DA:978,84 +DA:979,22 +DA:981,22 +DA:982,22 +DA:985,0 +DA:986,22 +DA:988,22 +DA:989,22 +DA:994,0 +DA:995,62 +DA:999,184 +DA:1000,184 +DA:1002,184 +DA:1005,184 +DA:1007,84 +DA:1010,0 +DA:1011,0 +DA:1014,84 +DA:1020,178 +DA:1021,178 +DA:1023,178 +DA:1024,178 +DA:1027,178 +DA:1029,178 +DA:1045,708 +DA:1054,708 +DA:1055,707 +DA:1056,1 +DA:1057,1 +DA:1064,707 +DA:1067,16 +DA:1068,2 +DA:1069,2 +DA:1070,1 +DA:1071,1 +DA:1073,2 +DA:1077,16 +DA:1085,691 +DA:1087,691 +DA:1094,688 +DA:1095,653 +DA:1096,653 +DA:1099,35 +DA:1101,35 +DA:1102,0 +DA:1103,0 +DA:1108,0 +DA:1111,35 +DA:1112,35 +DA:1113,35 +DA:1114,35 +DA:1115,35 +DA:1117,35 +DA:1120,35 +DA:1132,3 +DA:1156,693 +DA:1168,693 +DA:1169,692 +DA:1174,692 +DA:1176,692 +DA:1177,0 +DA:1179,692 +DA:1180,692 +DA:1181,0 +DA:1183,692 +DA:1184,692 +DA:1185,0 +DA:1195,692 +DA:1210,714 +DA:1218,714 +DA:1221,713 +DA:1222,692 +DA:1228,692 +DA:1229,0 +DA:1250,3098 +DA:1256,3098 +DA:1257,3097 +DA:1266,3097 +DA:1267,1673 +DA:1268,1672 +DA:1269,1672 +DA:1270,0 +DA:1271,0 +DA:1273,1673 +DA:1274,1 +DA:1275,1 +DA:1284,3097 +DA:1285,452 +DA:1286,0 +DA:1287,0 +DA:1293,3097 +DA:1294,452 +DA:1295,452 +DA:1297,0 +DA:1300,0 +DA:1303,3097 +DA:1308,29 +DA:1311,4 +DA:1315,25 +DA:1319,29 +DA:1320,29 +DA:1323,5 +DA:1326,5 +DA:1328,24 +DA:1335,24 +DA:1337,24 +DA:1339,0 +DA:1345,24 +DA:1368,3093 +DA:1385,3093 +DA:1386,3092 +DA:1387,3092 +DA:1392,3092 +DA:1395,452 +DA:1399,2640 +DA:1402,3092 +DA:1408,3092 +DA:1409,3092 +DA:1411,3092 +DA:1413,2824 +DA:1414,2824 +DA:1415,2824 +DA:1416,1508 +DA:1420,2824 +DA:1421,2824 +DA:1422,2824 +DA:1423,2824 +DA:1424,2824 +DA:1432,3092 +DA:1435,268 +DA:1437,0 +DA:1438,0 +DA:1442,268 +DA:1445,62 +DA:1449,62 +DA:1451,0 +DA:1452,0 +DA:1455,206 +DA:1459,102 +DA:1463,102 +DA:1465,0 +DA:1466,0 +DA:1469,104 +DA:1470,52 +DA:1471,52 +DA:1474,104 +DA:1477,268 +DA:1480,268 +DA:1481,268 +DA:1482,268 +DA:1485,268 +DA:1486,268 +DA:1487,268 +DA:1488,268 +DA:1489,268 +DA:1508,3299 +DA:1517,3299 +DA:1523,3298 +DA:1525,177 +DA:1527,0 +DA:1529,0 +DA:1532,177 +DA:1535,102 +DA:1539,75 +DA:1542,177 +DA:1550,177 +DA:1553,169 +DA:1557,8 +DA:1558,0 +DA:1562,0 +DA:1564,0 +DA:1565,0 +DA:1572,8 +DA:1574,8 +DA:1575,8 +DA:1580,177 +DA:1581,177 +DA:1584,164 +DA:1588,177 +DA:1591,0 +DA:1592,62 +LF:477 +LH:406 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/shared/dlt_common.c +FN:124,dlt_print_hex +FN:139,dlt_print_hex_string_delim +FN:167,dlt_print_hex_string +FN:172,dlt_print_mixed_string +FN:288,dlt_print_char_string +FN:320,dlt_strnlen_s +FN:332,dlt_print_id +FN:348,dlt_set_id +FN:380,dlt_clean_string +FN:392,dlt_filter_init +FN:404,dlt_filter_free +FN:414,dlt_filter_load +FN:482,dlt_filter_save +FN:523,dlt_filter_find +FN:559,dlt_filter_add +FN:591,dlt_filter_delete +FN:641,dlt_message_init +FN:664,dlt_message_free +FN:681,dlt_message_header +FN:686,dlt_message_header_flags +FN:814,dlt_message_payload +FN:956,dlt_message_filter_check +FN:987,dlt_message_read +FN:1128,dlt_message_get_extraparameters +FN:1156,dlt_message_set_extraparameters +FN:1188,dlt_file_init +FN:1212,dlt_file_set_filter +FN:1225,dlt_file_read_header +FN:1295,dlt_file_read_header_raw +FN:1394,dlt_file_read_header_extended +FN:1437,dlt_file_read_data +FN:1476,dlt_file_open +FN:1521,dlt_file_read +FN:1635,dlt_file_read_raw +FN:1711,dlt_file_close +FN:1726,dlt_file_message +FN:1762,dlt_file_free +FN:1784,dlt_log_set_level +FN:1797,dlt_log_set_filename +FN:1810,dlt_log_set_fifo_basedir +FN:1825,dlt_print_with_attributes +FN:1830,dlt_log_init +FN:1835,dlt_log_init_multiple_logfiles_support +FN:1863,dlt_log_init_single_logfile +FN:1876,dlt_log_init_multiple_logfiles +FN:1911,dlt_log_free +FN:1922,dlt_log_free_single_logfile +FN:1928,dlt_log_free_multiple_logfiles +FN:1936,dlt_user_printf +FN:1963,dlt_log +FN:2039,dlt_vlog +FN:2060,dlt_vnlog +FN:2087,dlt_receiver_init +FN:2124,dlt_receiver_init_global_buffer +FN:2152,dlt_receiver_free +FN:2171,dlt_receiver_free_global_buffer +FN:2187,dlt_receiver_receive +FN:2240,dlt_receiver_remove +FN:2260,dlt_receiver_move_to_begin +FN:2282,dlt_receiver_check_and_get +FN:2316,dlt_set_storageheader +FN:2352,dlt_check_rcv_data_size +FN:2363,dlt_check_storageheader +FN:2375,dlt_buffer_init_static_server +FN:2406,dlt_buffer_init_static_client +FN:2428,dlt_buffer_init_dynamic +FN:2488,dlt_buffer_free_static +FN:2503,dlt_buffer_free_dynamic +FN:2522,dlt_buffer_write_block +FN:2553,dlt_buffer_read_block +FN:2579,dlt_buffer_check_size +FN:2590,dlt_buffer_increase_size +FN:2656,dlt_buffer_minimize_size +FN:2703,dlt_buffer_reset +FN:2726,dlt_buffer_push +FN:2731,dlt_buffer_push3 +FN:2822,dlt_buffer_get +FN:2942,dlt_buffer_pull +FN:2947,dlt_buffer_copy +FN:2952,dlt_buffer_remove +FN:2957,dlt_buffer_info +FN:2970,dlt_buffer_status +FN:2993,dlt_buffer_get_total_size +FN:3002,dlt_buffer_get_used_size +FN:3027,dlt_buffer_get_message_count +FN:3042,dlt_setup_serial +FN:3109,dlt_convert_serial_speed +FN:3282,dlt_get_version +FN:3307,dlt_get_major_version +FN:3317,dlt_get_minor_version +FN:3328,dlt_uptime +FN:3347,dlt_message_print_header +FN:3359,dlt_message_print_hex +FN:3375,dlt_message_print_ascii +FN:3391,dlt_message_print_mixed_plain +FN:3407,dlt_message_print_mixed_html +FN:3424,dlt_message_argument_print +FN:4072,dlt_check_envvar +FN:4116,dlt_set_loginfo_parse_service_id +FN:4144,dlt_getloginfo_conv_ascii_to_uint16_t +FN:4165,dlt_getloginfo_conv_ascii_to_int16_t +FN:4184,dlt_getloginfo_conv_ascii_to_string +FN:4198,dlt_getloginfo_conv_ascii_to_id +FN:4220,dlt_hex_ascii_to_binary +FN:4270,dlt_file_quick_parsing +FN:4346,dlt_execute_command +FN:4409,get_filename_ext +FN:4420,dlt_extract_base_name_without_ext +FN:4433,dlt_log_multiple_files_write +FN:4443,dlt_is_log_in_multiple_files_active +FNDA:1,dlt_filter_free +FNDA:12,dlt_log_multiple_files_write +FNDA:7,dlt_filter_init +FNDA:6205,dlt_print_id +FNDA:41034,dlt_buffer_write_block +FNDA:6122,dlt_message_init +FNDA:859,dlt_buffer_check_size +FNDA:1722,dlt_receiver_receive +FNDA:8,dlt_buffer_minimize_size +FNDA:0,dlt_filter_delete +FNDA:5381,dlt_buffer_init_dynamic +FNDA:2733,dlt_print_hex_string_delim +FNDA:2503,dlt_buffer_get_used_size +FNDA:5355,dlt_buffer_free_dynamic +FNDA:133,dlt_receiver_check_and_get +FNDA:1062,dlt_print_mixed_string +FNDA:12,dlt_filter_find +FNDA:3,dlt_buffer_get_total_size +FNDA:2,dlt_buffer_status +FNDA:328,dlt_message_print_header +FNDA:9,dlt_receiver_init_global_buffer +FNDA:6296,dlt_uptime +FNDA:9,dlt_receiver_free_global_buffer +FNDA:9,dlt_get_minor_version +FNDA:15,dlt_log_free +FNDA:12,dlt_getloginfo_conv_ascii_to_int16_t +FNDA:742,dlt_message_filter_check +FNDA:7035,dlt_file_read_header +FNDA:4700,dlt_file_read_header_extended +FNDA:1964874,dlt_vlog +FNDA:0,dlt_buffer_init_static_server +FNDA:5250,dlt_check_envvar +FNDA:12,dlt_filter_add +FNDA:5244,dlt_vnlog +FNDA:0,dlt_file_close +FNDA:20,dlt_getloginfo_conv_ascii_to_id +FNDA:0,dlt_file_read_raw +FNDA:5292,dlt_receiver_init +FNDA:3965,dlt_file_message +FNDA:71,dlt_file_init +FNDA:6207,dlt_strnlen_s +FNDA:6,dlt_file_set_filter +FNDA:12099,dlt_set_storageheader +FNDA:5259,dlt_log_set_fifo_basedir +FNDA:2852,dlt_user_printf +FNDA:17,dlt_log_set_filename +FNDA:5291,dlt_receiver_free +FNDA:328,dlt_message_print_mixed_plain +FNDA:7415,dlt_message_get_extraparameters +FNDA:8,dlt_buffer_pull +FNDA:6093,dlt_receiver_remove +FNDA:54223,dlt_set_id +FNDA:0,dlt_hex_ascii_to_binary +FNDA:6,dlt_extract_base_name_without_ext +FNDA:67,dlt_file_open +FNDA:328,dlt_message_print_mixed_html +FNDA:2615,dlt_message_header +FNDA:14,dlt_getloginfo_conv_ascii_to_uint16_t +FNDA:2724,dlt_print_hex_string +FNDA:7,dlt_buffer_increase_size +FNDA:19,dlt_log_set_level +FNDA:2965,dlt_file_read +FNDA:6,dlt_filter_load +FNDA:2,dlt_buffer_info +FNDA:1661,dlt_print_char_string +FNDA:3551,dlt_message_argument_print +FNDA:0,dlt_buffer_init_static_client +FNDA:7,dlt_buffer_remove +FNDA:53,dlt_buffer_read_block +FNDA:0,dlt_file_read_header_raw +FNDA:9,dlt_get_major_version +FNDA:6979,dlt_check_storageheader +FNDA:37,dlt_is_log_in_multiple_files_active +FNDA:0,dlt_print_hex +FNDA:6675,dlt_message_read +FNDA:1549,dlt_clean_string +FNDA:9,dlt_buffer_reset +FNDA:26,dlt_log_init_multiple_logfiles_support +FNDA:4,dlt_log_init_single_logfile +FNDA:3,dlt_log_free_multiple_logfiles +FNDA:4070,dlt_file_read_data +FNDA:0,dlt_convert_serial_speed +FNDA:2,dlt_log_free_single_logfile +FNDA:2,dlt_set_loginfo_parse_service_id +FNDA:0,dlt_filter_save +FNDA:11,dlt_getloginfo_conv_ascii_to_string +FNDA:69,dlt_file_free +FNDA:8528,dlt_buffer_get_message_count +FNDA:22,dlt_get_version +FNDA:13,dlt_buffer_copy +FNDA:0,dlt_execute_command +FNDA:12,dlt_log_init +FNDA:3,dlt_file_quick_parsing +FNDA:0,dlt_setup_serial +FNDA:328,dlt_message_print_hex +FNDA:7516,dlt_buffer_push +FNDA:0,dlt_buffer_free_static +FNDA:1950518,dlt_log +FNDA:121,dlt_message_free +FNDA:3326,dlt_message_payload +FNDA:64,dlt_buffer_get +FNDA:4,dlt_log_init_multiple_logfiles +FNDA:7,dlt_check_rcv_data_size +FNDA:0,dlt_print_with_attributes +FNDA:328,dlt_message_print_ascii +FNDA:6242,dlt_message_set_extraparameters +FNDA:5317,dlt_message_header_flags +FNDA:5,get_filename_ext +FNDA:1716,dlt_receiver_move_to_begin +FNDA:15285,dlt_buffer_push3 +FNF:110 +FNH:96 +DA:124,0 +DA:128,0 +DA:131,0 +DA:132,0 +DA:133,0 +DA:135,0 +DA:139,2733 +DA:143,2733 +DA:147,2730 +DA:148,0 +DA:151,0 +DA:154,36449 +DA:155,33719 +DA:156,31017 +DA:157,31017 +DA:160,33719 +DA:161,33719 +DA:167,2724 +DA:169,2724 +DA:172,1062 +DA:177,1062 +DA:181,1056 +DA:182,528 +DA:185,528 +DA:189,528 +DA:192,528 +DA:197,1056 +DA:198,0 +DA:201,0 +DA:205,1728 +DA:208,672 +DA:210,672 +DA:211,0 +DA:213,672 +DA:218,672 +DA:219,672 +DA:222,672 +DA:225,672 +DA:230,672 +DA:235,672 +DA:236,336 +DA:237,336 +DA:240,336 +DA:241,336 +DA:246,1056 +DA:248,1056 +DA:251,984 +DA:253,984 +DA:254,0 +DA:256,984 +DA:261,984 +DA:263,984 +DA:266,984 +DA:268,9450 +DA:269,8466 +DA:270,8466 +DA:273,984 +DA:274,984 +DA:279,984 +DA:282,0 +DA:288,1661 +DA:292,1661 +DA:295,1658 +DA:296,0 +DA:299,0 +DA:302,19729 +DA:303,18071 +DA:304,10240 +DA:308,7831 +DA:309,7831 +DA:311,0 +DA:314,18071 +DA:320,6207 +DA:322,6207 +DA:325,27721 +DA:326,24857 +DA:327,3342 +DA:332,6205 +DA:335,6205 +DA:341,6202 +DA:343,6202 +DA:348,54223 +DA:351,54223 +DA:354,54220 +DA:355,54220 +DA:356,54220 +DA:357,47703 +DA:359,54220 +DA:360,37988 +DA:364,37988 +DA:365,37982 +DA:369,37982 +DA:370,37974 +DA:374,37974 +DA:375,37809 +DA:380,1549 +DA:384,1549 +DA:387,13405 +DA:388,11856 +DA:389,0 +DA:392,7 +DA:394,7 +DA:396,7 +DA:399,7 +DA:401,7 +DA:404,1 +DA:406,1 +DA:408,1 +DA:409,0 +DA:414,6 +DA:416,6 +DA:423,6 +DA:425,6 +DA:427,6 +DA:428,0 +DA:429,0 +DA:436,6 +DA:438,18 +DA:439,18 +DA:441,18 +DA:444,12 +DA:449,12 +DA:450,0 +DA:452,12 +DA:454,12 +DA:456,12 +DA:459,12 +DA:464,12 +DA:465,0 +DA:467,12 +DA:469,12 +DA:470,12 +DA:472,0 +DA:477,6 +DA:479,6 +DA:482,0 +DA:484,0 +DA:491,0 +DA:493,0 +DA:495,0 +DA:496,0 +DA:497,0 +DA:500,0 +DA:501,0 +DA:505,0 +DA:509,0 +DA:513,0 +DA:518,0 +DA:520,0 +DA:523,12 +DA:528,12 +DA:530,12 +DA:533,18 +DA:534,6 +DA:536,0 +DA:539,0 +DA:541,0 +DA:542,0 +DA:543,0 +DA:544,0 +DA:545,0 +DA:547,0 +DA:549,0 +DA:550,0 +DA:551,0 +DA:552,0 +DA:559,12 +DA:562,12 +DA:564,12 +DA:567,12 +DA:568,0 +DA:571,0 +DA:575,12 +DA:577,12 +DA:578,12 +DA:579,12 +DA:580,12 +DA:581,12 +DA:583,12 +DA:585,12 +DA:591,0 +DA:597,0 +DA:599,0 +DA:602,0 +DA:604,0 +DA:605,0 +DA:606,0 +DA:607,0 +DA:608,0 +DA:609,0 +DA:615,0 +DA:619,0 +DA:620,0 +DA:621,0 +DA:622,0 +DA:623,0 +DA:625,0 +DA:626,0 +DA:627,0 +DA:628,0 +DA:629,0 +DA:630,0 +DA:633,0 +DA:634,0 +DA:641,6122 +DA:643,6122 +DA:645,6122 +DA:649,6120 +DA:650,6120 +DA:652,6120 +DA:653,6120 +DA:655,6120 +DA:656,6120 +DA:657,6120 +DA:659,6120 +DA:661,6120 +DA:664,121 +DA:666,121 +DA:668,121 +DA:672,119 +DA:673,96 +DA:674,96 +DA:675,96 +DA:681,2615 +DA:683,2615 +DA:686,5317 +DA:691,5317 +DA:693,5317 +DA:696,5121 +DA:699,5121 +DA:702,5121 +DA:704,5121 +DA:706,3021 +DA:707,3021 +DA:708,3021 +DA:709,3021 +DA:710,3021 +DA:713,5121 +DA:715,3021 +DA:716,842 +DA:718,2179 +DA:721,5121 +DA:723,3021 +DA:725,5121 +DA:727,3021 +DA:728,842 +DA:730,2179 +DA:735,5121 +DA:736,3021 +DA:738,3021 +DA:739,1590 +DA:741,1431 +DA:743,3021 +DA:746,5121 +DA:747,3021 +DA:748,1590 +DA:750,1431 +DA:752,3021 +DA:756,5121 +DA:757,2630 +DA:758,1590 +DA:759,1590 +DA:760,1590 +DA:763,2630 +DA:764,1590 +DA:765,1451 +DA:766,1451 +DA:768,1590 +DA:769,0 +DA:770,0 +DA:772,1590 +DA:773,0 +DA:774,0 +DA:776,1590 +DA:777,139 +DA:778,139 +DA:780,1590 +DA:783,2630 +DA:785,1590 +DA:786,1451 +DA:788,139 +DA:790,1590 +DA:793,2630 +DA:795,1590 +DA:798,2491 +DA:799,1431 +DA:801,2491 +DA:802,1431 +DA:804,2491 +DA:805,1431 +DA:807,2491 +DA:808,1431 +DA:814,3326 +DA:832,3326 +DA:834,3326 +DA:835,3267 +DA:838,3136 +DA:839,10 +DA:840,10 +DA:844,3126 +DA:847,3126 +DA:848,526 +DA:851,2600 +DA:852,526 +DA:854,2074 +DA:855,526 +DA:857,1548 +DA:858,1548 +DA:867,1548 +DA:869,537 +DA:870,537 +DA:872,537 +DA:873,0 +DA:875,0 +DA:876,0 +DA:880,537 +DA:881,60 +DA:882,57 +DA:884,3 +DA:885,3 +DA:887,60 +DA:888,60 +DA:891,477 +DA:895,537 +DA:896,4 +DA:897,4 +DA:899,4 +DA:900,3 +DA:902,1 +DA:904,4 +DA:905,2 +DA:909,537 +DA:910,122 +DA:911,122 +DA:915,122 +DA:917,122 +DA:918,6 +DA:919,6 +DA:922,415 +DA:925,537 +DA:934,4336 +DA:935,3325 +DA:936,2328 +DA:937,2328 +DA:941,3325 +DA:942,3325 +DA:945,3325 +DA:947,3325 +DA:948,3325 +DA:956,742 +DA:962,742 +DA:964,742 +DA:967,736 +DA:971,936 +DA:973,624 +DA:974,624 +DA:975,0 +DA:976,0 +DA:977,0 +DA:978,0 +DA:979,0 +DA:987,6675 +DA:991,6675 +DA:993,6675 +DA:997,6243 +DA:1000,6243 +DA:1004,6243 +DA:1006,0 +DA:1007,0 +DA:1008,0 +DA:1012,6243 +DA:1014,6243 +DA:1019,0 +DA:1021,0 +DA:1022,0 +DA:1023,0 +DA:1024,0 +DA:1027,0 +DA:1028,0 +DA:1031,0 +DA:1033,0 +DA:1034,0 +DA:1040,6243 +DA:1044,6243 +DA:1047,6243 +DA:1048,6243 +DA:1051,6243 +DA:1053,6243 +DA:1054,6243 +DA:1058,6243 +DA:1061,6243 +DA:1062,0 +DA:1065,0 +DA:1068,6243 +DA:1072,6243 +DA:1073,0 +DA:1078,6243 +DA:1079,6243 +DA:1082,6243 +DA:1083,6243 +DA:1086,6243 +DA:1087,6243 +DA:1088,6243 +DA:1089,6243 +DA:1091,0 +DA:1093,6243 +DA:1097,6243 +DA:1102,6036 +DA:1103,6023 +DA:1104,7 +DA:1105,7 +DA:1106,7 +DA:1111,13 +DA:1112,13 +DA:1115,6036 +DA:1116,0 +DA:1119,0 +DA:1123,6036 +DA:1125,6036 +DA:1128,7415 +DA:1130,7415 +DA:1132,7415 +DA:1135,7413 +DA:1136,7219 +DA:1140,7413 +DA:1141,6927 +DA:1142,6927 +DA:1143,6927 +DA:1146,7413 +DA:1147,14438 +DA:1148,7219 +DA:1149,7219 +DA:1150,7219 +DA:1156,6242 +DA:1158,6242 +DA:1160,6242 +DA:1163,6240 +DA:1164,6044 +DA:1165,6044 +DA:1168,6240 +DA:1169,5999 +DA:1170,5999 +DA:1171,5999 +DA:1172,5999 +DA:1176,6240 +DA:1177,6044 +DA:1178,12088 +DA:1179,6044 +DA:1180,6044 +DA:1181,6044 +DA:1188,71 +DA:1190,71 +DA:1192,71 +DA:1196,71 +DA:1197,71 +DA:1198,71 +DA:1199,71 +DA:1201,71 +DA:1202,71 +DA:1203,71 +DA:1205,71 +DA:1207,71 +DA:1209,71 +DA:1212,6 +DA:1214,6 +DA:1216,6 +DA:1220,6 +DA:1222,6 +DA:1225,7035 +DA:1227,7035 +DA:1229,7035 +DA:1235,14070 +DA:1238,56 +DA:1239,0 +DA:1241,56 +DA:1243,56 +DA:1247,6979 +DA:1248,6979 +DA:1252,6979 +DA:1254,0 +DA:1257,0 +DA:1258,0 +DA:1268,6979 +DA:1269,6979 +DA:1274,6979 +DA:1277,6979 +DA:1278,0 +DA:1281,0 +DA:1283,6979 +DA:1287,6979 +DA:1288,0 +DA:1295,0 +DA:1299,0 +DA:1301,0 +DA:1305,0 +DA:1307,0 +DA:1308,0 +DA:1310,0 +DA:1313,0 +DA:1320,0 +DA:1322,0 +DA:1328,0 +DA:1332,0 +DA:1339,0 +DA:1346,0 +DA:1347,0 +DA:1348,0 +DA:1350,0 +DA:1354,0 +DA:1355,0 +DA:1361,0 +DA:1366,0 +DA:1367,0 +DA:1372,0 +DA:1375,0 +DA:1376,0 +DA:1379,0 +DA:1382,0 +DA:1386,0 +DA:1387,0 +DA:1394,4700 +DA:1396,4700 +DA:1398,4700 +DA:1402,4700 +DA:1403,1920 +DA:1406,0 +DA:1407,0 +DA:1410,960 +DA:1414,4700 +DA:1418,2368 +DA:1419,2368 +DA:1422,0 +DA:1423,0 +DA:1427,2368 +DA:1428,2368 +DA:1429,2368 +DA:1430,2368 +DA:1432,0 +DA:1437,4070 +DA:1439,4070 +DA:1441,4070 +DA:1445,4070 +DA:1446,129 +DA:1447,129 +DA:1450,4070 +DA:1452,186 +DA:1453,186 +DA:1456,4070 +DA:1457,0 +DA:1460,0 +DA:1464,8140 +DA:1465,52 +DA:1466,0 +DA:1469,0 +DA:1476,67 +DA:1478,67 +DA:1480,67 +DA:1484,61 +DA:1485,61 +DA:1486,61 +DA:1487,61 +DA:1488,61 +DA:1489,61 +DA:1491,61 +DA:1492,0 +DA:1495,61 +DA:1497,61 +DA:1498,0 +DA:1499,0 +DA:1502,61 +DA:1503,0 +DA:1504,0 +DA:1507,61 +DA:1509,61 +DA:1510,0 +DA:1511,0 +DA:1514,61 +DA:1516,1 +DA:1521,2965 +DA:1526,2965 +DA:1529,2965 +DA:1530,0 +DA:1533,2965 +DA:1534,368 +DA:1536,368 +DA:1539,368 +DA:1540,312 +DA:1541,312 +DA:1544,368 +DA:1548,2965 +DA:1549,0 +DA:1551,0 +DA:1555,2965 +DA:1556,0 +DA:1559,2965 +DA:1561,56 +DA:1562,56 +DA:1565,2909 +DA:1567,630 +DA:1569,0 +DA:1570,0 +DA:1572,0 +DA:1576,630 +DA:1579,318 +DA:1580,318 +DA:1581,318 +DA:1587,630 +DA:1589,0 +DA:1593,0 +DA:1594,0 +DA:1596,0 +DA:1602,2279 +DA:1603,2279 +DA:1606,0 +DA:1608,0 +DA:1609,0 +DA:1612,0 +DA:1613,0 +DA:1615,0 +DA:1619,2279 +DA:1620,2279 +DA:1621,2279 +DA:1627,2909 +DA:1630,2909 +DA:1632,2909 +DA:1635,0 +DA:1640,0 +DA:1641,0 +DA:1643,0 +DA:1647,0 +DA:1648,0 +DA:1650,0 +DA:1653,0 +DA:1654,0 +DA:1655,0 +DA:1658,0 +DA:1662,0 +DA:1666,0 +DA:1667,0 +DA:1670,0 +DA:1672,0 +DA:1673,0 +DA:1675,0 +DA:1679,0 +DA:1681,0 +DA:1682,0 +DA:1684,0 +DA:1687,0 +DA:1689,0 +DA:1690,0 +DA:1692,0 +DA:1696,0 +DA:1697,0 +DA:1698,0 +DA:1703,0 +DA:1706,0 +DA:1708,0 +DA:1711,0 +DA:1713,0 +DA:1715,0 +DA:1718,0 +DA:1719,0 +DA:1721,0 +DA:1723,0 +DA:1726,3965 +DA:1728,3965 +DA:1730,3965 +DA:1734,3965 +DA:1735,0 +DA:1736,0 +DA:1740,3965 +DA:1741,0 +DA:1742,0 +DA:1743,0 +DA:1747,3965 +DA:1750,3965 +DA:1753,3965 +DA:1757,3965 +DA:1759,3965 +DA:1762,69 +DA:1764,69 +DA:1766,69 +DA:1770,69 +DA:1771,54 +DA:1773,69 +DA:1776,69 +DA:1777,59 +DA:1779,69 +DA:1781,69 +DA:1784,19 +DA:1786,19 +DA:1787,0 +DA:1788,0 +DA:1790,0 +DA:1793,19 +DA:1795,19 +DA:1797,17 +DA:1800,17 +DA:1801,1 +DA:1802,1 +DA:1806,16 +DA:1810,5259 +DA:1813,5259 +DA:1814,5250 +DA:1825,0 +DA:1827,0 +DA:1828,0 +DA:1830,12 +DA:1832,12 +DA:1835,26 +DA:1838,26 +DA:1839,0 +DA:1840,0 +DA:1843,26 +DA:1845,26 +DA:1849,7 +DA:1850,4 +DA:1851,4 +DA:1852,4 +DA:1855,1 +DA:1856,1 +DA:1858,3 +DA:1859,3 +DA:1863,4 +DA:1866,4 +DA:1867,4 +DA:1869,4 +DA:1870,0 +DA:1871,0 +DA:1876,4 +DA:1880,4 +DA:1882,4 +DA:1883,4 +DA:1886,4 +DA:1888,4 +DA:1890,4 +DA:1892,3 +DA:1893,3 +DA:1895,3 +DA:1905,3 +DA:1911,15 +DA:1913,15 +DA:1914,5 +DA:1915,3 +DA:1917,2 +DA:1920,15 +DA:1922,2 +DA:1924,2 +DA:1925,2 +DA:1926,2 +DA:1928,3 +DA:1930,3 +DA:1933,3 +DA:1936,2852 +DA:1938,2852 +DA:1941,2852 +DA:1945,2852 +DA:1946,8 +DA:1951,8 +DA:1952,8 +DA:1953,2844 +DA:1954,2844 +DA:1955,2844 +DA:1958,2852 +DA:1960,2852 +DA:1963,1950518 +DA:1972,1950518 +DA:1975,1950517 +DA:1978,1949583 +DA:1981,1949583 +DA:1983,1949583 +DA:1984,437 +DA:1986,874 +DA:1987,437 +DA:1988,437 +DA:1990,437 +DA:1992,437 +DA:1993,437 +DA:1994,1949109 +DA:1996,3898218 +DA:1997,1949109 +DA:1998,1949109 +DA:2000,1949109 +DA:2003,0 +DA:2006,0 +DA:2007,0 +DA:2009,0 +DA:2010,0 +DA:2012,0 +DA:2014,0 +DA:2016,0 +DA:2017,32 +DA:2020,32 +DA:2021,24 +DA:2022,12 +DA:2024,20 +DA:2025,40 +DA:2026,20 +DA:2027,20 +DA:2039,1964874 +DA:2041,1964874 +DA:2045,1964874 +DA:2048,1964874 +DA:2051,1944265 +DA:2053,1944265 +DA:2055,1944265 +DA:2057,1944265 +DA:2060,5244 +DA:2066,5244 +DA:2069,5244 +DA:2072,5244 +DA:2075,5244 +DA:2077,5244 +DA:2079,5244 +DA:2081,5244 +DA:2084,5244 +DA:2087,5292 +DA:2089,5292 +DA:2092,5292 +DA:2093,5292 +DA:2098,5292 +DA:2099,0 +DA:2100,0 +DA:2103,5292 +DA:2104,5292 +DA:2105,5292 +DA:2106,5292 +DA:2107,5292 +DA:2108,5292 +DA:2109,5292 +DA:2110,5292 +DA:2113,5292 +DA:2114,0 +DA:2115,0 +DA:2118,5292 +DA:2121,5292 +DA:2124,9 +DA:2126,9 +DA:2129,9 +DA:2133,9 +DA:2135,9 +DA:2139,9 +DA:2140,9 +DA:2141,9 +DA:2142,9 +DA:2143,9 +DA:2144,9 +DA:2145,9 +DA:2146,9 +DA:2147,9 +DA:2149,9 +DA:2152,5291 +DA:2155,5291 +DA:2158,5291 +DA:2159,5289 +DA:2161,5291 +DA:2162,0 +DA:2164,5291 +DA:2165,5291 +DA:2166,5291 +DA:2168,5291 +DA:2171,9 +DA:2174,9 +DA:2177,9 +DA:2178,0 +DA:2180,9 +DA:2181,9 +DA:2182,9 +DA:2184,9 +DA:2187,1722 +DA:2191,1722 +DA:2194,1722 +DA:2197,1721 +DA:2198,1721 +DA:2200,1721 +DA:2201,0 +DA:2202,0 +DA:2203,0 +DA:2206,1721 +DA:2208,430 +DA:2209,430 +DA:2210,430 +DA:2212,1291 +DA:2214,1291 +DA:2215,1291 +DA:2216,1291 +DA:2220,0 +DA:2221,0 +DA:2222,0 +DA:2223,0 +DA:2225,0 +DA:2229,1721 +DA:2230,6 +DA:2231,6 +DA:2234,1715 +DA:2235,1715 +DA:2237,1715 +DA:2240,6093 +DA:2242,6093 +DA:2245,6136 +DA:2248,6136 +DA:2249,0 +DA:2250,0 +DA:2251,0 +DA:2254,6136 +DA:2255,263 +DA:2257,6093 +DA:2260,1716 +DA:2262,1716 +DA:2265,1716 +DA:2268,1716 +DA:2269,0 +DA:2271,0 +DA:2272,0 +DA:2276,0 +DA:2282,133 +DA:2287,133 +DA:2290,133 +DA:2291,88 +DA:2293,133 +DA:2294,133 +DA:2295,133 +DA:2301,133 +DA:2302,88 +DA:2306,133 +DA:2307,0 +DA:2308,0 +DA:2309,0 +DA:2313,133 +DA:2316,12099 +DA:2323,12099 +DA:2330,12099 +DA:2334,12099 +DA:2335,12099 +DA:2336,12099 +DA:2337,12099 +DA:2339,12099 +DA:2345,12099 +DA:2346,12099 +DA:2349,12099 +DA:2352,7 +DA:2355,7 +DA:2356,1 +DA:2360,7 +DA:2363,6979 +DA:2365,6979 +DA:2368,13958 +DA:2369,6979 +DA:2370,6979 +DA:2371,6979 +DA:2372,13958 +DA:2375,0 +DA:2377,0 +DA:2383,0 +DA:2384,0 +DA:2385,0 +DA:2386,0 +DA:2390,0 +DA:2391,0 +DA:2392,0 +DA:2393,0 +DA:2394,0 +DA:2397,0 +DA:2399,0 +DA:2401,0 +DA:2403,0 +DA:2406,0 +DA:2408,0 +DA:2412,0 +DA:2413,0 +DA:2414,0 +DA:2415,0 +DA:2418,0 +DA:2419,0 +DA:2421,0 +DA:2425,0 +DA:2428,5381 +DA:2434,5381 +DA:2438,5373 +DA:2441,5366 +DA:2444,5366 +DA:2448,5366 +DA:2449,5366 +DA:2450,5366 +DA:2453,5366 +DA:2455,5366 +DA:2456,0 +DA:2459,0 +DA:2464,5366 +DA:2465,5366 +DA:2466,5366 +DA:2467,5366 +DA:2469,5366 +DA:2470,0 +DA:2473,0 +DA:2476,5366 +DA:2478,5366 +DA:2483,5366 +DA:2485,5366 +DA:2488,0 +DA:2491,0 +DA:2494,0 +DA:2496,0 +DA:2497,0 +DA:2503,5355 +DA:2506,5355 +DA:2509,5354 +DA:2511,0 +DA:2512,0 +DA:2515,5354 +DA:2516,5354 +DA:2517,5354 +DA:2519,5354 +DA:2522,41034 +DA:2525,41034 +DA:2526,40015 +DA:2527,40015 +DA:2529,40014 +DA:2530,40014 +DA:2536,1 +DA:2538,1 +DA:2539,1 +DA:2540,1 +DA:2545,0 +DA:2549,1019 +DA:2551,41034 +DA:2553,53 +DA:2556,53 +DA:2557,37 +DA:2559,35 +DA:2560,35 +DA:2566,2 +DA:2568,1 +DA:2569,1 +DA:2570,1 +DA:2575,16 +DA:2577,53 +DA:2579,859 +DA:2581,859 +DA:2584,859 +DA:2585,0 +DA:2590,7 +DA:2596,7 +DA:2597,1 +DA:2598,1 +DA:2602,6 +DA:2607,6 +DA:2612,6 +DA:2614,6 +DA:2615,0 +DA:2618,0 +DA:2622,6 +DA:2625,6 +DA:2626,4 +DA:2627,4 +DA:2628,4 +DA:2629,4 +DA:2632,2 +DA:2633,2 +DA:2634,2 +DA:2635,2 +DA:2636,2 +DA:2640,6 +DA:2643,6 +DA:2644,6 +DA:2645,6 +DA:2647,6 +DA:2653,6 +DA:2656,8 +DA:2661,8 +DA:2662,1 +DA:2663,1 +DA:2666,7 +DA:2671,0 +DA:2673,0 +DA:2674,0 +DA:2677,0 +DA:2681,0 +DA:2684,0 +DA:2685,0 +DA:2686,0 +DA:2689,0 +DA:2690,0 +DA:2691,0 +DA:2693,0 +DA:2698,0 +DA:2700,0 +DA:2703,9 +DA:2706,9 +DA:2707,1 +DA:2708,1 +DA:2711,8 +DA:2713,8 +DA:2716,8 +DA:2717,8 +DA:2718,8 +DA:2721,8 +DA:2723,8 +DA:2726,7516 +DA:2728,7516 +DA:2731,15285 +DA:2744,15285 +DA:2747,15217 +DA:2749,0 +DA:2750,0 +DA:2754,15217 +DA:2755,15217 +DA:2756,15217 +DA:2759,15217 +DA:2760,0 +DA:2763,0 +DA:2764,0 +DA:2768,15217 +DA:2769,0 +DA:2770,15217 +DA:2773,15217 +DA:2776,15221 +DA:2778,4 +DA:2784,4 +DA:2785,4 +DA:2788,4 +DA:2789,0 +DA:2790,4 +DA:2793,4 +DA:2799,15217 +DA:2800,15217 +DA:2803,15217 +DA:2805,15217 +DA:2806,15217 +DA:2808,15217 +DA:2809,7703 +DA:2811,15217 +DA:2812,1877 +DA:2815,15217 +DA:2816,15217 +DA:2818,15217 +DA:2822,64 +DA:2826,64 +DA:2830,64 +DA:2833,47 +DA:2835,0 +DA:2836,0 +DA:2840,47 +DA:2841,47 +DA:2842,47 +DA:2845,47 +DA:2846,3 +DA:2849,3 +DA:2850,3 +DA:2854,44 +DA:2855,22 +DA:2856,1 +DA:2859,1 +DA:2862,22 +DA:2866,22 +DA:2867,21 +DA:2869,1 +DA:2872,22 +DA:2873,1 +DA:2876,1 +DA:2877,1 +DA:2881,21 +DA:2884,21 +DA:2885,1 +DA:2886,1 +DA:2887,1 +DA:2890,20 +DA:2891,0 +DA:2892,0 +DA:2893,0 +DA:2897,20 +DA:2898,1 +DA:2901,1 +DA:2902,1 +DA:2906,19 +DA:2907,1 +DA:2913,19 +DA:2915,14 +DA:2917,14 +DA:2919,3 +DA:2922,5 +DA:2924,5 +DA:2925,5 +DA:2927,0 +DA:2931,19 +DA:2932,8 +DA:2934,8 +DA:2936,5 +DA:2939,19 +DA:2942,8 +DA:2944,8 +DA:2947,13 +DA:2949,13 +DA:2952,7 +DA:2954,7 +DA:2957,2 +DA:2960,2 +DA:2961,1 +DA:2962,1 +DA:2965,1 +DA:2967,1 +DA:2970,2 +DA:2975,2 +DA:2976,1 +DA:2977,1 +DA:2981,1 +DA:2984,1 +DA:2985,1 +DA:2986,1 +DA:2988,1 +DA:2993,3 +DA:2996,3 +DA:2999,2 +DA:3002,2503 +DA:3007,2503 +DA:3011,2502 +DA:3014,2502 +DA:3015,2502 +DA:3016,2502 +DA:3018,2502 +DA:3021,2501 +DA:3022,2501 +DA:3024,0 +DA:3027,8528 +DA:3030,8528 +DA:3034,8528 +DA:3037,8528 +DA:3042,0 +DA:3047,0 +DA:3050,0 +DA:3059,0 +DA:3071,0 +DA:3077,0 +DA:3083,0 +DA:3084,0 +DA:3089,0 +DA:3090,0 +DA:3095,0 +DA:3096,0 +DA:3100,0 +DA:3101,0 +DA:3109,0 +DA:3114,0 +DA:3120,0 +DA:3123,0 +DA:3125,0 +DA:3128,0 +DA:3130,0 +DA:3133,0 +DA:3135,0 +DA:3138,0 +DA:3140,0 +DA:3143,0 +DA:3145,0 +DA:3148,0 +DA:3150,0 +DA:3153,0 +DA:3155,0 +DA:3158,0 +DA:3160,0 +DA:3163,0 +DA:3165,0 +DA:3168,0 +DA:3170,0 +DA:3173,0 +DA:3175,0 +DA:3178,0 +DA:3180,0 +DA:3183,0 +DA:3185,0 +DA:3188,0 +DA:3190,0 +DA:3193,0 +DA:3195,0 +DA:3198,0 +DA:3201,0 +DA:3204,0 +DA:3206,0 +DA:3209,0 +DA:3211,0 +DA:3214,0 +DA:3216,0 +DA:3219,0 +DA:3221,0 +DA:3224,0 +DA:3226,0 +DA:3229,0 +DA:3231,0 +DA:3234,0 +DA:3236,0 +DA:3239,0 +DA:3241,0 +DA:3244,0 +DA:3246,0 +DA:3249,0 +DA:3251,0 +DA:3254,0 +DA:3256,0 +DA:3259,0 +DA:3261,0 +DA:3264,0 +DA:3267,0 +DA:3270,0 +DA:3274,0 +DA:3282,22 +DA:3284,22 +DA:3285,0 +DA:3286,0 +DA:3307,9 +DA:3309,9 +DA:3310,0 +DA:3311,0 +DA:3317,9 +DA:3319,9 +DA:3320,0 +DA:3321,0 +DA:3328,6296 +DA:3338,6296 +DA:3339,6296 +DA:3347,328 +DA:3349,328 +DA:3352,316 +DA:3354,316 +DA:3356,316 +DA:3359,328 +DA:3361,328 +DA:3364,316 +DA:3366,316 +DA:3368,316 +DA:3370,316 +DA:3372,316 +DA:3375,328 +DA:3377,328 +DA:3380,316 +DA:3382,316 +DA:3384,316 +DA:3386,316 +DA:3388,316 +DA:3391,328 +DA:3393,328 +DA:3396,316 +DA:3398,316 +DA:3400,316 +DA:3402,316 +DA:3404,316 +DA:3407,328 +DA:3409,328 +DA:3412,316 +DA:3414,316 +DA:3416,316 +DA:3419,316 +DA:3421,316 +DA:3424,3551 +DA:3434,3551 +DA:3449,3536 +DA:3450,3536 +DA:3451,3536 +DA:3452,3536 +DA:3468,3536 +DA:3469,1549 +DA:3471,1549 +DA:3472,1549 +DA:3474,1549 +DA:3477,1549 +DA:3480,0 +DA:3483,1549 +DA:3484,0 +DA:3486,0 +DA:3489,0 +DA:3491,0 +DA:3494,0 +DA:3496,0 +DA:3497,0 +DA:3498,0 +DA:3499,0 +DA:3503,0 +DA:3504,0 +DA:3507,1549 +DA:3509,1549 +DA:3512,1987 +DA:3515,112 +DA:3516,0 +DA:3518,0 +DA:3521,0 +DA:3523,0 +DA:3526,0 +DA:3528,0 +DA:3529,0 +DA:3530,0 +DA:3531,0 +DA:3535,0 +DA:3536,0 +DA:3540,112 +DA:3542,112 +DA:3545,110 +DA:3547,1875 +DA:3549,0 +DA:3550,0 +DA:3552,0 +DA:3553,0 +DA:3555,0 +DA:3558,0 +DA:3559,0 +DA:3562,0 +DA:3568,0 +DA:3569,0 +DA:3571,0 +DA:3572,0 +DA:3574,0 +DA:3577,0 +DA:3578,0 +DA:3581,0 +DA:3587,1875 +DA:3589,0 +DA:3590,0 +DA:3592,0 +DA:3595,0 +DA:3598,0 +DA:3599,0 +DA:3601,0 +DA:3604,0 +DA:3607,0 +DA:3608,0 +DA:3610,0 +DA:3616,0 +DA:3617,0 +DA:3618,0 +DA:3620,0 +DA:3624,0 +DA:3625,0 +DA:3627,0 +DA:3630,0 +DA:3631,0 +DA:3634,1875 +DA:3637,1748 +DA:3638,0 +DA:3640,0 +DA:3643,0 +DA:3644,0 +DA:3646,0 +DA:3649,0 +DA:3651,0 +DA:3654,0 +DA:3656,0 +DA:3657,0 +DA:3658,0 +DA:3659,0 +DA:3663,0 +DA:3664,0 +DA:3666,0 +DA:3671,0 +DA:3673,0 +DA:3674,0 +DA:3677,1748 +DA:3678,0 +DA:3680,0 +DA:3683,0 +DA:3684,0 +DA:3688,0 +DA:3691,0 +DA:3692,0 +DA:3693,0 +DA:3695,0 +DA:3697,0 +DA:3700,0 +DA:3701,0 +DA:3702,0 +DA:3704,0 +DA:3706,0 +DA:3709,0 +DA:3710,0 +DA:3711,0 +DA:3720,1748 +DA:3721,14 +DA:3723,14 +DA:3725,7 +DA:3727,7 +DA:3730,7 +DA:3734,7 +DA:3736,7 +DA:3739,7 +DA:3744,21 +DA:3746,21 +DA:3749,7 +DA:3751,7 +DA:3754,7 +DA:3755,7 +DA:3760,14 +DA:3762,14 +DA:3765,14 +DA:3766,14 +DA:3771,1699 +DA:3773,1699 +DA:3776,287 +DA:3778,287 +DA:3781,287 +DA:3787,1412 +DA:3789,1412 +DA:3792,1412 +DA:3798,14 +DA:3800,14 +DA:3803,7 +DA:3805,7 +DA:3808,7 +DA:3818,7 +DA:3820,7 +DA:3823,7 +DA:3833,0 +DA:3835,0 +DA:3836,0 +DA:3838,0 +DA:3841,0 +DA:3842,0 +DA:3843,0 +DA:3851,127 +DA:3854,14 +DA:3855,0 +DA:3857,0 +DA:3860,0 +DA:3861,0 +DA:3863,0 +DA:3866,0 +DA:3868,0 +DA:3871,0 +DA:3873,0 +DA:3874,0 +DA:3875,0 +DA:3876,0 +DA:3880,0 +DA:3881,0 +DA:3883,0 +DA:3888,0 +DA:3890,0 +DA:3891,0 +DA:3894,14 +DA:3895,0 +DA:3897,0 +DA:3898,0 +DA:3900,0 +DA:3903,0 +DA:3904,0 +DA:3905,0 +DA:3907,0 +DA:3909,0 +DA:3910,0 +DA:3912,0 +DA:3915,0 +DA:3916,0 +DA:3917,0 +DA:3926,7 +DA:3928,7 +DA:3933,7 +DA:3935,7 +DA:3951,7 +DA:3953,7 +DA:3958,7 +DA:3973,0 +DA:3975,0 +DA:3976,0 +DA:3978,0 +DA:3981,0 +DA:3982,0 +DA:3983,0 +DA:3991,113 +DA:3994,112 +DA:3996,112 +DA:3999,110 +DA:4001,110 +DA:4002,0 +DA:4004,0 +DA:4007,0 +DA:4009,0 +DA:4012,0 +DA:4014,0 +DA:4015,0 +DA:4016,0 +DA:4017,0 +DA:4021,0 +DA:4022,0 +DA:4025,110 +DA:4028,9 +DA:4030,9 +DA:4031,9 +DA:4033,1 +DA:4036,0 +DA:4038,0 +DA:4041,0 +DA:4043,0 +DA:4045,0 +DA:4052,3430 +DA:4053,0 +DA:4054,0 +DA:4058,3430 +DA:4059,0 +DA:4061,0 +DA:4063,0 +DA:4064,0 +DA:4072,5250 +DA:4074,5250 +DA:4076,5250 +DA:4077,0 +DA:4079,5250 +DA:4081,5250 +DA:4082,0 +DA:4084,0 +DA:4085,0 +DA:4088,5250 +DA:4090,5250 +DA:4091,0 +DA:4093,0 +DA:4094,0 +DA:4098,5250 +DA:4100,5250 +DA:4101,0 +DA:4103,5250 +DA:4114,5250 +DA:4116,2 +DA:4124,2 +DA:4130,2 +DA:4132,2 +DA:4133,2 +DA:4135,2 +DA:4136,2 +DA:4137,2 +DA:4138,2 +DA:4144,14 +DA:4146,14 +DA:4149,14 +DA:4155,14 +DA:4156,14 +DA:4157,14 +DA:4158,14 +DA:4160,14 +DA:4162,14 +DA:4165,12 +DA:4167,12 +DA:4170,12 +DA:4176,12 +DA:4177,12 +DA:4179,12 +DA:4181,12 +DA:4184,11 +DA:4186,11 +DA:4192,11 +DA:4193,11 +DA:4195,11 +DA:4198,20 +DA:4200,20 +DA:4204,20 +DA:4210,289 +DA:4211,269 +DA:4212,269 +DA:4213,269 +DA:4214,269 +DA:4220,0 +DA:4222,0 +DA:4224,0 +DA:4229,0 +DA:4230,0 +DA:4231,0 +DA:4236,0 +DA:4237,0 +DA:4240,0 +DA:4242,0 +DA:4245,0 +DA:4247,0 +DA:4252,0 +DA:4257,0 +DA:4259,0 +DA:4262,0 +DA:4266,0 +DA:4270,3 +DA:4273,3 +DA:4275,3 +DA:4277,3 +DA:4280,1 +DA:4282,1 +DA:4283,0 +DA:4284,0 +DA:4287,106 +DA:4289,105 +DA:4290,0 +DA:4293,105 +DA:4295,105 +DA:4298,105 +DA:4300,105 +DA:4303,105 +DA:4305,105 +DA:4308,105 +DA:4310,0 +DA:4312,0 +DA:4313,0 +DA:4316,105 +DA:4319,105 +DA:4324,105 +DA:4327,105 +DA:4333,105 +DA:4334,105 +DA:4336,105 +DA:4338,105 +DA:4341,1 +DA:4342,1 +DA:4346,0 +DA:4351,0 +DA:4353,0 +DA:4357,0 +DA:4359,0 +DA:4361,0 +DA:4364,0 +DA:4365,0 +DA:4367,0 +DA:4369,0 +DA:4370,0 +DA:4372,0 +DA:4375,0 +DA:4377,0 +DA:4380,0 +DA:4383,0 +DA:4384,0 +DA:4386,0 +DA:4387,0 +DA:4388,0 +DA:4391,0 +DA:4395,0 +DA:4397,0 +DA:4399,0 +DA:4402,0 +DA:4405,0 +DA:4406,0 +DA:4409,5 +DA:4411,5 +DA:4412,0 +DA:4413,0 +DA:4416,5 +DA:4417,5 +DA:4420,6 +DA:4421,6 +DA:4423,6 +DA:4424,6 +DA:4425,5 +DA:4426,5 +DA:4428,5 +DA:4429,5 +DA:4430,5 +DA:4433,12 +DA:4435,12 +DA:4437,12 +DA:4439,12 +DA:4440,12 +DA:4441,12 +DA:4443,37 +DA:4445,37 +LF:1752 +LH:1117 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/shared/dlt_config_file_parser.c +FN:51,dlt_config_file_trim_line +FN:95,dlt_config_file_is_section_name +FN:121,dlt_config_file_set_section +FN:171,dlt_config_file_set_section_data +FN:251,dlt_config_file_get_section_name_from_string +FN:281,dlt_config_file_get_key_value +FN:321,dlt_config_file_read_line +FN:354,dlt_config_file_read_file +FN:407,dlt_config_file_find_section +FN:428,dlt_config_file_init +FN:462,dlt_config_file_release +FN:491,dlt_config_file_get_section_name +FN:504,dlt_config_file_get_num_sections +FN:518,dlt_config_file_get_value +FN:555,dlt_config_file_check_section_name_exists +FNDA:14,dlt_config_file_init +FNDA:14,dlt_config_file_read_file +FNDA:339,dlt_config_file_set_section_data +FNDA:339,dlt_config_file_get_key_value +FNDA:14,dlt_config_file_get_num_sections +FNDA:379,dlt_config_file_read_line +FNDA:379,dlt_config_file_trim_line +FNDA:4,dlt_config_file_check_section_name_exists +FNDA:468,dlt_config_file_find_section +FNDA:40,dlt_config_file_get_section_name +FNDA:14,dlt_config_file_release +FNDA:40,dlt_config_file_is_section_name +FNDA:40,dlt_config_file_get_section_name_from_string +FNDA:464,dlt_config_file_get_value +FNDA:40,dlt_config_file_set_section +FNF:15 +FNH:15 +DA:51,379 +DA:53,379 +DA:59,6707 +DA:60,6328 +DA:62,6328 +DA:63,5949 +DA:66,379 +DA:79,406 +DA:95,40 +DA:99,40 +DA:102,179 +DA:103,139 +DA:105,139 +DA:121,40 +DA:123,40 +DA:126,40 +DA:127,0 +DA:128,0 +DA:132,40 +DA:133,0 +DA:134,0 +DA:137,40 +DA:140,40 +DA:142,40 +DA:143,0 +DA:144,0 +DA:147,40 +DA:149,40 +DA:150,0 +DA:151,0 +DA:152,0 +DA:153,0 +DA:157,40 +DA:158,40 +DA:171,339 +DA:175,339 +DA:178,339 +DA:179,339 +DA:181,339 +DA:182,0 +DA:183,0 +DA:187,339 +DA:189,339 +DA:191,40 +DA:193,40 +DA:194,0 +DA:195,0 +DA:198,40 +DA:201,299 +DA:203,1589 +DA:204,1290 +DA:207,299 +DA:209,299 +DA:210,0 +DA:211,0 +DA:215,339 +DA:216,339 +DA:217,339 +DA:219,339 +DA:221,339 +DA:236,379 +DA:251,40 +DA:256,40 +DA:259,386 +DA:260,386 +DA:261,40 +DA:262,346 +DA:265,306 +DA:281,339 +DA:287,339 +DA:290,339 +DA:292,339 +DA:294,339 +DA:299,339 +DA:301,339 +DA:303,339 +DA:308,339 +DA:321,379 +DA:323,379 +DA:333,40 +DA:336,40 +DA:340,339 +DA:341,0 +DA:354,14 +DA:357,14 +DA:358,14 +DA:359,14 +DA:364,434 +DA:365,406 +DA:368,27 +DA:369,27 +DA:372,379 +DA:375,379 +DA:377,379 +DA:378,40 +DA:381,40 +DA:385,339 +DA:387,339 +DA:388,339 +DA:391,0 +DA:392,0 +DA:396,14 +DA:407,468 +DA:412,468 +DA:413,0 +DA:414,0 +DA:417,2140 +DA:418,2136 +DA:420,2136 +DA:421,464 +DA:428,14 +DA:433,14 +DA:434,0 +DA:435,0 +DA:438,14 +DA:440,14 +DA:441,0 +DA:442,0 +DA:445,14 +DA:448,14 +DA:449,0 +DA:450,0 +DA:451,0 +DA:454,14 +DA:457,14 +DA:459,14 +DA:462,14 +DA:466,14 +DA:467,14 +DA:469,54 +DA:470,40 +DA:471,40 +DA:472,40 +DA:474,40 +DA:475,40 +DA:477,379 +DA:479,339 +DA:480,339 +DA:481,339 +DA:482,339 +DA:486,14 +DA:487,14 +DA:489,14 +DA:491,40 +DA:495,40 +DA:498,40 +DA:499,40 +DA:501,40 +DA:504,14 +DA:506,14 +DA:513,14 +DA:515,14 +DA:518,464 +DA:526,464 +DA:532,464 +DA:534,464 +DA:537,464 +DA:539,464 +DA:541,2779 +DA:542,2650 +DA:543,335 +DA:544,335 +DA:547,2315 +DA:551,129 +DA:552,129 +DA:555,4 +DA:560,4 +DA:563,4 +DA:564,4 +DA:565,4 +LF:170 +LH:142 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/shared/dlt_multiple_files.c +FN:43,multiple_files_buffer_storage_dir_info +FN:117,multiple_files_buffer_file_name +FN:133,multiple_files_buffer_get_idx_of_log_file +FN:147,multiple_files_buffer_create_new_file +FN:225,multiple_files_buffer_get_total_size +FN:268,multiple_files_buffer_delete_oldest_file +FN:346,multiple_files_buffer_check_size +FN:377,multiple_files_buffer_open_file_for_append +FN:407,multiple_files_buffer_init +FN:439,multiple_files_buffer_rotate_file +FN:455,multiple_files_buffer_write_chunk +FN:473,multiple_files_buffer_write +FN:485,multiple_files_buffer_free +FNDA:3,multiple_files_buffer_open_file_for_append +FNDA:3,multiple_files_buffer_init +FNDA:53,multiple_files_buffer_get_idx_of_log_file +FNDA:12,multiple_files_buffer_storage_dir_info +FNDA:12,multiple_files_buffer_write +FNDA:9,multiple_files_buffer_delete_oldest_file +FNDA:9,multiple_files_buffer_file_name +FNDA:12,multiple_files_buffer_check_size +FNDA:9,multiple_files_buffer_create_new_file +FNDA:12,multiple_files_buffer_write_chunk +FNDA:3,multiple_files_buffer_free +FNDA:12,multiple_files_buffer_rotate_file +FNDA:21,multiple_files_buffer_get_total_size +FNF:13 +FNH:13 +DA:43,12 +DA:48,12 +DA:52,12 +DA:53,0 +DA:54,0 +DA:57,12 +DA:58,12 +DA:60,386 +DA:62,374 +DA:64,374 +DA:65,110 +DA:66,48 +DA:68,48 +DA:69,48 +DA:71,36 +DA:74,20 +DA:80,48 +DA:81,32 +DA:83,20 +DA:86,20 +DA:93,12 +DA:94,12 +DA:96,12 +DA:97,0 +DA:101,12 +DA:103,12 +DA:104,0 +DA:110,386 +DA:112,12 +DA:114,12 +DA:117,9 +DA:123,9 +DA:126,9 +DA:127,9 +DA:130,9 +DA:131,9 +DA:133,53 +DA:135,53 +DA:137,53 +DA:140,53 +DA:142,53 +DA:144,53 +DA:147,9 +DA:149,9 +DA:150,0 +DA:151,0 +DA:161,9 +DA:164,0 +DA:165,0 +DA:166,0 +DA:168,0 +DA:170,0 +DA:171,0 +DA:173,0 +DA:175,0 +DA:176,0 +DA:177,0 +DA:181,0 +DA:183,0 +DA:184,0 +DA:185,0 +DA:189,9 +DA:190,9 +DA:192,9 +DA:193,9 +DA:199,9 +DA:201,9 +DA:203,9 +DA:205,9 +DA:206,0 +DA:207,0 +DA:212,9 +DA:213,9 +DA:216,9 +DA:218,0 +DA:219,0 +DA:225,21 +DA:227,21 +DA:228,0 +DA:229,0 +DA:238,21 +DA:239,21 +DA:240,0 +DA:241,0 +DA:244,695 +DA:246,674 +DA:252,80 +DA:253,80 +DA:254,80 +DA:255,80 +DA:257,0 +DA:262,21 +DA:265,21 +DA:268,9 +DA:270,9 +DA:271,0 +DA:272,0 +DA:283,9 +DA:284,9 +DA:287,9 +DA:289,9 +DA:292,309 +DA:293,300 +DA:299,44 +DA:301,0 +DA:304,44 +DA:305,0 +DA:306,0 +DA:307,0 +DA:308,0 +DA:309,0 +DA:311,0 +DA:314,0 +DA:318,44 +DA:319,44 +DA:323,23 +DA:329,9 +DA:332,9 +DA:333,9 +DA:334,0 +DA:335,0 +DA:338,0 +DA:339,0 +DA:343,9 +DA:346,12 +DA:348,12 +DA:349,0 +DA:350,0 +DA:356,12 +DA:357,12 +DA:358,0 +DA:359,0 +DA:362,12 +DA:363,0 +DA:364,0 +DA:369,21 +DA:371,9 +DA:374,12 +DA:377,3 +DA:378,3 +DA:380,3 +DA:381,3 +DA:384,3 +DA:385,3 +DA:388,0 +DA:395,3 +DA:396,0 +DA:397,0 +DA:401,3 +DA:402,3 +DA:404,3 +DA:407,3 +DA:416,3 +DA:417,0 +DA:418,0 +DA:422,3 +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:432,3 +DA:434,3 +DA:435,3 +DA:436,3 +DA:439,12 +DA:442,12 +DA:445,9 +DA:446,9 +DA:449,9 +DA:452,9 +DA:455,12 +DA:459,12 +DA:460,0 +DA:461,0 +DA:464,12 +DA:465,12 +DA:466,0 +DA:467,0 +DA:473,12 +DA:477,12 +DA:479,12 +DA:482,12 +DA:485,3 +DA:487,3 +DA:488,0 +DA:489,0 +DA:492,3 +DA:495,3 +DA:497,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:6809,dlt_user_set_userheader +FNDA:6375,dlt_user_log_out3 +FNDA:432,dlt_user_log_out2 +FNDA:11831,dlt_user_check_userheader +FNDA:51,dlt_user_log_out2_with_timeout +FNDA:0,dlt_user_log_out3_with_timeout +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..4c10bad33 --- /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:38763760.8 %
Date:2023-11-29 14:15:44Functions: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_configure5
dlt_gateway_process_passive_node_messages5
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..c4dfc2931 --- /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:38763760.8 %
Date:2023-11-29 14:15:44Functions: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_messages5
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..293e966a4 --- /dev/null +++ b/dlt_lcov_report/gateway/dlt_gateway.c.gcov.html @@ -0,0 +1,1861 @@ + + + + + + + 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:38763760.8 %
Date:2023-11-29 14:15:44Functions: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-daemon_cfg.h"
+      44             : #include "dlt_daemon_common_cfg.h"
+      45             : #include "dlt_daemon_event_handler.h"
+      46             : #include "dlt_daemon_connection.h"
+      47             : #include "dlt_daemon_client.h"
+      48             : #include "dlt_daemon_offline_logstorage.h"
+      49             : 
+      50             : /**
+      51             :  * Check if given string is a valid IP address
+      52             :  *
+      53             :  * @param con   DltGatewayConnection to be updated
+      54             :  * @param value string to be tested
+      55             :  * @return Value from DltReturnValue enum
+      56             :  */
+      57           7 : DLT_STATIC DltReturnValue dlt_gateway_check_ip(DltGatewayConnection *con, char *value)
+      58             : {
+      59             :     struct sockaddr_in sa;
+      60             :     int ret = DLT_RETURN_ERROR;
+      61             : 
+      62           7 :     if ((con == NULL) || (value == NULL)) {
+      63           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+      64           1 :         return DLT_RETURN_WRONG_PARAMETER;
+      65             :     }
+      66             : 
+      67           6 :     ret = inet_pton(AF_INET, value, &(sa.sin_addr));
+      68             : 
+      69             :     /* valid IP address */
+      70           6 :     if (ret != 0) {
+      71           6 :         con->ip_address = strdup(value);
+      72             : 
+      73           6 :         if (con->ip_address == NULL) {
+      74           0 :             dlt_log(LOG_ERR, "Cannot copy passive node IP address string\n");
+      75           0 :             return DLT_RETURN_ERROR;
+      76             :         }
+      77             : 
+      78             :         return DLT_RETURN_OK;
+      79             :     }
+      80             :     else {
+      81           0 :         dlt_log(LOG_ERR, "IP address is not valid\n");
+      82             :     }
+      83             : 
+      84           0 :     return DLT_RETURN_ERROR;
+      85             : }
+      86             : 
+      87             : /**
+      88             :  * Check port number
+      89             :  *
+      90             :  * @param con     DltGatewayConnection to be updated
+      91             :  * @param value   string to be tested
+      92             :  * @return Value from DltReturnValue enum
+      93             :  */
+      94           9 : DLT_STATIC DltReturnValue dlt_gateway_check_port(DltGatewayConnection *con,
+      95             :                                                  char *value)
+      96             : {
+      97             :     long int tmp = -1;
+      98             : 
+      99           9 :     if ((con == NULL) || (value == NULL)) {
+     100           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     101           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     102             :     }
+     103             : 
+     104           8 :     errno = 0;
+     105           8 :     tmp = strtol(value, NULL, 10);
+     106           8 :     if ((errno == ERANGE && (tmp == LONG_MAX || tmp == LONG_MIN))
+     107           8 :          || (errno != 0 && tmp == 0)) {
+     108           0 :         dlt_vlog(LOG_ERR, "%s: cannot convert port number\n", __func__);
+     109           0 :         return DLT_RETURN_ERROR;
+     110             :     }
+     111             : 
+     112             :     /* port ranges for unprivileged applications */
+     113           8 :     if ((tmp > IPPORT_RESERVED) && ((unsigned)tmp <= USHRT_MAX))
+     114             :     {
+     115           6 :         con->port = (int)tmp;
+     116           6 :         return DLT_RETURN_OK;
+     117             :     }
+     118             :     else {
+     119           2 :         dlt_log(LOG_ERR, "Port number is invalid\n");
+     120             :     }
+     121             : 
+     122           2 :     return DLT_RETURN_ERROR;
+     123             : }
+     124             : 
+     125             : /**
+     126             :  * Check ECU name
+     127             :  *
+     128             :  * @param con     DltGatewayConnection to be updated
+     129             :  * @param value   string to be used as ECU identifier
+     130             :  * @return Value from DltReturnValue enum
+     131             :  */
+     132           6 : DLT_STATIC DltReturnValue dlt_gateway_check_ecu(DltGatewayConnection *con,
+     133             :                                                 char *value)
+     134             : {
+     135           6 :     if ((con == NULL) || (value == NULL)) {
+     136           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     137           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     138             :     }
+     139             : 
+     140           5 :     con->ecuid = strdup(value);
+     141             : 
+     142           5 :     if (con->ecuid == NULL)
+     143           0 :         return DLT_RETURN_ERROR;
+     144             : 
+     145             :     return DLT_RETURN_OK;
+     146             : }
+     147             : 
+     148             : /**
+     149             :  * Check connection trigger
+     150             :  *
+     151             :  * @param con     DltGatewayConnection to be updated
+     152             :  * @param value   string to be tested
+     153             :  * @return Value from DltReturnValue enum
+     154             :  */
+     155           7 : DLT_STATIC DltReturnValue dlt_gateway_check_connect_trigger(DltGatewayConnection *con,
+     156             :                                                             char *value)
+     157             : {
+     158           7 :     if ((con == NULL) || (value == NULL)) {
+     159           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     160           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     161             :     }
+     162             : 
+     163           6 :     if (strncasecmp(value, "OnStartup", strlen("OnStartup")) == 0) {
+     164           5 :         con->trigger = DLT_GATEWAY_ON_STARTUP;
+     165             :     }
+     166           1 :     else if (strncasecmp(value, "OnDemand", strlen("OnDemand")) == 0)
+     167             :     {
+     168           0 :         con->trigger = DLT_GATEWAY_ON_DEMAND;
+     169             :     }
+     170             :     else {
+     171           1 :         dlt_log(LOG_ERR, "Wrong connection trigger state given.\n");
+     172           1 :         con->trigger = DLT_GATEWAY_UNDEFINED;
+     173           1 :         return DLT_RETURN_ERROR;
+     174             :     }
+     175             : 
+     176             :     return DLT_RETURN_OK;
+     177             : }
+     178             : 
+     179             : /**
+     180             :  * Check connection timeout value
+     181             :  *
+     182             :  * @param con     DltGatewayConnection to be updated
+     183             :  * @param value   string to be tested
+     184             :  * @return Value from DltReturnValue enum
+     185             :  */
+     186           7 : DLT_STATIC DltReturnValue dlt_gateway_check_timeout(DltGatewayConnection *con,
+     187             :                                                     char *value)
+     188             : {
+     189           7 :     if ((con == NULL) || (value == NULL)) {
+     190           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     191           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     192             :     }
+     193             : 
+     194           6 :     con->timeout = (int)strtol(value, NULL, 10);
+     195             : 
+     196             : 
+     197           6 :     if (con->timeout >= 0)
+     198           5 :         return DLT_RETURN_OK;
+     199             : 
+     200             :     return DLT_RETURN_ERROR;
+     201             : }
+     202             : 
+     203             : /**
+     204             :  * Check connection interval value in General section
+     205             :  *
+     206             :  * @param con     DltGateway to be updated
+     207             :  * @param value   string to be tested
+     208             :  * @return Value from DltReturnValue enum
+     209             :  */
+     210           0 : DLT_STATIC DltReturnValue dlt_gateway_check_interval(DltGateway *gateway,
+     211             :                                                     char *value)
+     212             : {
+     213           0 :     if ((gateway == NULL) || (value == NULL)) {
+     214           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     215           0 :         return DLT_RETURN_WRONG_PARAMETER;
+     216             :     }
+     217             : 
+     218           0 :     gateway->interval = (int)strtol(value, NULL, 10);
+     219             : 
+     220           0 :     if (gateway->interval > 0)
+     221           0 :         return DLT_RETURN_OK;
+     222             : 
+     223             :     return DLT_RETURN_ERROR;
+     224             : }
+     225             : 
+     226             : /**
+     227             :  * Check the value for SendSerialHeader
+     228             :  *
+     229             :  * @param con   DltGatewayConnection to be updated
+     230             :  * @param value string to be tested
+     231             :  * @return Value from DltReturnValue enum
+     232             :  */
+     233           6 : DLT_STATIC DltReturnValue dlt_gateway_check_send_serial(DltGatewayConnection *con,
+     234             :                                                         char *value)
+     235             : {
+     236           6 :     if ((con == NULL) || (value == NULL)) {
+     237           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     238           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     239             :     }
+     240             : 
+     241           5 :     con->send_serial = !!((int)strtol(value, NULL, 10));
+     242             : 
+     243           5 :     return DLT_RETURN_OK;
+     244             : }
+     245             : 
+     246             : /**
+     247             :  * Allocate passive control messages
+     248             :  *
+     249             :  * @param con   DltGatewayConnection to be updated
+     250             :  * @return Value from DltReturnValue enum
+     251             :  */
+     252          17 : DLT_STATIC DltReturnValue dlt_gateway_allocate_control_messages(DltGatewayConnection *con)
+     253             : {
+     254          17 :     if (con == NULL) {
+     255           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     256           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     257             :     }
+     258             : 
+     259          16 :     if (con->p_control_msgs == NULL) {
+     260           7 :         con->p_control_msgs = calloc(1, sizeof(DltPassiveControlMessage));
+     261             : 
+     262           7 :         if (!con->p_control_msgs) {
+     263           0 :             dlt_log(LOG_ERR,
+     264             :                     "Passive Control Message could not be allocated\n");
+     265           0 :             return DLT_RETURN_ERROR;
+     266             :         }
+     267             :     }
+     268             :     else {
+     269           9 :         con->p_control_msgs->next = calloc(1, sizeof(DltPassiveControlMessage));
+     270             : 
+     271           9 :         if (!con->p_control_msgs->next) {
+     272           0 :             dlt_log(LOG_ERR,
+     273             :                     "Passive Control Message could not be allocated\n");
+     274           0 :             return DLT_RETURN_ERROR;
+     275             :         }
+     276             : 
+     277           9 :         con->p_control_msgs = con->p_control_msgs->next;
+     278             :     }
+     279             : 
+     280             :     return DLT_RETURN_OK;
+     281             : }
+     282             : 
+     283             : /**
+     284             :  * Check the specified control messages identifier
+     285             :  *
+     286             :  * @param con   DltGatewayConnection to be updated
+     287             :  * @param value string to be tested
+     288             :  * @return Value from DltReturnValue enum
+     289             :  */
+     290           6 : DLT_STATIC DltReturnValue dlt_gateway_check_control_messages(DltGatewayConnection *con,
+     291             :                                                              char *value)
+     292             : {
+     293             :     /* list of allowed clients given */
+     294             :     char *token = NULL;
+     295           6 :     char *rest = NULL;
+     296             :     DltPassiveControlMessage *head = NULL;
+     297             : 
+     298           6 :     if ((con == NULL) || (value == NULL)) {
+     299           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     300           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     301             :     }
+     302             : 
+     303           5 :     if (strlen(value) == 0)
+     304             :         return DLT_RETURN_OK;
+     305             : 
+     306             :     /* set on startup control msg id and interval*/
+     307           5 :     token = strtok_r(value, ",", &rest);
+     308             : 
+     309          18 :     while (token != NULL) {
+     310          13 :         if (dlt_gateway_allocate_control_messages(con) != DLT_RETURN_OK) {
+     311           0 :             dlt_log(LOG_ERR,
+     312             :                     "Passive Control Message could not be allocated\n");
+     313           0 :             return DLT_RETURN_ERROR;
+     314             :         }
+     315             : 
+     316          13 :         con->p_control_msgs->id = strtol(token, NULL, 16);
+     317          13 :         con->p_control_msgs->user_id = DLT_SERVICE_ID_PASSIVE_NODE_CONNECT;
+     318          13 :         con->p_control_msgs->type = CONTROL_MESSAGE_ON_STARTUP;
+     319          13 :         con->p_control_msgs->req = CONTROL_MESSAGE_NOT_REQUESTED;
+     320          13 :         con->p_control_msgs->interval = -1;
+     321             : 
+     322          13 :         if (head == NULL)
+     323             :             head = con->p_control_msgs;
+     324             : 
+     325          13 :         if ((errno == EINVAL) || (errno == ERANGE)) {
+     326           0 :             dlt_vlog(LOG_ERR,
+     327             :                      "Control message ID is not an integer: %s\n",
+     328             :                      token);
+     329           0 :             return DLT_RETURN_ERROR;
+     330             :         }
+     331          13 :         else if ((con->p_control_msgs->id < DLT_SERVICE_ID_SET_LOG_LEVEL) ||
+     332             :                  (con->p_control_msgs->id >= DLT_SERVICE_ID_LAST_ENTRY))
+     333             :         {
+     334           0 :             dlt_vlog(LOG_ERR,
+     335             :                      "Control message ID is not valid: %s\n",
+     336             :                      token);
+     337           0 :             return DLT_RETURN_ERROR;
+     338             :         }
+     339             : 
+     340          13 :         token = strtok_r(NULL, ",", &rest);
+     341             :     }
+     342             : 
+     343             :     /* get back to head */
+     344           5 :     con->p_control_msgs = head;
+     345           5 :     con->head = head;
+     346             : 
+     347           5 :     return DLT_RETURN_OK;
+     348             : }
+     349             : 
+     350             : /**
+     351             :  * Check the specified periodic control messages identifier
+     352             :  *
+     353             :  * @param con   DltGatewayConnection to be updated
+     354             :  * @param value string to be tested
+     355             :  * @return Value from DltReturnValue enum
+     356             :  */
+     357           2 : DLT_STATIC DltReturnValue dlt_gateway_check_periodic_control_messages(
+     358             :     DltGatewayConnection *con,
+     359             :     char *value)
+     360             : {
+     361             :     char *token = NULL;
+     362           2 :     char *rest = NULL;
+     363             :     DltPassiveControlMessage *head = NULL;
+     364             : 
+     365           2 :     if ((con == NULL) || (value == NULL)) {
+     366           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     367           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     368             :     }
+     369             : 
+     370           1 :     if (strlen(value) == 0)
+     371             :         return DLT_RETURN_OK;
+     372             : 
+     373             :     /* store head address */
+     374           1 :     head = con->p_control_msgs;
+     375             : 
+     376             :     /* set periodic control msg id and interval*/
+     377           1 :     token = strtok_r(value, ",", &rest);
+     378             : 
+     379           3 :     while (token != NULL) {
+     380             :         char *p_token = NULL;
+     381           2 :         char *p_rest = NULL;
+     382             :         uint32_t id = 0;
+     383             : 
+     384           2 :         p_token = strtok_r(token, ":", &p_rest);
+     385             : 
+     386           2 :         if ((p_token != NULL) && (strlen(p_token) != 0)) {
+     387           2 :             id = strtol(p_token, NULL, 16);
+     388             : 
+     389             :             /* get back to head */
+     390           2 :             con->p_control_msgs = head;
+     391             : 
+     392             :             /* check if there is already id set in p_control_msgs */
+     393           3 :             while (con->p_control_msgs != NULL) {
+     394           1 :                 if (con->p_control_msgs->id == id) {
+     395           0 :                     con->p_control_msgs->type = CONTROL_MESSAGE_BOTH;
+     396           0 :                     con->p_control_msgs->interval = strtol(p_rest, NULL, 10);
+     397             : 
+     398           0 :                     if (con->p_control_msgs->interval <= 0)
+     399           0 :                         dlt_vlog(LOG_WARNING,
+     400             :                                  "%s interval is %d. It won't be send periodically.\n",
+     401             :                                  dlt_get_service_name(con->p_control_msgs->id),
+     402             :                                  con->p_control_msgs->interval);
+     403             : 
+     404             :                     break;
+     405             :                 }
+     406             : 
+     407           1 :                 con->p_control_msgs = con->p_control_msgs->next;
+     408             :             }
+     409             : 
+     410             :             /* if the id is not added yet, p_control_msgs supposed to be NULL */
+     411           2 :             if (con->p_control_msgs == NULL) {
+     412             :                 /* get back to head */
+     413           2 :                 con->p_control_msgs = head;
+     414             : 
+     415             :                 /* go to last pointer */
+     416           2 :                 while (con->p_control_msgs != NULL) {
+     417           1 :                     if (con->p_control_msgs->next == NULL)
+     418             :                         break;
+     419             : 
+     420           0 :                     con->p_control_msgs = con->p_control_msgs->next;
+     421             :                 }
+     422             : 
+     423           2 :                 if (dlt_gateway_allocate_control_messages(con) != DLT_RETURN_OK) {
+     424           0 :                     dlt_log(LOG_ERR,
+     425             :                             "Passive Control Message could not be allocated\n");
+     426           0 :                     return DLT_RETURN_ERROR;
+     427             :                 }
+     428             : 
+     429           2 :                 con->p_control_msgs->id = id;
+     430           2 :                 con->p_control_msgs->user_id = DLT_SERVICE_ID_PASSIVE_NODE_CONNECT;
+     431           2 :                 con->p_control_msgs->type = CONTROL_MESSAGE_PERIODIC;
+     432           2 :                 con->p_control_msgs->req = CONTROL_MESSAGE_NOT_REQUESTED;
+     433           2 :                 con->p_control_msgs->interval = strtol(p_rest, NULL, 10);
+     434             : 
+     435           2 :                 if (con->p_control_msgs->interval <= 0)
+     436           0 :                     dlt_vlog(LOG_WARNING,
+     437             :                              "%s interval is %d. It won't be send periodically.\n",
+     438             :                              dlt_get_service_name(con->p_control_msgs->id),
+     439             :                              con->p_control_msgs->interval);
+     440             : 
+     441           2 :                 if (head == NULL)
+     442           1 :                     head = con->p_control_msgs;
+     443             :             }
+     444             :         }
+     445             : 
+     446           2 :         if ((errno == EINVAL) || (errno == ERANGE)) {
+     447           0 :             dlt_vlog(LOG_ERR,
+     448             :                      "Control message ID is not an integer: %s\n",
+     449             :                      p_token);
+     450           0 :             return DLT_RETURN_ERROR;
+     451             :         }
+     452           2 :         else if ((con->p_control_msgs->id < DLT_SERVICE_ID_SET_LOG_LEVEL) ||
+     453             :                  (con->p_control_msgs->id >= DLT_SERVICE_ID_LAST_ENTRY))
+     454             :         {
+     455           0 :             dlt_vlog(LOG_ERR,
+     456             :                      "Control message ID is not valid: %s\n",
+     457             :                      p_token);
+     458           0 :             return DLT_RETURN_ERROR;
+     459             :         }
+     460             : 
+     461           2 :         token = strtok_r(NULL, ",", &rest);
+     462             :     }
+     463             : 
+     464             :     /* get back to head */
+     465           1 :     con->p_control_msgs = head;
+     466           1 :     con->head = head;
+     467             : 
+     468           1 :     return DLT_RETURN_OK;
+     469             : }
+     470             : 
+     471             : /**
+     472             :  * Expected entries for a passive node configuration
+     473             :  * Caution: after changing entries here,
+     474             :  * dlt_gateway_check_param needs to be updated as well
+     475             :  * */
+     476             : DLT_STATIC DltGatewayConf configuration_entries[GW_CONF_COUNT] = {
+     477             :     [GW_CONF_IP_ADDRESS] = {
+     478             :         .key = "IPaddress",
+     479             :         .func = dlt_gateway_check_ip,
+     480             :         .is_opt = 0
+     481             :     },
+     482             :     [GW_CONF_PORT] = {
+     483             :         .key = "Port",
+     484             :         .func = dlt_gateway_check_port,
+     485             :         .is_opt = 1
+     486             :     },
+     487             :     [GW_CONF_ECUID] = {
+     488             :         .key = "EcuID",
+     489             :         .func = dlt_gateway_check_ecu,
+     490             :         .is_opt = 0
+     491             :     },
+     492             :     [GW_CONF_CONNECT] = {
+     493             :         .key = "Connect",
+     494             :         .func = dlt_gateway_check_connect_trigger,
+     495             :         .is_opt = 1
+     496             :     },
+     497             :     [GW_CONF_TIMEOUT] = {
+     498             :         .key = "Timeout",
+     499             :         .func = dlt_gateway_check_timeout,
+     500             :         .is_opt = 0
+     501             :     },
+     502             :     [GW_CONF_SEND_CONTROL] = {
+     503             :         .key = "SendControl",
+     504             :         .func = dlt_gateway_check_control_messages,
+     505             :         .is_opt = 1
+     506             :     },
+     507             :     [GW_CONF_SEND_PERIODIC_CONTROL] = {
+     508             :         .key = "SendPeriodicControl",
+     509             :         .func = dlt_gateway_check_periodic_control_messages,
+     510             :         .is_opt = 1
+     511             :     },
+     512             :     [GW_CONF_SEND_SERIAL_HEADER] = {
+     513             :         .key = "SendSerialHeader",
+     514             :         .func = dlt_gateway_check_send_serial,
+     515             :         .is_opt = 1
+     516             :     }
+     517             : };
+     518             : 
+     519             : DLT_STATIC DltGatewayGeneralConf general_entries[GW_CONF_COUNT] = {
+     520             :     [GW_CONF_GENERAL_INTERVAL] = {
+     521             :         .key = "Interval",
+     522             :         .func = dlt_gateway_check_interval,
+     523             :         .is_opt = 1
+     524             :     }
+     525             : };
+     526             : 
+     527             : #define DLT_GATEWAY_NUM_PROPERTIES_MAX GW_CONF_COUNT
+     528             : 
+     529             : /**
+     530             :  * Check if gateway connection general configuration parameter is valid.
+     531             :  *
+     532             :  * @param gateway    DltGateway
+     533             :  * @param ctype      DltGatwayGeneralConnection property
+     534             :  * @param value      specified property value from configuration file
+     535             :  * @return Value from DltReturnValue enum
+     536             :  */
+     537           0 : DLT_STATIC DltReturnValue dlt_gateway_check_general_param(DltGateway *gateway,
+     538             :                                                   DltGatewayGeneralConfType ctype,
+     539             :                                                   char *value)
+     540             : {
+     541           0 :     if ((gateway == NULL) || (value == NULL)) {
+     542           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     543           0 :         return DLT_RETURN_WRONG_PARAMETER;
+     544             :     }
+     545             : 
+     546           0 :     if (ctype < GW_CONF_GENEREL_COUNT)
+     547           0 :         return general_entries[ctype].func(gateway, value);
+     548             : 
+     549             :     return DLT_RETURN_ERROR;
+     550             : }
+     551             : 
+     552             : /**
+     553             :  * Check if gateway connection configuration parameter is valid.
+     554             :  *
+     555             :  * @param gateway    DltGateway
+     556             :  * @param con        DltGatewayConnection
+     557             :  * @param ctype      DltGatwayConnection property
+     558             :  * @param value      specified property value from configuration file
+     559             :  * @return Value from DltReturnValue enum
+     560             :  */
+     561          32 : DLT_STATIC DltReturnValue dlt_gateway_check_param(DltGateway *gateway,
+     562             :                                                   DltGatewayConnection *con,
+     563             :                                                   DltGatewayConfType ctype,
+     564             :                                                   char *value)
+     565             : {
+     566          32 :     if ((gateway == NULL) || (con == NULL) || (value == NULL)) {
+     567           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     568           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     569             :     }
+     570             : 
+     571          31 :     if (ctype < GW_CONF_COUNT)
+     572          31 :         return configuration_entries[ctype].func(con, value);
+     573             : 
+     574             :     return DLT_RETURN_ERROR;
+     575             : }
+     576             : 
+     577             : /**
+     578             :  * Store gateway connection in internal data structure
+     579             :  *
+     580             :  * @param gateway    DltGatway
+     581             :  * @param tmp        DltGatewayConnection
+     582             :  * @param verbose    verbose flag
+     583             :  * @return 0 on success, -1 otherwise
+     584             :  */
+     585           7 : int dlt_gateway_store_connection(DltGateway *gateway,
+     586             :                                  DltGatewayConnection *tmp,
+     587             :                                  int verbose)
+     588             : {
+     589             :     int i = 0;
+     590             : 
+     591           7 :     PRINT_FUNCTION_VERBOSE(verbose);
+     592             : 
+     593           7 :     if ((gateway == NULL) || (tmp == NULL)) {
+     594           2 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     595           2 :         return DLT_RETURN_WRONG_PARAMETER;
+     596             :     }
+     597             : 
+     598             :     /* find next free entry in connection array */
+     599           5 :     while (i < gateway->num_connections) {
+     600           5 :         if (gateway->connections[i].status == DLT_GATEWAY_UNINITIALIZED)
+     601             :             break;
+     602             : 
+     603           0 :         i++;
+     604             :     }
+     605             : 
+     606           5 :     if (&(gateway->connections[i]) == NULL)
+     607             :         return DLT_RETURN_ERROR;
+     608             : 
+     609             :     /* store values */
+     610           5 :     gateway->connections[i].ip_address = strdup(tmp->ip_address);
+     611           5 :     gateway->connections[i].ecuid = strdup(tmp->ecuid);
+     612           5 :     gateway->connections[i].sock_domain = tmp->sock_domain;
+     613           5 :     gateway->connections[i].sock_type = tmp->sock_type;
+     614           5 :     gateway->connections[i].sock_protocol = tmp->sock_protocol;
+     615           5 :     gateway->connections[i].port = tmp->port;
+     616           5 :     gateway->connections[i].trigger = tmp->trigger;
+     617           5 :     gateway->connections[i].timeout = tmp->timeout;
+     618           5 :     gateway->connections[i].handle = 0;
+     619           5 :     gateway->connections[i].status = DLT_GATEWAY_INITIALIZED;
+     620           5 :     gateway->connections[i].p_control_msgs = tmp->p_control_msgs;
+     621           5 :     gateway->connections[i].head = tmp->head;
+     622           5 :     gateway->connections[i].send_serial = tmp->send_serial;
+     623             : 
+     624           5 :     if (dlt_client_init_port(&gateway->connections[i].client,
+     625             :                              gateway->connections[i].port,
+     626             :                              verbose) != 0) {
+     627           0 :         free(gateway->connections[i].ip_address);
+     628           0 :         gateway->connections[i].ip_address = NULL;
+     629           0 :         free(gateway->connections[i].ecuid);
+     630           0 :         gateway->connections[i].ecuid = NULL;
+     631           0 :         free(gateway->connections[i].p_control_msgs);
+     632           0 :         gateway->connections[i].p_control_msgs = NULL;
+     633           0 :         dlt_log(LOG_CRIT, "dlt_client_init_port() failed for gateway connection\n");
+     634           0 :         return DLT_RETURN_ERROR;
+     635             :     }
+     636             : 
+     637             :     /* setup DltClient Structure */
+     638           5 :     if (dlt_client_set_server_ip(&gateway->connections[i].client,
+     639           5 :                                  gateway->connections[i].ip_address) == -1) {
+     640           0 :         dlt_log(LOG_ERR,
+     641             :                 "dlt_client_set_server_ip() failed for gateway connection \n");
+     642           0 :         return DLT_RETURN_ERROR;
+     643             :     }
+     644             : 
+     645             :     return DLT_RETURN_OK;
+     646             : }
+     647             : 
+     648             : /**
+     649             :  * Read configuration file and initialize connection data structures
+     650             :  *
+     651             :  * @param gateway       DltGateway
+     652             :  * @param config_file   Gateway configuration
+     653             :  * @param verbose       verbose flag
+     654             :  * @return 0 on success, -1 otherwise
+     655             :  */
+     656           5 : int dlt_gateway_configure(DltGateway *gateway, char *config_file, int verbose)
+     657             : {
+     658             :     int ret = 0;
+     659             :     int i = 0;
+     660             :     DltConfigFile *file = NULL;
+     661           5 :     int num_sections = 0;
+     662             : 
+     663           5 :     PRINT_FUNCTION_VERBOSE(verbose);
+     664             : 
+     665           5 :     if ((gateway == NULL) || (config_file == 0) || (config_file[0] == '\0')) {
+     666           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     667           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     668             :     }
+     669             : 
+     670             :     /* read configuration file */
+     671           4 :     file = dlt_config_file_init(config_file);
+     672           4 :     if(file == NULL) {
+     673             :         return DLT_RETURN_ERROR;
+     674             :     }
+     675             : 
+     676             :     /* get number of entries and allocate memory to store information */
+     677           4 :     ret = dlt_config_file_get_num_sections(file, &num_sections);
+     678           4 :     if (ret != 0) {
+     679           0 :         dlt_config_file_release(file);
+     680           0 :         dlt_log(LOG_ERR, "Invalid number of sections in configuration file\n");
+     681           0 :         return DLT_RETURN_ERROR;
+     682             :     }
+     683             : 
+     684           4 :     ret = dlt_config_file_check_section_name_exists(file, DLT_GATEWAY_GENERAL_SECTION_NAME);
+     685           4 :     if (ret == -1) {
+     686             :         /*
+     687             :          * No General section in configuration file.
+     688             :          * Try to use default for interval.
+     689             :          */
+     690           4 :         gateway->num_connections = num_sections;
+     691           4 :         dlt_vlog(LOG_WARNING,
+     692             :                 "Missing General section in gateway. Using default interval %d (secs)\n",
+     693             :                 gateway->interval);
+     694             :     }
+     695             :     else {
+     696             :         /*
+     697             :          * Since the General section is also counted in num_sections,
+     698             :          * so number of connections must be number of sections - 1.
+     699             :          */
+     700           0 :         gateway->num_connections = num_sections - 1;
+     701             :     }
+     702             : 
+     703           4 :     gateway->connections = calloc(gateway->num_connections,
+     704             :                                 sizeof(DltGatewayConnection));
+     705             : 
+     706           4 :     if (gateway->connections == NULL) {
+     707           0 :         dlt_config_file_release(file);
+     708           0 :         dlt_log(LOG_CRIT, "Memory allocation for gateway connections failed\n");
+     709           0 :         return DLT_RETURN_ERROR;
+     710             :     }
+     711             : 
+     712           8 :     for (i = 0; i < num_sections; i++) {
+     713             :         DltGatewayConnection tmp;
+     714             :         int invalid = 0;
+     715             :         DltGatewayConfType j = 0;
+     716             :         DltGatewayGeneralConfType g = 0;
+     717           4 :         char section[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = { '\0' };
+     718           4 :         char value[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = { '\0' };
+     719             : 
+     720             :         memset(&tmp, 0, sizeof(tmp));
+     721             : 
+     722             :         /* Set default */
+     723           4 :         tmp.send_serial = gateway->send_serial;
+     724           4 :         tmp.port = DLT_DAEMON_TCP_PORT;
+     725             : 
+     726           4 :         ret = dlt_config_file_get_section_name(file, i, section);
+     727           4 :         if (ret != 0) {
+     728           0 :             dlt_log(LOG_WARNING, "Get section name failed\n");
+     729           0 :             continue;
+     730             :         }
+     731             : 
+     732           4 :         if (strncmp(section, DLT_GATEWAY_GENERAL_SECTION_NAME,
+     733             :                 sizeof(DLT_GATEWAY_GENERAL_SECTION_NAME)) == 0) {
+     734           0 :             for (g = 0; g < GW_CONF_GENEREL_COUNT; g++) {
+     735           0 :                 ret = dlt_config_file_get_value(file,
+     736             :                                                 section,
+     737           0 :                                                 general_entries[g].key,
+     738             :                                                 value);
+     739             : 
+     740           0 :                 if ((ret != 0) && general_entries[g].is_opt) {
+     741             :                     /* Use default values for this key */
+     742           0 :                     dlt_vlog(LOG_WARNING,
+     743             :                              "Using default for %s.\n",
+     744             :                              general_entries[g].key);
+     745           0 :                     continue;
+     746             :                 }
+     747           0 :                 else if (ret != 0)
+     748             :                 {
+     749           0 :                     dlt_vlog(LOG_WARNING,
+     750             :                              "Missing configuration for %s.\n",
+     751             :                              general_entries[g].key);
+     752           0 :                     break;
+     753             :                 }
+     754             : 
+     755             :                 /* check value and store general configuration */
+     756           0 :                 ret = dlt_gateway_check_general_param(gateway, g, value);
+     757             : 
+     758           0 :                 if (ret != 0)
+     759           0 :                     dlt_vlog(LOG_ERR,
+     760             :                              "Configuration %s = %s is invalid. Using default.\n",
+     761             :                              general_entries[g].key, value);
+     762             :             }
+     763             :         }
+     764             :         else {
+     765          36 :             for (j = 0; j < GW_CONF_COUNT; j++) {
+     766          32 :                 ret = dlt_config_file_get_value(file,
+     767             :                                                 section,
+     768          32 :                                                 configuration_entries[j].key,
+     769             :                                                 value);
+     770             : 
+     771          32 :                 if ((ret != 0) && configuration_entries[j].is_opt) {
+     772             :                     /* Use default values for this key */
+     773           4 :                     dlt_vlog(LOG_WARNING,
+     774             :                              "Using default for %s.\n",
+     775             :                              configuration_entries[j].key);
+     776           4 :                     continue;
+     777             :                 }
+     778          28 :                 else if (ret != 0)
+     779             :                 {
+     780           0 :                     dlt_vlog(LOG_WARNING,
+     781             :                              "Missing configuration for %s.\n",
+     782             :                              configuration_entries[j].key);
+     783             :                     invalid = 1;
+     784           0 :                     break;
+     785             :                 }
+     786             : 
+     787             :                 /* check value and store temporary */
+     788          28 :                 ret = dlt_gateway_check_param(gateway, &tmp, j, value);
+     789             : 
+     790          28 :                 if (ret != 0)
+     791           0 :                     dlt_vlog(LOG_ERR,
+     792             :                              "Configuration %s = %s is invalid.\n"
+     793             :                              "Using default.\n",
+     794             :                              configuration_entries[j].key, value);
+     795             :             }
+     796             : 
+     797           4 :             if (!tmp.ip_address) {
+     798             :                 invalid = 1;
+     799             :             }
+     800             : 
+     801           4 :             if (invalid) {
+     802           0 :                 dlt_vlog(LOG_ERR,
+     803             :                          "%s configuration is invalid.\n"
+     804             :                          "Ignoring.\n",
+     805             :                          section);
+     806             :             }
+     807             :             else {
+     808           4 :                 ret = dlt_gateway_store_connection(gateway, &tmp, verbose);
+     809             : 
+     810           4 :                 if (ret != 0)
+     811           0 :                     dlt_log(LOG_ERR, "Storing gateway connection data failed\n");
+     812             :             }
+     813             :         }
+     814             : 
+     815             :         /* strdup used inside some get_value function */
+     816           4 :         if (tmp.ecuid != NULL) {
+     817           4 :             free(tmp.ecuid);
+     818           4 :             tmp.ecuid = NULL;
+     819             :         }
+     820           4 :         if (tmp.ip_address != NULL) {
+     821           4 :             free(tmp.ip_address);
+     822             :             tmp.ip_address = NULL;
+     823             :         }
+     824             :     }
+     825             : 
+     826           4 :     dlt_config_file_release(file);
+     827           4 :     return ret;
+     828             : }
+     829             : 
+     830           4 : int dlt_gateway_init(DltDaemonLocal *daemon_local, int verbose)
+     831             : {
+     832           4 :     PRINT_FUNCTION_VERBOSE(verbose);
+     833             : 
+     834           4 :     if (daemon_local == NULL) {
+     835           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     836           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     837             :     }
+     838             : 
+     839           3 :     DltGateway *gateway = &daemon_local->pGateway;
+     840             : 
+     841             :     if (gateway != NULL) {
+     842             :         /* Get default value from daemon_local */
+     843           3 :         gateway->send_serial = daemon_local->flags.lflag;
+     844           3 :         gateway->interval = DLT_GATEWAY_TIMER_DEFAULT_INTERVAL;
+     845             : 
+     846           3 :         if (dlt_gateway_configure(gateway,
+     847           3 :                                   daemon_local->flags.gatewayConfigFile,
+     848             :                                   verbose) != 0) {
+     849           0 :             dlt_log(LOG_ERR, "Gateway initialization failed\n");
+     850           0 :             return DLT_RETURN_ERROR;
+     851             :         }
+     852             :     }
+     853             :     else {
+     854             :         dlt_log(LOG_CRIT, "Pointer to Gateway structure is NULL\n");
+     855             :         return DLT_RETURN_ERROR;
+     856             :     }
+     857             : 
+     858             :     /* ignore return value */
+     859           3 :     dlt_gateway_establish_connections(gateway, daemon_local, verbose);
+     860             : 
+     861           3 :     return DLT_RETURN_OK;
+     862             : }
+     863             : 
+     864          10 : void dlt_gateway_deinit(DltGateway *gateway, int verbose)
+     865             : {
+     866             :     DltPassiveControlMessage *msg;
+     867             :     int i = 0;
+     868             : 
+     869          10 :     if (gateway == NULL) {
+     870           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     871           0 :         return;
+     872             :     }
+     873             : 
+     874          10 :     PRINT_FUNCTION_VERBOSE(verbose);
+     875             : 
+     876          12 :     for (i = 0; i < gateway->num_connections; i++) {
+     877           2 :         DltGatewayConnection *c = &gateway->connections[i];
+     878           2 :         dlt_client_cleanup(&c->client, verbose);
+     879           2 :         free(c->ip_address);
+     880           2 :         c->ip_address = NULL;
+     881           2 :         free(c->ecuid);
+     882           2 :         c->ecuid = NULL;
+     883             : 
+     884           6 :         while (c->p_control_msgs != NULL) {
+     885           4 :             msg = c->p_control_msgs->next;
+     886           4 :             free(c->p_control_msgs);
+     887           4 :             c->p_control_msgs = msg;
+     888             :         }
+     889             :     }
+     890             : 
+     891          10 :     free(gateway->connections);
+     892          10 :     gateway->connections = NULL;
+     893             : }
+     894             : 
+     895             : /**
+     896             :  * If connection to passive node established, add to event loop
+     897             :  *
+     898             :  * @param daemon_local  DltDaemonLocal
+     899             :  * @param con           DltGatewayConnection
+     900             :  * @param verbose       verbose flag
+     901             :  * @return 0 on success, -1 otherwise
+     902             :  */
+     903           3 : DLT_STATIC int dlt_gateway_add_to_event_loop(DltDaemonLocal *daemon_local,
+     904             :                                              DltGatewayConnection *con,
+     905             :                                              int verbose)
+     906             : {
+     907             :     DltPassiveControlMessage *control_msg = NULL;
+     908             :     int sendtime = 1;
+     909             : 
+     910           3 :     if ((daemon_local == NULL) || (con == NULL)) {
+     911           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     912           0 :         return DLT_RETURN_WRONG_PARAMETER;
+     913             :     }
+     914             : 
+     915             :     /* connection to passive node established, add to event loop */
+     916           3 :     con->status = DLT_GATEWAY_CONNECTED;
+     917           3 :     con->reconnect_cnt = 0;
+     918           3 :     con->timeout_cnt = 0;
+     919           3 :     con->sendtime_cnt = 0;
+     920             : 
+     921             :     /* setup dlt connection and add to poll event loop here */
+     922           3 :     if (dlt_connection_create(daemon_local,
+     923             :                               &daemon_local->pEvent,
+     924             :                               con->client.sock,
+     925             :                               POLLIN,
+     926             :                               DLT_CONNECTION_GATEWAY) != 0) {
+     927           0 :         dlt_log(LOG_ERR, "Gateway connection creation failed\n");
+     928           0 :         return DLT_RETURN_ERROR;
+     929             :     }
+     930             : 
+     931             :     /* immediately send configured control messages */
+     932           3 :     control_msg = con->p_control_msgs;
+     933             : 
+     934           9 :     while (control_msg != NULL) {
+     935           6 :         if ((control_msg->type == CONTROL_MESSAGE_ON_STARTUP) ||
+     936             :             (control_msg->type == CONTROL_MESSAGE_BOTH)) {
+     937           6 :             if (dlt_gateway_send_control_message(con,
+     938             :                                                  control_msg,
+     939             :                                                  NULL,
+     940             :                                                  verbose) == DLT_RETURN_OK)
+     941           6 :                 control_msg->req = CONTROL_MESSAGE_REQUESTED;
+     942             :         }
+     943             : 
+     944             :         /* multiply periodic sending time */
+     945           6 :         if (((control_msg->type == CONTROL_MESSAGE_PERIODIC) ||
+     946           0 :              (control_msg->type == CONTROL_MESSAGE_BOTH)) &&
+     947           0 :             (control_msg->interval > 0))
+     948           0 :             sendtime *= control_msg->interval;
+     949             : 
+     950           6 :         control_msg = control_msg->next;
+     951             :     }
+     952             : 
+     953             :     /* set periodic sending time */
+     954           3 :     con->sendtime = sendtime;
+     955           3 :     con->sendtime_cnt = con->sendtime;
+     956             : 
+     957           3 :     return DLT_RETURN_OK;
+     958             : }
+     959             : 
+     960           6 : int dlt_gateway_establish_connections(DltGateway *gateway,
+     961             :                                       DltDaemonLocal *daemon_local,
+     962             :                                       int verbose)
+     963             : {
+     964             :     int i = 0;
+     965             :     int ret = 0;
+     966             : 
+     967           6 :     PRINT_FUNCTION_VERBOSE(verbose);
+     968             : 
+     969           6 :     if ((gateway == NULL) || (daemon_local == NULL)) {
+     970           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     971           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     972             :     }
+     973             : 
+     974          10 :     for (i = 0; i < gateway->num_connections; i++) {
+     975           5 :         DltGatewayConnection *con = &(gateway->connections[i]);
+     976             :         DltPassiveControlMessage *control_msg = NULL;
+     977             : 
+     978           5 :         if (con == NULL) {
+     979           0 :             dlt_log(LOG_CRIT, "Cannot retrieve gateway connection details\n");
+     980           0 :             return DLT_RETURN_ERROR;
+     981             :         }
+     982             : 
+     983           5 :         if ((con->status != DLT_GATEWAY_CONNECTED) &&
+     984           5 :             (con->trigger != DLT_GATEWAY_ON_DEMAND) &&
+     985             :             (con->trigger != DLT_GATEWAY_DISABLED)) {
+     986           5 :             ret = dlt_client_connect(&con->client, verbose);
+     987             : 
+     988           5 :             if (ret == 0) {
+     989             :                 /* setup dlt connection and add to poll event loop here */
+     990           3 :                 if (dlt_gateway_add_to_event_loop(daemon_local, con, verbose) != DLT_RETURN_OK) {
+     991           0 :                     dlt_log(LOG_ERR, "Gateway connection creation failed\n");
+     992           0 :                     return DLT_RETURN_ERROR;
+     993             :                 }
+     994             :             }
+     995             :             else {
+     996           2 :                 dlt_log(LOG_DEBUG,
+     997             :                         "Passive Node is not up. Connection failed.\n");
+     998             : 
+     999           2 :                 con->timeout_cnt++;
+    1000             : 
+    1001           2 :                 if (con->timeout > 0) {
+    1002           0 :                     if (con->timeout_cnt > con->timeout) {
+    1003           0 :                         con->trigger = DLT_GATEWAY_DISABLED;
+    1004           0 :                         dlt_log(LOG_WARNING,
+    1005             :                                 "Passive Node connection retry timed out. "
+    1006             :                                 "Give up.\n");
+    1007             :                     }
+    1008             :                 }
+    1009           2 :                 else if (con->timeout == 0) {
+    1010           2 :                     dlt_vlog(LOG_DEBUG, "Retried [%d] times\n", con->timeout_cnt);
+    1011             :                 }
+    1012             :             }
+    1013             :         }
+    1014           0 :         else if ((con->status == DLT_GATEWAY_CONNECTED) &&
+    1015           0 :                  (con->trigger != DLT_GATEWAY_DISABLED))
+    1016             :         {
+    1017             :             /* setup dlt connection and add to poll event loop here */
+    1018           0 :             if (dlt_connection_create(daemon_local,
+    1019             :                                       &daemon_local->pEvent,
+    1020             :                                       con->client.sock,
+    1021             :                                       POLLIN,
+    1022             :                                       DLT_CONNECTION_GATEWAY) != 0) {
+    1023           0 :                 dlt_log(LOG_ERR, "Gateway connection creation failed\n");
+    1024           0 :                 return DLT_RETURN_ERROR;
+    1025             :             }
+    1026             : 
+    1027             :             /* immediately send periodic configured control messages */
+    1028           0 :             control_msg = con->p_control_msgs;
+    1029             : 
+    1030           0 :             while (control_msg != NULL) {
+    1031           0 :                 if ((control_msg->type == CONTROL_MESSAGE_PERIODIC) ||
+    1032             :                     (control_msg->type == CONTROL_MESSAGE_BOTH)) {
+    1033           0 :                     if (dlt_gateway_send_control_message(con,
+    1034             :                                                          control_msg,
+    1035             :                                                          NULL,
+    1036             :                                                          verbose) == DLT_RETURN_OK)
+    1037           0 :                         control_msg->req = CONTROL_MESSAGE_REQUESTED;
+    1038             :                 }
+    1039             : 
+    1040           0 :                 control_msg = control_msg->next;
+    1041             :             }
+    1042             : 
+    1043             :             /* check sendtime counter */
+    1044           0 :             if (con->sendtime_cnt > 0)
+    1045           0 :                 con->sendtime_cnt--;
+    1046             : 
+    1047           0 :             if (con->sendtime_cnt == 0)
+    1048           0 :                 con->sendtime_cnt = con->sendtime;
+    1049             :         }
+    1050             :     }
+    1051             : 
+    1052             :     return DLT_RETURN_OK;
+    1053             : }
+    1054             : 
+    1055           6 : DltReceiver *dlt_gateway_get_connection_receiver(DltGateway *gateway, int fd)
+    1056             : {
+    1057             :     int i = 0;
+    1058             : 
+    1059           6 :     if (gateway == NULL) {
+    1060           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+    1061           1 :         return NULL;
+    1062             :     }
+    1063             : 
+    1064           6 :     for (i = 0; i < gateway->num_connections; i++) {
+    1065           5 :         DltGatewayConnection *c = &gateway->connections[i];
+    1066             : 
+    1067           5 :         if ((c->status == DLT_GATEWAY_CONNECTED) && (c->client.sock == fd))
+    1068           4 :             return &c->client.receiver;
+    1069             :     }
+    1070             : 
+    1071             :     return NULL;
+    1072             : }
+    1073             : 
+    1074             : /**
+    1075             :  * Parse GET_LOG_INFO
+    1076             :  *
+    1077             :  * @param daemon          DltDaemon
+    1078             :  * @param ecu             Ecu ID
+    1079             :  * @param msg             DltMessage
+    1080             :  * @param req             1 if requested from gateway, 0 otherwise
+    1081             :  * @param verbose verbose flag
+    1082             :  * @return Value from DltReturnValue enum
+    1083             :  */
+    1084           3 : DLT_STATIC DltReturnValue dlt_gateway_parse_get_log_info(DltDaemon *daemon,
+    1085             :                                                          char *ecu,
+    1086             :                                                          DltMessage *msg,
+    1087             :                                                          int req,
+    1088             :                                                          int verbose)
+    1089             : {
+    1090           3 :     char resp_text[DLT_RECEIVE_BUFSIZE] = { '\0' };
+    1091             :     DltServiceGetLogInfoResponse *resp = NULL;
+    1092             :     AppIDsType app;
+    1093             :     ContextIDsInfoType con;
+    1094             :     int i = 0;
+    1095             :     int j = 0;
+    1096             : 
+    1097           3 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1098             : 
+    1099           3 :     if ((msg == NULL) || (msg->databuffer == NULL)) {
+    1100           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+    1101           1 :         return DLT_RETURN_WRONG_PARAMETER;
+    1102             :     }
+    1103             : 
+    1104           2 :     if (dlt_check_rcv_data_size(msg->datasize, sizeof(DltServiceGetLogInfoResponse)) < 0)
+    1105             :         return DLT_RETURN_ERROR;
+    1106             : 
+    1107             :     /* if the request was send from gateway, clear all application and context list */
+    1108           1 :     if (req == CONTROL_MESSAGE_REQUESTED) {
+    1109             :         /* clear application list */
+    1110           0 :         if (dlt_daemon_applications_clear(daemon, ecu, verbose) == DLT_RETURN_ERROR) {
+    1111           0 :             dlt_log(LOG_ERR, "Cannot clear applications list\n");
+    1112           0 :             return DLT_RETURN_ERROR;
+    1113             :         }
+    1114             : 
+    1115             :         /* clear context list */
+    1116           0 :         if (dlt_daemon_contexts_clear(daemon, ecu, verbose) == DLT_RETURN_ERROR) {
+    1117           0 :             dlt_log(LOG_ERR, "Cannot clear contexts list\n");
+    1118           0 :             return DLT_RETURN_ERROR;
+    1119             :         }
+    1120             :     }
+    1121             : 
+    1122             :     /* check response */
+    1123           1 :     if (dlt_message_payload(msg,
+    1124             :                             resp_text,
+    1125             :                             DLT_RECEIVE_BUFSIZE,
+    1126             :                             DLT_OUTPUT_ASCII, 0) != DLT_RETURN_OK) {
+    1127           0 :         dlt_log(LOG_ERR, "GET_LOG_INFO payload failed\n");
+    1128           0 :         return DLT_RETURN_ERROR;
+    1129             :     }
+    1130             : 
+    1131             :     /* prepare pointer to message request */
+    1132           1 :     resp = (DltServiceGetLogInfoResponse *)calloc(1, sizeof(DltServiceGetLogInfoResponse));
+    1133             : 
+    1134           1 :     if (resp == NULL) {
+    1135           0 :         dlt_log(LOG_ERR,
+    1136             :                 "Get Log Info Response could not be allocated\n");
+    1137           0 :         return DLT_RETURN_ERROR;
+    1138             :     }
+    1139             : 
+    1140           1 :     if (dlt_set_loginfo_parse_service_id(resp_text, &resp->service_id, &resp->status) != DLT_RETURN_OK) {
+    1141           0 :         dlt_log(LOG_ERR, "Parsing GET_LOG_INFO failed\n");
+    1142           0 :         dlt_client_cleanup_get_log_info(resp);
+    1143           0 :         return DLT_RETURN_ERROR;
+    1144             :     }
+    1145             : 
+    1146           1 :     if (dlt_client_parse_get_log_info_resp_text(resp, resp_text) != DLT_RETURN_OK) {
+    1147           0 :         dlt_log(LOG_ERR, "Parsing GET_LOG_INFO failed\n");
+    1148           0 :         dlt_client_cleanup_get_log_info(resp);
+    1149           0 :         return DLT_RETURN_ERROR;
+    1150             :     }
+    1151             : 
+    1152           2 :     for (i = 0; i < resp->log_info_type.count_app_ids; i++) {
+    1153           1 :         app = resp->log_info_type.app_ids[i];
+    1154             : 
+    1155             :         /* add application */
+    1156           1 :         if (dlt_daemon_application_add(daemon,
+    1157             :                                        app.app_id,
+    1158             :                                        0,
+    1159             :                                        app.app_description,
+    1160             :                                        -1,
+    1161             :                                        ecu,
+    1162             :                                        verbose) == 0) {
+    1163           0 :             dlt_vlog(LOG_WARNING,
+    1164             :                      "%s: dlt_daemon_application_add failed\n",
+    1165             :                      __func__);
+    1166           0 :             dlt_client_cleanup_get_log_info(resp);
+    1167           0 :             return DLT_RETURN_ERROR;
+    1168             :         }
+    1169             : 
+    1170           2 :         for (j = 0; j < app.count_context_ids; j++) {
+    1171           1 :             con = app.context_id_info[j];
+    1172             : 
+    1173             :             /* add context */
+    1174           1 :             if (dlt_daemon_context_add(daemon,
+    1175             :                                        app.app_id,
+    1176             :                                        con.context_id,
+    1177           1 :                                        con.log_level,
+    1178           1 :                                        con.trace_status,
+    1179             :                                        0,
+    1180             :                                        -1,
+    1181             :                                        con.context_description,
+    1182             :                                        ecu,
+    1183             :                                        verbose) == 0) {
+    1184           0 :                 dlt_vlog(LOG_WARNING,
+    1185             :                          "%s: dlt_daemon_context_add failed for %4s\n",
+    1186             :                          __func__,
+    1187             :                          app.app_id);
+    1188           0 :                 dlt_client_cleanup_get_log_info(resp);
+    1189           0 :                 return DLT_RETURN_ERROR;
+    1190             :             }
+    1191             :         }
+    1192             :     }
+    1193             : 
+    1194             :     /* free response */
+    1195           1 :     dlt_client_cleanup_get_log_info(resp);
+    1196             : 
+    1197           1 :     return DLT_RETURN_OK;
+    1198             : }
+    1199             : 
+    1200             : /**
+    1201             :  * Parse GET_DEFAULT_LOG_LEVEL
+    1202             :  *
+    1203             :  * @param daemon          DltDaemon
+    1204             :  * @param daemon_local    DltDaemonLocal
+    1205             :  * @param ecu             Ecu ID
+    1206             :  * @param msg             DltMessage
+    1207             :  * @param verbose verbose flag
+    1208             :  * @return 0 on success, -1 otherwise
+    1209             :  */
+    1210           0 : DLT_STATIC int dlt_gateway_parse_get_default_log_level(DltDaemon *daemon,
+    1211             :                                                        DltDaemonLocal *daemon_local,
+    1212             :                                                        char *ecu,
+    1213             :                                                        DltMessage *msg,
+    1214             :                                                        int verbose)
+    1215             : {
+    1216             :     DltServiceGetDefaultLogLevelResponse *resp = NULL;
+    1217             :     DltGatewayConnection *con = NULL;
+    1218             : 
+    1219           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1220             : 
+    1221           0 :     if ((daemon == NULL) || (daemon_local == NULL)) {
+    1222           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+    1223           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    1224             :     }
+    1225             : 
+    1226           0 :     if (dlt_check_rcv_data_size(msg->datasize,
+    1227             :                                 sizeof(DltServiceGetDefaultLogLevelResponse)) < 0) {
+    1228           0 :         dlt_log(LOG_ERR, "Received data incomplete.\n");
+    1229           0 :         return DLT_RETURN_ERROR;
+    1230             :     }
+    1231             : 
+    1232             :     /* prepare pointer to message request */
+    1233           0 :     resp = (DltServiceGetDefaultLogLevelResponse *)(msg->databuffer);
+    1234             : 
+    1235           0 :     con = dlt_gateway_get_connection(&daemon_local->pGateway,
+    1236             :                                      ecu,
+    1237             :                                      verbose);
+    1238             : 
+    1239           0 :     if (con == NULL) {
+    1240           0 :         dlt_vlog(LOG_ERR, "No information about passive ECU: %s\n",
+    1241             :                  ecu);
+    1242             : 
+    1243           0 :         return DLT_RETURN_ERROR;
+    1244             :     }
+    1245             : 
+    1246           0 :     con->default_log_level = resp->log_level;
+    1247             : 
+    1248           0 :     return DLT_RETURN_OK;
+    1249             : }
+    1250             : 
+    1251             : /**
+    1252             :  * Service offline logstorage
+    1253             :  *
+    1254             :  * @param daemon       DltDaemon
+    1255             :  * @param daemon_local DltDaemonLocal
+    1256             :  * @param verbose      int
+    1257             :  * @return 0 on success, -1 otherwise
+    1258             :  */
+    1259           1 : DLT_STATIC int dlt_gateway_control_service_logstorage(DltDaemon *daemon,
+    1260             :                                                       DltDaemonLocal *daemon_local,
+    1261             :                                                       int verbose)
+    1262             : {
+    1263             :     unsigned int connection_type = 0;
+    1264             :     int i = 0;
+    1265             : 
+    1266           1 :     if (daemon_local->flags.offlineLogstorageMaxDevices <= 0) {
+    1267           1 :         dlt_log(LOG_INFO,
+    1268             :                 "Logstorage functionality not enabled or MAX device set is 0\n");
+    1269           1 :         return DLT_RETURN_ERROR;
+    1270             :     }
+    1271             : 
+    1272           0 :     for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++) {
+    1273           0 :         connection_type = daemon->storage_handle[i].connection_type;
+    1274             : 
+    1275           0 :         if (connection_type == DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED)
+    1276             :             /* Check if log level of running application needs an update */
+    1277           0 :             dlt_daemon_logstorage_update_application_loglevel(daemon,
+    1278             :                                                               daemon_local,
+    1279             :                                                               i,
+    1280             :                                                               verbose);
+    1281             :     }
+    1282             : 
+    1283             :     return DLT_RETURN_OK;
+    1284             : }
+    1285             : 
+    1286           5 : DltReturnValue dlt_gateway_process_passive_node_messages(DltDaemon *daemon,
+    1287             :                                                          DltDaemonLocal *daemon_local,
+    1288             :                                                          DltReceiver *receiver,
+    1289             :                                                          int verbose)
+    1290             : {
+    1291             :     int i = 0;
+    1292             :     DltGateway *gateway = NULL;
+    1293             :     DltGatewayConnection *con = NULL;
+    1294           5 :     DltMessage msg = { 0 };
+    1295             :     bool b_reset_receiver = false;
+    1296             : 
+    1297           5 :     if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
+    1298           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+    1299           1 :         return DLT_RETURN_WRONG_PARAMETER;
+    1300             :     }
+    1301             : 
+    1302           4 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1303             : 
+    1304             :     gateway = &daemon_local->pGateway;
+    1305             : 
+    1306             :     if (gateway == NULL) {
+    1307             :         dlt_log(LOG_ERR, "Gateway structure is NULL\n");
+    1308             :         return DLT_RETURN_ERROR;
+    1309             :     }
+    1310             : 
+    1311           4 :     for (i = 0; i < gateway->num_connections; i++)
+    1312           4 :         if ((gateway->connections[i].status == DLT_GATEWAY_CONNECTED) && (gateway->connections[i].client.sock == receiver->fd)) {
+    1313             :             con = &gateway->connections[i];
+    1314             :             break;
+    1315             :         }
+    1316             : 
+    1317           4 :     if (con == NULL) {
+    1318           0 :         dlt_log(LOG_ERR, "Cannot associate fd to passive Node connection\n");
+    1319           0 :         return DLT_RETURN_ERROR;
+    1320             :     }
+    1321             : 
+    1322             :     /* now the corresponding passive node connection is available */
+    1323           4 :     if (dlt_message_init(&msg, verbose) == -1) {
+    1324           0 :         dlt_log(LOG_ERR,
+    1325             :                 "Cannot initialize DLT message for passive node forwarding\n");
+    1326           0 :         return DLT_RETURN_ERROR;
+    1327             :     }
+    1328             : 
+    1329             :     /* nearly copy and paste of dlt_client_main_loop function */
+    1330           4 :     if (dlt_receiver_receive(receiver) <= 0) {
+    1331             :         /* No more data to be received */
+    1332           1 :         if (dlt_message_free(&msg, verbose) < 0) {
+    1333           0 :             dlt_log(LOG_ERR, "Cannot free DLT message\n");
+    1334           0 :             return DLT_RETURN_ERROR;
+    1335             :         }
+    1336             : 
+    1337           1 :         dlt_log(LOG_WARNING, "Connection to passive node lost\n");
+    1338             : 
+    1339           1 :         if (con->reconnect_cnt < DLT_GATEWAY_RECONNECT_MAX) {
+    1340           1 :             dlt_log(LOG_WARNING, "Try to reconnect.\n");
+    1341           1 :             con->reconnect_cnt += 1;
+    1342           1 :             con->timeout_cnt = 0;
+    1343             :         }
+    1344             :         else {
+    1345           0 :             con->status = DLT_GATEWAY_DISCONNECTED;
+    1346             : 
+    1347           0 :             if (dlt_event_handler_unregister_connection(&daemon_local->pEvent,
+    1348             :                                                         daemon_local,
+    1349             :                                                         receiver->fd) != 0)
+    1350           0 :                 dlt_log(LOG_ERR, "Remove passive node Connection failed\n");
+    1351             :         }
+    1352             : 
+    1353           1 :         return DLT_RETURN_OK;
+    1354             :     }
+    1355             : 
+    1356          15 :     while (dlt_message_read(&msg,
+    1357          15 :                             (unsigned char *)receiver->buf,
+    1358          15 :                             receiver->bytesRcvd,
+    1359             :                             0,
+    1360          15 :                             verbose) == DLT_MESSAGE_ERROR_OK) {
+    1361             :         DltStandardHeaderExtra *header = (DltStandardHeaderExtra *)
+    1362             :             (msg.headerbuffer +
+    1363             :              sizeof(DltStorageHeader) +
+    1364             :              sizeof(DltStandardHeader));
+    1365             : 
+    1366             :         /* only forward messages if the received ECUid is the expected one */
+    1367          12 :         if (strncmp(header->ecu, con->ecuid, DLT_ID_SIZE) == 0) {
+    1368             :             uint32_t id;
+    1369             :             uint32_t id_tmp;
+    1370          12 :             DltPassiveControlMessage *control_msg = con->p_control_msgs;
+    1371             : 
+    1372          12 :             dlt_vlog(LOG_DEBUG,
+    1373             :                      "Received ECUid (%.*s) similar to configured ECUid(%s). "
+    1374             :                      "Forwarding message (%s).\n",
+    1375             :                      DLT_ID_SIZE,
+    1376             :                      header->ecu,
+    1377             :                      con->ecuid,
+    1378             :                      msg.databuffer);
+    1379             : 
+    1380          12 :             id_tmp = *((uint32_t *)(msg.databuffer));
+    1381          12 :             id = DLT_ENDIAN_GET_32(msg.standardheader->htyp, id_tmp);
+    1382             : 
+    1383             :             /* if ID is GET_LOG_INFO, parse msg */
+    1384          12 :             if (id == DLT_SERVICE_ID_GET_LOG_INFO) {
+    1385           1 :                 while (control_msg) {
+    1386           1 :                     if (control_msg->id == id) {
+    1387           1 :                         if (dlt_gateway_parse_get_log_info(daemon,
+    1388             :                                                            header->ecu,
+    1389             :                                                            &msg,
+    1390           1 :                                                            control_msg->req,
+    1391             :                                                            verbose) == DLT_RETURN_ERROR)
+    1392           1 :                             dlt_log(LOG_WARNING, "Parsing GET_LOG_INFO message failed!\n");
+    1393             : 
+    1394             :                         /* Check for logstorage */
+    1395           1 :                         dlt_gateway_control_service_logstorage(daemon,
+    1396             :                                                                daemon_local,
+    1397             :                                                                verbose);
+    1398             : 
+    1399             :                         /* initialize the flag */
+    1400           1 :                         control_msg->req = CONTROL_MESSAGE_NOT_REQUESTED;
+    1401           1 :                         break;
+    1402             :                     }
+    1403             : 
+    1404           0 :                     control_msg = control_msg->next;
+    1405             :                 }
+    1406             :             }
+    1407          11 :             else if (id == DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL)
+    1408             :             {
+    1409           0 :                 if (dlt_gateway_parse_get_default_log_level(
+    1410             :                         daemon,
+    1411             :                         daemon_local,
+    1412             :                         header->ecu,
+    1413             :                         &msg,
+    1414             :                         verbose) == DLT_RETURN_ERROR)
+    1415           0 :                     dlt_log(LOG_WARNING,
+    1416             :                             "Parsing GET_DEFAULT_LOG_LEVEL message failed!\n");
+    1417             :             }
+    1418             : 
+    1419             :             /* prepare storage header */
+    1420          12 :             if (dlt_set_storageheader(msg.storageheader,
+    1421             :                                       msg.headerextra.ecu) == DLT_RETURN_ERROR) {
+    1422           0 :                 dlt_vlog(LOG_ERR, "%s: Can't set storage header\n", __func__);
+    1423           0 :                 return DLT_RETURN_ERROR;
+    1424             :             }
+    1425             : 
+    1426          12 :             dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL,
+    1427             :                                        daemon,
+    1428             :                                        daemon_local,
+    1429             :                                        msg.headerbuffer,
+    1430             :                                        sizeof(DltStorageHeader),
+    1431             :                                        msg.headerbuffer + sizeof(DltStorageHeader),
+    1432          12 :                                        msg.headersize - sizeof(DltStorageHeader),
+    1433          12 :                                        msg.databuffer,
+    1434             :                                        msg.datasize,
+    1435             :                                        verbose);
+    1436             :         } else { /* otherwise remove this connection and do not connect again */
+    1437           0 :             dlt_vlog(LOG_WARNING,
+    1438             :                      "Received ECUid (%.*s) differs to configured ECUid(%s). "
+    1439             :                      "Discard this message.\n",
+    1440             :                      DLT_ID_SIZE,
+    1441             :                      header->ecu,
+    1442             :                      con->ecuid);
+    1443             : 
+    1444             :             /* disconnect from passive node */
+    1445           0 :             con->status = DLT_GATEWAY_DISCONNECTED;
+    1446           0 :             con->trigger = DLT_GATEWAY_DISABLED;
+    1447             : 
+    1448           0 :             if (dlt_event_handler_unregister_connection(&daemon_local->pEvent,
+    1449             :                                                         daemon_local,
+    1450             :                                                         receiver->fd)
+    1451             :                 != 0)
+    1452           0 :                 dlt_log(LOG_ERR, "Remove passive node Connection failed\n");
+    1453             : 
+    1454           0 :             dlt_log(LOG_WARNING,
+    1455             :                     "Disconnect from passive node due to invalid ECUid\n");
+    1456             : 
+    1457             :             /* it is possible that a partial log was received through the last recv call */
+    1458             :             /* however, the rest will never be received since the socket will be closed by above method */
+    1459             :             /* as such, we need to reset the receiver to prevent permanent corruption */
+    1460             :             b_reset_receiver = true;
+    1461             :         }
+    1462             : 
+    1463          12 :         if (msg.found_serialheader) {
+    1464           0 :             if (dlt_receiver_remove(receiver,
+    1465           0 :                                     msg.headersize +
+    1466           0 :                                     msg.datasize -
+    1467           0 :                                     sizeof(DltStorageHeader) +
+    1468             :                                     sizeof(dltSerialHeader)) == -1) {
+    1469             :                 /* Return value ignored */
+    1470           0 :                 dlt_message_free(&msg, verbose);
+    1471           0 :                 return DLT_RETURN_ERROR;
+    1472             :             }
+    1473             :         }
+    1474          12 :         else if (dlt_receiver_remove(receiver,
+    1475          12 :                                      msg.headersize +
+    1476          12 :                                      msg.datasize -
+    1477             :                                      sizeof(DltStorageHeader)) == -1) {
+    1478             :             /* Return value ignored */
+    1479           0 :             dlt_message_free(&msg, verbose);
+    1480           0 :             return DLT_RETURN_ERROR;
+    1481             :         }
+    1482             :     }
+    1483             : 
+    1484           3 :     if (b_reset_receiver)
+    1485           0 :         dlt_receiver_remove(receiver, receiver->bytesRcvd);
+    1486             : 
+    1487           3 :     if (dlt_receiver_move_to_begin(receiver) == -1) {
+    1488             :         /* Return value ignored */
+    1489           0 :         dlt_message_free(&msg, verbose);
+    1490           0 :         return DLT_RETURN_ERROR;
+    1491             :     }
+    1492             : 
+    1493           3 :     if (dlt_message_free(&msg, verbose) == -1)
+    1494           0 :         return DLT_RETURN_ERROR;
+    1495             : 
+    1496             :     return DLT_RETURN_OK;
+    1497             : }
+    1498             : 
+    1499           2 : int dlt_gateway_process_gateway_timer(DltDaemon *daemon,
+    1500             :                                       DltDaemonLocal *daemon_local,
+    1501             :                                       DltReceiver *receiver,
+    1502             :                                       int verbose)
+    1503             : {
+    1504           2 :     uint64_t expir = 0;
+    1505             :     ssize_t res = 0;
+    1506             : 
+    1507           2 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1508             : 
+    1509           2 :     if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
+    1510           1 :         dlt_vlog(LOG_ERR,
+    1511             :                  "%s: invalid parameters\n",
+    1512             :                  __func__);
+    1513           1 :         return DLT_RETURN_WRONG_PARAMETER;
+    1514             :     }
+    1515             : 
+    1516           1 :     res = read(receiver->fd, &expir, sizeof(expir));
+    1517             : 
+    1518           1 :     if (res < 0)
+    1519           1 :         dlt_vlog(LOG_WARNING,
+    1520             :                  "%s: Fail to read timer (%s)\n",
+    1521             :                  __func__,
+    1522           1 :                  strerror(errno));
+    1523             :         /* Activity received on timer_wd, but unable to read the fd:
+    1524             :          * let's go on sending notification */
+    1525             : 
+    1526             :     /* try to connect to passive nodes */
+    1527           1 :     dlt_gateway_establish_connections(&daemon_local->pGateway,
+    1528             :                                       daemon_local,
+    1529             :                                       verbose);
+    1530             : 
+    1531           1 :     dlt_log(LOG_DEBUG, "Gateway Timer\n");
+    1532             : 
+    1533           1 :     return DLT_RETURN_OK;
+    1534             : }
+    1535             : 
+    1536           0 : int dlt_gateway_forward_control_message(DltGateway *gateway,
+    1537             :                                         DltDaemonLocal *daemon_local,
+    1538             :                                         DltMessage *msg,
+    1539             :                                         char *ecu,
+    1540             :                                         int verbose)
+    1541             : {
+    1542             :     int i = 0;
+    1543             :     int ret = 0;
+    1544             :     DltGatewayConnection *con = NULL;
+    1545             :     uint32_t id_tmp;
+    1546             :     uint32_t id;
+    1547             : 
+    1548           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1549             : 
+    1550           0 :     if ((gateway == NULL) || (daemon_local == NULL) || (msg == NULL) || (ecu == NULL)) {
+    1551           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+    1552           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    1553             :     }
+    1554             : 
+    1555           0 :     for (i = 0; i < gateway->num_connections; i++)
+    1556           0 :         if (strncmp(gateway->connections[i].ecuid,
+    1557             :                     ecu,
+    1558             :                     DLT_ID_SIZE) == 0) {
+    1559             :             con = &gateway->connections[i];
+    1560             :             break;
+    1561             :         }
+    1562             : 
+    1563             : 
+    1564             : 
+    1565           0 :     if (con == NULL) {
+    1566           0 :         dlt_log(LOG_WARNING, "Unknown passive node identifier\n");
+    1567           0 :         return DLT_RETURN_ERROR;
+    1568             :     }
+    1569             : 
+    1570           0 :     if (con->status != DLT_GATEWAY_CONNECTED) {
+    1571           0 :         dlt_log(LOG_INFO, "Passive node is not connected\n");
+    1572           0 :         return DLT_RETURN_ERROR;
+    1573             :     }
+    1574             : 
+    1575           0 :     if (con->send_serial) { /* send serial header */
+    1576           0 :         ret = send(con->client.sock,
+    1577             :                    (void *)dltSerialHeader,
+    1578             :                    sizeof(dltSerialHeader),
+    1579             :                    0);
+    1580             : 
+    1581           0 :         if (ret == -1) {
+    1582           0 :             dlt_log(LOG_ERR, "Sending message to passive DLT Daemon failed\n");
+    1583           0 :             return DLT_RETURN_ERROR;
+    1584             :         }
+    1585             :     }
+    1586             : 
+    1587           0 :     ret = send(con->client.sock,
+    1588             :                msg->headerbuffer + sizeof(DltStorageHeader),
+    1589           0 :                msg->headersize - sizeof(DltStorageHeader),
+    1590             :                0);
+    1591             : 
+    1592           0 :     if (ret == -1) {
+    1593           0 :         dlt_log(LOG_ERR, "Sending message to passive DLT Daemon failed\n");
+    1594           0 :         return DLT_RETURN_ERROR;
+    1595             :     }
+    1596             :     else {
+    1597           0 :         ret = send(con->client.sock, msg->databuffer, msg->datasize, 0);
+    1598             : 
+    1599           0 :         if (ret == -1) {
+    1600           0 :             dlt_log(LOG_ERR, "Sending message to passive DLT Daemon failed\n");
+    1601           0 :             return DLT_RETURN_ERROR;
+    1602             :         }
+    1603             :     }
+    1604             : 
+    1605           0 :     id_tmp = *((uint32_t *)(msg->databuffer));
+    1606           0 :     id = DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp);
+    1607             : 
+    1608           0 :     dlt_vlog(LOG_INFO,
+    1609             :              "Control message forwarded : %s\n",
+    1610             :              dlt_get_service_name(id));
+    1611           0 :     return DLT_RETURN_OK;
+    1612             : }
+    1613             : 
+    1614           3 : int dlt_gateway_process_on_demand_request(DltGateway *gateway,
+    1615             :                                           DltDaemonLocal *daemon_local,
+    1616             :                                           char node_id[DLT_ID_SIZE],
+    1617             :                                           int connection_status,
+    1618             :                                           int verbose)
+    1619             : {
+    1620             :     int i = 0;
+    1621             :     DltGatewayConnection *con = NULL;
+    1622             : 
+    1623           3 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1624             : 
+    1625           3 :     if ((gateway == NULL) || (daemon_local == NULL) || (node_id == NULL)) {
+    1626           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+    1627           1 :         return DLT_RETURN_WRONG_PARAMETER;
+    1628             :     }
+    1629             : 
+    1630             :     /* find connection by ECU id */
+    1631           2 :     for (i = 0; i < gateway->num_connections; i++) {
+    1632           2 :         if (strncmp(node_id, gateway->connections[i].ecuid, DLT_ID_SIZE) == 0) {
+    1633             :             con = &gateway->connections[i];
+    1634             :             break;
+    1635             :         }
+    1636             :     }
+    1637             : 
+    1638           2 :     if (con == NULL) {
+    1639           0 :         dlt_log(LOG_WARNING, "Specified ECUid not found\n");
+    1640           0 :         return DLT_RETURN_ERROR;
+    1641             :     }
+    1642             : 
+    1643           2 :     if (connection_status == 1) { /* try to connect */
+    1644             : 
+    1645           2 :         if (con->status != DLT_GATEWAY_CONNECTED) {
+    1646           1 :             if (dlt_client_connect(&con->client, verbose) == 0) {
+    1647             :                 /* setup dlt connection and add to poll event loop here */
+    1648           0 :                 if (dlt_gateway_add_to_event_loop(daemon_local, con, verbose) != DLT_RETURN_OK) {
+    1649           0 :                     dlt_log(LOG_ERR, "Gateway connection creation failed\n");
+    1650           0 :                     return DLT_RETURN_ERROR;
+    1651             :                 }
+    1652             :             }
+    1653             :             else {
+    1654           1 :                 dlt_log(LOG_ERR, "Could not connect to passive node\n");
+    1655           1 :                 return DLT_RETURN_ERROR;
+    1656             :             }
+    1657             :         }
+    1658             :         else {
+    1659           1 :             dlt_log(LOG_INFO, "Passive node already connected\n");
+    1660             :         }
+    1661             :     }
+    1662           0 :     else if (connection_status == 0) /* disconnect*/
+    1663             :     {
+    1664             : 
+    1665           0 :         con->status = DLT_GATEWAY_DISCONNECTED;
+    1666           0 :         con->trigger = DLT_GATEWAY_ON_DEMAND;
+    1667             : 
+    1668           0 :         if (dlt_event_handler_unregister_connection(&daemon_local->pEvent,
+    1669             :                                                     daemon_local,
+    1670             :                                                     con->client.sock) != 0)
+    1671           0 :             dlt_log(LOG_ERR,
+    1672             :                     "Remove passive node event handler connection failed\n");
+    1673             :     }
+    1674             :     else {
+    1675           0 :         dlt_log(LOG_ERR, "Unknown command (connection_status)\n");
+    1676           0 :         return DLT_RETURN_ERROR;
+    1677             :     }
+    1678             : 
+    1679             :     return DLT_RETURN_OK;
+    1680             : }
+    1681             : 
+    1682          12 : int dlt_gateway_send_control_message(DltGatewayConnection *con,
+    1683             :                                      DltPassiveControlMessage *control_msg,
+    1684             :                                      void *data,
+    1685             :                                      int verbose)
+    1686             : {
+    1687             :     int ret = DLT_RETURN_OK;
+    1688             : 
+    1689          12 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1690             : 
+    1691          12 :     if (con == NULL) {
+    1692           1 :         dlt_vlog(LOG_WARNING,
+    1693             :                  "%s: Invalid parameter given\n",
+    1694             :                  __func__);
+    1695           1 :         return DLT_RETURN_WRONG_PARAMETER;
+    1696             :     }
+    1697             : 
+    1698             :     /* no (more) control message to be send */
+    1699          11 :     if (control_msg->id == 0)
+    1700             :         return DLT_RETURN_ERROR;
+    1701             : 
+    1702             :     /* check sendtime counter and message interval */
+    1703             :     /* sendtime counter is 0 on startup, otherwise positive value */
+    1704          11 :     if ((control_msg->type != CONTROL_MESSAGE_ON_DEMAND) && (con->sendtime_cnt > 0)) {
+    1705           0 :         if (control_msg->interval <= 0)
+    1706             :             return DLT_RETURN_ERROR;
+    1707             : 
+    1708           0 :         if ((control_msg->type == CONTROL_MESSAGE_PERIODIC) ||
+    1709             :             (control_msg->type == CONTROL_MESSAGE_BOTH)) {
+    1710           0 :             if ((con->sendtime_cnt - 1) % control_msg->interval != 0)
+    1711             :                 return DLT_RETURN_ERROR;
+    1712             :         }
+    1713             :     }
+    1714             : 
+    1715          11 :     if (con->send_serial) { /* send serial header */
+    1716           0 :         ret = send(con->client.sock,
+    1717             :                    (void *)dltSerialHeader,
+    1718             :                    sizeof(dltSerialHeader),
+    1719             :                    0);
+    1720             : 
+    1721           0 :         if (ret == -1) {
+    1722           0 :             dlt_log(LOG_ERR, "Sending message to passive DLT Daemon failed\n");
+    1723           0 :             return DLT_RETURN_ERROR;
+    1724             :         }
+    1725             :     }
+    1726             : 
+    1727          11 :     switch (control_msg->id) {
+    1728           4 :     case DLT_SERVICE_ID_GET_LOG_INFO:
+    1729           4 :         return dlt_client_get_log_info(&con->client);
+    1730             :         break;
+    1731           1 :     case DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL:
+    1732           1 :         return dlt_client_get_default_log_level(&con->client);
+    1733             :         break;
+    1734           4 :     case DLT_SERVICE_ID_GET_SOFTWARE_VERSION:
+    1735           4 :         return dlt_client_get_software_version(&con->client);
+    1736             :         break;
+    1737           2 :     case DLT_SERVICE_ID_SET_LOG_LEVEL:
+    1738             : 
+    1739           2 :         if (data == NULL) {
+    1740           1 :             dlt_vlog(LOG_WARNING,
+    1741             :                      "Insufficient data for %s received. Send control request failed.\n",
+    1742             :                      dlt_get_service_name(control_msg->id));
+    1743           1 :             return DLT_RETURN_ERROR;
+    1744             :         }
+    1745             : 
+    1746             :         DltServiceSetLogLevel *req = (DltServiceSetLogLevel *)data;
+    1747           1 :         return dlt_client_send_log_level(&con->client,
+    1748           1 :                                          req->apid,
+    1749           1 :                                          req->ctid,
+    1750           1 :                                          req->log_level);
+    1751             :         break;
+    1752           0 :     default:
+    1753           0 :         dlt_vlog(LOG_WARNING,
+    1754             :                  "Cannot forward request: %s.\n",
+    1755             :                  dlt_get_service_name(control_msg->id));
+    1756             :     }
+    1757             : 
+    1758           0 :     return DLT_RETURN_OK;
+    1759             : }
+    1760             : 
+    1761           0 : DltGatewayConnection *dlt_gateway_get_connection(DltGateway *gateway,
+    1762             :                                                  char *ecu,
+    1763             :                                                  int verbose)
+    1764             : {
+    1765             :     DltGatewayConnection *con = NULL;
+    1766             :     int i = 0;
+    1767             : 
+    1768           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1769             : 
+    1770           0 :     if ((gateway == NULL) || (ecu == NULL)) {
+    1771           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+    1772           0 :         return con;
+    1773             :     }
+    1774             : 
+    1775           0 :     for (i = 0; i < gateway->num_connections; i++) {
+    1776           0 :         con = &gateway->connections[i];
+    1777             : 
+    1778           0 :         if (strncmp(con->ecuid, ecu, DLT_ID_SIZE) == 0)
+    1779           0 :             return con;
+    1780             :     }
+    1781             : 
+    1782           0 :     dlt_vlog(LOG_ERR, "%s: No connection found\n", ecu);
+    1783             : 
+    1784           0 :     return con;
+    1785             : }
+
+
+
+ + + + +
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..c9d9f0942 --- /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:38763760.8 %
Date:2023-11-29 14:15:44Functions:232882.1 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_gateway.c +
60.8%60.8%
+
60.8 %387 / 63782.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..bcc2aa1eb --- /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:38763760.8 %
Date:2023-11-29 14:15:44Functions:232882.1 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_gateway.c +
60.8%60.8%
+
60.8 %387 / 63782.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..5e1056577 --- /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:38763760.8 %
Date:2023-11-29 14:15:44Functions:232882.1 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_gateway.c +
60.8%60.8%
+
60.8 %387 / 63782.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..149819e5b --- /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:60051104254.4 %
Date:2023-11-29 14:15:44Functions:48566273.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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 +
47.9%47.9%
+
47.9 %1250 / 260864.6 %128 / 198
daemon +
48.2%48.2%
+
48.2 %1645 / 341668.2 %107 / 157
console +
42.4%42.4%
+
42.4 %267 / 62975.9 %22 / 29
gateway +
60.8%60.8%
+
60.8 %387 / 63782.1 %23 / 28
offlinelogstorage +
75.9%75.9%
+
75.9 %941 / 124088.9 %64 / 72
shared +
66.0%66.0%
+
66.0 %1440 / 218289.0 %130 / 146
+
+
+ + + + +
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..edfe4a1ba --- /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:60051104254.4 %
Date:2023-11-29 14:15:44Functions:48566273.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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.4%42.4%
+
42.4 %267 / 62975.9 %22 / 29
lib +
47.9%47.9%
+
47.9 %1250 / 260864.6 %128 / 198
daemon +
48.2%48.2%
+
48.2 %1645 / 341668.2 %107 / 157
gateway +
60.8%60.8%
+
60.8 %387 / 63782.1 %23 / 28
shared +
66.0%66.0%
+
66.0 %1440 / 218289.0 %130 / 146
offlinelogstorage +
75.9%75.9%
+
75.9 %941 / 124088.9 %64 / 72
+
+
+ + + + +
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..7c2664e9a --- /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:60051104254.4 %
Date:2023-11-29 14:15:44Functions:48566273.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_filetransfer.c +
0.0%
+
0.0 %0 / 1900.0 %0 / 17
dlt_env_ll.c +
6.1%6.1%
+
6.1 %8 / 13216.7 %2 / 12
dlt_client.c +
44.3%44.3%
+
44.3 %234 / 52848.4 %15 / 31
dlt_user.c +
57.3%57.3%
+
57.3 %1008 / 175880.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..26bf38cfa --- /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:1250260847.9 %
Date:2023-11-29 14:15:44Functions:12819864.6 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_filetransfer.c +
0.0%
+
0.0 %0 / 1900.0 %0 / 17
dlt_env_ll.c +
6.1%6.1%
+
6.1 %8 / 13216.7 %2 / 12
dlt_client.c +
44.3%44.3%
+
44.3 %234 / 52848.4 %15 / 31
dlt_user.c +
57.3%57.3%
+
57.3 %1008 / 175880.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..a4e1bcdbb --- /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:1250260847.9 %
Date:2023-11-29 14:15:44Functions:12819864.6 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_client.c +
44.3%44.3%
+
44.3 %234 / 52848.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 / 1900.0 %0 / 17
dlt_user.c +
57.3%57.3%
+
57.3 %1008 / 175880.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..b543d7d4e --- /dev/null +++ b/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage.c.func-sort-c.html @@ -0,0 +1,280 @@ + + + + + + + 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:53576370.1 %
Date:2023-11-29 14:15:44Functions:445284.6 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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_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_read_bool9
dlt_logstorage_load_config10
dlt_logstorage_store_filters11
dlt_logstorage_set_number12
dlt_logstorage_count_ids13
dlt_logstorage_filter_set_strategy13
dlt_logstorage_list_destroy13
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_list_add58
dlt_logstorage_list_add_config59
dlt_logstorage_filter_config_free75
dlt_logstorage_get_keys_list76
dlt_logstorage_read_list_of_names76
dlt_logstorage_read_number81
dlt_logstorage_get_filter_section_value468
dlt_logstorage_get_filter_value468
dlt_logstorage_write5842
dlt_logstorage_filter5843
dlt_logstorage_get_config5878
dlt_logstorage_list_find40273
+
+
+ + + +
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..9e0af6e20 --- /dev/null +++ b/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage.c.func.html @@ -0,0 +1,280 @@ + + + + + + + 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:53576370.1 %
Date:2023-11-29 14:15:44Functions:445284.6 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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_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_ids13
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_filter5843
dlt_logstorage_filter_config_free75
dlt_logstorage_filter_set_strategy13
dlt_logstorage_free7
dlt_logstorage_get_config5878
dlt_logstorage_get_filter_section_value468
dlt_logstorage_get_filter_value468
dlt_logstorage_get_keys_list76
dlt_logstorage_get_loglevel_by_key37
dlt_logstorage_list_add58
dlt_logstorage_list_add_config59
dlt_logstorage_list_destroy13
dlt_logstorage_list_find40273
dlt_logstorage_load_config10
dlt_logstorage_prepare_table38
dlt_logstorage_read_bool9
dlt_logstorage_read_list_of_names76
dlt_logstorage_read_number81
dlt_logstorage_set_loglevel5
dlt_logstorage_set_number12
dlt_logstorage_set_sync_strategy0
dlt_logstorage_setup_table36
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..a9700c848 --- /dev/null +++ b/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage.c.gcov.html @@ -0,0 +1,2716 @@ + + + + + + + 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:53576370.1 %
Date:2023-11-29 14:15:44Functions:445284.6 %
+
+ + + + + + + + +

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

Function Name Sort by function nameHit count Sort by hit count
dlt_logstorage_close_file2
dlt_logstorage_rearrange_file_name3
dlt_logstorage_write_to_log5
dlt_logstorage_find_last_dlt_header86
dlt_logstorage_log_file_name147
dlt_logstorage_sync_to_file187
dlt_logstorage_open_log_output_file198
dlt_logstorage_check_write_ret200
dlt_logstorage_find_dlt_header270
dlt_logstorage_concat_logfile_name297
dlt_logstorage_sort_file_name321
dlt_logstorage_open_log_file324
dlt_logstorage_storage_dir_info325
dlt_logstorage_get_idx_of_log_file457
dlt_logstorage_write_on_msg693
dlt_logstorage_prepare_on_msg708
dlt_logstorage_sync_on_msg714
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..657f2544a --- /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:40647785.1 %
Date:2023-11-29 14:15:44Functions:2020100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_offline_logstorage.c +
70.1%70.1%
+
70.1 %535 / 76384.6 %44 / 52
dlt_offline_logstorage_behavior.c +
85.1%85.1%
+
85.1 %406 / 477100.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..96ad4f495 --- /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:941124075.9 %
Date:2023-11-29 14:15:44Functions:647288.9 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_offline_logstorage.c +
70.1%70.1%
+
70.1 %535 / 76384.6 %44 / 52
dlt_offline_logstorage_behavior.c +
85.1%85.1%
+
85.1 %406 / 477100.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..6fd0a149a --- /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:941124075.9 %
Date:2023-11-29 14:15:44Functions:647288.9 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_offline_logstorage.c +
70.1%70.1%
+
70.1 %535 / 76384.6 %44 / 52
dlt_offline_logstorage_behavior.c +
85.1%85.1%
+
85.1 %406 / 477100.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..bbd548004 --- /dev/null +++ b/dlt_lcov_report/shared/dlt_common.c.func-sort-c.html @@ -0,0 +1,512 @@ + + + + + + + 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:1117175263.8 %
Date:2023-11-29 14:15:44Functions:9611087.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_log_free_single_logfile2
dlt_set_loginfo_parse_service_id2
dlt_buffer_get_total_size3
dlt_file_quick_parsing3
dlt_log_free_multiple_logfiles3
dlt_log_init_multiple_logfiles4
dlt_log_init_single_logfile4
get_filename_ext5
dlt_extract_base_name_without_ext6
dlt_file_set_filter6
dlt_filter_load6
dlt_buffer_increase_size7
dlt_buffer_remove7
dlt_check_rcv_data_size7
dlt_filter_init7
dlt_buffer_minimize_size8
dlt_buffer_pull8
dlt_buffer_reset9
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_log_init12
dlt_log_multiple_files_write12
dlt_buffer_copy13
dlt_getloginfo_conv_ascii_to_uint16_t14
dlt_log_free15
dlt_log_set_filename17
dlt_log_set_level19
dlt_getloginfo_conv_ascii_to_id20
dlt_get_version22
dlt_log_init_multiple_logfiles_support26
dlt_is_log_in_multiple_files_active37
dlt_buffer_read_block53
dlt_buffer_get64
dlt_file_open67
dlt_file_free69
dlt_file_init71
dlt_message_free121
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_string1549
dlt_print_char_string1661
dlt_receiver_move_to_begin1716
dlt_receiver_receive1722
dlt_buffer_get_used_size2503
dlt_message_header2615
dlt_print_hex_string2724
dlt_print_hex_string_delim2733
dlt_user_printf2852
dlt_file_read2965
dlt_message_payload3326
dlt_message_argument_print3551
dlt_file_message3965
dlt_file_read_data4070
dlt_file_read_header_extended4700
dlt_vnlog5244
dlt_check_envvar5250
dlt_log_set_fifo_basedir5259
dlt_receiver_free5291
dlt_receiver_init5292
dlt_message_header_flags5317
dlt_buffer_free_dynamic5355
dlt_buffer_init_dynamic5381
dlt_receiver_remove6093
dlt_message_init6122
dlt_print_id6205
dlt_strnlen_s6207
dlt_message_set_extraparameters6242
dlt_uptime6296
dlt_message_read6675
dlt_check_storageheader6979
dlt_file_read_header7035
dlt_message_get_extraparameters7415
dlt_buffer_push7516
dlt_buffer_get_message_count8528
dlt_set_storageheader12099
dlt_buffer_push315285
dlt_buffer_write_block41034
dlt_set_id54223
dlt_log1950518
dlt_vlog1964874
+
+
+ + + +
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..757f42b85 --- /dev/null +++ b/dlt_lcov_report/shared/dlt_common.c.func.html @@ -0,0 +1,512 @@ + + + + + + + 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:1117175263.8 %
Date:2023-11-29 14:15:44Functions:9611087.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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

Function Name Sort by function nameHit count Sort by hit count
dlt_config_file_check_section_name_exists4
dlt_config_file_find_section468
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_value464
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..2734bf34a --- /dev/null +++ b/dlt_lcov_report/shared/dlt_config_file_parser.c.gcov.html @@ -0,0 +1,644 @@ + + + + + + + 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:2023-11-29 14:15:44Functions: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-daemon_cfg.h"
+      36             : 
+      37             : /* internal defines */
+      38             : #define DLT_CONFIG_FILE_NEW_SECTION 0x0a
+      39             : #define DLT_CONFIG_FILE_NEW_DATA    0x0b
+      40             : 
+      41             : 
+      42             : /* internal helper functions */
+      43             : 
+      44             : /**
+      45             :  * dlt_config_file_trim_line
+      46             :  *
+      47             :  * Trim all whitespace from a string
+      48             :  *
+      49             :  * @param line  String to remove whitespace from
+      50             :  */
+      51         379 : static void dlt_config_file_trim_line(char *line)
+      52             : {
+      53         379 :     if (line == NULL)
+      54             :         return;
+      55             : 
+      56             :     char *i = line;
+      57             :     char *j = line;
+      58             : 
+      59        6707 :     while (*j != '\0') {
+      60        6328 :         *i = *j++;
+      61             : 
+      62        6328 :         if (!isspace(*i))
+      63        5949 :             i++;
+      64             :     }
+      65             : 
+      66         379 :     *i = '\0';
+      67             : }
+      68             : 
+      69             : /**
+      70             :  * dlt_config_file_ignore_line
+      71             :  *
+      72             :  * Check if a line has to be ignored, because it contains a comment or is empty
+      73             :  *
+      74             :  * @param line  Line of configuration file
+      75             :  * @return 0 if ignore, -1 do not ignore
+      76             :  */
+      77             : static int dlt_config_file_ignore_line(char *line)
+      78             : {
+      79         406 :     if ((line[0] == '#') || (line[0] == ';') || (line[0] == '\n') ||
+      80             :         (line[0] == '\0'))
+      81             :         return 0; /* ignore */
+      82             :     else
+      83             :         return -1; /* do not ignore */
+      84             : }
+      85             : 
+      86             : /**
+      87             :  * dlt_config_file_is_section_name
+      88             :  *
+      89             :  * Check if section name already used
+      90             :  *
+      91             :  * @param file  DltConfigFile
+      92             :  * @param name  Name of section
+      93             :  * @return 0, section name not used, -1 section name already used
+      94             :  */
+      95          40 : static int dlt_config_file_is_section_name(DltConfigFile *file, char *name)
+      96             : {
+      97             :     int i = 0;
+      98             : 
+      99          40 :     if ((file == NULL) || (name == NULL))
+     100             :         return -1;
+     101             : 
+     102         179 :     for (i = 0; i < file->num_sections; i++) {
+     103         139 :         DltConfigFileSection *s = &file->sections[i];
+     104             : 
+     105         139 :         if (strncmp(s->name, name, DLT_CONFIG_FILE_ENTRY_MAX_LEN) == 0)
+     106             :             return -1;
+     107             :     }
+     108             : 
+     109             :     return 0; /* section name not used */
+     110             : }
+     111             : 
+     112             : /**
+     113             :  * dlt_config_file_set_section
+     114             :  *
+     115             :  * Store section in internal data structure
+     116             :  *
+     117             :  * @param file  DltConfigFile
+     118             :  * @param name  Name of section
+     119             :  * @return 0 on success, else -1
+     120             :  */
+     121          40 : static int dlt_config_file_set_section(DltConfigFile *file, char *name)
+     122             : {
+     123          40 :     int section = file->num_sections;
+     124             : 
+     125             :     /* check if adding another section would exceed max number of sections */
+     126          40 :     if (section >= DLT_CONFIG_FILE_SECTIONS_MAX) {
+     127           0 :         dlt_log(LOG_WARNING, "Cannot store more sections\n");
+     128           0 :         return -1; /* reached max number of sections */
+     129             :     }
+     130             : 
+     131             :     /* do not store section with same name again */
+     132          40 :     if (dlt_config_file_is_section_name(file, name) != 0) {
+     133           0 :         dlt_log(LOG_WARNING, "Cannot store section name again\n");
+     134           0 :         return -1;
+     135             :     }
+     136             : 
+     137          40 :     DltConfigFileSection *s = &file->sections[section];
+     138             : 
+     139             :     /* alloc data for entries */
+     140          40 :     s->name = calloc(sizeof(char), DLT_CONFIG_FILE_ENTRY_MAX_LEN + 1);
+     141             : 
+     142          40 :     if (s->name == NULL) {
+     143           0 :         dlt_log(LOG_ERR, "Cannot allocate memory for internal data structure\n");
+     144           0 :         return -1;
+     145             :     }
+     146             : 
+     147          40 :     s->keys = calloc(sizeof(char), DLT_CONFIG_FILE_ENTRY_MAX_LEN * DLT_CONFIG_FILE_KEYS_MAX + 1);
+     148             : 
+     149          40 :     if (s->keys == NULL) {
+     150           0 :         free(s->name);
+     151           0 :         s->name = NULL;
+     152           0 :         dlt_log(LOG_ERR, "Cannot allocate memory for internal data structure\n");
+     153           0 :         return -1;
+     154             :     }
+     155             : 
+     156             :     strncpy(file->sections[section].name, name, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
+     157          40 :     file->num_sections += 1;
+     158          40 :     return 0;
+     159             : }
+     160             : 
+     161             : /**
+     162             :  * dlt_config_file_set_section_data
+     163             :  *
+     164             :  * Store data pair of a section
+     165             :  *
+     166             :  * @param file DltConfigFile
+     167             :  * @param str1 string used for key
+     168             :  * @param str2 string used for value
+     169             :  * @return 0 on success, else -1
+     170             :  */
+     171         339 : static int dlt_config_file_set_section_data(DltConfigFile *file, char *str1, char *str2)
+     172             : {
+     173             :     DltConfigKeyData **tmp = NULL;
+     174             : 
+     175         339 :     if ((file == NULL) || (str1 == NULL) || (str2 == NULL))
+     176             :         return -1;
+     177             : 
+     178         339 :     DltConfigFileSection *s = &file->sections[file->num_sections - 1];
+     179         339 :     int key_number = s->num_entries;
+     180             : 
+     181         339 :     if (key_number + 1 >= DLT_CONFIG_FILE_KEYS_MAX) {
+     182           0 :         dlt_log(LOG_WARNING, "Cannot store more keys in section\n");
+     183           0 :         return -1; /* reached max number of keys per section */
+     184             :     }
+     185             : 
+     186             :     /* copy data into structure */
+     187         339 :     strncpy(&s->keys[key_number * DLT_CONFIG_FILE_ENTRY_MAX_LEN], str1, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
+     188             : 
+     189         339 :     if (s->list == NULL) {
+     190             :         /* creating a list if it doesnt exists */
+     191          40 :         s->list = malloc(sizeof(DltConfigKeyData));
+     192             : 
+     193          40 :         if (s->list == NULL) {
+     194           0 :             dlt_log(LOG_WARNING, "Could not allocate initial memory to list \n");
+     195           0 :             return -1;
+     196             :         }
+     197             : 
+     198          40 :         tmp = &s->list;
+     199             :     }
+     200             :     else {
+     201         299 :         tmp = &s->list;
+     202             : 
+     203        1589 :         while (*(tmp) != NULL)
+     204        1290 :             tmp = &(*tmp)->next;
+     205             : 
+     206             :         /* Adding new entry to the list */
+     207         299 :         *tmp = malloc(sizeof(DltConfigKeyData));
+     208             : 
+     209         299 :         if (*tmp == NULL) {
+     210           0 :             dlt_log(LOG_WARNING, "Could not allocate memory to list \n");
+     211           0 :             return -1;
+     212             :         }
+     213             :     }
+     214             : 
+     215         339 :     (*tmp)->key = strdup(str1);
+     216         339 :     (*tmp)->data = strdup(str2);
+     217         339 :     (*tmp)->next = NULL;
+     218             : 
+     219         339 :     s->num_entries += 1;
+     220             : 
+     221         339 :     return 0;
+     222             : }
+     223             : 
+     224             : /**
+     225             :  * dlt_config_file_has_section
+     226             :  *
+     227             :  * Check if a certain line in config file is a section header
+     228             :  *
+     229             :  * @param line  Line in configuration file
+     230             :  * @return 0 if section header, else -1
+     231             :  */
+     232             : static int dlt_config_file_line_has_section(char *line)
+     233             : {
+     234             :     (void)line; /* avoid compiler warnings */
+     235             : 
+     236         379 :     if (line[0] == '[') /* section found */
+     237             :         return 0;
+     238             :     else
+     239             :         return -1;
+     240             : }
+     241             : 
+     242             : /**
+     243             :  * dlt_config_file_get_section_name_from_string
+     244             :  *
+     245             :  * Extract section name from line
+     246             :  *
+     247             :  * @param line  Line in configuration file containing a section header
+     248             :  * @param name  Section name
+     249             :  * @return 0 on success, else -1
+     250             :  */
+     251          40 : static int dlt_config_file_get_section_name_from_string(char *line, char *name)
+     252             : {
+     253             :     int i = 0;
+     254             :     int j = 0;
+     255             : 
+     256          40 :     if ((line == NULL) || (name == NULL))
+     257             :         return -1;
+     258             : 
+     259         386 :     for (i = 0; i < DLT_CONFIG_FILE_ENTRY_MAX_LEN; i++) {
+     260         386 :         if ((line[i] == '[') || isspace(line[i]))
+     261          40 :             continue;
+     262         346 :         else if ((line[i] == ']') || (line[i] == '\n') || (line[i] == '\0'))
+     263             :             break;
+     264             :         else
+     265         306 :             name[j++] = line[i];
+     266             :     }
+     267             : 
+     268             :     return 0;
+     269             : }
+     270             : 
+     271             : /**
+     272             :  * dlt_config_file_get_key_value
+     273             :  *
+     274             :  * Get key and value from a line of configuration file
+     275             :  *
+     276             :  * @param line      Line on configuration file
+     277             :  * @param[out] str1 String to be used as key
+     278             :  * @param[out] str2 String to be used as value
+     279             :  * @return 0 on success, else -1
+     280             :  */
+     281         339 : static int dlt_config_file_get_key_value(char *line, char *str1, char *str2)
+     282             : {
+     283             :     char *delimiter = "=";
+     284             :     char *ptr;
+     285             :     char *save_ptr;
+     286             : 
+     287         339 :     if ((line == NULL) || (str1 == NULL) || (str2 == NULL))
+     288             :         return -1;
+     289             : 
+     290         339 :     ptr = strtok_r(line, delimiter, &save_ptr);
+     291             : 
+     292         339 :     if (ptr != NULL) { /* get key */
+     293             :         strncpy(str1, ptr, DLT_CONFIG_FILE_ENTRY_MAX_LEN - 1);
+     294         339 :         str1[DLT_CONFIG_FILE_ENTRY_MAX_LEN - 1] = '\0';
+     295             :     } else {
+     296             :         return -1;
+     297             :     }
+     298             : 
+     299         339 :     ptr = strtok_r(NULL, delimiter, &save_ptr);
+     300             : 
+     301         339 :     if (ptr != NULL) {
+     302             :         strncpy(str2, ptr, DLT_CONFIG_FILE_ENTRY_MAX_LEN - 1);
+     303         339 :         str2[DLT_CONFIG_FILE_ENTRY_MAX_LEN - 1] = '\0';
+     304             :     } else {
+     305             :         return -1;
+     306             :     }
+     307             : 
+     308         339 :     return 0;
+     309             : }
+     310             : 
+     311             : /**
+     312             :  * dlt_config_file_read_line
+     313             :  *
+     314             :  * Read line from configuration file
+     315             :  *
+     316             :  * @param       line Line from configuration file
+     317             :  * @param[out]  str1 String contains section header or key
+     318             :  * @param[out]  str2 String contains value or is empty
+     319             :  * @return 0 on success, else -1
+     320             :  */
+     321         379 : static int dlt_config_file_read_line(char *line, char *str1, char *str2)
+     322             : {
+     323         379 :     if ((line == NULL) || (str1 == NULL) || (str2 == NULL))
+     324             :         return -1;
+     325             : 
+     326             :     /* reset values to zero */
+     327             :     memset(str1, 0, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
+     328             :     memset(str2, 0, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
+     329             : 
+     330             :     /* check if line contains a section */
+     331             :     if ((dlt_config_file_line_has_section(line)) == 0) {
+     332             :         /* retrieve section name */
+     333          40 :         if (dlt_config_file_get_section_name_from_string(line, str1) != 0)
+     334             :             return -1;
+     335             : 
+     336          40 :         return DLT_CONFIG_FILE_NEW_SECTION;
+     337             :     }
+     338             : 
+     339             :     /* copy strings as key value pair into str1, str2 */
+     340         339 :     if (dlt_config_file_get_key_value(line, str1, str2) != 0)
+     341           0 :         return -1;
+     342             : 
+     343             :     return DLT_CONFIG_FILE_NEW_DATA;
+     344             : }
+     345             : 
+     346             : /**
+     347             :  * dlt_config_file_read_file
+     348             :  *
+     349             :  * Read configuration file line by line and fill internal structures
+     350             :  *
+     351             :  * @param file DltConfigFile
+     352             :  * @param hdl  FILE handle of opened configuration file
+     353             :  */
+     354          14 : static void dlt_config_file_read_file(DltConfigFile *file, FILE *hdl)
+     355             : {
+     356             :     int ret = 0;
+     357          14 :     char line[DLT_CONFIG_FILE_LINE_MAX_LEN] = { '\0' };
+     358          14 :     char str1[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = { '\0' };
+     359          14 :     char str2[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = { '\0' };
+     360             :     int line_number = 0;
+     361             :     int is_section_valid = -1; /* to check if section name is given twice or invalid */
+     362             : 
+     363             :     /* read configuration file line by line */
+     364         434 :     while (fgets(line, DLT_CONFIG_FILE_LINE_MAX_LEN, hdl) != NULL) {
+     365         406 :         line_number++;
+     366             : 
+     367             :         /* ignore empty and comment lines */
+     368          27 :         if (dlt_config_file_ignore_line(line) == 0)
+     369          27 :             continue;
+     370             : 
+     371             :         /* trim line end */
+     372         379 :         dlt_config_file_trim_line(line);
+     373             : 
+     374             :         /* parse content of line */
+     375         379 :         ret = dlt_config_file_read_line(line, str1, str2);
+     376             : 
+     377         379 :         switch (ret) {
+     378          40 :         case DLT_CONFIG_FILE_NEW_SECTION:     /* store str1 as new section */
+     379             :             is_section_valid = -1;
+     380             : 
+     381          40 :             if ((ret = dlt_config_file_set_section(file, str1)) == 0)
+     382             :                 is_section_valid = 0;
+     383             : 
+     384             :             break;
+     385         339 :         case DLT_CONFIG_FILE_NEW_DATA:     /* store str1 and str2 as new data for section */
+     386             : 
+     387         339 :             if (is_section_valid == 0)
+     388         339 :                 ret = dlt_config_file_set_section_data(file, str1, str2);
+     389             : 
+     390             :             break;
+     391           0 :         default:     /* something is wrong with the line */
+     392           0 :             dlt_vlog(LOG_WARNING, "Line (%d) \"%s\" is invalid\n", line_number,
+     393             :                      line);
+     394             :         }
+     395             :     }
+     396          14 : }
+     397             : 
+     398             : /**
+     399             :  * dlt_config_file_find_section
+     400             :  *
+     401             :  * Find a section
+     402             :  *
+     403             :  * @param file      DltConfigFile
+     404             :  * @param section   Name of section
+     405             :  * @return number of section on success, else -1
+     406             :  */
+     407         468 : static int dlt_config_file_find_section(const DltConfigFile *file,
+     408             :                                         const char *section)
+     409             : {
+     410             :     int i = 0;
+     411             : 
+     412         468 :     if ((file == NULL) || (section == NULL) || (file->num_sections <= 0)) {
+     413           0 :         dlt_log(LOG_WARNING, "Section cannot be found due to invalid parameters\n");
+     414           0 :         return -1;
+     415             :     }
+     416             : 
+     417        2140 :     for (i = 0; i < file->num_sections; i++) {
+     418        2136 :         DltConfigFileSection *s = &file->sections[i];
+     419             : 
+     420        2136 :         if (strncmp(s->name, section, DLT_CONFIG_FILE_ENTRY_MAX_LEN) == 0)
+     421         464 :             return i;
+     422             :     }
+     423             : 
+     424             :     return -1;
+     425             : }
+     426             : 
+     427             : /************************** interface implementation ***************************/
+     428          14 : DltConfigFile *dlt_config_file_init(char *file_name)
+     429             : {
+     430             :     DltConfigFile *file;
+     431             :     FILE *hdl = NULL;
+     432             : 
+     433          14 :     if ((file_name == NULL) || (strlen(file_name) >= DLT_PATH_MAX)) {
+     434           0 :         dlt_log(LOG_ERR, "Given configuration file invalid\n");
+     435           0 :         return NULL;
+     436             :     }
+     437             : 
+     438          14 :     file = calloc(sizeof(DltConfigFile), 1);
+     439             : 
+     440          14 :     if (file == NULL) {
+     441           0 :         dlt_log(LOG_ERR, "Setup internal data structure to parse config file failed\n");
+     442           0 :         return NULL;
+     443             :     }
+     444             : 
+     445          14 :     file->sections = calloc(sizeof(DltConfigFileSection), DLT_CONFIG_FILE_SECTIONS_MAX);
+     446             : 
+     447             :     /* open file */
+     448          14 :     if ((hdl = fopen(file_name, "r")) == NULL) {
+     449           0 :         dlt_log(LOG_ERR, "Cannot open configuration file\n");
+     450           0 :         free(file);
+     451           0 :         return NULL;
+     452             :     }
+     453             : 
+     454          14 :     dlt_config_file_read_file(file, hdl);
+     455             : 
+     456             :     /* all information stored internally */
+     457          14 :     fclose(hdl);
+     458             : 
+     459          14 :     return file;
+     460             : }
+     461             : 
+     462          14 : void dlt_config_file_release(DltConfigFile *file)
+     463             : {
+     464             :     int i = 0;
+     465             : 
+     466          14 :     if (file != NULL) {
+     467          14 :         int max = file->num_sections;
+     468             : 
+     469          54 :         for (i = 0; i < max; i++) {
+     470          40 :             DltConfigFileSection *s = &file->sections[i];
+     471          40 :             DltConfigKeyData *node = file->sections[i].list;
+     472          40 :             free(s->name);
+     473             : 
+     474          40 :             if (s->keys != NULL)
+     475          40 :                 free(s->keys);
+     476             : 
+     477         379 :             while (node) {
+     478             :                 DltConfigKeyData *tmp = node;
+     479         339 :                 node = node->next;
+     480         339 :                 free(tmp->key);
+     481         339 :                 free(tmp->data);
+     482         339 :                 free(tmp);
+     483             :             }
+     484             :         }
+     485             : 
+     486          14 :         free(file->sections);
+     487          14 :         free(file);
+     488             :     }
+     489          14 : }
+     490             : 
+     491          40 : int dlt_config_file_get_section_name(const DltConfigFile *file,
+     492             :                                      int num,
+     493             :                                      char *name)
+     494             : {
+     495          40 :     if ((file == NULL) || (name == NULL) || (num < 0) || (num >= file->num_sections))
+     496             :         return -1;
+     497             : 
+     498          40 :     strncpy(name, (file->sections + num)->name, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
+     499          40 :     name[DLT_CONFIG_FILE_ENTRY_MAX_LEN - 1] = '\0';
+     500             : 
+     501          40 :     return 0;
+     502             : }
+     503             : 
+     504          14 : int dlt_config_file_get_num_sections(const DltConfigFile *file, int *num)
+     505             : {
+     506          14 :     if ((file == NULL) || (file->num_sections < 0))
+     507             :         return -1;
+     508             : 
+     509             :     /*
+     510             :      * Note: Since General section could be used in configuration file,
+     511             :      * this number could be also containing General section.
+     512             :      */
+     513          14 :     *num = file->num_sections;
+     514             : 
+     515          14 :     return 0;
+     516             : }
+     517             : 
+     518         464 : int dlt_config_file_get_value(const DltConfigFile *file,
+     519             :                               const char *section,
+     520             :                               const char *key, char *value)
+     521             : {
+     522             :     DltConfigFileSection *s = NULL;
+     523             :     DltConfigKeyData **tmp = NULL;
+     524             :     int num_section = 0;
+     525             : 
+     526         464 :     if ((file == NULL) || (section == NULL) || (key == NULL) || (value == NULL))
+     527             :         return -1;
+     528             : 
+     529             :     /* clean value */
+     530             :     memset(value, 0, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
+     531             : 
+     532         464 :     num_section = dlt_config_file_find_section(file, section);
+     533             : 
+     534         464 :     if (num_section == -1)
+     535             :         return -1;
+     536             : 
+     537         464 :     s = (file->sections + num_section);
+     538             : 
+     539         464 :     tmp = &s->list;
+     540             : 
+     541        2779 :     while (*(tmp) != NULL) {
+     542        2650 :         if (strncmp((*tmp)->key, key, DLT_CONFIG_FILE_ENTRY_MAX_LEN) == 0) {
+     543         335 :             strncpy(value, (*tmp)->data, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
+     544         335 :             return 0;
+     545             :         }
+     546             :         else { /* not found yet see list for more */
+     547        2315 :             tmp = &(*tmp)->next;
+     548             :         }
+     549             :     }
+     550             : 
+     551         129 :     dlt_vlog(LOG_WARNING, "Entry does not exist in section: %s\n", key);
+     552         129 :     return -1;
+     553             : }
+     554             : 
+     555           4 : int dlt_config_file_check_section_name_exists(const DltConfigFile *file,
+     556             :                                              const char *name)
+     557             : {
+     558             :     int ret = 0;
+     559             : 
+     560           4 :     if ((file == NULL) || (file->num_sections <= 0) || (name == NULL))
+     561             :         return -1;
+     562             : 
+     563           4 :     ret = dlt_config_file_find_section(file, name);
+     564           4 :     if (ret == -1)
+     565           4 :         return ret;
+     566             : 
+     567             :     return 0;
+     568             : }
+
+
+
+ + + + +
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..afbdadb94 --- /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:2023-11-29 14:15:44Functions: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..6de15a56d --- /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:2023-11-29 14:15:44Functions: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..331f32a48 --- /dev/null +++ b/dlt_lcov_report/shared/dlt_multiple_files.c.gcov.html @@ -0,0 +1,574 @@ + + + + + + + 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:2023-11-29 14:15:44Functions: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             : 
+      43          12 : unsigned int multiple_files_buffer_storage_dir_info(const char *path, const char *file_name,
+      44             :                                                     char *newest, char *oldest)
+      45             : {
+      46             :     int i = 0;
+      47             :     unsigned int num_log_files = 0;
+      48          12 :     struct dirent **files = { 0 };
+      49             :     char *tmp_old = NULL;
+      50             :     char *tmp_new = NULL;
+      51             : 
+      52          12 :     if ((path == NULL) || (file_name == NULL) || (newest == NULL) || (oldest == NULL)) {
+      53           0 :         fprintf(stderr, "multiple_files_buffer_storage_dir_info: Invalid parameter(s)");
+      54           0 :         return 0;
+      55             :     }
+      56             : 
+      57          12 :     const int file_cnt = scandir(path, &files, NULL, alphasort);
+      58          12 :     if (file_cnt <= 0) return 0;
+      59             : 
+      60         386 :     for (i = 0; i < file_cnt; i++) {
+      61             :         int len = 0;
+      62         374 :         len = strlen(file_name);
+      63             : 
+      64         374 :         if ((strncmp(files[i]->d_name, file_name, len) == 0) &&
+      65         110 :             (files[i]->d_name[len] == MULTIPLE_FILES_FILENAME_INDEX_DELIM[0])) {
+      66          48 :             num_log_files++;
+      67             : 
+      68          48 :             if ((tmp_old == NULL) || (strlen(tmp_old) >= strlen(files[i]->d_name))) {
+      69          48 :                 if (tmp_old == NULL) {
+      70             :                     tmp_old = files[i]->d_name;
+      71          36 :                 } else if (strlen(tmp_old) > strlen(files[i]->d_name)) {
+      72             :                     /* when file name is smaller, it is older */
+      73             :                     tmp_old = files[i]->d_name;
+      74          20 :                 } else if (strcmp(tmp_old, files[i]->d_name) > 0) {
+      75             :                     /* filename length is equal, do a string compare */
+      76             :                     tmp_old = files[i]->d_name;
+      77             :                 }
+      78             :             }
+      79             : 
+      80          48 :             if ((tmp_new == NULL) || (strlen(tmp_new) <= strlen(files[i]->d_name))) {
+      81          32 :                 if (tmp_new == NULL) {
+      82             :                     tmp_new = files[i]->d_name;
+      83          20 :                 } else if (strlen(tmp_new) < strlen(files[i]->d_name)) {
+      84             :                     /* when file name is longer, it is younger */
+      85             :                     tmp_new = files[i]->d_name;
+      86          20 :                 } else if (strcmp(tmp_new, files[i]->d_name) < 0) {
+      87             :                     tmp_new = files[i]->d_name;
+      88             :                 }
+      89             :             }
+      90             :         }
+      91             :     }
+      92             : 
+      93          12 :     if (num_log_files > 0) {
+      94          12 :         if ((tmp_old != NULL) && (strlen(tmp_old) < NAME_MAX)) {
+      95             :             strncpy(oldest, tmp_old, NAME_MAX);
+      96          12 :             oldest[NAME_MAX] = '\0';
+      97           0 :         } else if ((tmp_old != NULL) && (strlen(tmp_old) >=  NAME_MAX)) {
+      98             :             printf("length mismatch of file %s\n", tmp_old);
+      99             :         }
+     100             : 
+     101          12 :         if ((tmp_new != NULL) && (strlen(tmp_new) < NAME_MAX)) {
+     102             :             strncpy(newest, tmp_new, NAME_MAX);
+     103          12 :             oldest[NAME_MAX] = '\0';
+     104           0 :         } else if ((tmp_new != NULL) && (strlen(tmp_new) >=  NAME_MAX)) {
+     105             :             printf("length mismatch of file %s\n", tmp_new);
+     106             :         }
+     107             :     }
+     108             : 
+     109             :     /* free scandir result */
+     110         386 :     for (i = 0; i < file_cnt; i++) free(files[i]);
+     111             : 
+     112          12 :     free(files);
+     113             : 
+     114          12 :     return num_log_files;
+     115             : }
+     116             : 
+     117           9 : void multiple_files_buffer_file_name(MultipleFilesRingBuffer *files_buffer, const size_t length, const unsigned int idx)
+     118             : {
+     119             :     char file_index[11]; /* UINT_MAX = 4294967295 -> 10 digits */
+     120             :     snprintf(file_index, sizeof(file_index), "%010u", idx);
+     121             : 
+     122             :     /* create log file name */
+     123           9 :     char* file_name = files_buffer->filename;
+     124             :     memset(file_name, 0, length * sizeof(char));
+     125             : 
+     126           9 :     const size_t size = length - strlen(file_name) - 1;
+     127           9 :     strncat(file_name, files_buffer->filenameBase, size);
+     128             :     strncat(file_name, MULTIPLE_FILES_FILENAME_INDEX_DELIM, size);
+     129             :     strncat(file_name, file_index, size);
+     130           9 :     strncat(file_name, files_buffer->filenameExt, size);
+     131           9 : }
+     132             : 
+     133          53 : unsigned int multiple_files_buffer_get_idx_of_log_file(char *file)
+     134             : {
+     135          53 :     if ((file == NULL) || (file[0] == '\0')) return 0;
+     136             : 
+     137          53 :     const char d[2] = MULTIPLE_FILES_FILENAME_INDEX_DELIM;
+     138             :     char *token;
+     139             : 
+     140          53 :     token = strtok(file, d);
+     141             :     /* we are interested in 2. token because of log file name */
+     142          53 :     token = strtok(NULL, d);
+     143             : 
+     144          53 :     return token != NULL ? strtol(token, NULL, 10) : 0;
+     145             : }
+     146             : 
+     147           9 : DltReturnValue multiple_files_buffer_create_new_file(MultipleFilesRingBuffer *files_buffer)
+     148             : {
+     149           9 :     if (files_buffer == NULL) {
+     150           0 :         fprintf(stderr, "multiple files buffer not set\n");
+     151           0 :         return DLT_RETURN_ERROR;
+     152             :     }
+     153             : 
+     154             :     time_t t;
+     155             :     struct tm tmp;
+     156             :     char file_path[PATH_MAX + 1];
+     157             :     unsigned int idx = 0;
+     158             :     int ret = 0;
+     159             : 
+     160             :     /* set filename */
+     161           9 :     if (files_buffer->filenameTimestampBased) {
+     162             :         /* timestamp format: "yyyymmdd_hhmmss" */
+     163             :         char timestamp[16];
+     164           0 :         t = time(NULL);
+     165           0 :         tzset();
+     166           0 :         localtime_r(&t, &tmp);
+     167             : 
+     168           0 :         strftime(timestamp, sizeof(timestamp), "%Y%m%d_%H%M%S", &tmp);
+     169             : 
+     170           0 :         ret = snprintf(files_buffer->filename, sizeof(files_buffer->filename), "%s%s%s%s",
+     171           0 :                        files_buffer->filenameBase,
+     172             :                        MULTIPLE_FILES_FILENAME_TIMESTAMP_DELIM, timestamp,
+     173           0 :                        files_buffer->filenameExt);
+     174             : 
+     175           0 :         if ((ret < 0) || ((size_t)ret >= (int)sizeof(files_buffer->filename))) {
+     176           0 :             fprintf(stderr, "filename cannot be concatenated\n");
+     177           0 :             return DLT_RETURN_ERROR;
+     178             :         }
+     179             : 
+     180             :         ret = snprintf(file_path, sizeof(file_path), "%s/%s",
+     181           0 :                        files_buffer->directory, files_buffer->filename);
+     182             : 
+     183           0 :         if ((ret < 0) || ((size_t)ret >= (int)sizeof(file_path))) {
+     184           0 :             fprintf(stderr, "file path cannot be concatenated\n");
+     185           0 :             return DLT_RETURN_ERROR;
+     186             :         }
+     187             :     }
+     188             :     else {
+     189           9 :         char newest[NAME_MAX + 1] = { 0 };
+     190           9 :         char oldest[NAME_MAX + 1] = { 0 };
+     191             :         /* targeting newest file, ignoring number of files in dir returned */
+     192           9 :         if (0 == multiple_files_buffer_storage_dir_info(files_buffer->directory,
+     193           9 :                                                         files_buffer->filenameBase,
+     194             :                                                         newest,
+     195             :                                                         oldest)) {
+     196             :             printf("No multiple files found\n");
+     197             :         }
+     198             : 
+     199           9 :         idx = multiple_files_buffer_get_idx_of_log_file(newest) + 1;
+     200             : 
+     201           9 :         multiple_files_buffer_file_name(files_buffer, sizeof(files_buffer->filename), idx);
+     202             :         ret = snprintf(file_path, sizeof(file_path), "%s/%s",
+     203           9 :                        files_buffer->directory, files_buffer->filename);
+     204             : 
+     205           9 :         if ((ret < 0) || (ret >= NAME_MAX)) {
+     206           0 :             fprintf(stderr, "filename cannot be concatenated\n");
+     207           0 :             return DLT_RETURN_ERROR;
+     208             :         }
+     209             :     }
+     210             : 
+     211             :     /* open DLT output file */
+     212           9 :     errno = 0;
+     213           9 :     files_buffer->ohandle = open(file_path, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR |
+     214             :                                                                 S_IRGRP | S_IROTH); /* mode: wb */
+     215             : 
+     216           9 :     if (files_buffer->ohandle == -1) {
+     217             :         /* file cannot be opened */
+     218           0 :         fprintf(stderr, "file %s cannot be created, error: %s\n", file_path, strerror(errno));
+     219           0 :         return DLT_RETURN_ERROR;
+     220             :     }
+     221             : 
+     222             :     return DLT_RETURN_OK;
+     223             : }
+     224             : 
+     225          21 : ssize_t multiple_files_buffer_get_total_size(const MultipleFilesRingBuffer *files_buffer)
+     226             : {
+     227          21 :     if (files_buffer == NULL) {
+     228           0 :         fprintf(stderr, "multiple files buffer not set\n");
+     229           0 :         return -1;
+     230             :     }
+     231             : 
+     232             :     struct dirent *dp;
+     233             :     char filename[PATH_MAX + 1];
+     234             :     ssize_t size = 0;
+     235             :     struct stat status;
+     236             : 
+     237             :     /* go through all dlt files in directory */
+     238          21 :     DIR *dir = opendir(files_buffer->directory);
+     239          21 :     if (!dir) {
+     240           0 :         fprintf(stderr, "directory %s cannot be opened, error=%s\n", files_buffer->directory, strerror(errno));
+     241           0 :         return -1;
+     242             :     }
+     243             : 
+     244         695 :     while ((dp = readdir(dir)) != NULL) {
+     245             :         // consider files matching with a specific base name and a particular extension
+     246         674 :         if (strstr(dp->d_name, files_buffer->filenameBase)  && strstr(dp->d_name, files_buffer->filenameExt)) {
+     247             :             int res = snprintf(filename, sizeof(filename), "%s/%s", files_buffer->directory, dp->d_name);
+     248             : 
+     249             :             /* if the total length of the string is greater than the buffer, silently forget it. */
+     250             :             /* snprintf: a return value of size  or more means that the output was truncated */
+     251             :             /*           if an output error is encountered, a negative value is returned. */
+     252          80 :             if (((unsigned int)res < sizeof(filename)) && (res > 0)) {
+     253          80 :                 errno = 0;
+     254          80 :                 if (0 == stat(filename, &status))
+     255          80 :                     size += status.st_size;
+     256             :                 else
+     257           0 :                     fprintf(stderr, "file %s cannot be stat-ed, error=%s\n", filename, strerror(errno));
+     258             :             }
+     259             :         }
+     260             :     }
+     261             : 
+     262          21 :     closedir(dir);
+     263             : 
+     264             :     /* return size */
+     265          21 :     return size;
+     266             : }
+     267             : 
+     268           9 : int multiple_files_buffer_delete_oldest_file(MultipleFilesRingBuffer *files_buffer)
+     269             : {
+     270           9 :     if (files_buffer == NULL) {
+     271           0 :         fprintf(stderr, "multiple files buffer not set\n");
+     272           0 :         return -1;  /* ERROR */
+     273             :     }
+     274             : 
+     275             :     struct dirent *dp;
+     276             :     char filename[PATH_MAX + 1];
+     277             :     char filename_oldest[PATH_MAX + 1];
+     278             :     unsigned long size_oldest = 0;
+     279             :     struct stat status;
+     280             :     time_t time_oldest = 0;
+     281             :     int index_oldest = INT_MAX;
+     282             : 
+     283           9 :     filename[0] = 0;
+     284           9 :     filename_oldest[0] = 0;
+     285             : 
+     286             :     /* go through all dlt files in directory */
+     287           9 :     DIR *dir = opendir(files_buffer->directory);
+     288             : 
+     289           9 :     if(!dir)
+     290             :         return -1;
+     291             : 
+     292         309 :     while ((dp = readdir(dir)) != NULL) {
+     293         300 :         if (strstr(dp->d_name, files_buffer->filenameBase) && strstr(dp->d_name, files_buffer->filenameExt)) {
+     294             :             int res = snprintf(filename, sizeof(filename), "%s/%s", files_buffer->directory, dp->d_name);
+     295             : 
+     296             :             /* if the total length of the string is greater than the buffer, silently forget it. */
+     297             :             /* snprintf: a return value of size  or more means that the output was truncated */
+     298             :             /*           if an output error is encountered, a negative value is returned. */
+     299          44 :             if (((unsigned int) res >= sizeof(filename)) || (res <= 0)) {
+     300             :                 printf("Filename for delete oldest too long. Skip file.\n");
+     301           0 :                 continue;
+     302             :             }
+     303             : 
+     304          44 :             if (files_buffer->filenameTimestampBased) {
+     305           0 :                 errno = 0;
+     306           0 :                 if (0 == stat(filename, &status)) {
+     307           0 :                     if ((time_oldest == 0) || (status.st_mtime < time_oldest)) {
+     308           0 :                         time_oldest = status.st_mtime;
+     309           0 :                         size_oldest = status.st_size;
+     310             :                         strncpy(filename_oldest, filename, PATH_MAX);
+     311           0 :                         filename_oldest[PATH_MAX] = 0;
+     312             :                     }
+     313             :                 } else {
+     314           0 :                     printf("Old file %s cannot be stat-ed, error=%s\n", filename, strerror(errno));
+     315             :                 }
+     316             :             } else {
+     317             :                 //index based
+     318          44 :                 const int index = multiple_files_buffer_get_idx_of_log_file(filename);
+     319          44 :                 if (index < index_oldest) {
+     320             :                     index_oldest = index;
+     321             :                     snprintf(filename, sizeof(filename), "%s/%s", files_buffer->directory, dp->d_name);
+     322             :                     strncpy(filename_oldest, filename, PATH_MAX);
+     323          23 :                     filename_oldest[PATH_MAX] = 0;
+     324             :                 }
+     325             :             }
+     326             :         }
+     327             :     }
+     328             : 
+     329           9 :     closedir(dir);
+     330             : 
+     331             :     /* delete file */
+     332           9 :     if (filename_oldest[0]) {
+     333           9 :         if (remove(filename_oldest)) {
+     334           0 :             fprintf(stderr, "Remove file %s failed! error=%s\n", filename_oldest, strerror(errno));
+     335           0 :             return -1; /* ERROR */
+     336             :         }
+     337             :     } else {
+     338           0 :         fprintf(stderr, "No file to be removed!\n");
+     339           0 :         return -1; /* ERROR */
+     340             :     }
+     341             : 
+     342             :     /* return size of deleted file*/
+     343           9 :     return size_oldest;
+     344             : }
+     345             : 
+     346          12 : DltReturnValue multiple_files_buffer_check_size(MultipleFilesRingBuffer *files_buffer)
+     347             : {
+     348          12 :     if (files_buffer == NULL) {
+     349           0 :         fprintf(stderr, "multiple files buffer not set\n");
+     350           0 :         return DLT_RETURN_ERROR;
+     351             :     }
+     352             : 
+     353             :     struct stat status;
+     354             : 
+     355             :     /* check for existence of buffer files directory */
+     356          12 :     errno = 0;
+     357          12 :     if (stat(files_buffer->directory, &status) == -1) {
+     358           0 :         fprintf(stderr, "Buffer files directory: %s doesn't exist, error=%s\n", files_buffer->directory, strerror(errno));
+     359           0 :         return DLT_RETURN_ERROR;
+     360             :     }
+     361             :     /* check for accessibility of buffer files directory */
+     362          12 :     else if (access(files_buffer->directory, W_OK) != 0) {
+     363           0 :         fprintf(stderr, "Buffer files directory: %s doesn't have the write access \n", files_buffer->directory);
+     364           0 :         return DLT_RETURN_ERROR;
+     365             :     }
+     366             : 
+     367             :     ssize_t total_size = 0;
+     368             :     /* check size of complete buffer file */
+     369          21 :     while ((total_size = multiple_files_buffer_get_total_size(files_buffer)) > (files_buffer->maxSize - files_buffer->fileSize)) {
+     370             :         /* remove the oldest files as long as new file will not fit in completely into complete multiple files buffer */
+     371           9 :         if (multiple_files_buffer_delete_oldest_file(files_buffer) < 0) return DLT_RETURN_ERROR;
+     372             :     }
+     373             : 
+     374          12 :     return total_size == -1 ? DLT_RETURN_ERROR : DLT_RETURN_OK;
+     375             : }
+     376             : 
+     377           3 : DltReturnValue multiple_files_buffer_open_file_for_append(MultipleFilesRingBuffer *files_buffer) {
+     378           3 :     if (files_buffer == NULL || files_buffer->filenameTimestampBased) return DLT_RETURN_ERROR;
+     379             : 
+     380           3 :     char newest[NAME_MAX + 1] = {0};
+     381           3 :     char oldest[NAME_MAX + 1] = {0};
+     382             :     /* targeting the newest file, ignoring number of files in dir returned */
+     383             : 
+     384           3 :     if (0 == multiple_files_buffer_storage_dir_info(files_buffer->directory,
+     385           3 :                                                    files_buffer->filenameBase, newest, oldest) ) {
+     386             :         // no file for appending found. Create a new one
+     387             :         printf("No multiple files for appending found. Create a new one\n");
+     388           0 :         return multiple_files_buffer_create_new_file(files_buffer);
+     389             :     }
+     390             : 
+     391             :     char file_path[PATH_MAX + 1];
+     392             :     int ret = snprintf(file_path, sizeof(file_path), "%s/%s",
+     393             :                          files_buffer->directory, newest);
+     394             : 
+     395           3 :     if ((ret < 0) || (ret >= NAME_MAX)) {
+     396           0 :         fprintf(stderr, "filename cannot be concatenated\n");
+     397           0 :         return DLT_RETURN_ERROR;
+     398             :     }
+     399             : 
+     400             :     /* open DLT output file */
+     401           3 :     errno = 0;
+     402           3 :     files_buffer->ohandle = open(file_path, O_WRONLY | O_APPEND); /* mode: wb */
+     403             : 
+     404           3 :     return files_buffer->ohandle == -1 ? DLT_RETURN_ERROR : DLT_RETURN_OK;
+     405             : }
+     406             : 
+     407           3 : DltReturnValue multiple_files_buffer_init(MultipleFilesRingBuffer *files_buffer,
+     408             :                                           const char *directory,
+     409             :                                           const int file_size,
+     410             :                                           const int max_size,
+     411             :                                           const bool filename_timestamp_based,
+     412             :                                           const bool append,
+     413             :                                           const char *filename_base,
+     414             :                                           const char *filename_ext)
+     415             : {
+     416           3 :     if (files_buffer == NULL) {
+     417           0 :         fprintf(stderr, "multiple files buffer not set\n");
+     418           0 :         return DLT_RETURN_ERROR;
+     419             :     }
+     420             : 
+     421             :     /* init parameters */
+     422           3 :     strncpy(files_buffer->directory, directory, NAME_MAX);
+     423           3 :     files_buffer->directory[NAME_MAX] = 0;
+     424           3 :     files_buffer->fileSize = file_size;
+     425           3 :     files_buffer->maxSize = max_size;
+     426           3 :     files_buffer->filenameTimestampBased = filename_timestamp_based;
+     427           3 :     strncpy(files_buffer->filenameBase, filename_base, NAME_MAX);
+     428           3 :     files_buffer->filenameBase[NAME_MAX] = 0;
+     429           3 :     strncpy(files_buffer->filenameExt, filename_ext, NAME_MAX);
+     430           3 :     files_buffer->filenameExt[NAME_MAX] = 0;
+     431             : 
+     432           3 :     if (DLT_RETURN_ERROR == multiple_files_buffer_check_size(files_buffer)) return DLT_RETURN_ERROR;
+     433             : 
+     434           3 :     return (!files_buffer->filenameTimestampBased && append)
+     435           3 :         ? multiple_files_buffer_open_file_for_append(files_buffer)
+     436           3 :         : multiple_files_buffer_create_new_file(files_buffer);
+     437             : }
+     438             : 
+     439          12 : void multiple_files_buffer_rotate_file(MultipleFilesRingBuffer *files_buffer, const int size)
+     440             : {
+     441             :     /* check file size here */
+     442          12 :     if ((lseek(files_buffer->ohandle, 0, SEEK_CUR) + size) < files_buffer->fileSize) return;
+     443             : 
+     444             :     /* close old file */
+     445           9 :     close(files_buffer->ohandle);
+     446           9 :     files_buffer->ohandle = -1;
+     447             : 
+     448             :     /* check complete files size, remove old logs if needed */
+     449           9 :     if (DLT_RETURN_ERROR == multiple_files_buffer_check_size(files_buffer)) return;
+     450             : 
+     451             :     /* create new file */
+     452           9 :     multiple_files_buffer_create_new_file(files_buffer);
+     453             : }
+     454             : 
+     455          12 : DltReturnValue multiple_files_buffer_write_chunk(const MultipleFilesRingBuffer *files_buffer,
+     456             :                                                  const unsigned char *data,
+     457             :                                                  const int size)
+     458             : {
+     459          12 :     if (files_buffer == NULL) {
+     460           0 :         fprintf(stderr, "multiple files buffer not set\n");
+     461           0 :         return DLT_RETURN_ERROR;
+     462             :     }
+     463             : 
+     464          12 :     if (data && (files_buffer->ohandle >= 0)) {
+     465          12 :         if (write(files_buffer->ohandle, data, size) != size) {
+     466           0 :             fprintf(stderr, "file write failed!\n");
+     467           0 :             return DLT_RETURN_ERROR;
+     468             :         }
+     469             :     }
+     470             :     return DLT_RETURN_OK;
+     471             : }
+     472             : 
+     473          12 : DltReturnValue multiple_files_buffer_write(MultipleFilesRingBuffer *files_buffer,
+     474             :                                            const unsigned char *data,
+     475             :                                            const int size)
+     476             : {
+     477          12 :     if (files_buffer->ohandle < 0) return DLT_RETURN_ERROR;
+     478             : 
+     479          12 :     multiple_files_buffer_rotate_file(files_buffer, size);
+     480             : 
+     481             :     /* write data into log file */
+     482          12 :     return multiple_files_buffer_write_chunk(files_buffer, data, size);
+     483             : }
+     484             : 
+     485           3 : DltReturnValue multiple_files_buffer_free(const MultipleFilesRingBuffer *files_buffer)
+     486             : {
+     487           3 :     if (files_buffer == NULL) {
+     488           0 :         fprintf(stderr, "multiple files buffer not set\n");
+     489           0 :         return DLT_RETURN_ERROR;
+     490             :     }
+     491             : 
+     492           3 :     if (files_buffer->ohandle < 0) return DLT_RETURN_ERROR;
+     493             : 
+     494             :     /* close last used log file */
+     495           3 :     close(files_buffer->ohandle);
+     496             : 
+     497           3 :     return DLT_RETURN_OK;
+     498             : }
+
+
+
+ + + + +
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..c224494ce --- /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:2023-11-29 14:15:44Functions: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..460884767 --- /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:2023-11-29 14:15:44Functions: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..3b442a26b --- /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:2023-11-29 14:15:44Functions: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..8b839392a --- /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:2023-11-29 14:15:44Functions: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..e97bd2b95 --- /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:2023-11-29 14:15:44Functions: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..f86d60672 --- /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:2023-11-29 14:15:44Functions: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..a0a8ef7c7 --- /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:2023-11-29 14:15:44Functions: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..c61712464 --- /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:2023-11-29 14:15:44Functions: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..1825b32bf --- /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:2023-11-29 14:15:44Functions: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..060f841c6 --- /dev/null +++ b/dlt_lcov_report/shared/index-sort-f.html @@ -0,0 +1,143 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - sharedHitTotalCoverage
Test:dlt_final_coverage.infoLines:1440218266.0 %
Date:2023-11-29 14:15:44Functions: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 +
63.8%63.8%
+
63.8 %1117 / 175287.3 %96 / 110
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
+
+
+ + + + +
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..a24dfe8fd --- /dev/null +++ b/dlt_lcov_report/shared/index-sort-l.html @@ -0,0 +1,143 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - sharedHitTotalCoverage
Test:dlt_final_coverage.infoLines:1440218266.0 %
Date:2023-11-29 14:15:44Functions: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 +
63.8%63.8%
+
63.8 %1117 / 175287.3 %96 / 110
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
+
+
+ + + + +
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..8c4b6e851 --- /dev/null +++ b/dlt_lcov_report/shared/index.html @@ -0,0 +1,143 @@ + + + + + + + LCOV - dlt_final_coverage.info - shared + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - sharedHitTotalCoverage
Test:dlt_final_coverage.infoLines:1440218266.0 %
Date:2023-11-29 14:15:44Functions:13014689.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_common.c +
63.8%63.8%
+
63.8 %1117 / 175287.3 %96 / 110
dlt_config_file_parser.c +
83.5%83.5%
+
83.5 %142 / 170100.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