From 64469b1301ba7c155c32b017c01122ac471a51b6 Mon Sep 17 00:00:00 2001 From: github-actions Date: Fri, 1 Sep 2023 07:46:31 +0000 Subject: [PATCH] Upload lcov report for dlt-daemon --- .gitmodules | 3 - dlt_lcov_report/amber.png | Bin 0 -> 141 bytes .../daemon/dlt-daemon.c.func-sort-c.html | 232 + dlt_lcov_report/daemon/dlt-daemon.c.func.html | 232 + dlt_lcov_report/daemon/dlt-daemon.c.gcov.html | 3988 ++++++ .../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 | 510 + ...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 | 11393 ++++++++++++++++ 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 | 133 + dlt_lcov_report/index-sort-l.html | 133 + dlt_lcov_report/index.html | 133 + .../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 | 5266 +++++++ 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 | 1650 +++ .../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 - 94 files changed, 54888 insertions(+), 4 deletions(-) create mode 100644 dlt_lcov_report/amber.png 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 - 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:435111039.2 %
Date:2023-09-01 07:46:27Functions:234057.5 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_process_client_messages_serial0
dlt_daemon_process_control_connect0
dlt_daemon_process_control_messages0
dlt_daemon_process_user_message_log0
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_application0
dlt_daemon_process_user_message_register_context0
dlt_daemon_process_user_message_set_app_ll_ts0
dlt_daemon_process_user_message_unregister_application0
dlt_daemon_process_user_message_unregister_context0
dlt_daemon_process_user_messages0
dlt_daemon_send_message_overflow0
enforce_context_ll_and_ts_keep_message0
usage0
dlt_daemon_send_ringbuffer_to_client1
dlt_daemon_close_socket2
dlt_daemon_create_pipes_dir2
dlt_daemon_daemonize2
dlt_daemon_exit_trigger2
dlt_daemon_init_fifo2
dlt_daemon_init_serial2
dlt_daemon_initialize_control_socket2
dlt_daemon_local_cleanup2
dlt_daemon_local_connection_init2
dlt_daemon_local_ecu_version_init2
dlt_daemon_local_init_p12
dlt_daemon_local_init_p22
dlt_daemon_signal_handler2
dlt_mkdir_recursive2
main2
option_file_parser2
option_handling2
create_timer_fd3
dlt_daemon_check_numeric_setting3
dlt_daemon_process_client_connect3
dlt_daemon_process_client_messages8
dlt_daemon_log_internal9
+
+
+ + + +
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..18745b1de --- /dev/null +++ b/dlt_lcov_report/daemon/dlt-daemon.c.func.html @@ -0,0 +1,232 @@ + + + + + + + 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:435111039.2 %
Date:2023-09-01 07:46:27Functions:234057.5 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
create_timer_fd3
dlt_daemon_check_numeric_setting3
dlt_daemon_close_socket2
dlt_daemon_create_pipes_dir2
dlt_daemon_daemonize2
dlt_daemon_exit_trigger2
dlt_daemon_init_fifo2
dlt_daemon_init_serial2
dlt_daemon_initialize_control_socket2
dlt_daemon_local_cleanup2
dlt_daemon_local_connection_init2
dlt_daemon_local_ecu_version_init2
dlt_daemon_local_init_p12
dlt_daemon_local_init_p22
dlt_daemon_log_internal9
dlt_daemon_process_client_connect3
dlt_daemon_process_client_messages8
dlt_daemon_process_client_messages_serial0
dlt_daemon_process_control_connect0
dlt_daemon_process_control_messages0
dlt_daemon_process_user_message_log0
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_application0
dlt_daemon_process_user_message_register_context0
dlt_daemon_process_user_message_set_app_ll_ts0
dlt_daemon_process_user_message_unregister_application0
dlt_daemon_process_user_message_unregister_context0
dlt_daemon_process_user_messages0
dlt_daemon_send_message_overflow0
dlt_daemon_send_ringbuffer_to_client1
dlt_daemon_signal_handler2
dlt_mkdir_recursive2
enforce_context_ll_and_ts_keep_message0
main2
option_file_parser2
option_handling2
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..3d9e36139 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt-daemon.c.gcov.html @@ -0,0 +1,3988 @@ + + + + + + + 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:435111039.2 %
Date:2023-09-01 07:46:27Functions:234057.5 %
+
+ + + + + + + + +

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

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_client_send_message_to_all_client0
dlt_daemon_control_callsw_cinjection0
dlt_daemon_control_message_buffer_overflow0
dlt_daemon_control_message_marker0
dlt_daemon_control_message_time0
dlt_daemon_control_message_timezone0
dlt_daemon_control_message_unregister_context0
dlt_daemon_control_passive_node_connect0
dlt_daemon_control_passive_node_connect_status0
dlt_daemon_control_service_logstorage0
dlt_daemon_control_set_all_log_level0
dlt_daemon_control_set_all_trace_status0
dlt_daemon_control_set_default_log_level0
dlt_daemon_control_set_default_trace_status0
dlt_daemon_control_set_timing_packets0
dlt_daemon_control_set_trace_status0
dlt_daemon_find_multiple_context_and_send_log_level0
dlt_daemon_find_multiple_context_and_send_trace_status0
dlt_daemon_process_sixty_s_timer0
dlt_daemon_process_systemd_timer0
dlt_daemon_send_log_level0
dlt_daemon_send_trace_status0
dlt_daemon_control_get_default_log_level1
dlt_daemon_control_service_response1
dlt_daemon_control_set_log_level1
dlt_daemon_process_one_s_timer1
dlt_daemon_control_get_software_version3
dlt_daemon_control_get_log_info4
dlt_daemon_control_message_connection_info5
dlt_daemon_client_process_control9
dlt_daemon_client_send_all_multiple9
dlt_daemon_client_send_control_message14
dlt_daemon_client_send37
+
+
+ + + +
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..8d8b9007c --- /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:21697122.2 %
Date:2023-09-01 07:46:27Functions:113333.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_client_process_control9
dlt_daemon_client_send37
dlt_daemon_client_send_all_multiple9
dlt_daemon_client_send_control_message14
dlt_daemon_client_send_message_to_all_client0
dlt_daemon_control_callsw_cinjection0
dlt_daemon_control_get_default_log_level1
dlt_daemon_control_get_log_info4
dlt_daemon_control_get_software_version3
dlt_daemon_control_message_buffer_overflow0
dlt_daemon_control_message_connection_info5
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_logstorage0
dlt_daemon_control_service_response1
dlt_daemon_control_set_all_log_level0
dlt_daemon_control_set_all_trace_status0
dlt_daemon_control_set_default_log_level0
dlt_daemon_control_set_default_trace_status0
dlt_daemon_control_set_log_level1
dlt_daemon_control_set_timing_packets0
dlt_daemon_control_set_trace_status0
dlt_daemon_find_multiple_context_and_send_log_level0
dlt_daemon_find_multiple_context_and_send_trace_status0
dlt_daemon_process_one_s_timer1
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..e3280a901 --- /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:21697122.2 %
Date:2023-09-01 07:46:27Functions: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           9 : 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           9 :     PRINT_FUNCTION_VERBOSE(verbose);
+     119             : 
+     120           9 :     if ((daemon == NULL) || (daemon_local == NULL)) {
+     121           0 :         dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
+     122           0 :         return 0;
+     123             :     }
+     124             : 
+     125          56 :     for (i = 0; i < daemon_local->pEvent.nfds; i++)
+     126             :     {
+     127          47 :         temp = dlt_event_handler_find_connection(&(daemon_local->pEvent),
+     128          47 :                                         daemon_local->pEvent.pfd[i].fd);
+     129             : 
+     130          47 :         if ((temp == NULL) || (temp->receiver == NULL) ||
+     131          47 :             !((1 << temp->type) & type_mask)) {
+     132          36 :             dlt_log(LOG_DEBUG, "The connection not found or the connection type not TCP/Serial.\n");
+     133          36 :             continue;
+     134             :         }
+     135             : 
+     136          11 :         ret = dlt_connection_send_multiple(temp,
+     137             :                                            data1,
+     138             :                                            size1,
+     139             :                                            data2,
+     140             :                                            size2,
+     141             :                                            daemon->sendserialheader);
+     142             : 
+     143          11 :         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          11 :         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          37 : 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          37 :     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          37 :     if ((sock != DLT_DAEMON_SEND_TO_ALL) && (sock != DLT_DAEMON_SEND_FORCE)) {
+     184             :         /* Send message to specific socket */
+     185          12 :         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          12 :             if ((ret =
+     194          12 :                      dlt_daemon_socket_send(sock, data1, size1, data2, size2,
+     195          12 :                                             daemon->sendserialheader))) {
+     196           0 :                 dlt_vlog(LOG_WARNING, "%s: socket send dlt message failed\n", __func__);
+     197           0 :                 return ret;
+     198             :             }
+     199             :         }
+     200             : 
+     201          12 :         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          25 :     if ((sock != DLT_DAEMON_SEND_FORCE) && (daemon->state != DLT_DAEMON_STATE_SEND_BUFFER)) {
+     209          23 :         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          23 :         if (daemon_local->flags.offlineLogstorageMaxDevices > 0)
+     228           0 :             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          25 :     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          25 :         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           9 :             if (ret_logstorage != 1) {
+     257           9 :                 sent = dlt_daemon_client_send_all_multiple(daemon,
+     258             :                                                            daemon_local,
+     259             :                                                            data1,
+     260             :                                                            size1,
+     261             :                                                            data2,
+     262             :                                                            size2,
+     263             :                                                            verbose);
+     264             : 
+     265           9 :                 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          25 :     if ((sock != DLT_DAEMON_SEND_FORCE) &&
+     274          23 :         ((daemon->state == DLT_DAEMON_STATE_BUFFER) || (daemon->state == DLT_DAEMON_STATE_SEND_BUFFER) ||
+     275             :          (daemon->state == DLT_DAEMON_STATE_BUFFER_FULL))) {
+     276          16 :         if (daemon->state != DLT_DAEMON_STATE_BUFFER_FULL) {
+     277             :             /* Store message in history buffer */
+     278          16 :             ret = dlt_buffer_push3(&(daemon->client_ringbuffer), data1, size1, data2, size2, 0, 0);
+     279          16 :             if (ret < DLT_RETURN_OK) {
+     280           0 :                 dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_BUFFER_FULL);
+     281             :             }
+     282             :         }
+     283          16 :         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           9 :         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           0 : 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           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+     323             : 
+     324           0 :     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           0 :     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           0 :     if (DLT_IS_HTYP_WEID(daemon_local->msg.standardheader->htyp)) {
+     350           0 :         ecu_ptr = daemon_local->msg.headerextra.ecu;
+     351             :     } else {
+     352           0 :         ecu_ptr = daemon->ecuid;
+     353             :     }
+     354             : 
+     355           0 :     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           0 :     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           0 :     } 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           0 :     } 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           0 :     return dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL, daemon, daemon_local,
+     382           0 :                 daemon_local->msg.headerbuffer, sizeof(DltStorageHeader),
+     383             :                 daemon_local->msg.headerbuffer + sizeof(DltStorageHeader),
+     384           0 :                 (int) (daemon_local->msg.headersize - sizeof(DltStorageHeader)),
+     385           0 :                 daemon_local->msg.databuffer, (int) daemon_local->msg.datasize, verbose);
+     386             : 
+     387             : }
+     388             : 
+     389          14 : 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          14 :     PRINT_FUNCTION_VERBOSE(verbose);
+     401             : 
+     402          14 :     if ((daemon == 0) || (msg == 0) || (apid == 0) || (ctid == 0))
+     403             :         return DLT_DAEMON_ERROR_UNKNOWN;
+     404             : 
+     405             :     /* prepare storage header */
+     406          14 :     msg->storageheader = (DltStorageHeader *)msg->headerbuffer;
+     407             : 
+     408          14 :     if (dlt_set_storageheader(msg->storageheader, daemon->ecuid) == DLT_RETURN_ERROR)
+     409             :         return DLT_DAEMON_ERROR_UNKNOWN;
+     410             : 
+     411             :     /* prepare standard header */
+     412          14 :     msg->standardheader = (DltStandardHeader *)(msg->headerbuffer + sizeof(DltStorageHeader));
+     413          14 :     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          14 :     msg->standardheader->mcnt = 0;
+     420             : 
+     421             :     /* Set header extra parameters */
+     422          14 :     dlt_set_id(msg->headerextra.ecu, daemon->ecuid);
+     423             : 
+     424             :     /*msg->headerextra.seid = 0; */
+     425             : 
+     426          14 :     msg->headerextra.tmsp = dlt_uptime();
+     427             : 
+     428          14 :     dlt_message_set_extraparameters(msg, verbose);
+     429             : 
+     430             :     /* prepare extended header */
+     431          14 :     msg->extendedheader =
+     432          14 :         (DltExtendedHeader *)(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+     433          14 :                               DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp));
+     434          14 :     msg->extendedheader->msin = DLT_MSIN_CONTROL_RESPONSE;
+     435             : 
+     436          14 :     msg->extendedheader->noar = 1; /* number of arguments */
+     437             : 
+     438          14 :     if (strcmp(apid, "") == 0)
+     439          14 :         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          14 :     if (strcmp(ctid, "") == 0)
+     444          14 :         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          14 :     msg->headersize = (uint32_t) (sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) +
+     450          14 :         DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp));
+     451             : 
+     452          14 :     len = (int32_t) (msg->headersize - sizeof(DltStorageHeader) + msg->datasize);
+     453             : 
+     454          14 :     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          14 :     msg->standardheader->len = DLT_HTOBE_16(((uint16_t)len));
+     460             : 
+     461          14 :     if ((ret =
+     462          14 :              dlt_daemon_client_send(sock, daemon, daemon_local, msg->headerbuffer, sizeof(DltStorageHeader),
+     463             :                                     msg->headerbuffer + sizeof(DltStorageHeader),
+     464          14 :                                     (int) (msg->headersize - sizeof(DltStorageHeader)),
+     465          14 :                                     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           9 : 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           9 :     PRINT_FUNCTION_VERBOSE(verbose);
+     483             : 
+     484           9 :     if ((daemon == NULL) || (daemon_local == NULL) || (msg == NULL))
+     485             :         return -1;
+     486             : 
+     487           9 :     if (msg->datasize < (int32_t)sizeof(uint32_t))
+     488             :         return -1;
+     489             : 
+     490           9 :     extra = msg->headerextra;
+     491             : 
+     492             :     /* check if the message needs to be forwarded */
+     493           9 :     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           9 :     id_tmp = *((uint32_t *)(msg->databuffer));
+     503           9 :     id = DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp);
+     504             : 
+     505           9 :     if ((id > DLT_SERVICE_ID) && (id < DLT_SERVICE_ID_CALLSW_CINJECTION)) {
+     506             :         /* Control message handling */
+     507           9 :         switch (id) {
+     508           1 :         case DLT_SERVICE_ID_SET_LOG_LEVEL:
+     509             :         {
+     510           1 :             dlt_daemon_control_set_log_level(sock, daemon, daemon_local, msg, verbose);
+     511           1 :             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           4 :         case DLT_SERVICE_ID_GET_LOG_INFO:
+     519             :         {
+     520           4 :             dlt_daemon_control_get_log_info(sock, daemon, daemon_local, msg, verbose);
+     521           4 :             break;
+     522             :         }
+     523           1 :         case DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL:
+     524             :         {
+     525           1 :             dlt_daemon_control_get_default_log_level(sock, daemon, daemon_local, verbose);
+     526           1 :             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           3 :         case DLT_SERVICE_ID_GET_SOFTWARE_VERSION:
+     673             :         {
+     674           3 :             dlt_daemon_control_get_software_version(sock, daemon, daemon_local, verbose);
+     675           3 :             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           0 :         case DLT_SERVICE_ID_OFFLINE_LOGSTORAGE:
+     684             :         {
+     685           0 :             dlt_daemon_control_service_logstorage(sock, daemon, daemon_local, msg, verbose);
+     686           0 :             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           3 : 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           3 :     PRINT_FUNCTION_VERBOSE(verbose);
+     742             : 
+     743           3 :     if (daemon == 0)
+     744           0 :         return;
+     745             : 
+     746             :     /* initialise new message */
+     747           3 :     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           3 :     len = (uint32_t) strlen(daemon->ECUVersionString);
+     759             : 
+     760             :     /* msg.datasize = sizeof(serviceID) + sizeof(status) + sizeof(length) + len */
+     761           3 :     msg.datasize = (uint32_t) (sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint32_t) + len);
+     762             : 
+     763           3 :     if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
+     764           0 :         free(msg.databuffer);
+     765           0 :         msg.databuffer = 0;
+     766             :     }
+     767             : 
+     768           3 :     if (msg.databuffer == 0) {
+     769           3 :         msg.databuffer = (uint8_t *)malloc(msg.datasize);
+     770           3 :         msg.databuffersize = msg.datasize;
+     771             :     }
+     772             : 
+     773           3 :     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           3 :     resp->service_id = DLT_SERVICE_ID_GET_SOFTWARE_VERSION;
+     785           3 :     resp->status = DLT_SERVICE_RESPONSE_OK;
+     786           3 :     resp->length = len;
+     787           3 :     memcpy(msg.databuffer + msg.datasize - len, daemon->ECUVersionString, len);
+     788             : 
+     789             :     /* send message */
+     790           3 :     dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose);
+     791             : 
+     792             :     /* free message */
+     793           3 :     dlt_message_free(&msg, 0);
+     794             : }
+     795             : 
+     796           1 : 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           1 :     PRINT_FUNCTION_VERBOSE(verbose);
+     802             : 
+     803           1 :     if (daemon == 0)
+     804           0 :         return;
+     805             : 
+     806             :     /* initialise new message */
+     807           1 :     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           1 :     msg.datasize = sizeof(DltServiceGetDefaultLogLevelResponse);
+     818             : 
+     819           1 :     if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
+     820           0 :         free(msg.databuffer);
+     821           0 :         msg.databuffer = 0;
+     822             :     }
+     823             : 
+     824           1 :     if (msg.databuffer == 0) {
+     825           1 :         msg.databuffer = (uint8_t *)malloc(msg.datasize);
+     826           1 :         msg.databuffersize = msg.datasize;
+     827             :     }
+     828             : 
+     829           1 :     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           1 :     resp->service_id = DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL;
+     841           1 :     resp->status = DLT_SERVICE_RESPONSE_OK;
+     842           1 :     resp->log_level = (uint8_t) daemon->default_log_level;
+     843             : 
+     844             :     /* send message */
+     845           1 :     dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose);
+     846             : 
+     847             :     /* free message */
+     848           1 :     dlt_message_free(&msg, 0);
+     849             : }
+     850             : 
+     851           4 : 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           4 :     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           4 :     PRINT_FUNCTION_VERBOSE(verbose);
+     883             : 
+     884           4 :     if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
+     885           0 :         return;
+     886             : 
+     887           4 :     if (dlt_check_rcv_data_size(msg->datasize, sizeof(DltServiceGetLogInfoRequest)) < 0)
+     888             :         return;
+     889             : 
+     890           4 :     user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+     891             : 
+     892           4 :     if (user_list == NULL)
+     893             :         return;
+     894             : 
+     895             :     /* prepare pointer to message request */
+     896           4 :     req = (DltServiceGetLogInfoRequest *)(msg->databuffer);
+     897             : 
+     898             :     /* initialise new message */
+     899           4 :     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           4 :     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           4 :     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           4 :         num_applications = user_list->num_applications;
+     950           4 :         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           4 :     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           4 :     if ((req->options == 5) || (req->options == 6) || (req->options == 7))
+     966           4 :         sizecont += sizeof(int8_t); /* trace status */
+     967             : 
+     968           4 :     resp.datasize += (uint32_t) (((uint32_t) num_applications * (sizeof(uint32_t) /* app_id */ + sizeof(uint16_t) /* count_con_ids */)) +
+     969           4 :         ((size_t) num_contexts * sizecont));
+     970             : 
+     971           4 :     resp.datasize += (uint32_t) sizeof(uint16_t) /* count_app_ids */;
+     972             : 
+     973             :     /* Add additional size for response of Mode 7 */
+     974           4 :     if (req->options == 7) {
+     975           4 :         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           4 :             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           4 :             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           4 :     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           4 :     resp.databuffer = (uint8_t *)malloc(resp.datasize);
+    1043           4 :     resp.databuffersize = resp.datasize;
+    1044             : 
+    1045           4 :     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           4 :     sid = DLT_SERVICE_ID_GET_LOG_INFO;
+    1060             :     memcpy(resp.databuffer, &sid, sizeof(uint32_t));
+    1061             :     offset += sizeof(uint32_t);
+    1062             : 
+    1063           4 :     value = (int8_t) (((num_applications != 0) && (num_contexts != 0)) ? req->options : 8); /* 8 = no matching context found */
+    1064             : 
+    1065           4 :     memcpy(resp.databuffer + offset, &value, sizeof(int8_t));
+    1066             :     offset += sizeof(int8_t);
+    1067             : 
+    1068           4 :     count_app_ids = (uint16_t) num_applications;
+    1069             : 
+    1070           4 :     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           4 :     dlt_set_id((char *)(resp.databuffer + offset), DLT_DAEMON_REMO_STRING);
+    1211             : 
+    1212             :     /* send message */
+    1213           4 :     dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &resp, "", "", verbose);
+    1214             : 
+    1215             :     /* free message */
+    1216           4 :     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           1 : 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           1 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1291             : 
+    1292           1 :     if (daemon == 0)
+    1293           0 :         return;
+    1294             : 
+    1295             :     /* initialise new message */
+    1296           1 :     if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+    1297             :         return;
+    1298             : 
+    1299             :     /* prepare payload of data */
+    1300           1 :     msg.datasize = sizeof(DltServiceResponse);
+    1301             : 
+    1302           1 :     if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
+    1303           0 :         free(msg.databuffer);
+    1304           0 :         msg.databuffer = 0;
+    1305             :     }
+    1306             : 
+    1307           1 :     if (msg.databuffer == 0) {
+    1308           1 :         msg.databuffer = (uint8_t *)malloc(msg.datasize);
+    1309           1 :         msg.databuffersize = msg.datasize;
+    1310             :     }
+    1311             : 
+    1312           1 :     if (msg.databuffer == 0)
+    1313             :         return;
+    1314             : 
+    1315             :     resp = (DltServiceResponse *)msg.databuffer;
+    1316           1 :     resp->service_id = service_id;
+    1317           1 :     resp->status = (uint8_t) status;
+    1318             : 
+    1319             :     /* send message */
+    1320           1 :     dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose);
+    1321             : 
+    1322             :     /* free message */
+    1323           1 :     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           5 : 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           5 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1392             : 
+    1393           5 :     if (daemon == 0)
+    1394             :         return -1;
+    1395             : 
+    1396             :     /* initialise new message */
+    1397           5 :     if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+    1398             :         return -1;
+    1399             : 
+    1400             :     /* prepare payload of data */
+    1401           5 :     msg.datasize = sizeof(DltServiceConnectionInfo);
+    1402             : 
+    1403           5 :     if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
+    1404           0 :         free(msg.databuffer);
+    1405           0 :         msg.databuffer = 0;
+    1406             :     }
+    1407             : 
+    1408           5 :     if (msg.databuffer == 0) {
+    1409           5 :         msg.databuffer = (uint8_t *)malloc(msg.datasize);
+    1410           5 :         msg.databuffersize = msg.datasize;
+    1411             :     }
+    1412             : 
+    1413           5 :     if (msg.databuffer == 0)
+    1414             :         return -1;
+    1415             : 
+    1416             :     resp = (DltServiceConnectionInfo *)msg.databuffer;
+    1417           5 :     resp->service_id = DLT_SERVICE_ID_CONNECTION_INFO;
+    1418           5 :     resp->status = DLT_SERVICE_RESPONSE_OK;
+    1419           5 :     resp->state = state;
+    1420           5 :     dlt_set_id(resp->comid, comid);
+    1421             : 
+    1422             :     /* send message */
+    1423           5 :     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           5 :     dlt_message_free(&msg, 0);
+    1430             : 
+    1431           5 :     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           1 : void dlt_daemon_control_set_log_level(int sock,
+    1735             :                                       DltDaemon *daemon,
+    1736             :                                       DltDaemonLocal *daemon_local,
+    1737             :                                       DltMessage *msg,
+    1738             :                                       int verbose)
+    1739             : {
+    1740           1 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1741             : 
+    1742           1 :     char apid[DLT_ID_SIZE + 1] = { 0 };
+    1743           1 :     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           1 :     if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
+    1750           0 :         return;
+    1751             : 
+    1752           1 :     if (dlt_check_rcv_data_size(msg->datasize, sizeof(DltServiceSetLogLevel)) < 0)
+    1753             :         return;
+    1754             : 
+    1755           1 :     req = (DltServiceSetLogLevel *)(msg->databuffer);
+    1756             : 
+    1757           1 :     if (daemon_local->flags.enforceContextLLAndTS)
+    1758           0 :         req->log_level = (uint8_t) getStatus(req->log_level, daemon_local->flags.contextLogLevel);
+    1759             : 
+    1760           1 :     dlt_set_id(apid, req->apid);
+    1761           1 :     dlt_set_id(ctid, req->ctid);
+    1762           1 :     apid_length = (int8_t) strlen(apid);
+    1763           1 :     ctid_length = (int8_t) strlen(ctid);
+    1764             : 
+    1765           1 :     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           1 :     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           1 :     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           1 :     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           1 :         context = dlt_daemon_context_find(daemon,
+    1810             :                                           apid,
+    1811             :                                           ctid,
+    1812           1 :                                           daemon->ecuid,
+    1813             :                                           verbose);
+    1814             : 
+    1815             :         /* Set log level */
+    1816           1 :         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           1 :             dlt_vlog(LOG_ERR, "Could not set log level: %d. Context [%.4s:%.4s] not found:", req->log_level, apid,
+    1821             :                      ctid);
+    1822           1 :             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           1 : int dlt_daemon_process_one_s_timer(DltDaemon *daemon,
+    2265             :                                    DltDaemonLocal *daemon_local,
+    2266             :                                    DltReceiver *receiver,
+    2267             :                                    int verbose)
+    2268             : {
+    2269           1 :     uint64_t expir = 0;
+    2270             :     ssize_t res = 0;
+    2271             : 
+    2272           1 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2273             : 
+    2274           1 :     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           1 :     res = read(receiver->fd, &expir, sizeof(expir));
+    2280             : 
+    2281           1 :     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           1 :     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           1 :     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           1 :     dlt_log(LOG_DEBUG, "Timer timingpacket\n");
+    2305             : 
+    2306           1 :     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           0 : 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           0 :     struct stat daemon_mpoint_st = {0};
+    2432             :     int daemon_st_status = 0;
+    2433             : 
+    2434           0 :     struct stat req_mpoint_st = {0};
+    2435             :     int req_st_status = 0;
+    2436             : 
+    2437           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2438             : 
+    2439           0 :     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           0 :     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           0 :     if (dlt_check_rcv_data_size(msg->datasize, sizeof(DltServiceOfflineLogstorage)) < 0)
+    2460             :         return;
+    2461             : 
+    2462           0 :     req = (DltServiceOfflineLogstorage *)(msg->databuffer);
+    2463             : 
+    2464           0 :     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           0 :     for (i = 0; i < (uint32_t) daemon_local->flags.offlineLogstorageMaxDevices; i++) {
+    2483           0 :         connection_type = daemon->storage_handle[i].connection_type;
+    2484             : 
+    2485             :         memset(&daemon_mpoint_st, 0, sizeof(struct stat));
+    2486           0 :         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           0 :         if ((connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) &&
+    2515           0 :             (device_index == -1))
+    2516           0 :             device_index = (int) i;
+    2517             :     }
+    2518             : 
+    2519             :     /* It might be possible to sync all caches of all devices */
+    2520           0 :     if ((req->connection_type == DLT_OFFLINE_LOGSTORAGE_SYNC_CACHES) &&
+    2521           0 :         (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           0 :     device = &daemon->storage_handle[device_index];
+    2538             : 
+    2539           0 :     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           0 :     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           0 :     else if (req->connection_type == DLT_OFFLINE_LOGSTORAGE_SYNC_CACHES)
+    2606             :     {
+    2607             :         ret = 0;
+    2608             : 
+    2609           0 :         if (device_index == -1) { /* sync all Logstorage devices */
+    2610             : 
+    2611           0 :             for (i = 0; i < (uint32_t) daemon_local->flags.offlineLogstorageMaxDevices; i++)
+    2612           0 :                 if (daemon->storage_handle[i].connection_type ==
+    2613             :                     DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED)
+    2614           0 :                     ret = dlt_daemon_logstorage_sync_cache(
+    2615             :                         daemon,
+    2616             :                         daemon_local,
+    2617           0 :                         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           0 :         if (ret == 0)
+    2629           0 :             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..06ebaeafc --- /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:28461945.9 %
Date:2023-09-01 07:46:27Functions:203262.5 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_application_del0
dlt_daemon_applications_save0
dlt_daemon_cmp_apid0
dlt_daemon_configuration_save0
dlt_daemon_context_del0
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_log_state0
dlt_daemon_user_send_all_log_state1
dlt_daemon_application_reset_user_handle2
dlt_daemon_applications_load2
dlt_daemon_configuration_load2
dlt_daemon_free2
dlt_daemon_init_runtime_configuration2
dlt_daemon_application_add3
dlt_daemon_applications_clear3
dlt_daemon_context_add3
dlt_daemon_contexts_clear3
dlt_daemon_user_send_log_level3
dlt_daemon_change_state4
dlt_daemon_applications_invalidate_fd5
dlt_daemon_contexts_invalidate_fd5
dlt_daemon_cmp_apid_ctid6
dlt_daemon_application_find9
dlt_daemon_init10
dlt_daemon_init_user_information11
dlt_daemon_context_find12
dlt_daemon_find_users_list51
+
+
+ + + +
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..6b6796ad4 --- /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:28461945.9 %
Date:2023-09-01 07:46:27Functions:203262.5 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_application_add3
dlt_daemon_application_del0
dlt_daemon_application_find9
dlt_daemon_application_reset_user_handle2
dlt_daemon_applications_clear3
dlt_daemon_applications_invalidate_fd5
dlt_daemon_applications_load2
dlt_daemon_applications_save0
dlt_daemon_change_state4
dlt_daemon_cmp_apid0
dlt_daemon_cmp_apid_ctid6
dlt_daemon_configuration_load2
dlt_daemon_configuration_save0
dlt_daemon_context_add3
dlt_daemon_context_del0
dlt_daemon_context_find12
dlt_daemon_contexts_clear3
dlt_daemon_contexts_invalidate_fd5
dlt_daemon_contexts_load0
dlt_daemon_contexts_save0
dlt_daemon_control_reset_to_factory_default0
dlt_daemon_find_users_list51
dlt_daemon_free2
dlt_daemon_init10
dlt_daemon_init_runtime_configuration2
dlt_daemon_init_user_information11
dlt_daemon_user_send_all_log_level_update0
dlt_daemon_user_send_all_log_state1
dlt_daemon_user_send_all_trace_status_update0
dlt_daemon_user_send_default_update0
dlt_daemon_user_send_log_level3
dlt_daemon_user_send_log_state0
+
+
+ + + +
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..25320b58d --- /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:28461945.9 %
Date:2023-09-01 07:46:27Functions:203262.5 %
+
+ + + + + + + + +

+
          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           6 :     if ((m1 == NULL) || (m2 == NULL))
+      94             :         return -1;
+      95             : 
+      96             :     DltDaemonApplication *mi1 = (DltDaemonApplication *)m1;
+      97             :     DltDaemonApplication *mi2 = (DltDaemonApplication *)m2;
+      98             : 
+      99           6 :     return memcmp(mi1->apid, mi2->apid, DLT_ID_SIZE);
+     100             : }
+     101             : 
+     102           6 : static int dlt_daemon_cmp_apid_ctid(const void *m1, const void *m2)
+     103             : {
+     104           6 :     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           6 :     cmp = memcmp(mi1->apid, mi2->apid, DLT_ID_SIZE);
+     112             : 
+     113           6 :     if (cmp < 0)
+     114             :         ret = -1;
+     115           6 :     else if (cmp == 0)
+     116           6 :         ret = memcmp(mi1->ctid, mi2->ctid, DLT_ID_SIZE);
+     117             :     else
+     118             :         ret = 1;
+     119             : 
+     120             :     return ret;
+     121             : }
+     122             : 
+     123          51 : DltDaemonRegisteredUsers *dlt_daemon_find_users_list(DltDaemon *daemon,
+     124             :                                                      char *ecu,
+     125             :                                                      int verbose)
+     126             : {
+     127          51 :     PRINT_FUNCTION_VERBOSE(verbose);
+     128             : 
+     129             :     int i = 0;
+     130             : 
+     131          51 :     if ((daemon == NULL) || (ecu == NULL)) {
+     132           0 :         dlt_vlog(LOG_ERR, "%s: Wrong parameters", __func__);
+     133           0 :         return (DltDaemonRegisteredUsers *)NULL;
+     134             :     }
+     135             : 
+     136          53 :     for (i = 0; i < daemon->num_user_lists; i++)
+     137          53 :         if (strncmp(ecu, daemon->user_list[i].ecu, DLT_ID_SIZE) == 0)
+     138          51 :             return &daemon->user_list[i];
+     139             : 
+     140           0 :     dlt_vlog(LOG_ERR, "Cannot find user list for ECU: %4s\n", ecu);
+     141           0 :     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           2 : int dlt_daemon_init_runtime_configuration(DltDaemon *daemon, const char *runtime_directory, int verbose)
+     230             : {
+     231           2 :     PRINT_FUNCTION_VERBOSE(verbose);
+     232             :     size_t append_length = 0;
+     233             : 
+     234           2 :     if (daemon == NULL)
+     235             :         return DLT_RETURN_ERROR;
+     236             : 
+     237             :     /* Default */
+     238           2 :     daemon->mode = DLT_USER_MODE_EXTERNAL;
+     239             : 
+     240           2 :     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           2 :     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           2 :         strncpy(daemon->runtime_application_cfg, DLT_RUNTIME_DEFAULT_DIRECTORY, append_length);
+     252           2 :         daemon->runtime_application_cfg[append_length] = 0;
+     253             :     }
+     254             : 
+     255           2 :     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           2 :     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           2 :         strncpy(daemon->runtime_context_cfg, DLT_RUNTIME_DEFAULT_DIRECTORY, append_length);
+     265           2 :         daemon->runtime_context_cfg[append_length] = 0;
+     266             :     }
+     267             : 
+     268           2 :     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           2 :     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           2 :         strncpy(daemon->runtime_configuration, DLT_RUNTIME_DEFAULT_DIRECTORY, append_length);
+     278           2 :         daemon->runtime_configuration[append_length] = 0;
+     279             :     }
+     280             : 
+     281           2 :     strcat(daemon->runtime_configuration, DLT_RUNTIME_CONFIGURATION); /* strcat uncritical here, because max length already checked */
+     282             : 
+     283           2 :     return DLT_RETURN_OK;
+     284             : }
+     285             : 
+     286          10 : 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          10 :     PRINT_FUNCTION_VERBOSE(verbose);
+     297             : 
+     298          10 :     if ((daemon == NULL) || (runtime_directory == NULL))
+     299             :         return -1;
+     300             : 
+     301          10 :     daemon->user_list = NULL;
+     302          10 :     daemon->num_user_lists = 0;
+     303             : 
+     304          10 :     daemon->default_log_level = (int8_t) InitialContextLogLevel;
+     305          10 :     daemon->default_trace_status = (int8_t) InitialContextTraceStatus;
+     306          10 :     daemon->force_ll_ts = (int8_t) ForceLLTS;
+     307             : 
+     308          10 :     daemon->overflow_counter = 0;
+     309             : 
+     310          10 :     daemon->runtime_context_cfg_loaded = 0;
+     311             : 
+     312          10 :     daemon->connectionState = 0; /* no logger connected */
+     313             : 
+     314          10 :     daemon->state = DLT_DAEMON_STATE_INIT; /* initial logging state */
+     315             : 
+     316          10 :     daemon->sendserialheader = 0;
+     317          10 :     daemon->timingpackets = 0;
+     318             : 
+     319          10 :     dlt_set_id(daemon->ecuid, "");
+     320             : 
+     321             :     /* initialize ring buffer for client connection */
+     322          10 :     dlt_vlog(LOG_INFO, "Ringbuffer configuration: %lu/%lu/%lu\n",
+     323             :              RingbufferMinSize, RingbufferMaxSize, RingbufferStepSize);
+     324             : 
+     325          10 :     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          10 :     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          10 :     return 0;
+     336             : }
+     337             : 
+     338           2 : int dlt_daemon_free(DltDaemon *daemon, int verbose)
+     339             : {
+     340             :     int i = 0;
+     341             :     DltDaemonRegisteredUsers *user_list = NULL;
+     342             : 
+     343           2 :     PRINT_FUNCTION_VERBOSE(verbose);
+     344             : 
+     345           2 :     if ((daemon == NULL) || (daemon->user_list == NULL))
+     346             :         return -1;
+     347             : 
+     348             :     /* free all registered user information */
+     349           5 :     for (i = 0; i < daemon->num_user_lists; i++) {
+     350           3 :         user_list = &daemon->user_list[i];
+     351             : 
+     352           3 :         if (user_list != NULL) {
+     353             :             /* ignore return values */
+     354           3 :             dlt_daemon_contexts_clear(daemon, user_list->ecu, verbose);
+     355           3 :             dlt_daemon_applications_clear(daemon, user_list->ecu, verbose);
+     356             :         }
+     357             :     }
+     358             : 
+     359           2 :     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           2 :     if (app_recv_buffer)
+     368           2 :         free(app_recv_buffer);
+     369             : 
+     370             :     /* free ringbuffer */
+     371           2 :     dlt_buffer_free_dynamic(&(daemon->client_ringbuffer));
+     372             : 
+     373           2 :     return 0;
+     374             : }
+     375             : 
+     376          11 : 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          11 :     PRINT_FUNCTION_VERBOSE(verbose);
+     385             : 
+     386          11 :     if ((daemon == NULL) || ((gateway_mode == 1) && (gateway == NULL)))
+     387             :         return DLT_RETURN_ERROR;
+     388             : 
+     389          11 :     if (gateway_mode == 0) {
+     390             :         /* initialize application list */
+     391          10 :         daemon->user_list = calloc((size_t) nodes, sizeof(DltDaemonRegisteredUsers));
+     392             : 
+     393          10 :         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          10 :         dlt_set_id(daemon->user_list[0].ecu, daemon->ecuid);
+     399          10 :         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           5 : 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           5 :     PRINT_FUNCTION_VERBOSE(verbose);
+     431             : 
+     432           5 :     if ((daemon == NULL) || (ecu == NULL))
+     433             :         return DLT_RETURN_ERROR;
+     434             : 
+     435           5 :     user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+     436             : 
+     437           5 :     if (user_list != NULL) {
+     438           7 :         for (i = 0; i < user_list->num_applications; i++)
+     439           2 :             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           3 : int dlt_daemon_applications_clear(DltDaemon *daemon, char *ecu, int verbose)
+     449             : {
+     450             :     int i;
+     451             :     DltDaemonRegisteredUsers *user_list = NULL;
+     452             : 
+     453           3 :     PRINT_FUNCTION_VERBOSE(verbose);
+     454             : 
+     455           3 :     if ((daemon == NULL) || (daemon->user_list == NULL) || (ecu == NULL))
+     456             :         return DLT_RETURN_WRONG_PARAMETER;
+     457             : 
+     458           3 :     user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+     459             : 
+     460           3 :     if (user_list == NULL)
+     461             :         return DLT_RETURN_ERROR;
+     462             : 
+     463           3 :     for (i = 0; i < user_list->num_applications; i++)
+     464           0 :         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           0 :             free(user_list->applications[i].application_description);
+     472           0 :             user_list->applications[i].application_description = NULL;
+     473             :         }
+     474             : 
+     475           3 :     if (user_list->applications != NULL)
+     476           0 :         free(user_list->applications);
+     477             : 
+     478           3 :     user_list->applications = NULL;
+     479           3 :     user_list->num_applications = 0;
+     480             : 
+     481           3 :     return 0;
+     482             : }
+     483             : 
+     484           2 : 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           2 :     if (application->user_handle == DLT_FD_INIT)
+     493             :         return;
+     494             : 
+     495           0 :     user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+     496           0 :     if (user_list != NULL) {
+     497           0 :         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           0 :     if (application->owns_user_handle)
+     505           0 :         close(application->user_handle);
+     506             : 
+     507           0 :     application->user_handle = DLT_FD_INIT;
+     508           0 :     application->owns_user_handle = false;
+     509             : }
+     510             : 
+     511           3 : 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           3 :     if ((daemon == NULL) || (apid == NULL) || (apid[0] == '\0') || (ecu == NULL))
+     531             :         return (DltDaemonApplication *)NULL;
+     532             : 
+     533           3 :     user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+     534             : 
+     535           3 :     if (user_list == NULL)
+     536             :         return (DltDaemonApplication *)NULL;
+     537             : 
+     538           3 :     if (user_list->applications == NULL) {
+     539           3 :         user_list->applications = (DltDaemonApplication *)
+     540           3 :             malloc(sizeof(DltDaemonApplication) * DLT_DAEMON_APPL_ALLOC_SIZE);
+     541             : 
+     542           3 :         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           3 :     application = dlt_daemon_application_find(daemon, apid, ecu, verbose);
+     550             : 
+     551           3 :     if (application == NULL) {
+     552           3 :         user_list->num_applications += 1;
+     553             : 
+     554           3 :         if (user_list->num_applications != 0) {
+     555           3 :             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           3 :         application = &(user_list->applications[user_list->num_applications - 1]);
+     577             : 
+     578           3 :         dlt_set_id(application->apid, apid);
+     579           3 :         application->pid = 0;
+     580           3 :         application->application_description = NULL;
+     581           3 :         application->num_contexts = 0;
+     582           3 :         application->user_handle = DLT_FD_INIT;
+     583           3 :         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           3 :     if (application->application_description) {
+     600           0 :         free(application->application_description);
+     601           0 :         application->application_description = NULL;
+     602             :     }
+     603             : 
+     604           3 :     if (description != NULL) {
+     605           3 :         application->application_description = malloc(strlen(description) + 1);
+     606             : 
+     607           3 :         if (application->application_description) {
+     608           3 :             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           3 :     if (application->pid != pid) {
+     617           2 :         dlt_daemon_application_reset_user_handle(daemon, application, verbose);
+     618           2 :         application->pid = 0;
+     619             :     }
+     620             : 
+     621             :     /* open user pipe only if it is not yet opened */
+     622           3 :     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           2 :             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           2 :         dlt_daemon_applications_invalidate_fd(daemon, ecu, dlt_user_handle, verbose);
+     653           2 :         dlt_daemon_contexts_invalidate_fd(daemon, ecu, dlt_user_handle, verbose);
+     654             : 
+     655           2 :         application->user_handle = dlt_user_handle;
+     656           2 :         application->owns_user_handle = owns_user_handle;
+     657           2 :         application->pid = pid;
+     658             :     }
+     659             : 
+     660             :     /* Sort */
+     661           3 :     if (new_application) {
+     662           3 :         qsort(user_list->applications,
+     663           3 :               (size_t) user_list->num_applications,
+     664             :               sizeof(DltDaemonApplication),
+     665             :               dlt_daemon_cmp_apid);
+     666             : 
+     667             :         /* Find new position of application with apid*/
+     668           3 :         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           0 : 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           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+     688             : 
+     689           0 :     if ((daemon == NULL) || (application == NULL) || (ecu == NULL))
+     690             :         return -1;
+     691             : 
+     692           0 :     user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+     693             : 
+     694           0 :     if (user_list == NULL)
+     695             :         return -1;
+     696             : 
+     697           0 :     if (user_list->num_applications > 0) {
+     698           0 :         dlt_daemon_application_reset_user_handle(daemon, application, verbose);
+     699             : 
+     700             :         /* Free description of application to be deleted */
+     701           0 :         if (application->application_description) {
+     702           0 :             free(application->application_description);
+     703           0 :             application->application_description = NULL;
+     704             :         }
+     705             : 
+     706           0 :         pos = (int) (application - (user_list->applications));
+     707             : 
+     708             :         /* move all applications above pos to pos */
+     709           0 :         memmove(&(user_list->applications[pos]),
+     710           0 :                 &(user_list->applications[pos + 1]),
+     711           0 :                 sizeof(DltDaemonApplication) * ((user_list->num_applications - 1) - pos));
+     712             : 
+     713             :         /* Clear last application */
+     714           0 :         memset(&(user_list->applications[user_list->num_applications - 1]),
+     715             :                0,
+     716             :                sizeof(DltDaemonApplication));
+     717             : 
+     718           0 :         user_list->num_applications--;
+     719             :     }
+     720             : 
+     721             :     return 0;
+     722             : }
+     723             : 
+     724           9 : 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           9 :     PRINT_FUNCTION_VERBOSE(verbose);
+     733             : 
+     734           9 :     if ((daemon == NULL) || (daemon->user_list == NULL) || (apid == NULL) ||
+     735           9 :         (apid[0] == '\0') || (ecu == NULL))
+     736             :         return (DltDaemonApplication *)NULL;
+     737             : 
+     738           9 :     user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+     739             : 
+     740           9 :     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           6 :     if ((memcmp(apid, user_list->applications[0].apid, DLT_ID_SIZE) < 0) ||
+     745           6 :         (memcmp(apid,
+     746           6 :                 user_list->applications[user_list->num_applications - 1].apid,
+     747             :                 DLT_ID_SIZE) > 0))
+     748             :         return (DltDaemonApplication *)NULL;
+     749             : 
+     750           6 :     dlt_set_id(application.apid, apid);
+     751           6 :     return (DltDaemonApplication *)bsearch(&application,
+     752           6 :                                            user_list->applications,
+     753           6 :                                            (size_t) user_list->num_applications,
+     754             :                                            sizeof(DltDaemonApplication),
+     755             :                                            dlt_daemon_cmp_apid);
+     756             : }
+     757             : 
+     758           2 : 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           2 :     PRINT_FUNCTION_VERBOSE(verbose);
+     767             : 
+     768           2 :     if ((daemon == NULL) || (filename == NULL) || (filename[0] == '\0'))
+     769             :         return -1;
+     770             : 
+     771           2 :     fd = fopen(filename, "r");
+     772             : 
+     773           2 :     if (fd == NULL) {
+     774           2 :         dlt_vlog(LOG_WARNING,
+     775             :                  "%s: cannot open file %s: %s\n",
+     776             :                  __func__,
+     777             :                  filename,
+     778           2 :                  strerror(errno));
+     779             : 
+     780           2 :         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           3 : 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           3 :     PRINT_FUNCTION_VERBOSE(verbose);
+     917             : 
+     918           3 :     if ((daemon == NULL) || (apid == NULL) || (apid[0] == '\0') ||
+     919           3 :         (ctid == NULL) || (ctid[0] == '\0') || (ecu == NULL))
+     920             :         return (DltDaemonContext *)NULL;
+     921             : 
+     922           3 :     if ((log_level < DLT_LOG_DEFAULT) || (log_level > DLT_LOG_VERBOSE))
+     923             :         return (DltDaemonContext *)NULL;
+     924             : 
+     925           3 :     if ((trace_status < DLT_TRACE_STATUS_DEFAULT) || (trace_status > DLT_TRACE_STATUS_ON))
+     926             :         return (DltDaemonContext *)NULL;
+     927             : 
+     928           3 :     user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+     929             : 
+     930           3 :     if (user_list == NULL)
+     931             :         return (DltDaemonContext *)NULL;
+     932             : 
+     933           3 :     if (user_list->contexts == NULL) {
+     934           3 :         user_list->contexts = (DltDaemonContext *)malloc(sizeof(DltDaemonContext) * DLT_DAEMON_CONTEXT_ALLOC_SIZE);
+     935             : 
+     936           3 :         if (user_list->contexts == NULL)
+     937             :             return (DltDaemonContext *)NULL;
+     938             :     }
+     939             : 
+     940             :     /* Check if application [apid] is available */
+     941           3 :     application = dlt_daemon_application_find(daemon, apid, ecu, verbose);
+     942             : 
+     943           3 :     if (application == NULL)
+     944             :         return (DltDaemonContext *)NULL;
+     945             : 
+     946             :     /* Check if context [apid, ctid] is already available */
+     947           3 :     context = dlt_daemon_context_find(daemon, apid, ctid, ecu, verbose);
+     948             : 
+     949           3 :     if (context == NULL) {
+     950           3 :         user_list->num_contexts += 1;
+     951             : 
+     952           3 :         if (user_list->num_contexts != 0) {
+     953           3 :             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           3 :         context = &(user_list->contexts[user_list->num_contexts - 1]);
+     975             :         memset(context, 0, sizeof(DltDaemonContext));
+     976             : 
+     977           3 :         dlt_set_id(context->apid, apid);
+     978           3 :         dlt_set_id(context->ctid, ctid);
+     979             : 
+     980           3 :         application->num_contexts++;
+     981             :         new_context = 1;
+     982             :     }
+     983             : 
+     984             :     /* Set context description */
+     985           3 :     if (context->context_description) {
+     986           0 :         free(context->context_description);
+     987           0 :         context->context_description = NULL;
+     988             :     }
+     989             : 
+     990           3 :     if (description != NULL) {
+     991           3 :         context->context_description = malloc(strlen(description) + 1);
+     992             : 
+     993           3 :         if (context->context_description) {
+     994           3 :             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           3 :     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           3 :     if ((new_context == 1) ||
+    1051           0 :         ((new_context == 0) && (daemon->runtime_context_cfg_loaded == 0))) {
+    1052           3 :         context->log_level = log_level;
+    1053           3 :         context->trace_status = trace_status;
+    1054             :     }
+    1055             : 
+    1056           3 :     context->log_level_pos = log_level_pos;
+    1057           3 :     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           3 :     if (context->user_handle == 0)
+    1063           0 :         context->predefined = true;
+    1064             :     else
+    1065           3 :         context->predefined = false;
+    1066             : 
+    1067             :     /* Sort */
+    1068           3 :     if (new_context) {
+    1069           3 :         qsort(user_list->contexts,
+    1070           3 :               (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           3 :         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           0 : 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           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1128             : 
+    1129           0 :     if ((daemon == NULL) || (context == NULL) || (ecu == NULL))
+    1130             :         return -1;
+    1131             : 
+    1132           0 :     user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+    1133             : 
+    1134           0 :     if (user_list == NULL)
+    1135             :         return -1;
+    1136             : 
+    1137           0 :     if (user_list->num_contexts > 0) {
+    1138           0 :         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           0 :         if (context->context_description) {
+    1145           0 :             free(context->context_description);
+    1146           0 :             context->context_description = NULL;
+    1147             :         }
+    1148             : 
+    1149           0 :         pos = (int) (context - (user_list->contexts));
+    1150             : 
+    1151             :         /* move all contexts above pos to pos */
+    1152           0 :         memmove(&(user_list->contexts[pos]),
+    1153           0 :                 &(user_list->contexts[pos + 1]),
+    1154           0 :                 sizeof(DltDaemonContext) * ((user_list->num_contexts - 1) - pos));
+    1155             : 
+    1156             :         /* Clear last context */
+    1157           0 :         memset(&(user_list->contexts[user_list->num_contexts - 1]),
+    1158             :                0,
+    1159             :                sizeof(DltDaemonContext));
+    1160             : 
+    1161           0 :         user_list->num_contexts--;
+    1162             : 
+    1163             :         /* Check if application [apid] is available */
+    1164           0 :         if (application != NULL)
+    1165           0 :             application->num_contexts--;
+    1166             :     }
+    1167             : 
+    1168             :     return 0;
+    1169             : }
+    1170             : 
+    1171          12 : 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          12 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1181             : 
+    1182          12 :     if ((daemon == NULL) || (apid == NULL) || (apid[0] == '\0') ||
+    1183          12 :         (ctid == NULL) || (ctid[0] == '\0') || (ecu == NULL))
+    1184             :         return (DltDaemonContext *)NULL;
+    1185             : 
+    1186          12 :     user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+    1187             : 
+    1188          12 :     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           6 :     if ((memcmp(apid, user_list->contexts[0].apid, DLT_ID_SIZE) < 0) ||
+    1193           6 :         (memcmp(apid,
+    1194           6 :                 user_list->contexts[user_list->num_contexts - 1].apid,
+    1195             :                 DLT_ID_SIZE) > 0))
+    1196             :         return (DltDaemonContext *)NULL;
+    1197             : 
+    1198           6 :     dlt_set_id(context.apid, apid);
+    1199           6 :     dlt_set_id(context.ctid, ctid);
+    1200             : 
+    1201           6 :     return (DltDaemonContext *)bsearch(&context,
+    1202           6 :                                        user_list->contexts,
+    1203           6 :                                        (size_t) user_list->num_contexts,
+    1204             :                                        sizeof(DltDaemonContext),
+    1205             :                                        dlt_daemon_cmp_apid_ctid);
+    1206             : }
+    1207             : 
+    1208           5 : 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           5 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1217             : 
+    1218           5 :     if ((daemon == NULL) || (ecu == NULL))
+    1219             :         return -1;
+    1220             : 
+    1221           5 :     user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+    1222             : 
+    1223           5 :     if (user_list != NULL) {
+    1224           5 :         for (i = 0; i < user_list->num_contexts; i++)
+    1225           0 :             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           3 : int dlt_daemon_contexts_clear(DltDaemon *daemon, char *ecu, int verbose)
+    1235             : {
+    1236             :     int i;
+    1237             :     DltDaemonRegisteredUsers *users = NULL;
+    1238             : 
+    1239           3 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1240             : 
+    1241           3 :     if ((daemon == NULL) || (ecu == NULL))
+    1242             :         return DLT_RETURN_WRONG_PARAMETER;
+    1243             : 
+    1244           3 :     users = dlt_daemon_find_users_list(daemon, ecu, verbose);
+    1245             : 
+    1246           3 :     if (users == NULL)
+    1247             :         return DLT_RETURN_ERROR;
+    1248             : 
+    1249           3 :     for (i = 0; i < users->num_contexts; i++)
+    1250           0 :         if (users->contexts[i].context_description != NULL) {
+    1251           0 :             free(users->contexts[i].context_description);
+    1252           0 :             users->contexts[i].context_description = NULL;
+    1253             :         }
+    1254             : 
+    1255           3 :     if (users->contexts) {
+    1256           0 :         free(users->contexts);
+    1257           0 :         users->contexts = NULL;
+    1258             :     }
+    1259             : 
+    1260           3 :     for (i = 0; i < users->num_applications; i++)
+    1261           0 :         users->applications[i].num_contexts = 0;
+    1262             : 
+    1263           3 :     users->num_contexts = 0;
+    1264             : 
+    1265           3 :     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           2 : int dlt_daemon_configuration_load(DltDaemon *daemon, const char *filename, int verbose)
+    1454             : {
+    1455           2 :     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           2 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1465             : 
+    1466           2 :     pFile = fopen (filename, "r");
+    1467             : 
+    1468           2 :     if (pFile != NULL) {
+    1469             :         while (1) {
+    1470             :             /* fetch line from configuration file */
+    1471           4 :             if (fgets (line, 1024, pFile) != NULL) {
+    1472           2 :                 pch = strtok (line, " =\r\n");
+    1473           2 :                 token[0] = 0;
+    1474           2 :                 value[0] = 0;
+    1475             : 
+    1476           4 :                 while (pch != NULL) {
+    1477           2 :                     if (strcmp(pch, "#") == 0)
+    1478             :                         break;
+    1479             : 
+    1480           2 :                     if (token[0] == 0) {
+    1481             :                         strncpy(token, pch, sizeof(token) - 1);
+    1482           2 :                         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           2 :                     pch = strtok (NULL, " =\r\n");
+    1491             :                 }
+    1492             : 
+    1493           2 :                 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           2 :         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           3 : 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           3 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1528             : 
+    1529           3 :     if ((daemon == NULL) || (context == NULL)) {
+    1530           0 :         dlt_vlog(LOG_ERR, "NULL parameter in %s", __func__);
+    1531           0 :         return -1;
+    1532             :     }
+    1533             : 
+    1534           3 :     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           3 :     if ((context->storage_log_level != DLT_LOG_DEFAULT) &&
+    1540           2 :         (daemon->maintain_logstorage_loglevel != DLT_MAINTAIN_LOGSTORAGE_LOGLEVEL_OFF))
+    1541           0 :             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           3 :         usercontext.log_level =
+    1545           3 :             (uint8_t) ((context->log_level == DLT_LOG_DEFAULT) ? daemon->default_log_level : context->log_level);
+    1546             : 
+    1547           3 :     usercontext.trace_status =
+    1548           3 :         (uint8_t) ((context->trace_status == DLT_TRACE_STATUS_DEFAULT) ? daemon->default_trace_status : context->trace_status);
+    1549             : 
+    1550           3 :     usercontext.log_level_pos = context->log_level_pos;
+    1551             : 
+    1552           3 :     dlt_vlog(LOG_NOTICE, "Send log-level to context: %.4s:%.4s [%i -> %i] [%i -> %i]\n",
+    1553           3 :              context->apid,
+    1554           3 :              context->ctid,
+    1555           3 :              context->log_level,
+    1556           3 :              usercontext.log_level,
+    1557             :              context->trace_status,
+    1558             :              usercontext.trace_status);
+    1559             : 
+    1560             :     /* log to FIFO */
+    1561           3 :     errno = 0;
+    1562           3 :     ret = dlt_user_log_out2_with_timeout(context->user_handle,
+    1563             :                             &(userheader), sizeof(DltUserHeader),
+    1564             :                             &(usercontext), sizeof(DltUserControlMsgLogLevel));
+    1565             : 
+    1566           3 :     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           3 :     return (ret == DLT_RETURN_OK) ? DLT_RETURN_OK : DLT_RETURN_ERROR;
+    1579             : }
+    1580             : 
+    1581           0 : 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           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1588             : 
+    1589           0 :     if ((daemon == NULL) || (app == NULL))
+    1590             :         return -1;
+    1591             : 
+    1592           0 :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_LOG_STATE) < DLT_RETURN_OK)
+    1593             :         return -1;
+    1594             : 
+    1595           0 :     logstate.log_state = daemon->connectionState;
+    1596             : 
+    1597             :     /* log to FIFO */
+    1598           0 :     ret = dlt_user_log_out2_with_timeout(app->user_handle,
+    1599             :                             &(userheader), sizeof(DltUserHeader),
+    1600             :                             &(logstate), sizeof(DltUserControlMsgLogState));
+    1601             : 
+    1602           0 :     if (ret < DLT_RETURN_OK) {
+    1603           0 :         if (errno == EPIPE)
+    1604           0 :             dlt_daemon_application_reset_user_handle(daemon, app, verbose);
+    1605             :     }
+    1606             : 
+    1607           0 :     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           1 : 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           1 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1793             : 
+    1794           1 :     if (daemon == NULL) {
+    1795           0 :         dlt_log(LOG_WARNING, "Wrong parameter: Null pointer\n");
+    1796           0 :         return;
+    1797             :     }
+    1798             : 
+    1799           1 :     user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+    1800             : 
+    1801           1 :     if (user_list == NULL)
+    1802             :         return;
+    1803             : 
+    1804           1 :     for (count = 0; count < user_list->num_applications; count++) {
+    1805           0 :         app = &(user_list->applications[count]);
+    1806             : 
+    1807           0 :         if (app != NULL) {
+    1808           0 :             if (app->user_handle >= DLT_FD_MINIMUM)
+    1809           0 :                 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           4 : void dlt_daemon_change_state(DltDaemon *daemon, DltDaemonState newState)
+    1816             : {
+    1817           4 :     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           2 :     case DLT_DAEMON_STATE_BUFFER:
+    1823           2 :         dlt_log(LOG_INFO, "Switched to buffer state for socket connections.\n");
+    1824           2 :         daemon->state = DLT_DAEMON_STATE_BUFFER;
+    1825           2 :         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           1 :     case DLT_DAEMON_STATE_SEND_BUFFER:
+    1831           1 :         dlt_log(LOG_INFO, "Switched to send buffer state for socket connections.\n");
+    1832           1 :         daemon->state = DLT_DAEMON_STATE_SEND_BUFFER;
+    1833           1 :         break;
+    1834           1 :     case DLT_DAEMON_STATE_SEND_DIRECT:
+    1835           1 :         dlt_log(LOG_INFO, "Switched to send direct state.\n");
+    1836           1 :         daemon->state = DLT_DAEMON_STATE_SEND_DIRECT;
+    1837           1 :         break;
+    1838             :     }
+    1839           4 : }
+
+
+
+ + + + +
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..63de5eaf4 --- /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:9311283.0 %
Date:2023-09-01 07:46:27Functions:88100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_connection_get_next2
dlt_connection_send_multiple14
dlt_connection_get_callback15
dlt_connection_create16
dlt_connection_get_receiver17
dlt_connection_destroy18
dlt_connection_destroy_receiver19
dlt_connection_send28
+
+
+ + + +
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..e6113553a --- /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:9311283.0 %
Date:2023-09-01 07:46:27Functions:88100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_connection_create16
dlt_connection_destroy18
dlt_connection_destroy_receiver19
dlt_connection_get_callback15
dlt_connection_get_next2
dlt_connection_get_receiver17
dlt_connection_send28
dlt_connection_send_multiple14
+
+
+ + + +
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..04ceba585 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_connection.c.gcov.html @@ -0,0 +1,510 @@ + + + + + + + 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:9311283.0 %
Date:2023-09-01 07:46:27Functions: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          28 : 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          28 :     if ((conn != NULL) && (conn->receiver != NULL))
+      76          28 :         type = conn->type;
+      77             : 
+      78          28 :     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          26 :     case DLT_CONNECTION_CLIENT_MSG_TCP:
+      87          26 :         ret = dlt_daemon_socket_sendreliable(conn->receiver->fd,
+      88             :                                              msg,
+      89             :                                              msg_size);
+      90          26 :         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          14 : 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          14 :     if (con == NULL)
+     120             :         return DLT_DAEMON_ERROR_UNKNOWN;
+     121             : 
+     122          13 :     if (sendserialheader)
+     123           1 :         ret = dlt_connection_send(con,
+     124             :                                   (void *)dltSerialHeader,
+     125             :                                   sizeof(dltSerialHeader));
+     126             : 
+     127          13 :     if ((data1 != NULL) && (ret == DLT_RETURN_OK))
+     128          13 :         ret = dlt_connection_send(con, data1, size1);
+     129             : 
+     130          13 :     if ((data2 != NULL) && (ret == DLT_RETURN_OK))
+     131          11 :         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          19 : DLT_STATIC void dlt_connection_destroy_receiver(DltConnection *con)
+     157             : {
+     158          19 :     if (!con)
+     159             :         return;
+     160             : 
+     161          19 :     switch (con->type) {
+     162             :     case DLT_CONNECTION_GATEWAY:
+     163             :         /* We rely on the gateway for clean-up */
+     164             :         break;
+     165           2 :     case DLT_CONNECTION_APP_MSG:
+     166           2 :         dlt_receiver_free_global_buffer(con->receiver);
+     167           2 :         free(con->receiver);
+     168           2 :         con->receiver = NULL;
+     169           2 :         break;
+     170          13 :     default:
+     171          13 :         (void)dlt_receiver_free(con->receiver);
+     172          13 :         free(con->receiver);
+     173          13 :         con->receiver = NULL;
+     174          13 :         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          17 : 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          17 :     switch (type) {
+     201           8 :     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           8 :         ret = calloc(1, sizeof(DltReceiver));
+     209             : 
+     210           8 :         if (ret)
+     211           8 :             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           2 :     case DLT_CONNECTION_APP_MSG:
+     222           2 :         ret = calloc(1, sizeof(DltReceiver));
+     223             : 
+     224             :         receiver_type = DLT_RECEIVE_FD;
+     225             : 
+     226           2 :         if (fstat(fd, &statbuf) == 0) {
+     227           2 :             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           2 :         if (ret)
+     235           2 :             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           3 :     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           3 :         ret = calloc(1, sizeof(DltReceiver));
+     252             : 
+     253           3 :         if (ret)
+     254           3 :             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          17 :     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          15 : void *dlt_connection_get_callback(DltConnection *con)
+     280             : {
+     281             :     void *ret = NULL;
+     282             :     DltConnectionType type = DLT_CONNECTION_TYPE_MAX;
+     283             : 
+     284          15 :     if (con)
+     285          15 :         type = con->type;
+     286             : 
+     287          15 :     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           0 :     case DLT_CONNECTION_APP_MSG:
+     303             :         ret = dlt_daemon_process_user_messages;
+     304           0 :         break;
+     305           1 :     case DLT_CONNECTION_ONE_S_TIMER:
+     306             :         ret = dlt_daemon_process_one_s_timer;
+     307           1 :         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           0 :     case DLT_CONNECTION_CONTROL_CONNECT:
+     317             :         ret = dlt_daemon_process_control_connect;
+     318           0 :         break;
+     319           0 :     case DLT_CONNECTION_CONTROL_MSG:
+     320             :         ret = dlt_daemon_process_control_messages;
+     321           0 :         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          15 :     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          18 : void dlt_connection_destroy(DltConnection *to_destroy)
+     345             : {
+     346          18 :     to_destroy->id = 0;
+     347          18 :     close(to_destroy->receiver->fd);
+     348          18 :     dlt_connection_destroy_receiver(to_destroy);
+     349          18 :     free(to_destroy);
+     350          18 : }
+     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          16 : 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          16 :     if (fd < 0)
+     376             :         /* Nothing to do */
+     377             :         return 0;
+     378             : 
+     379          16 :     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          16 :     temp = (DltConnection *)malloc(sizeof(DltConnection));
+     388             : 
+     389          16 :     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          16 :     temp->receiver = dlt_connection_get_receiver(daemon_local, type, fd);
+     397             : 
+     398          16 :     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          16 :     timeout.tv_sec = 5;
+     407          16 :     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          16 :     if (setsockopt (temp->receiver->fd, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof timeout) < 0)  {
+     417           6 :         dlt_vlog(LOG_WARNING, "Unable to set send timeout %s.\n", strerror(errno));
+     418             :     }
+     419             : 
+     420             :     /* We are single threaded no need for protection. */
+     421          16 :     temp->id = connectionId++;
+     422             : 
+     423          16 :     if (!temp->id)
+     424             :         /* Skipping 0 */
+     425           4 :         temp->id = connectionId++;
+     426             : 
+     427          16 :     temp->type = type;
+     428          16 :     temp->status = ACTIVE;
+     429             : 
+     430             :     /* Now give the ownership of the newly created connection
+     431             :      * to the event handler, by registering for events.
+     432             :      */
+     433          16 :     return dlt_event_handler_register_connection(evh, daemon_local, temp, mask);
+     434             : }
+
+
+
+ + + + +
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..64229e28c --- /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:12315082.0 %
Date:2023-09-01 07:46:27Functions:1111100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_event_handler_cleanup_connections3
dlt_event_handler_unregister_connection4
dlt_event_handler_disable_fd5
dlt_daemon_add_connection7
dlt_daemon_prepare_event_handling9
dlt_daemon_remove_connection17
dlt_event_handler_enable_fd19
dlt_event_handler_register_connection19
dlt_daemon_handle_event20
dlt_connection_check_activate25
dlt_event_handler_find_connection66
+
+
+ + + +
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..b0c80f010 --- /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:12315082.0 %
Date:2023-09-01 07:46:27Functions:1111100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_connection_check_activate25
dlt_daemon_add_connection7
dlt_daemon_handle_event20
dlt_daemon_prepare_event_handling9
dlt_daemon_remove_connection17
dlt_event_handler_cleanup_connections3
dlt_event_handler_disable_fd5
dlt_event_handler_enable_fd19
dlt_event_handler_find_connection66
dlt_event_handler_register_connection19
dlt_event_handler_unregister_connection4
+
+
+ + + +
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..a627b6fb6 --- /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:12315082.0 %
Date:2023-09-01 07:46:27Functions: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         149 :     pfd->fd = -1;
+      65         149 :     pfd->events = 0;
+      66         149 :     pfd->revents = 0;
+      67           5 : }
+      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           9 : int dlt_daemon_prepare_event_handling(DltEventHandler *ev)
+      78             : {
+      79             :     int i = 0;
+      80             : 
+      81           9 :     if (ev == NULL)
+      82             :         return DLT_RETURN_ERROR;
+      83             : 
+      84           8 :     ev->pfd = calloc(DLT_EV_BASE_FD, sizeof(struct pollfd));
+      85             : 
+      86           8 :     if (ev->pfd == NULL) {
+      87           0 :         dlt_log(LOG_CRIT, "Creation of poll instance failed!\n");
+      88           0 :         return -1;
+      89             :     }
+      90             : 
+      91         136 :     for (i = 0; i < DLT_EV_BASE_FD; i++)
+      92         128 :         init_poll_fd(&ev->pfd[i]);
+      93             : 
+      94           8 :     ev->nfds = 0;
+      95           8 :     ev->max_nfds = DLT_EV_BASE_FD;
+      96             : 
+      97           8 :     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          19 : static void dlt_event_handler_enable_fd(DltEventHandler *ev, int fd, int mask)
+     110             : {
+     111          19 :     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          19 :     ev->pfd[ev->nfds].fd = fd;
+     130          19 :     ev->pfd[ev->nfds].events = mask;
+     131          19 :     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           5 : static void dlt_event_handler_disable_fd(DltEventHandler *ev, int fd)
+     143             : {
+     144             :     unsigned int i = 0;
+     145             :     unsigned int j = 0;
+     146           5 :     unsigned int nfds = ev->nfds;
+     147             : 
+     148          20 :     for (; i < nfds; i++, j++) {
+     149          15 :         if (ev->pfd[i].fd == fd) {
+     150             :             init_poll_fd(&ev->pfd[i]);
+     151           5 :             j++;
+     152           5 :             ev->nfds--;
+     153             :         }
+     154             : 
+     155          15 :         if (i == j)
+     156          10 :             continue;
+     157             : 
+     158             :         /* Compressing the table */
+     159           5 :         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           5 : }
+     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          20 : 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          20 :     if ((pEvent == NULL) || (daemon == NULL) || (daemon_local == NULL))
+     191             :         return DLT_RETURN_ERROR;
+     192             : 
+     193          19 :     ret = poll(pEvent->pfd, pEvent->nfds, DLT_EV_TIMEOUT_MSEC);
+     194             : 
+     195          19 :     if (ret <= 0) {
+     196             :         /* We are not interested in EINTR has it comes
+     197             :          * either from timeout or signal.
+     198             :          */
+     199           2 :         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           2 :         return ret;
+     206             :     }
+     207             : 
+     208         112 :     for (i = 0; i < pEvent->nfds; i++) {
+     209             :         int fd = 0;
+     210             :         DltConnection *con = NULL;
+     211             :         DltConnectionType type = DLT_CONNECTION_TYPE_MAX;
+     212             : 
+     213          95 :         if (pEvent->pfd[i].revents == 0)
+     214          78 :             continue;
+     215             : 
+     216          17 :         con = dlt_event_handler_find_connection(pEvent, pEvent->pfd[i].fd);
+     217             : 
+     218          17 :         if (con && con->receiver) {
+     219          17 :             type = con->type;
+     220          17 :             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          17 :         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          15 :         callback = dlt_connection_get_callback(con);
+     247             : 
+     248          15 :         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          15 :         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          66 : DltConnection *dlt_event_handler_find_connection(DltEventHandler *ev, int fd)
+     280             : {
+     281          85 :     DltConnection *temp = ev->connections;
+     282             : 
+     283         296 :     while (temp != NULL) {
+     284         280 :         if ((temp->receiver != NULL) && (temp->receiver->fd == fd))
+     285          50 :             return temp;
+     286         211 :         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          17 : DLT_STATIC int dlt_daemon_remove_connection(DltEventHandler *ev,
+     303             :                                             DltConnection *to_remove)
+     304             : {
+     305          17 :     if ((ev == NULL) || (to_remove == NULL))
+     306             :         return DLT_RETURN_ERROR;
+     307             : 
+     308          17 :     DltConnection *curr = ev->connections;
+     309             :     DltConnection *prev = curr;
+     310             : 
+     311             :     /* Find the address where to_remove value is registered */
+     312          28 :     while (curr && (curr != to_remove)) {
+     313             :         prev = curr;
+     314          11 :         curr = curr->next;
+     315             :     }
+     316             : 
+     317          17 :     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          17 :     else if (curr == ev->connections)
+     323             :     {
+     324          14 :         ev->connections = curr->next;
+     325             :     }
+     326             :     else {
+     327           3 :         prev->next = curr->next;
+     328             :     }
+     329             : 
+     330             :     /* Now we can destroy our pointer */
+     331          17 :     dlt_connection_destroy(to_remove);
+     332             : 
+     333          17 :     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           3 : void dlt_event_handler_cleanup_connections(DltEventHandler *ev)
+     343             : {
+     344             :     unsigned int i = 0;
+     345             : 
+     346           3 :     if (ev == NULL)
+     347             :         /* Nothing to do. */
+     348             :         return;
+     349             : 
+     350          15 :     while (ev->connections != NULL)
+     351             :         /* We don really care on failure */
+     352          12 :         (void)dlt_daemon_remove_connection(ev, ev->connections);
+     353             : 
+     354          14 :     for (i = 0; i < ev->nfds; i++)
+     355          11 :         init_poll_fd(&ev->pfd[i]);
+     356             : 
+     357           3 :     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           7 : DLT_STATIC void dlt_daemon_add_connection(DltEventHandler *ev,
+     368             :                                           DltConnection *connection)
+     369             : {
+     370             : 
+     371          20 :     DltConnection **temp = &ev->connections;
+     372             : 
+     373          59 :     while (*temp != NULL)
+     374          39 :         temp = &(*temp)->next;
+     375             : 
+     376          20 :     *temp = connection;
+     377           7 : }
+     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          25 : int dlt_connection_check_activate(DltEventHandler *evhdl,
+     393             :                                   DltConnection *con,
+     394             :                                   int activation_type)
+     395             : {
+     396          25 :     if (!evhdl || !con || !con->receiver) {
+     397           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameters.\n", __func__);
+     398           1 :         return -1;
+     399             :     }
+     400             : 
+     401          24 :     switch (con->status) {
+     402           5 :     case ACTIVE:
+     403             : 
+     404           5 :         if (activation_type == DEACTIVATE) {
+     405           5 :             dlt_vlog(LOG_INFO, "Deactivate connection type: %u\n", con->type);
+     406             : 
+     407           5 :             dlt_event_handler_disable_fd(evhdl, con->receiver->fd);
+     408             : 
+     409           5 :             if (con->type == DLT_CONNECTION_CLIENT_CONNECT)
+     410           0 :                 con->receiver->fd = -1;
+     411             : 
+     412           5 :             con->status = INACTIVE;
+     413             :         }
+     414             : 
+     415             :         break;
+     416          19 :     case INACTIVE:
+     417             : 
+     418          19 :         if (activation_type == ACTIVATE) {
+     419          19 :             dlt_vlog(LOG_INFO, "Activate connection type: %u\n", con->type);
+     420             : 
+     421          19 :             dlt_event_handler_enable_fd(evhdl,
+     422          19 :                                         con->receiver->fd,
+     423             :                                         con->ev_mask);
+     424             : 
+     425          19 :             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          19 : int dlt_event_handler_register_connection(DltEventHandler *evhdl,
+     454             :                                           DltDaemonLocal *daemon_local,
+     455             :                                           DltConnection *connection,
+     456             :                                           int mask)
+     457             : {
+     458          19 :     if (!evhdl || !connection || !connection->receiver) {
+     459           1 :         dlt_log(LOG_ERR, "Wrong parameters when registering connection.\n");
+     460           1 :         return -1;
+     461             :     }
+     462             : 
+     463           5 :     dlt_daemon_add_connection(evhdl, connection);
+     464             : 
+     465          18 :     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          18 :     connection->status = INACTIVE;
+     471             : 
+     472          18 :     connection->next = NULL;
+     473          18 :     connection->ev_mask = mask;
+     474             : 
+     475          18 :     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           4 : int dlt_event_handler_unregister_connection(DltEventHandler *evhdl,
+     495             :                                             DltDaemonLocal *daemon_local,
+     496             :                                             int fd)
+     497             : {
+     498           4 :     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           4 :     if (!temp) {
+     507           0 :         dlt_log(LOG_ERR, "Connection not found for unregistration.\n");
+     508           0 :         return -1;
+     509             :     }
+     510             : 
+     511           4 :     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           4 :     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           4 :     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..fd0e521b0 --- /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:19233257.8 %
Date:2023-09-01 07:46:27Functions: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_cleanup2
dlt_daemon_logstorage_get_loglevel2
dlt_daemon_logstorage_reset_application_loglevel2
dlt_daemon_logstorage_send_log_level2
dlt_daemon_logstorage_setup_internal_storage2
dlt_daemon_logstorage_sync_cache2
dlt_daemon_logstorage_write2
dlt_logstorage_split_multi2
dlt_daemon_logstorage_get_device3
dlt_daemon_logstorage_set_logstorage_cache_size3
dlt_daemon_logstorage_update_application_loglevel4
dlt_logstorage_update_all_contexts4
dlt_logstorage_update_context_loglevel5
dlt_logstorage_update_context6
dlt_logstorage_split_key10
+
+
+ + + +
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..8c9aab08a --- /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:19233257.8 %
Date:2023-09-01 07:46:27Functions:192382.6 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_logstorage_cleanup2
dlt_daemon_logstorage_force_reset_level0
dlt_daemon_logstorage_get_device3
dlt_daemon_logstorage_get_loglevel2
dlt_daemon_logstorage_reset_application_loglevel2
dlt_daemon_logstorage_reset_log_level1
dlt_daemon_logstorage_send_log_level2
dlt_daemon_logstorage_set_logstorage_cache_size3
dlt_daemon_logstorage_setup_internal_storage2
dlt_daemon_logstorage_sync_cache2
dlt_daemon_logstorage_update_application_loglevel4
dlt_daemon_logstorage_update_passive_node_context0
dlt_daemon_logstorage_write2
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_key10
dlt_logstorage_split_multi2
dlt_logstorage_update_all_contexts4
dlt_logstorage_update_context6
dlt_logstorage_update_context_loglevel5
+
+
+ + + +
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..e74a8ce67 --- /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:19233257.8 %
Date:2023-09-01 07:46:27Functions: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           2 : 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           2 :     if (len > DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN)
+     214             :         return DLT_RETURN_ERROR;
+     215             : 
+     216           2 :     tok = strtok(key, ":");
+     217             : 
+     218           2 :     if (tok == NULL)
+     219             :         return DLT_RETURN_ERROR;
+     220             : 
+     221           2 :     len = strlen(tok);
+     222             : 
+     223           2 :     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           2 :         tok = strtok(NULL, ":");
+     236             : 
+     237           2 :         if (tok != NULL)
+     238             :             strncpy(apid, tok, DLT_ID_SIZE);
+     239             : 
+     240           2 :         tok = strtok(NULL, ":");
+     241             : 
+     242           2 :         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          10 : 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          10 :     if ((key == NULL) || (apid == NULL) || (ctid == NULL) || (ecuid == NULL))
+     270             :         return DLT_RETURN_WRONG_PARAMETER;
+     271             : 
+     272           5 :     len = strlen(key);
+     273             : 
+     274           5 :     sep = strchr (key, ':');
+     275             : 
+     276           5 :     if (sep == NULL)
+     277             :         return DLT_RETURN_WRONG_PARAMETER;
+     278             : 
+     279             :     /* key is ecuid only ecuid::*/
+     280           5 :     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           5 :     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           5 :     else if ((key[0] == ':') && (key[len - 1] == ':'))
+     287           1 :         return dlt_logstorage_split_apid(key, len, apid, ctid);
+     288             :     /* key is :apid:ctid */
+     289           4 :     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           3 :     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           2 :         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           6 : 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           6 :     if ((daemon == NULL) || (daemon_local == NULL) || (apid == NULL)
+     629           5 :         || (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           5 :     context = dlt_daemon_context_find(daemon, apid, ctid, ecuid, verbose);
+     635             : 
+     636           5 :     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           2 :         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           2 :             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           2 :             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           5 : 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           5 :     char apid[DLT_ID_SIZE + 1] = { '\0' };
+     699           5 :     char ctid[DLT_ID_SIZE + 1] = { '\0' };
+     700           5 :     char ecuid[DLT_ID_SIZE + 1] = { '\0' };
+     701             : 
+     702           5 :     PRINT_FUNCTION_VERBOSE(verbose);
+     703             : 
+     704           5 :     if ((daemon == NULL) || (daemon_local == NULL) || (key == NULL))
+     705             :         return DLT_RETURN_WRONG_PARAMETER;
+     706             : 
+     707           4 :     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           4 :     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           4 :     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           4 :     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           3 :     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           3 :     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           2 :         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           4 : 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           4 :     char key[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = { '\0' };
+     881             :     int i = 0;
+     882             :     int log_level = 0;
+     883             : 
+     884           4 :     PRINT_FUNCTION_VERBOSE(verbose);
+     885             : 
+     886           4 :     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           3 :     handle = &(daemon->storage_handle[dev_num]);
+     895             : 
+     896           3 :     if ((handle->connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) ||
+     897           3 :         (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           3 :     tmp = &(handle->config_list);
+     903           6 :     while (*(tmp) != NULL)
+     904             :     {
+     905           6 :         for (i = 0; i < (*tmp)->num_keys; i++)
+     906             :         {
+     907             :             memset(key, 0, sizeof(key));
+     908             : 
+     909           3 :             strncpy(key, ((*tmp)->key_list
+     910           3 :                     + (i * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN)),
+     911             :                     DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN);
+     912             : 
+     913             :             /* Obtain storage configuration data */
+     914           3 :             log_level = dlt_logstorage_get_loglevel_by_key(handle, key);
+     915           3 :             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           3 :             dlt_logstorage_update_context_loglevel(daemon,
+     923             :                                                 daemon_local,
+     924             :                                                 key,
+     925             :                                                 log_level,
+     926             :                                                 verbose);
+     927             :         }
+     928           3 :         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           2 : int dlt_daemon_logstorage_get_loglevel(DltDaemon *daemon,
+     947             :                                        int max_device,
+     948             :                                        char *apid,
+     949             :                                        char *ctid)
+     950             : {
+     951           2 :     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           2 :     if ((daemon == NULL) || (max_device == 0) || (apid == NULL) || (ctid == NULL))
+     959             :         return DLT_RETURN_WRONG_PARAMETER;
+     960             : 
+     961           2 :     for (i = 0; i < max_device; i++)
+     962           1 :         if (daemon->storage_handle[i].config_status ==
+     963             :             DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE) {
+     964           1 :             num_config = dlt_logstorage_get_config(&(daemon->storage_handle[i]),
+     965             :                                                    config,
+     966             :                                                    apid,
+     967             :                                                    ctid,
+     968           1 :                                                    daemon->ecuid);
+     969             : 
+     970           1 :             if (num_config == 0) {
+     971           0 :                 dlt_log(LOG_DEBUG, "No valid filter configuration found\n");
+     972           0 :                 continue;
+     973             :             }
+     974             : 
+     975           2 :             for (j = 0; j < num_config; j++)
+     976             :             {
+     977           1 :                 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           1 :                 if (config[j]->file_name == NULL) {
+     983           0 :                     storage_loglevel = config[j]->log_level;
+     984           0 :                     break;
+     985             :                 }
+     986             : 
+     987           1 :                 configured_loglevel = config[j]->log_level;
+     988           1 :                 storage_loglevel = DLT_OFFLINE_LOGSTORAGE_MAX(
+     989             :                     configured_loglevel,
+     990             :                     storage_loglevel);
+     991             :             }
+     992             :         }
+     993             : 
+     994           1 :     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           2 : 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           2 :     if ((daemon == NULL) || (user_config == NULL) ||
+    1028           1 :         (user_config->offlineLogstorageMaxDevices <= 0) || (data1 == NULL) ||
+    1029           1 :         (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           1 :     file_config.logfile_timestamp = user_config->offlineLogstorageTimestamp;
+    1039           1 :     file_config.logfile_delimiter = user_config->offlineLogstorageDelimiter;
+    1040           1 :     file_config.logfile_maxcounter = user_config->offlineLogstorageMaxCounter;
+    1041           1 :     file_config.logfile_optional_counter = user_config->offlineLogstorageOptionalCounter;
+    1042           1 :     file_config.logfile_counteridxlen =
+    1043           1 :         user_config->offlineLogstorageMaxCounterIdx;
+    1044             : 
+    1045           2 :     for (i = 0; i < user_config->offlineLogstorageMaxDevices; i++) {
+    1046           1 :         if (daemon->storage_handle[i].config_status ==
+    1047             :             DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE) {
+    1048           1 :             int disable_nw = 0;
+    1049           1 :             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           1 :             if (i == 0) {
+    1068           1 :                 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           2 : 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           2 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1101             : 
+    1102           2 :     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           1 :     ret = dlt_logstorage_device_connected(&(daemon->storage_handle[0]), path);
+    1108             : 
+    1109           1 :     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           1 :     dlt_daemon_logstorage_update_application_loglevel(daemon,
+    1116             :                                                       daemon_local,
+    1117             :                                                       0,
+    1118             :                                                       verbose);
+    1119             : 
+    1120           1 :     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           3 : void dlt_daemon_logstorage_set_logstorage_cache_size(unsigned int size)
+    1134             : {
+    1135             :     /* store given [KB] size in [Bytes] */
+    1136           3 :     g_logstorage_cache_max = size * 1024;
+    1137           3 : }
+    1138             : 
+    1139           2 : int dlt_daemon_logstorage_cleanup(DltDaemon *daemon,
+    1140             :                                   DltDaemonLocal *daemon_local,
+    1141             :                                   int verbose)
+    1142             : {
+    1143             :     int i = 0;
+    1144             : 
+    1145           2 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1146             : 
+    1147           2 :     if ((daemon == NULL) || (daemon_local == NULL) || (daemon->storage_handle == NULL))
+    1148             :         return DLT_RETURN_WRONG_PARAMETER;
+    1149             : 
+    1150           2 :     for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++)
+    1151             :         /* call disconnect on all currently connected devices */
+    1152           1 :         if (daemon->storage_handle[i].connection_type ==
+    1153             :             DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED)
+    1154             :         {
+    1155           0 :             (&daemon->storage_handle[i])->uconfig.logfile_counteridxlen =
+    1156           0 :                                         daemon_local->flags.offlineLogstorageMaxCounterIdx;
+    1157           0 :             (&daemon->storage_handle[i])->uconfig.logfile_delimiter =
+    1158           0 :                                         daemon_local->flags.offlineLogstorageDelimiter;
+    1159           0 :             (&daemon->storage_handle[i])->uconfig.logfile_maxcounter =
+    1160           0 :                                         daemon_local->flags.offlineLogstorageMaxCounter;
+    1161           0 :             (&daemon->storage_handle[i])->uconfig.logfile_timestamp =
+    1162           0 :                                         daemon_local->flags.offlineLogstorageTimestamp;
+    1163           0 :             (&daemon->storage_handle[i])->uconfig.logfile_optional_counter =
+    1164           0 :                 daemon_local->flags.offlineLogstorageOptionalCounter;
+    1165             : 
+    1166           0 :             dlt_logstorage_device_disconnected(
+    1167             :                 &daemon->storage_handle[i],
+    1168             :                 DLT_LOGSTORAGE_SYNC_ON_DAEMON_EXIT);
+    1169             :         }
+    1170             : 
+    1171             :     return 0;
+    1172             : }
+    1173             : 
+    1174           2 : 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           2 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1183             : 
+    1184           2 :     if ((daemon == NULL) || (daemon_local == NULL) || (mnt_point == NULL))
+    1185             :         return DLT_RETURN_WRONG_PARAMETER;
+    1186             : 
+    1187           1 :     if (strlen(mnt_point) > 0) { /* mount point is given */
+    1188           1 :         handle = dlt_daemon_logstorage_get_device(daemon,
+    1189             :                                                   daemon_local,
+    1190             :                                                   mnt_point,
+    1191             :                                                   verbose);
+    1192             : 
+    1193           1 :         if (handle == NULL) {
+    1194             :             return DLT_RETURN_ERROR;
+    1195             :         }
+    1196             :         else {
+    1197           1 :             handle->uconfig.logfile_counteridxlen =
+    1198           1 :                 daemon_local->flags.offlineLogstorageMaxCounterIdx;
+    1199           1 :             handle->uconfig.logfile_delimiter =
+    1200           1 :                 daemon_local->flags.offlineLogstorageDelimiter;
+    1201           1 :             handle->uconfig.logfile_maxcounter =
+    1202           1 :                 daemon_local->flags.offlineLogstorageMaxCounter;
+    1203           1 :             handle->uconfig.logfile_timestamp =
+    1204           1 :                 daemon_local->flags.offlineLogstorageTimestamp;
+    1205           1 :             handle->uconfig.logfile_optional_counter =
+    1206           1 :                 daemon_local->flags.offlineLogstorageOptionalCounter;
+    1207             : 
+    1208           1 :             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           3 : 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           3 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1247             : 
+    1248           3 :     if ((daemon == NULL) || (daemon_local == NULL) || (mnt_point == NULL))
+    1249             :         return NULL;
+    1250             : 
+    1251           2 :     len1 = strlen(mnt_point);
+    1252             : 
+    1253           2 :     for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++) {
+    1254           2 :         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           2 :         len = len1 > len2 ? len2 : len1;
+    1260             : 
+    1261           2 :         if (strncmp(daemon->storage_handle[i].device_mount_point, mnt_point, len) == 0)
+    1262           2 :             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..f17f9a0d1 --- /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-09-01 07:46:27Functions: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..4f7463d1f --- /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-09-01 07:46:27Functions: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..00637945f --- /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-09-01 07:46:27Functions: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..042446b2b --- /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-09-01 07:46:27Functions: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_open2
dlt_daemon_socket_send12
dlt_daemon_socket_sendreliable50
+
+
+ + + +
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..bd98da320 --- /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-09-01 07:46:27Functions: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_open2
dlt_daemon_socket_send12
dlt_daemon_socket_sendreliable50
+
+
+ + + +
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..5d3d78e02 --- /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-09-01 07:46:27Functions: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           2 : int dlt_daemon_socket_open(int *sock, unsigned int servPort, char *ip)
+      59             : {
+      60           2 :     int yes = 1;
+      61             :     int ret_inet_pton = 1;
+      62             :     int lastErrno = 0;
+      63             : 
+      64             : #ifdef DLT_USE_IPv6
+      65             : 
+      66             :     /* create socket */
+      67           2 :     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           2 :     dlt_vlog(LOG_INFO, "%s: Socket created\n", __FUNCTION__);
+      86             : 
+      87             :     /* setsockpt SO_REUSEADDR */
+      88           2 :     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           2 :     forced_addr.sin6_family = AF_INET6;
+     103           2 :     forced_addr.sin6_port = htons(servPort);
+     104             : 
+     105           2 :     if (0 == strcmp(ip, "0.0.0.0")) {
+     106           2 :         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           2 :     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           2 :     dlt_vlog(LOG_INFO, "%s: Listening on ip %s and port: %u\n", __FUNCTION__, ip, servPort);
+     141             : 
+     142             :     /* get socket buffer size */
+     143           4 :     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           2 :     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          12 : 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          12 :     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          12 :     if ((data1 != NULL) && (size1 > 0)) {
+     187          12 :         ret = dlt_daemon_socket_sendreliable(sock, data1, size1);
+     188             : 
+     189          12 :         if (ret != DLT_RETURN_OK) {
+     190             :             return ret;
+     191             :         }
+     192             :     }
+     193             : 
+     194          12 :     if ((data2 != NULL) && (size2 > 0)) {
+     195          12 :         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           2 :     int n = 0;
+     204           2 :     socklen_t m = sizeof(n);
+     205           2 :     getsockopt(sock, SOL_SOCKET, SO_SNDBUF, (void *)&n, &m);
+     206             : 
+     207           2 :     return n;
+     208             : }
+     209             : 
+     210          50 : int dlt_daemon_socket_sendreliable(int sock, void *data_buffer, int message_size)
+     211             : {
+     212             :     int data_sent = 0;
+     213             : 
+     214         100 :     while (data_sent < message_size) {
+     215          50 :         ssize_t ret = send(sock,
+     216             :                            (uint8_t *)data_buffer + data_sent,
+     217          50 :                            message_size - data_sent,
+     218             :                            0);
+     219             : 
+     220          50 :         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          50 :             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..573316998 --- /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-09-01 07:46:27Functions:1250.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_unix_socket_close0
dlt_daemon_unix_socket_open2
+
+
+ + + +
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..1110b0c91 --- /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-09-01 07:46:27Functions:1250.0 %
+
+ +
+ + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_unix_socket_close0
dlt_daemon_unix_socket_open2
+
+
+ + + +
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..256bbab0f --- /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-09-01 07:46:27Functions: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           2 : 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           2 :     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           2 :     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           2 :     addr.sun_family = AF_UNIX;
+     146             :     memcpy(addr.sun_path, sock_path, sizeof(addr.sun_path));
+     147             : 
+     148           2 :     unlink(sock_path);
+     149             : 
+     150             :     /* set appropriate access permissions */
+     151           2 :     old_mask = umask(mask);
+     152             : 
+     153           2 :     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           2 :     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           2 :     umask(old_mask);
+     167             : 
+     168             : #ifdef DLT_SYSTEM_SOCKET_ACTIVATION_ENABLE
+     169             :     } // end of: if (!sd_socket_open) {
+     170             : #endif
+     171             : 
+     172             : 
+     173           2 :     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..f84c8ccc7 --- /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:1383338440.9 %
Date:2023-09-01 07:46:27Functions:9615561.9 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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.2%22.2%
+
22.2 %216 / 97133.3 %11 / 33
dlt_daemon_unix_socket.c +
40.0%40.0%
+
40.0 %10 / 2550.0 %1 / 2
dlt-daemon.c +
39.2%39.2%
+
39.2 %435 / 111057.5 %23 / 40
dlt_daemon_socket.c +
52.6%52.6%
+
52.6 %30 / 5760.0 %3 / 5
dlt_daemon_common.c +
45.9%45.9%
+
45.9 %284 / 61962.5 %20 / 32
dlt_daemon_offline_logstorage.c +
57.8%57.8%
+
57.8 %192 / 33282.6 %19 / 23
dlt_daemon_connection.c +
83.0%83.0%
+
83.0 %93 / 112100.0 %8 / 8
dlt_daemon_event_handler.c +
82.0%82.0%
+
82.0 %123 / 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..4fef873eb --- /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:1383338440.9 %
Date:2023-09-01 07:46:27Functions:9615561.9 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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.2%22.2%
+
22.2 %216 / 97133.3 %11 / 33
dlt-daemon.c +
39.2%39.2%
+
39.2 %435 / 111057.5 %23 / 40
dlt_daemon_unix_socket.c +
40.0%40.0%
+
40.0 %10 / 2550.0 %1 / 2
dlt_daemon_common.c +
45.9%45.9%
+
45.9 %284 / 61962.5 %20 / 32
dlt_daemon_socket.c +
52.6%52.6%
+
52.6 %30 / 5760.0 %3 / 5
dlt_daemon_offline_logstorage.c +
57.8%57.8%
+
57.8 %192 / 33282.6 %19 / 23
dlt_daemon_event_handler.c +
82.0%82.0%
+
82.0 %123 / 150100.0 %11 / 11
dlt_daemon_connection.c +
83.0%83.0%
+
83.0 %93 / 112100.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..c1ece8b15 --- /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:1383338440.9 %
Date:2023-09-01 07:46:27Functions:9615561.9 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt-daemon.c +
39.2%39.2%
+
39.2 %435 / 111057.5 %23 / 40
dlt_daemon_client.c +
22.2%22.2%
+
22.2 %216 / 97133.3 %11 / 33
dlt_daemon_common.c +
45.9%45.9%
+
45.9 %284 / 61962.5 %20 / 32
dlt_daemon_connection.c +
83.0%83.0%
+
83.0 %93 / 112100.0 %8 / 8
dlt_daemon_event_handler.c +
82.0%82.0%
+
82.0 %123 / 150100.0 %11 / 11
dlt_daemon_offline_logstorage.c +
57.8%57.8%
+
57.8 %192 / 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..1263eb748 --- /dev/null +++ b/dlt_lcov_report/dlt_final_coverage.info @@ -0,0 +1,11393 @@ +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:1025,dlt_mkdir_recursive +FN:1074,dlt_daemon_create_pipes_dir +FN:1117,main +FN:1351,dlt_daemon_local_init_p1 +FN:1412,dlt_daemon_local_init_p2 +FN:1514,dlt_daemon_init_serial +FN:1572,dlt_daemon_init_fifo +FN:1746,dlt_daemon_initialize_control_socket +FN:1793,dlt_daemon_local_connection_init +FN:1909,dlt_daemon_local_ecu_version_init +FN:1983,dlt_daemon_local_cleanup +FN:2037,dlt_daemon_exit_trigger +FN:2061,dlt_daemon_signal_handler +FN:2110,dlt_daemon_daemonize +FN:2180,dlt_daemon_log_internal +FN:2257,dlt_daemon_check_numeric_setting +FN:2273,dlt_daemon_process_client_connect +FN:2383,dlt_daemon_process_client_messages +FN:2460,dlt_daemon_process_client_messages_serial +FN:2529,dlt_daemon_process_control_connect +FN:2625,dlt_daemon_process_control_messages +FN:2693,dlt_daemon_process_user_message_not_sup +FN:2734,dlt_daemon_process_user_messages +FN:2814,dlt_daemon_process_user_message_overflow +FN:2852,dlt_daemon_send_message_overflow +FN:2872,dlt_daemon_process_user_message_register_application +FN:2990,dlt_daemon_process_user_message_register_context +FN:3198,dlt_daemon_process_user_message_unregister_application +FN:3296,dlt_daemon_process_user_message_unregister_context +FN:3374,dlt_daemon_process_user_message_log +FN:3505,enforce_context_ll_and_ts_keep_message +FN:3530,dlt_daemon_process_user_message_set_app_ll_ts +FN:3606,dlt_daemon_process_user_message_log_mode +FN:3639,dlt_daemon_process_user_message_marker +FN:3669,dlt_daemon_send_ringbuffer_to_client +FN:3773,create_timer_fd +FN:3865,dlt_daemon_close_socket +FNDA:0,dlt_daemon_process_user_message_marker +FNDA:2,dlt_daemon_local_init_p1 +FNDA:3,dlt_daemon_check_numeric_setting +FNDA:0,dlt_daemon_process_user_messages +FNDA:0,enforce_context_ll_and_ts_keep_message +FNDA:0,dlt_daemon_process_user_message_register_context +FNDA:2,dlt_daemon_close_socket +FNDA:2,dlt_daemon_init_serial +FNDA:0,dlt_daemon_process_user_message_unregister_application +FNDA:2,dlt_daemon_exit_trigger +FNDA:0,dlt_daemon_process_user_message_log_mode +FNDA:2,dlt_daemon_init_fifo +FNDA:2,option_file_parser +FNDA:0,usage +FNDA:2,dlt_daemon_create_pipes_dir +FNDA:3,dlt_daemon_process_client_connect +FNDA:0,dlt_daemon_send_message_overflow +FNDA:9,dlt_daemon_log_internal +FNDA:0,dlt_daemon_process_user_message_not_sup +FNDA:0,dlt_daemon_process_control_messages +FNDA:2,dlt_daemon_local_ecu_version_init +FNDA:0,dlt_daemon_process_user_message_log +FNDA:0,dlt_daemon_process_user_message_unregister_context +FNDA:8,dlt_daemon_process_client_messages +FNDA:2,main +FNDA:2,dlt_daemon_local_connection_init +FNDA:2,dlt_mkdir_recursive +FNDA:1,dlt_daemon_send_ringbuffer_to_client +FNDA:2,dlt_daemon_local_cleanup +FNDA:0,dlt_daemon_process_control_connect +FNDA:2,dlt_daemon_local_init_p2 +FNDA:2,option_handling +FNDA:3,create_timer_fd +FNDA:2,dlt_daemon_initialize_control_socket +FNDA:2,dlt_daemon_signal_handler +FNDA:0,dlt_daemon_process_user_message_set_app_ll_ts +FNDA:0,dlt_daemon_process_user_message_register_application +FNDA:2,dlt_daemon_daemonize +FNDA:0,dlt_daemon_process_user_message_overflow +FNDA:0,dlt_daemon_process_client_messages_serial +FNF:40 +FNH:23 +DA:177,0 +DA:180,0 +DA:213,0 +DA:218,2 +DA:226,2 +DA:227,0 +DA:228,0 +DA:235,2 +DA:238,2 +DA:245,2 +DA:253,6 +DA:254,4 +DA:255,2 +DA:257,2 +DA:258,2 +DA:260,1 +DA:262,1 +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,2 +DA:332,2 +DA:340,2 +DA:347,2 +DA:348,2 +DA:350,2 +DA:351,2 +DA:352,2 +DA:358,2 +DA:359,2 +DA:360,2 +DA:361,2 +DA:362,2 +DA:363,2 +DA:364,2 +DA:365,2 +DA:372,2 +DA:377,2 +DA:378,0 +DA:381,2 +DA:382,2 +DA:383,2 +DA:385,2 +DA:386,2 +DA:387,2 +DA:388,2 +DA:389,2 +DA:390,2 +DA:391,2 +DA:392,2 +DA:393,2 +DA:394,2 +DA:395,2 +DA:396,2 +DA:397,2 +DA:398,2 +DA:399,2 +DA:400,2 +DA:401,2 +DA:403,2 +DA:414,2 +DA:416,2 +DA:417,2 +DA:420,2 +DA:421,2 +DA:422,2 +DA:423,2 +DA:429,2 +DA:430,2 +DA:433,2 +DA:434,1 +DA:439,2 +DA:441,2 +DA:444,28 +DA:445,13 +DA:446,13 +DA:447,13 +DA:449,26 +DA:450,26 +DA:453,26 +DA:454,13 +DA:455,13 +DA:458,13 +DA:459,13 +DA:460,13 +DA:463,13 +DA:466,13 +DA:468,13 +DA:469,0 +DA:472,13 +DA:474,0 +DA:477,13 +DA:479,0 +DA:482,13 +DA:484,0 +DA:487,13 +DA:489,0 +DA:492,13 +DA:494,1 +DA:497,12 +DA:499,0 +DA:502,12 +DA:504,0 +DA:507,12 +DA:509,0 +DA:512,12 +DA:514,0 +DA:517,12 +DA:519,0 +DA:520,0 +DA:523,12 +DA:525,0 +DA:526,0 +DA:529,12 +DA:531,1 +DA:532,1 +DA:535,11 +DA:537,0 +DA:538,0 +DA:541,11 +DA:543,1 +DA:546,10 +DA:548,1 +DA:551,9 +DA:556,1 +DA:559,8 +DA:561,0 +DA:563,8 +DA:565,0 +DA:567,8 +DA:569,0 +DA:571,8 +DA:573,1 +DA:576,7 +DA:578,1 +DA:582,6 +DA:584,1 +DA:588,5 +DA:590,1 +DA:594,4 +DA:596,1 +DA:599,3 +DA:601,0 +DA:604,0 +DA:607,3 +DA:609,0 +DA:612,3 +DA:614,0 +DA:617,3 +DA:619,0 +DA:622,3 +DA:624,0 +DA:627,3 +DA:632,0 +DA:635,3 +DA:637,0 +DA:640,3 +DA:642,0 +DA:644,3 +DA:646,0 +DA:650,3 +DA:653,0 +DA:654,0 +DA:656,3 +DA:659,0 +DA:660,0 +DA:662,3 +DA:664,0 +DA:665,0 +DA:666,3 +DA:667,0 +DA:669,3 +DA:671,0 +DA:672,0 +DA:673,0 +DA:676,3 +DA:687,2 +DA:689,1 +DA:692,1 +DA:703,0 +DA:707,0 +DA:708,0 +DA:712,0 +DA:719,0 +DA:723,0 +DA:724,0 +DA:728,0 +DA:735,0 +DA:739,0 +DA:740,0 +DA:744,0 +DA:751,0 +DA:753,0 +DA:760,0 +DA:763,0 +DA:793,0 +DA:798,0 +DA:800,0 +DA:801,0 +DA:803,0 +DA:804,0 +DA:805,0 +DA:806,0 +DA:809,0 +DA:812,0 +DA:815,0 +DA:817,0 +DA:818,0 +DA:820,0 +DA:821,0 +DA:822,0 +DA:823,0 +DA:826,0 +DA:829,0 +DA:831,0 +DA:836,0 +DA:839,0 +DA:840,0 +DA:843,0 +DA:852,1 +DA:855,1 +DA:1025,2 +DA:1034,2 +DA:1036,2 +DA:1037,0 +DA:1039,2 +DA:1041,8 +DA:1042,6 +DA:1043,0 +DA:1045,0 +DA:1046,0 +DA:1054,0 +DA:1059,2 +DA:1060,2 +DA:1067,2 +DA:1070,2 +DA:1074,2 +DA:1078,2 +DA:1079,0 +DA:1080,0 +DA:1084,2 +DA:1087,2 +DA:1088,0 +DA:1093,0 +DA:1097,2 +DA:1101,2 +DA:1102,0 +DA:1105,0 +DA:1107,0 +DA:1117,2 +DA:1129,2 +DA:1130,0 +DA:1131,0 +DA:1133,0 +DA:1137,2 +DA:1138,0 +DA:1139,0 +DA:1141,0 +DA:1145,2 +DA:1146,2 +DA:1148,2 +DA:1149,2 +DA:1153,2 +DA:1154,0 +DA:1171,2 +DA:1173,2 +DA:1175,2 +DA:1180,2 +DA:1181,0 +DA:1182,0 +DA:1194,2 +DA:1195,0 +DA:1196,0 +DA:1201,2 +DA:1203,0 +DA:1204,0 +DA:1208,2 +DA:1209,0 +DA:1210,0 +DA:1215,2 +DA:1216,0 +DA:1217,0 +DA:1224,2 +DA:1227,2 +DA:1228,0 +DA:1229,0 +DA:1243,2 +DA:1244,0 +DA:1249,0 +DA:1272,2 +DA:1275,2 +DA:1276,2 +DA:1277,0 +DA:1280,2 +DA:1281,1 +DA:1282,0 +DA:1283,0 +DA:1287,1 +DA:1296,2 +DA:1297,0 +DA:1299,2 +DA:1301,2 +DA:1310,2 +DA:1311,0 +DA:1312,0 +DA:1314,0 +DA:1316,2 +DA:1322,20 +DA:1323,18 +DA:1327,2 +DA:1329,2 +DA:1331,2 +DA:1333,2 +DA:1339,2 +DA:1341,2 +DA:1343,2 +DA:1345,2 +DA:1347,2 +DA:1351,2 +DA:1353,2 +DA:1356,2 +DA:1357,0 +DA:1358,0 +DA:1380,2 +DA:1386,2 +DA:1387,2 +DA:1390,2 +DA:1392,2 +DA:1393,0 +DA:1395,0 +DA:1396,0 +DA:1399,2 +DA:1401,2 +DA:1402,2 +DA:1403,2 +DA:1404,2 +DA:1409,2 +DA:1412,2 +DA:1414,2 +DA:1416,2 +DA:1417,0 +DA:1418,0 +DA:1422,2 +DA:1423,2 +DA:1427,0 +DA:1428,0 +DA:1432,2 +DA:1433,0 +DA:1434,0 +DA:1435,0 +DA:1438,0 +DA:1442,0 +DA:1443,0 +DA:1448,2 +DA:1449,0 +DA:1451,0 +DA:1452,0 +DA:1453,0 +DA:1460,2 +DA:1461,1 +DA:1463,1 +DA:1466,2 +DA:1487,2 +DA:1488,0 +DA:1489,0 +DA:1493,2 +DA:1494,0 +DA:1497,2 +DA:1498,2 +DA:1500,2 +DA:1501,0 +DA:1502,0 +DA:1505,2 +DA:1509,2 +DA:1511,2 +DA:1514,2 +DA:1520,2 +DA:1523,0 +DA:1525,0 +DA:1526,0 +DA:1529,0 +DA:1530,0 +DA:1533,0 +DA:1536,0 +DA:1537,0 +DA:1539,0 +DA:1541,0 +DA:1542,0 +DA:1543,0 +DA:1545,0 +DA:1546,0 +DA:1548,0 +DA:1551,0 +DA:1552,0 +DA:1555,0 +DA:1556,0 +DA:1559,0 +DA:1560,0 +DA:1561,0 +DA:1564,0 +DA:1572,2 +DA:1579,2 +DA:1582,2 +DA:1583,2 +DA:1585,2 +DA:1587,2 +DA:1588,0 +DA:1589,0 +DA:1590,0 +DA:1594,2 +DA:1595,0 +DA:1596,0 +DA:1598,0 +DA:1599,0 +DA:1601,0 +DA:1602,0 +DA:1606,0 +DA:1608,0 +DA:1613,0 +DA:1621,2 +DA:1622,0 +DA:1623,0 +DA:1624,0 +DA:1631,2 +DA:1633,0 +DA:1634,0 +DA:1638,2 +DA:1639,0 +DA:1641,2 +DA:1648,2 +DA:1746,2 +DA:1751,2 +DA:1753,2 +DA:1754,0 +DA:1755,0 +DA:1774,2 +DA:1775,2 +DA:1779,2 +DA:1780,2 +DA:1785,0 +DA:1793,2 +DA:1797,2 +DA:1799,2 +DA:1801,2 +DA:1802,0 +DA:1803,0 +DA:1806,2 +DA:1817,2 +DA:1818,0 +DA:1819,0 +DA:1832,2 +DA:1834,2 +DA:1836,2 +DA:1837,2 +DA:1842,0 +DA:1843,0 +DA:1847,0 +DA:1848,0 +DA:1853,0 +DA:1855,0 +DA:1856,0 +DA:1861,0 +DA:1867,0 +DA:1870,0 +DA:1873,0 +DA:1874,0 +DA:1875,0 +DA:1895,2 +DA:1896,0 +DA:1897,0 +DA:1901,2 +DA:1902,0 +DA:1903,0 +DA:1909,2 +DA:1914,2 +DA:1917,2 +DA:1920,2 +DA:1922,2 +DA:1924,2 +DA:1925,2 +DA:1929,0 +DA:1932,0 +DA:1933,0 +DA:1934,0 +DA:1935,0 +DA:1940,0 +DA:1942,0 +DA:1943,0 +DA:1944,0 +DA:1945,0 +DA:1949,0 +DA:1951,0 +DA:1952,0 +DA:1953,0 +DA:1954,0 +DA:1959,0 +DA:1960,0 +DA:1962,0 +DA:1963,0 +DA:1964,0 +DA:1965,0 +DA:1966,0 +DA:1969,0 +DA:1970,0 +DA:1971,0 +DA:1972,0 +DA:1973,0 +DA:1977,0 +DA:1978,0 +DA:1979,0 +DA:1980,0 +DA:1983,2 +DA:1985,2 +DA:1987,2 +DA:1988,0 +DA:1989,0 +DA:1993,2 +DA:1995,2 +DA:1998,2 +DA:1999,0 +DA:2002,2 +DA:2006,2 +DA:2019,2 +DA:2021,0 +DA:2025,0 +DA:2028,2 +DA:2029,2 +DA:2031,2 +DA:2034,2 +DA:2037,2 +DA:2040,2 +DA:2043,2 +DA:2046,2 +DA:2047,2 +DA:2048,0 +DA:2052,2 +DA:2059,2 +DA:2061,2 +DA:2063,2 +DA:2065,2 +DA:2066,2 +DA:2072,2 +DA:2074,2 +DA:2075,2 +DA:2084,2 +DA:2110,2 +DA:2115,2 +DA:2117,2 +DA:2120,2 +DA:2122,4 +DA:2123,0 +DA:2124,0 +DA:2127,4 +DA:2128,2 +DA:2135,2 +DA:2136,0 +DA:2137,0 +DA:2143,2 +DA:2145,2 +DA:2146,0 +DA:2149,2 +DA:2150,0 +DA:2152,2 +DA:2155,0 +DA:2156,0 +DA:2160,2 +DA:2163,2 +DA:2164,0 +DA:2167,2 +DA:2168,2 +DA:2169,2 +DA:2170,2 +DA:2172,2 +DA:2180,9 +DA:2182,9 +DA:2189,9 +DA:2192,9 +DA:2193,9 +DA:2196,9 +DA:2197,9 +DA:2199,9 +DA:2203,9 +DA:2208,9 +DA:2209,9 +DA:2210,9 +DA:2213,9 +DA:2214,9 +DA:2215,9 +DA:2216,9 +DA:2218,9 +DA:2219,9 +DA:2220,9 +DA:2223,9 +DA:2224,9 +DA:2225,9 +DA:2227,9 +DA:2228,9 +DA:2230,9 +DA:2231,0 +DA:2232,0 +DA:2237,9 +DA:2238,9 +DA:2239,9 +DA:2240,9 +DA:2241,9 +DA:2244,9 +DA:2246,9 +DA:2249,9 +DA:2250,9 +DA:2252,9 +DA:2254,9 +DA:2257,3 +DA:2260,3 +DA:2261,3 +DA:2262,3 +DA:2263,3 +DA:2264,3 +DA:2265,0 +DA:2268,0 +DA:2273,3 +DA:2282,3 +DA:2284,3 +DA:2286,3 +DA:2287,0 +DA:2290,0 +DA:2294,3 +DA:2296,3 +DA:2297,0 +DA:2299,0 +DA:2300,0 +DA:2306,3 +DA:2307,3 +DA:2311,3 +DA:2312,3 +DA:2314,3 +DA:2319,0 +DA:2321,3 +DA:2326,0 +DA:2328,0 +DA:2332,3 +DA:2340,3 +DA:2342,0 +DA:2347,0 +DA:2348,0 +DA:2354,3 +DA:2358,3 +DA:2360,3 +DA:2362,3 +DA:2363,1 +DA:2364,0 +DA:2366,1 +DA:2368,1 +DA:2369,0 +DA:2370,0 +DA:2372,0 +DA:2376,1 +DA:2377,1 +DA:2383,8 +DA:2391,8 +DA:2393,8 +DA:2394,0 +DA:2397,0 +DA:2400,8 +DA:2402,8 +DA:2403,0 +DA:2407,0 +DA:2411,17 +DA:2412,17 +DA:2413,17 +DA:2415,17 +DA:2417,9 +DA:2418,9 +DA:2419,9 +DA:2425,9 +DA:2426,9 +DA:2429,9 +DA:2432,9 +DA:2433,0 +DA:2435,9 +DA:2436,0 +DA:2438,0 +DA:2442,8 +DA:2443,0 +DA:2445,0 +DA:2448,8 +DA:2452,0 +DA:2460,0 +DA:2467,0 +DA:2469,0 +DA:2470,0 +DA:2473,0 +DA:2476,0 +DA:2477,0 +DA:2480,0 +DA:2484,0 +DA:2485,0 +DA:2486,0 +DA:2488,0 +DA:2490,0 +DA:2491,0 +DA:2497,0 +DA:2498,0 +DA:2502,0 +DA:2503,0 +DA:2506,0 +DA:2509,0 +DA:2510,0 +DA:2512,0 +DA:2513,0 +DA:2515,0 +DA:2519,0 +DA:2520,0 +DA:2523,0 +DA:2529,0 +DA:2539,0 +DA:2541,0 +DA:2542,0 +DA:2545,0 +DA:2549,0 +DA:2551,0 +DA:2552,0 +DA:2553,0 +DA:2559,0 +DA:2560,0 +DA:2562,0 +DA:2567,0 +DA:2569,0 +DA:2572,0 +DA:2573,0 +DA:2625,0 +DA:2633,0 +DA:2635,0 +DA:2636,0 +DA:2639,0 +DA:2642,0 +DA:2643,0 +DA:2650,0 +DA:2654,0 +DA:2656,0 +DA:2657,0 +DA:2659,0 +DA:2661,0 +DA:2662,0 +DA:2663,0 +DA:2668,0 +DA:2669,0 +DA:2672,0 +DA:2675,0 +DA:2676,0 +DA:2678,0 +DA:2679,0 +DA:2681,0 +DA:2685,0 +DA:2686,0 +DA:2687,0 +DA:2693,0 +DA:2698,0 +DA:2702,0 +DA:2704,0 +DA:2708,0 +DA:2709,0 +DA:2712,0 +DA:2734,0 +DA:2745,0 +DA:2747,0 +DA:2748,0 +DA:2751,0 +DA:2754,0 +DA:2756,0 +DA:2757,0 +DA:2761,0 +DA:2763,0 +DA:2764,0 +DA:2766,0 +DA:2770,0 +DA:2774,0 +DA:2776,0 +DA:2777,0 +DA:2779,0 +DA:2780,0 +DA:2784,0 +DA:2788,0 +DA:2789,0 +DA:2791,0 +DA:2794,0 +DA:2796,0 +DA:2804,0 +DA:2805,0 +DA:2808,0 +DA:2814,0 +DA:2822,0 +DA:2824,0 +DA:2825,0 +DA:2827,0 +DA:2830,0 +DA:2839,0 +DA:2847,0 +DA:2852,0 +DA:2855,0 +DA:2857,0 +DA:2858,0 +DA:2859,0 +DA:2863,0 +DA:2864,0 +DA:2867,0 +DA:2872,0 +DA:2882,0 +DA:2887,0 +DA:2889,0 +DA:2890,0 +DA:2892,0 +DA:2896,0 +DA:2902,0 +DA:2907,0 +DA:2911,0 +DA:2914,0 +DA:2916,0 +DA:2918,0 +DA:2922,0 +DA:2924,0 +DA:2925,0 +DA:2936,0 +DA:2938,0 +DA:2941,0 +DA:2942,0 +DA:2943,0 +DA:2946,0 +DA:2948,0 +DA:2949,0 +DA:2951,0 +DA:2952,0 +DA:2954,0 +DA:2963,0 +DA:2965,0 +DA:2966,0 +DA:2968,0 +DA:2970,0 +DA:2972,0 +DA:2974,0 +DA:2977,0 +DA:2980,0 +DA:2984,0 +DA:2990,0 +DA:2998,0 +DA:3006,0 +DA:3008,0 +DA:3009,0 +DA:3011,0 +DA:3015,0 +DA:3020,0 +DA:3025,0 +DA:3029,0 +DA:3032,0 +DA:3034,0 +DA:3035,0 +DA:3040,0 +DA:3042,0 +DA:3043,0 +DA:3054,0 +DA:3056,0 +DA:3059,0 +DA:3060,0 +DA:3061,0 +DA:3064,0 +DA:3066,0 +DA:3069,0 +DA:3070,0 +DA:3076,0 +DA:3080,0 +DA:3081,0 +DA:3084,0 +DA:3091,0 +DA:3092,0 +DA:3095,0 +DA:3101,0 +DA:3104,0 +DA:3105,0 +DA:3112,0 +DA:3113,0 +DA:3116,0 +DA:3119,0 +DA:3121,0 +DA:3124,0 +DA:3125,0 +DA:3128,0 +DA:3129,0 +DA:3131,0 +DA:3134,0 +DA:3136,0 +DA:3137,0 +DA:3138,0 +DA:3142,0 +DA:3145,0 +DA:3147,0 +DA:3148,0 +DA:3149,0 +DA:3152,0 +DA:3154,0 +DA:3155,0 +DA:3156,0 +DA:3159,0 +DA:3160,0 +DA:3161,0 +DA:3164,0 +DA:3165,0 +DA:3166,0 +DA:3171,0 +DA:3172,0 +DA:3173,0 +DA:3174,0 +DA:3175,0 +DA:3177,0 +DA:3179,0 +DA:3182,0 +DA:3183,0 +DA:3185,0 +DA:3186,0 +DA:3190,0 +DA:3198,0 +DA:3210,0 +DA:3212,0 +DA:3213,0 +DA:3216,0 +DA:3219,0 +DA:3226,0 +DA:3228,0 +DA:3231,0 +DA:3235,0 +DA:3240,0 +DA:3244,0 +DA:3245,0 +DA:3247,0 +DA:3248,0 +DA:3250,0 +DA:3252,0 +DA:3256,0 +DA:3258,0 +DA:3259,0 +DA:3261,0 +DA:3267,0 +DA:3271,0 +DA:3273,0 +DA:3275,0 +DA:3278,0 +DA:3284,0 +DA:3288,0 +DA:3296,0 +DA:3305,0 +DA:3307,0 +DA:3308,0 +DA:3312,0 +DA:3315,0 +DA:3322,0 +DA:3325,0 +DA:3332,0 +DA:3334,0 +DA:3335,0 +DA:3340,0 +DA:3343,0 +DA:3351,0 +DA:3352,0 +DA:3357,0 +DA:3362,0 +DA:3363,0 +DA:3374,0 +DA:3382,0 +DA:3384,0 +DA:3385,0 +DA:3386,0 +DA:3440,0 +DA:3441,0 +DA:3442,0 +DA:3446,0 +DA:3447,0 +DA:3455,0 +DA:3457,0 +DA:3465,0 +DA:3468,0 +DA:3477,0 +DA:3484,0 +DA:3485,0 +DA:3488,0 +DA:3489,0 +DA:3492,0 +DA:3495,0 +DA:3496,0 +DA:3497,0 +DA:3505,0 +DA:3511,0 +DA:3512,0 +DA:3516,0 +DA:3527,0 +DA:3530,0 +DA:3543,0 +DA:3545,0 +DA:3546,0 +DA:3549,0 +DA:3552,0 +DA:3554,0 +DA:3559,0 +DA:3566,0 +DA:3568,0 +DA:3573,0 +DA:3577,0 +DA:3578,0 +DA:3580,0 +DA:3581,0 +DA:3583,0 +DA:3584,0 +DA:3585,0 +DA:3587,0 +DA:3588,0 +DA:3591,0 +DA:3592,0 +DA:3595,0 +DA:3596,0 +DA:3606,0 +DA:3614,0 +DA:3616,0 +DA:3617,0 +DA:3618,0 +DA:3623,0 +DA:3631,0 +DA:3634,0 +DA:3636,0 +DA:3639,0 +DA:3646,0 +DA:3648,0 +DA:3649,0 +DA:3651,0 +DA:3656,0 +DA:3664,0 +DA:3666,0 +DA:3669,1 +DA:3678,1 +DA:3680,1 +DA:3681,0 +DA:3682,0 +DA:3685,1 +DA:3686,0 +DA:3687,0 +DA:3698,2 +DA:3710,2 +DA:3711,2 +DA:3713,0 +DA:3715,2 +DA:3717,2 +DA:3718,0 +DA:3720,2 +DA:3721,1 +DA:3722,1 +DA:3773,3 +DA:3781,3 +DA:3782,0 +DA:3783,0 +DA:3786,3 +DA:3788,3 +DA:3789,0 +DA:3790,0 +DA:3793,3 +DA:3795,0 +DA:3801,3 +DA:3803,3 +DA:3804,0 +DA:3805,0 +DA:3807,3 +DA:3808,3 +DA:3809,3 +DA:3810,3 +DA:3812,3 +DA:3813,0 +DA:3814,0 +DA:3857,3 +DA:3861,3 +DA:3865,2 +DA:3867,2 +DA:3869,2 +DA:3871,2 +DA:3872,0 +DA:3873,0 +DA:3877,2 +DA:3881,2 +DA:3883,0 +DA:3884,0 +DA:3889,0 +DA:3890,0 +DA:3893,2 +DA:3900,2 +DA:3904,2 +DA:3905,2 +DA:3907,2 +LF:1110 +LH:435 +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:0,dlt_daemon_control_service_logstorage +FNDA:4,dlt_daemon_control_get_log_info +FNDA:1,dlt_daemon_control_service_response +FNDA:9,dlt_daemon_client_process_control +FNDA:0,dlt_daemon_control_set_default_trace_status +FNDA:0,dlt_daemon_send_trace_status +FNDA:0,dlt_daemon_control_set_default_log_level +FNDA:0,dlt_daemon_find_multiple_context_and_send_log_level +FNDA:0,dlt_daemon_control_set_trace_status +FNDA:0,dlt_daemon_process_sixty_s_timer +FNDA:0,dlt_daemon_find_multiple_context_and_send_trace_status +FNDA:0,dlt_daemon_control_set_all_trace_status +FNDA:0,dlt_daemon_control_callsw_cinjection +FNDA:37,dlt_daemon_client_send +FNDA:0,dlt_daemon_control_message_marker +FNDA:0,dlt_daemon_client_send_message_to_all_client +FNDA:0,dlt_daemon_control_message_buffer_overflow +FNDA:0,dlt_daemon_control_passive_node_connect_status +FNDA:1,dlt_daemon_process_one_s_timer +FNDA:3,dlt_daemon_control_get_software_version +FNDA:0,dlt_daemon_control_passive_node_connect +FNDA:0,dlt_daemon_send_log_level +FNDA:0,dlt_daemon_control_set_timing_packets +FNDA:14,dlt_daemon_client_send_control_message +FNDA:5,dlt_daemon_control_message_connection_info +FNDA:0,dlt_daemon_control_message_timezone +FNDA:0,dlt_daemon_control_set_all_log_level +FNDA:9,dlt_daemon_client_send_all_multiple +FNDA:0,dlt_daemon_control_message_time +FNDA:0,dlt_daemon_control_message_unregister_context +FNDA:0,dlt_daemon_process_systemd_timer +FNDA:1,dlt_daemon_control_get_default_log_level +FNDA:1,dlt_daemon_control_set_log_level +FNF:33 +FNH:11 +DA:80,0 +DA:103,9 +DA:118,9 +DA:120,9 +DA:121,0 +DA:122,0 +DA:125,56 +DA:127,47 +DA:128,47 +DA:130,47 +DA:131,47 +DA:132,36 +DA:133,36 +DA:136,11 +DA:143,11 +DA:144,0 +DA:145,0 +DA:151,11 +DA:152,0 +DA:163,37 +DA:178,37 +DA:179,0 +DA:180,0 +DA:183,37 +DA:185,12 +DA:186,0 +DA:187,0 +DA:188,0 +DA:189,0 +DA:190,0 +DA:193,12 +DA:194,12 +DA:195,12 +DA:196,0 +DA:197,0 +DA:201,12 +DA:208,25 +DA:209,23 +DA:210,0 +DA:211,0 +DA:215,0 +DA:216,0 +DA:217,0 +DA:227,23 +DA:228,0 +DA:239,25 +DA:254,25 +DA:256,9 +DA:257,9 +DA:265,9 +DA:273,25 +DA:274,23 +DA:276,16 +DA:278,16 +DA:279,16 +DA:280,0 +DA:283,16 +DA:284,0 +DA:285,0 +DA:286,0 +DA:288,0 +DA:291,9 +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,0 +DA:322,0 +DA:324,0 +DA:325,0 +DA:326,0 +DA:330,0 +DA:331,0 +DA:334,0 +DA:337,0 +DA:338,0 +DA:340,0 +DA:344,0 +DA:345,0 +DA:349,0 +DA:350,0 +DA:352,0 +DA:355,0 +DA:356,0 +DA:358,0 +DA:359,0 +DA:363,0 +DA:364,0 +DA:365,0 +DA:367,0 +DA:368,0 +DA:369,0 +DA:370,0 +DA:372,0 +DA:373,0 +DA:374,0 +DA:375,0 +DA:377,0 +DA:381,0 +DA:382,0 +DA:384,0 +DA:385,0 +DA:389,14 +DA:400,14 +DA:402,14 +DA:406,14 +DA:408,14 +DA:412,14 +DA:413,14 +DA:419,14 +DA:422,14 +DA:426,14 +DA:428,14 +DA:431,14 +DA:432,14 +DA:433,14 +DA:434,14 +DA:436,14 +DA:438,14 +DA:439,14 +DA:441,0 +DA:443,14 +DA:444,14 +DA:446,0 +DA:449,14 +DA:450,14 +DA:452,14 +DA:454,14 +DA:455,0 +DA:456,0 +DA:459,14 +DA:461,14 +DA:462,14 +DA:464,14 +DA:465,14 +DA:466,0 +DA:467,0 +DA:473,9 +DA:482,9 +DA:484,9 +DA:487,9 +DA:490,9 +DA:493,9 +DA:494,0 +DA:495,0 +DA:502,9 +DA:503,9 +DA:505,9 +DA:507,9 +DA:508,1 +DA:510,1 +DA:511,1 +DA:513,0 +DA:515,0 +DA:516,0 +DA:518,4 +DA:520,4 +DA:521,4 +DA:523,1 +DA:525,1 +DA:526,1 +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,3 +DA:674,3 +DA:675,3 +DA:677,0 +DA:679,0 +DA:681,0 +DA:683,0 +DA:685,0 +DA:686,0 +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,3 +DA:741,3 +DA:743,3 +DA:744,0 +DA:747,3 +DA:748,0 +DA:754,0 +DA:758,3 +DA:761,3 +DA:763,3 +DA:764,0 +DA:765,0 +DA:768,3 +DA:769,3 +DA:770,3 +DA:773,3 +DA:774,0 +DA:780,0 +DA:784,3 +DA:785,3 +DA:786,3 +DA:787,3 +DA:790,3 +DA:793,3 +DA:796,1 +DA:801,1 +DA:803,1 +DA:804,0 +DA:807,1 +DA:808,0 +DA:814,0 +DA:817,1 +DA:819,1 +DA:820,0 +DA:821,0 +DA:824,1 +DA:825,1 +DA:826,1 +DA:829,1 +DA:830,0 +DA:836,0 +DA:840,1 +DA:841,1 +DA:842,1 +DA:845,1 +DA:848,1 +DA:851,4 +DA:863,4 +DA:882,4 +DA:884,4 +DA:885,0 +DA:887,4 +DA:890,4 +DA:892,4 +DA:896,4 +DA:899,4 +DA:900,0 +DA:906,0 +DA:910,4 +DA:911,0 +DA:917,0 +DA:920,4 +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,4 +DA:950,4 +DA:961,4 +DA:965,4 +DA:966,4 +DA:968,4 +DA:969,4 +DA:971,4 +DA:974,4 +DA:975,4 +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,4 +DA:1020,0 +DA:1022,0 +DA:1023,0 +DA:1024,0 +DA:1027,4 +DA:1028,0 +DA:1030,0 +DA:1031,0 +DA:1036,4 +DA:1037,0 +DA:1042,4 +DA:1043,4 +DA:1045,4 +DA:1046,0 +DA:1052,0 +DA:1059,4 +DA:1063,4 +DA:1065,4 +DA:1068,4 +DA:1070,4 +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,4 +DA:1213,4 +DA:1216,4 +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,1 +DA:1290,1 +DA:1292,1 +DA:1293,0 +DA:1296,1 +DA:1300,1 +DA:1302,1 +DA:1303,0 +DA:1304,0 +DA:1307,1 +DA:1308,1 +DA:1309,1 +DA:1312,1 +DA:1316,1 +DA:1317,1 +DA:1320,1 +DA:1323,1 +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,5 +DA:1391,5 +DA:1393,5 +DA:1397,5 +DA:1401,5 +DA:1403,5 +DA:1404,0 +DA:1405,0 +DA:1408,5 +DA:1409,5 +DA:1410,5 +DA:1413,5 +DA:1417,5 +DA:1418,5 +DA:1419,5 +DA:1420,5 +DA:1423,5 +DA:1424,0 +DA:1425,0 +DA:1429,5 +DA:1431,5 +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,1 +DA:1740,1 +DA:1742,1 +DA:1743,1 +DA:1749,1 +DA:1750,0 +DA:1752,1 +DA:1755,1 +DA:1757,1 +DA:1758,0 +DA:1760,1 +DA:1761,1 +DA:1762,1 +DA:1763,1 +DA:1765,1 +DA:1766,0 +DA:1771,0 +DA:1772,0 +DA:1775,1 +DA:1777,0 +DA:1782,0 +DA:1783,0 +DA:1786,1 +DA:1788,0 +DA:1794,0 +DA:1797,1 +DA:1799,0 +DA:1805,0 +DA:1809,1 +DA:1812,1 +DA:1816,1 +DA:1817,0 +DA:1820,1 +DA:1822,1 +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,1 +DA:2269,1 +DA:2272,1 +DA:2274,1 +DA:2275,0 +DA:2276,0 +DA:2279,1 +DA:2281,1 +DA:2282,0 +DA:2283,0 +DA:2288,1 +DA:2290,0 +DA:2293,0 +DA:2297,1 +DA:2298,0 +DA:2299,0 +DA:2304,1 +DA:2306,1 +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,0 +DA:2431,0 +DA:2434,0 +DA:2437,0 +DA:2439,0 +DA:2440,0 +DA:2443,0 +DA:2446,0 +DA:2447,0 +DA:2454,0 +DA:2456,0 +DA:2459,0 +DA:2462,0 +DA:2464,0 +DA:2465,0 +DA:2466,0 +DA:2467,0 +DA:2468,0 +DA:2475,0 +DA:2478,0 +DA:2482,0 +DA:2483,0 +DA:2486,0 +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,0 +DA:2515,0 +DA:2516,0 +DA:2520,0 +DA:2521,0 +DA:2525,0 +DA:2526,0 +DA:2532,0 +DA:2533,0 +DA:2537,0 +DA:2539,0 +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,0 +DA:2586,0 +DA:2593,0 +DA:2596,0 +DA:2605,0 +DA:2609,0 +DA:2611,0 +DA:2612,0 +DA:2614,0 +DA:2617,0 +DA:2622,0 +DA:2624,0 +DA:2628,0 +DA:2629,0 +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:216 +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:5,dlt_daemon_contexts_invalidate_fd +FNDA:0,dlt_daemon_application_del +FNDA:12,dlt_daemon_context_find +FNDA:2,dlt_daemon_applications_load +FNDA:1,dlt_daemon_user_send_all_log_state +FNDA:9,dlt_daemon_application_find +FNDA:3,dlt_daemon_contexts_clear +FNDA:51,dlt_daemon_find_users_list +FNDA:3,dlt_daemon_user_send_log_level +FNDA:0,dlt_daemon_cmp_apid +FNDA:0,dlt_daemon_applications_save +FNDA:0,dlt_daemon_user_send_all_trace_status_update +FNDA:0,dlt_daemon_user_send_all_log_level_update +FNDA:0,dlt_daemon_context_del +FNDA:2,dlt_daemon_init_runtime_configuration +FNDA:3,dlt_daemon_applications_clear +FNDA:3,dlt_daemon_application_add +FNDA:4,dlt_daemon_change_state +FNDA:10,dlt_daemon_init +FNDA:5,dlt_daemon_applications_invalidate_fd +FNDA:0,dlt_daemon_configuration_save +FNDA:6,dlt_daemon_cmp_apid_ctid +FNDA:3,dlt_daemon_context_add +FNDA:0,dlt_daemon_contexts_load +FNDA:0,dlt_daemon_user_send_default_update +FNDA:2,dlt_daemon_configuration_load +FNDA:11,dlt_daemon_init_user_information +FNDA:2,dlt_daemon_free +FNDA:0,dlt_daemon_user_send_log_state +FNDA:0,dlt_daemon_contexts_save +FNDA:2,dlt_daemon_application_reset_user_handle +FNDA:0,dlt_daemon_control_reset_to_factory_default +FNF:32 +FNH:20 +DA:91,0 +DA:93,6 +DA:99,6 +DA:102,6 +DA:104,6 +DA:111,6 +DA:113,6 +DA:115,6 +DA:116,6 +DA:123,51 +DA:127,51 +DA:131,51 +DA:132,0 +DA:133,0 +DA:136,53 +DA:137,53 +DA:138,51 +DA:140,0 +DA:141,0 +DA:229,2 +DA:231,2 +DA:234,2 +DA:238,2 +DA:240,2 +DA:246,2 +DA:247,0 +DA:248,0 +DA:251,2 +DA:252,2 +DA:255,2 +DA:259,2 +DA:260,0 +DA:261,0 +DA:264,2 +DA:265,2 +DA:268,2 +DA:272,2 +DA:273,0 +DA:274,0 +DA:277,2 +DA:278,2 +DA:281,2 +DA:283,2 +DA:286,10 +DA:296,10 +DA:298,10 +DA:301,10 +DA:302,10 +DA:304,10 +DA:305,10 +DA:306,10 +DA:308,10 +DA:310,10 +DA:312,10 +DA:314,10 +DA:316,10 +DA:317,10 +DA:319,10 +DA:322,10 +DA:325,10 +DA:331,10 +DA:335,10 +DA:338,2 +DA:343,2 +DA:345,2 +DA:349,5 +DA:350,3 +DA:352,3 +DA:354,3 +DA:355,3 +DA:359,2 +DA:367,2 +DA:368,2 +DA:371,2 +DA:373,2 +DA:376,11 +DA:384,11 +DA:386,11 +DA:389,11 +DA:391,10 +DA:393,10 +DA:394,0 +DA:395,0 +DA:398,10 +DA:399,10 +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,5 +DA:430,5 +DA:432,5 +DA:435,5 +DA:437,5 +DA:438,7 +DA:439,2 +DA:440,0 +DA:448,3 +DA:453,3 +DA:455,3 +DA:458,3 +DA:460,3 +DA:463,3 +DA:464,0 +DA:471,0 +DA:472,0 +DA:475,3 +DA:476,0 +DA:478,3 +DA:479,3 +DA:481,3 +DA:484,2 +DA:492,2 +DA:495,0 +DA:496,0 +DA:497,0 +DA:498,0 +DA:499,0 +DA:500,0 +DA:504,0 +DA:505,0 +DA:507,0 +DA:508,0 +DA:511,3 +DA:530,3 +DA:533,3 +DA:535,3 +DA:538,3 +DA:539,3 +DA:540,3 +DA:542,3 +DA:549,3 +DA:551,3 +DA:552,3 +DA:554,3 +DA:555,3 +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,3 +DA:578,3 +DA:579,3 +DA:580,3 +DA:581,3 +DA:582,3 +DA:583,3 +DA:588,0 +DA:591,0 +DA:599,3 +DA:600,0 +DA:601,0 +DA:604,3 +DA:605,3 +DA:607,3 +DA:608,3 +DA:610,0 +DA:611,0 +DA:612,0 +DA:616,3 +DA:617,2 +DA:618,2 +DA:622,3 +DA:642,2 +DA:643,0 +DA:644,0 +DA:652,2 +DA:653,2 +DA:655,2 +DA:656,2 +DA:657,2 +DA:661,3 +DA:662,3 +DA:663,3 +DA:668,3 +DA:679,0 +DA:687,0 +DA:689,0 +DA:692,0 +DA:694,0 +DA:697,0 +DA:698,0 +DA:701,0 +DA:702,0 +DA:703,0 +DA:706,0 +DA:709,0 +DA:710,0 +DA:711,0 +DA:714,0 +DA:718,0 +DA:724,9 +DA:732,9 +DA:734,9 +DA:735,9 +DA:738,9 +DA:740,9 +DA:744,6 +DA:745,6 +DA:746,6 +DA:750,6 +DA:751,6 +DA:752,6 +DA:753,6 +DA:758,2 +DA:766,2 +DA:768,2 +DA:771,2 +DA:773,2 +DA:774,2 +DA:778,2 +DA:780,2 +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,3 +DA:916,3 +DA:918,3 +DA:919,3 +DA:922,3 +DA:925,3 +DA:928,3 +DA:930,3 +DA:933,3 +DA:934,3 +DA:936,3 +DA:941,3 +DA:943,3 +DA:947,3 +DA:949,3 +DA:950,3 +DA:952,3 +DA:953,3 +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,3 +DA:977,3 +DA:978,3 +DA:980,3 +DA:985,3 +DA:986,0 +DA:987,0 +DA:990,3 +DA:991,3 +DA:993,3 +DA:994,3 +DA:1028,3 +DA:1032,0 +DA:1036,0 +DA:1039,0 +DA:1050,3 +DA:1051,0 +DA:1052,3 +DA:1053,3 +DA:1056,3 +DA:1057,3 +DA:1062,3 +DA:1063,0 +DA:1065,3 +DA:1068,3 +DA:1069,3 +DA:1070,3 +DA:1075,3 +DA:1118,0 +DA:1127,0 +DA:1129,0 +DA:1132,0 +DA:1134,0 +DA:1137,0 +DA:1138,0 +DA:1144,0 +DA:1145,0 +DA:1146,0 +DA:1149,0 +DA:1152,0 +DA:1153,0 +DA:1154,0 +DA:1157,0 +DA:1161,0 +DA:1164,0 +DA:1165,0 +DA:1171,12 +DA:1180,12 +DA:1182,12 +DA:1183,12 +DA:1186,12 +DA:1188,12 +DA:1192,6 +DA:1193,6 +DA:1194,6 +DA:1198,6 +DA:1199,6 +DA:1201,6 +DA:1202,6 +DA:1203,6 +DA:1208,5 +DA:1216,5 +DA:1218,5 +DA:1221,5 +DA:1223,5 +DA:1224,5 +DA:1225,0 +DA:1226,0 +DA:1234,3 +DA:1239,3 +DA:1241,3 +DA:1244,3 +DA:1246,3 +DA:1249,3 +DA:1250,0 +DA:1251,0 +DA:1252,0 +DA:1255,3 +DA:1256,0 +DA:1257,0 +DA:1260,3 +DA:1261,0 +DA:1263,3 +DA:1265,3 +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,2 +DA:1455,2 +DA:1464,2 +DA:1466,2 +DA:1468,2 +DA:1471,4 +DA:1472,2 +DA:1473,2 +DA:1474,2 +DA:1476,4 +DA:1477,2 +DA:1480,2 +DA:1482,2 +DA:1486,0 +DA:1487,0 +DA:1490,2 +DA:1493,2 +DA:1495,0 +DA:1496,0 +DA:1497,0 +DA:1501,0 +DA:1511,2 +DA:1514,0 +DA:1520,3 +DA:1527,3 +DA:1529,3 +DA:1530,0 +DA:1531,0 +DA:1534,3 +DA:1535,0 +DA:1536,0 +DA:1539,3 +DA:1540,2 +DA:1541,0 +DA:1544,3 +DA:1545,3 +DA:1547,3 +DA:1548,3 +DA:1550,3 +DA:1552,3 +DA:1553,3 +DA:1554,3 +DA:1555,3 +DA:1556,3 +DA:1561,3 +DA:1562,3 +DA:1566,3 +DA:1567,0 +DA:1569,0 +DA:1571,0 +DA:1572,0 +DA:1573,0 +DA:1574,0 +DA:1578,3 +DA:1581,0 +DA:1587,0 +DA:1589,0 +DA:1592,0 +DA:1595,0 +DA:1598,0 +DA:1602,0 +DA:1603,0 +DA:1604,0 +DA:1607,0 +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,1 +DA:1792,1 +DA:1794,1 +DA:1795,0 +DA:1796,0 +DA:1799,1 +DA:1801,1 +DA:1804,1 +DA:1805,0 +DA:1807,0 +DA:1808,0 +DA:1809,0 +DA:1810,0 +DA:1815,4 +DA:1817,4 +DA:1818,0 +DA:1819,0 +DA:1820,0 +DA:1821,0 +DA:1822,2 +DA:1823,2 +DA:1824,2 +DA:1825,2 +DA:1826,0 +DA:1827,0 +DA:1828,0 +DA:1829,0 +DA:1830,1 +DA:1831,1 +DA:1832,1 +DA:1833,1 +DA:1834,1 +DA:1835,1 +DA:1836,1 +DA:1837,1 +DA:1839,4 +LF:619 +LH:284 +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:17,dlt_connection_get_receiver +FNDA:14,dlt_connection_send_multiple +FNDA:2,dlt_connection_get_next +FNDA:16,dlt_connection_create +FNDA:15,dlt_connection_get_callback +FNDA:28,dlt_connection_send +FNDA:19,dlt_connection_destroy_receiver +FNDA:18,dlt_connection_destroy +FNF:8 +FNH:8 +DA:68,28 +DA:75,28 +DA:76,28 +DA:78,28 +DA:79,1 +DA:81,1 +DA:82,1 +DA:86,26 +DA:87,26 +DA:90,26 +DA:110,14 +DA:119,14 +DA:122,13 +DA:123,1 +DA:127,13 +DA:128,13 +DA:130,13 +DA:131,11 +DA:148,2 +DA:150,3 +DA:151,1 +DA:153,2 +DA:156,19 +DA:158,19 +DA:161,19 +DA:165,2 +DA:166,2 +DA:167,2 +DA:168,2 +DA:169,2 +DA:170,13 +DA:171,13 +DA:172,13 +DA:173,13 +DA:174,13 +DA:192,17 +DA:200,17 +DA:201,8 +DA:208,8 +DA:210,8 +DA:211,8 +DA:214,1 +DA:215,1 +DA:217,1 +DA:218,1 +DA:221,2 +DA:222,2 +DA:226,2 +DA:227,2 +DA:230,0 +DA:234,2 +DA:235,2 +DA:242,3 +DA:251,3 +DA:253,3 +DA:254,3 +DA:257,3 +DA:259,3 +DA:260,3 +DA:265,17 +DA:279,15 +DA:284,15 +DA:285,15 +DA:287,15 +DA:291,8 +DA:293,8 +DA:294,0 +DA:296,0 +DA:302,0 +DA:304,0 +DA:305,1 +DA:307,1 +DA:308,0 +DA:310,0 +DA:316,0 +DA:318,0 +DA:319,0 +DA:321,0 +DA:322,3 +DA:324,3 +DA:325,0 +DA:327,0 +DA:328,0 +DA:332,15 +DA:344,18 +DA:346,18 +DA:347,18 +DA:348,18 +DA:349,18 +DA:350,18 +DA:367,16 +DA:375,16 +DA:379,16 +DA:387,16 +DA:389,16 +DA:390,0 +DA:391,0 +DA:396,16 +DA:398,16 +DA:399,0 +DA:401,0 +DA:402,0 +DA:406,16 +DA:407,16 +DA:416,16 +DA:417,6 +DA:421,16 +DA:423,16 +DA:425,4 +DA:427,16 +DA:428,16 +DA:433,16 +LF:112 +LH:93 +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:66,dlt_event_handler_find_connection +FNDA:4,dlt_event_handler_unregister_connection +FNDA:7,dlt_daemon_add_connection +FNDA:5,dlt_event_handler_disable_fd +FNDA:20,dlt_daemon_handle_event +FNDA:17,dlt_daemon_remove_connection +FNDA:19,dlt_event_handler_register_connection +FNDA:19,dlt_event_handler_enable_fd +FNDA:9,dlt_daemon_prepare_event_handling +FNDA:3,dlt_event_handler_cleanup_connections +FNDA:25,dlt_connection_check_activate +FNF:11 +FNH:11 +DA:64,149 +DA:65,149 +DA:66,149 +DA:67,5 +DA:77,9 +DA:81,9 +DA:84,8 +DA:86,8 +DA:87,0 +DA:88,0 +DA:91,136 +DA:92,128 +DA:94,8 +DA:95,8 +DA:97,8 +DA:109,19 +DA:111,19 +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,19 +DA:130,19 +DA:131,19 +DA:142,5 +DA:146,5 +DA:148,20 +DA:149,15 +DA:151,5 +DA:152,5 +DA:155,15 +DA:156,10 +DA:159,5 +DA:160,0 +DA:161,0 +DA:162,0 +DA:168,5 +DA:182,20 +DA:190,20 +DA:193,19 +DA:195,19 +DA:199,2 +DA:202,1 +DA:203,0 +DA:205,2 +DA:208,112 +DA:213,95 +DA:214,78 +DA:216,17 +DA:218,17 +DA:219,17 +DA:220,17 +DA:223,0 +DA:224,0 +DA:228,17 +DA:231,2 +DA:236,2 +DA:238,0 +DA:242,2 +DA:246,15 +DA:248,15 +DA:249,0 +DA:251,0 +DA:255,15 +DA:259,0 +DA:261,0 +DA:279,66 +DA:281,85 +DA:283,296 +DA:284,280 +DA:285,50 +DA:286,211 +DA:302,17 +DA:305,17 +DA:308,17 +DA:312,28 +DA:314,11 +DA:317,17 +DA:319,0 +DA:320,0 +DA:322,17 +DA:324,14 +DA:327,3 +DA:331,17 +DA:333,17 +DA:342,3 +DA:346,3 +DA:350,15 +DA:352,12 +DA:354,14 +DA:355,11 +DA:357,3 +DA:367,7 +DA:371,20 +DA:373,59 +DA:374,39 +DA:376,20 +DA:377,7 +DA:392,25 +DA:396,25 +DA:397,1 +DA:398,1 +DA:401,24 +DA:402,5 +DA:404,5 +DA:405,5 +DA:407,5 +DA:409,5 +DA:410,0 +DA:412,5 +DA:416,19 +DA:418,19 +DA:419,19 +DA:421,19 +DA:422,19 +DA:425,19 +DA:429,0 +DA:430,0 +DA:431,0 +DA:453,19 +DA:458,19 +DA:459,1 +DA:460,1 +DA:463,5 +DA:465,18 +DA:467,4 +DA:470,18 +DA:472,18 +DA:473,18 +DA:475,18 +DA:494,4 +DA:498,4 +DA:504,2 +DA:506,4 +DA:507,0 +DA:508,0 +DA:511,4 +DA:513,3 +DA:515,3 +DA:516,0 +DA:517,0 +DA:521,4 +DA:524,0 +DA:527,4 +LF:150 +LH:123 +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:1,dlt_logstorage_split_apid_ctid +FNDA:5,dlt_logstorage_update_context_loglevel +FNDA:6,dlt_logstorage_update_context +FNDA:2,dlt_daemon_logstorage_setup_internal_storage +FNDA:4,dlt_daemon_logstorage_update_application_loglevel +FNDA:2,dlt_daemon_logstorage_write +FNDA:4,dlt_logstorage_update_all_contexts +FNDA:2,dlt_daemon_logstorage_get_loglevel +FNDA:0,dlt_daemon_logstorage_update_passive_node_context +FNDA:2,dlt_daemon_logstorage_sync_cache +FNDA:3,dlt_daemon_logstorage_set_logstorage_cache_size +FNDA:0,dlt_daemon_logstorage_force_reset_level +FNDA:3,dlt_daemon_logstorage_get_device +FNDA:10,dlt_logstorage_split_key +FNDA:1,dlt_logstorage_split_ecuid_apid +FNDA:1,dlt_logstorage_split_apid +FNDA:2,dlt_daemon_logstorage_send_log_level +FNDA:2,dlt_daemon_logstorage_reset_application_loglevel +FNDA:0,dlt_logstorage_split_ecuid +FNDA:1,dlt_daemon_logstorage_reset_log_level +FNDA:2,dlt_logstorage_split_multi +FNDA:0,dlt_logstorage_split_ctid +FNDA:2,dlt_daemon_logstorage_cleanup +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,2 +DA:213,2 +DA:216,2 +DA:218,2 +DA:221,2 +DA:223,2 +DA:226,0 +DA:228,0 +DA:235,2 +DA:237,2 +DA:240,2 +DA:242,2 +DA:263,10 +DA:269,10 +DA:272,5 +DA:274,5 +DA:276,5 +DA:280,5 +DA:281,0 +DA:283,5 +DA:284,0 +DA:286,5 +DA:287,1 +DA:289,4 +DA:290,1 +DA:292,3 +DA:293,1 +DA:296,2 +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,6 +DA:628,6 +DA:629,5 +DA:630,1 +DA:631,1 +DA:634,5 +DA:636,5 +DA:637,3 +DA:638,2 +DA:645,1 +DA:653,2 +DA:656,0 +DA:665,2 +DA:671,2 +DA:691,5 +DA:698,5 +DA:699,5 +DA:700,5 +DA:702,5 +DA:704,5 +DA:707,4 +DA:708,0 +DA:710,0 +DA:713,4 +DA:714,2 +DA:717,4 +DA:720,0 +DA:727,0 +DA:729,4 +DA:732,1 +DA:739,0 +DA:742,3 +DA:746,0 +DA:753,0 +DA:757,3 +DA:765,2 +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,4 +DA:880,4 +DA:884,4 +DA:886,4 +DA:888,1 +DA:891,1 +DA:894,3 +DA:896,3 +DA:897,3 +DA:902,3 +DA:903,6 +DA:905,6 +DA:909,3 +DA:910,3 +DA:914,3 +DA:915,3 +DA:917,0 +DA:918,0 +DA:922,3 +DA:928,3 +DA:946,2 +DA:951,2 +DA:958,2 +DA:961,2 +DA:962,1 +DA:964,1 +DA:968,1 +DA:970,1 +DA:971,0 +DA:972,0 +DA:975,2 +DA:977,1 +DA:978,0 +DA:982,1 +DA:983,0 +DA:984,0 +DA:987,1 +DA:988,1 +DA:994,1 +DA:1014,2 +DA:1027,2 +DA:1028,1 +DA:1029,1 +DA:1030,1 +DA:1033,1 +DA:1038,1 +DA:1039,1 +DA:1040,1 +DA:1041,1 +DA:1042,1 +DA:1043,1 +DA:1045,2 +DA:1046,1 +DA:1048,1 +DA:1049,1 +DA:1058,0 +DA:1063,0 +DA:1064,0 +DA:1067,1 +DA:1068,1 +DA:1072,0 +DA:1093,2 +DA:1100,2 +DA:1102,2 +DA:1107,1 +DA:1109,1 +DA:1110,0 +DA:1111,0 +DA:1115,1 +DA:1120,1 +DA:1122,0 +DA:1125,0 +DA:1133,3 +DA:1136,3 +DA:1137,3 +DA:1139,2 +DA:1145,2 +DA:1147,2 +DA:1150,2 +DA:1152,1 +DA:1155,0 +DA:1156,0 +DA:1157,0 +DA:1158,0 +DA:1159,0 +DA:1160,0 +DA:1161,0 +DA:1162,0 +DA:1163,0 +DA:1164,0 +DA:1166,0 +DA:1174,2 +DA:1182,2 +DA:1184,2 +DA:1187,1 +DA:1188,1 +DA:1193,1 +DA:1197,1 +DA:1198,1 +DA:1199,1 +DA:1200,1 +DA:1201,1 +DA:1202,1 +DA:1203,1 +DA:1204,1 +DA:1205,1 +DA:1206,1 +DA:1208,1 +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,3 +DA:1246,3 +DA:1248,3 +DA:1251,2 +DA:1253,2 +DA:1254,2 +DA:1259,2 +DA:1261,2 +DA:1262,2 +LF:332 +LH:192 +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:12,dlt_daemon_socket_send +FNDA:50,dlt_daemon_socket_sendreliable +FNDA:2,dlt_daemon_socket_open +FNDA:0,dlt_daemon_socket_close +FNDA:0,dlt_daemon_socket_get_send_qeue_max_size +FNF:5 +FNH:3 +DA:58,2 +DA:60,2 +DA:67,2 +DA:68,0 +DA:69,0 +DA:71,0 +DA:85,2 +DA:88,2 +DA:89,0 +DA:90,0 +DA:95,0 +DA:102,2 +DA:103,2 +DA:105,2 +DA:106,2 +DA:108,0 +DA:120,0 +DA:121,0 +DA:122,0 +DA:128,0 +DA:131,2 +DA:132,0 +DA:133,0 +DA:134,0 +DA:136,0 +DA:140,2 +DA:143,4 +DA:146,2 +DA:147,0 +DA:148,0 +DA:152,0 +DA:158,0 +DA:160,0 +DA:162,0 +DA:165,12 +DA:175,12 +DA:176,0 +DA:180,0 +DA:186,12 +DA:187,12 +DA:189,12 +DA:194,12 +DA:195,12 +DA:201,0 +DA:203,2 +DA:204,2 +DA:205,2 +DA:207,2 +DA:210,50 +DA:214,100 +DA:215,50 +DA:217,50 +DA:220,50 +DA:221,0 +DA:222,0 +DA:223,0 +DA:225,50 +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:0,dlt_daemon_unix_socket_close +FNDA:2,dlt_daemon_unix_socket_open +FNF:2 +FNH:1 +DA:87,2 +DA:92,2 +DA:93,0 +DA:94,0 +DA:139,2 +DA:140,0 +DA:141,0 +DA:145,2 +DA:148,2 +DA:151,2 +DA:153,2 +DA:154,0 +DA:155,0 +DA:156,0 +DA:159,2 +DA:160,0 +DA:161,0 +DA:162,0 +DA:166,2 +DA:173,2 +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:6,dlt_gateway_establish_connections +FNDA:0,dlt_gateway_forward_control_message +FNDA:7,dlt_gateway_check_ip +FNDA:6,dlt_gateway_get_connection_receiver +FNDA:9,dlt_gateway_check_port +FNDA:7,dlt_gateway_check_timeout +FNDA:3,dlt_gateway_add_to_event_loop +FNDA:3,dlt_gateway_deinit +FNDA:17,dlt_gateway_allocate_control_messages +FNDA:0,dlt_gateway_get_connection +FNDA:0,dlt_gateway_check_general_param +FNDA:6,dlt_gateway_check_control_messages +FNDA:1,dlt_gateway_control_service_logstorage +FNDA:7,dlt_gateway_store_connection +FNDA:5,dlt_gateway_configure +FNDA:4,dlt_gateway_init +FNDA:5,dlt_gateway_process_passive_node_messages +FNDA:0,dlt_gateway_parse_get_default_log_level +FNDA:6,dlt_gateway_check_ecu +FNDA:0,dlt_gateway_check_interval +FNDA:2,dlt_gateway_process_gateway_timer +FNDA:7,dlt_gateway_check_connect_trigger +FNDA:3,dlt_gateway_parse_get_log_info +FNDA:3,dlt_gateway_process_on_demand_request +FNDA:6,dlt_gateway_check_send_serial +FNDA:2,dlt_gateway_check_periodic_control_messages +FNDA:32,dlt_gateway_check_param +FNDA:12,dlt_gateway_send_control_message +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,3 +DA:869,3 +DA:870,0 +DA:871,0 +DA:874,3 +DA:876,5 +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,3 +DA:892,3 +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:4,dlt_client_get_log_info +FNDA:1,dlt_client_get_default_log_level +FNDA:0,dlt_client_set_serial_device +FNDA:0,dlt_client_register_message_callback +FNDA:0,dlt_client_setbaudrate +FNDA:0,dlt_client_init +FNDA:6,dlt_client_connect +FNDA:0,dlt_client_set_mode +FNDA:0,dlt_client_send_timing_pakets +FNDA:4,dlt_client_get_software_version +FNDA:0,dlt_client_send_all_trace_status +FNDA:0,dlt_client_set_host_if_address +FNDA:0,dlt_client_send_inject_msg +FNDA:1,dlt_client_send_log_level +FNDA:0,dlt_client_send_default_trace_status +FNDA:2,dlt_client_parse_get_log_info_resp_text +FNDA:0,dlt_client_register_fetch_next_message_callback +FNDA:0,dlt_client_free_calloc_failed_get_log_info +FNDA:10,dlt_client_send_ctrl_msg +FNDA:0,dlt_client_send_reset_to_factory_default +FNDA:0,dlt_client_send_trace_status +FNDA:0,dlt_client_send_all_log_level +FNDA:2,dlt_client_cleanup +FNDA:5,dlt_client_init_port +FNDA:5,dlt_client_set_server_ip +FNDA:0,dlt_client_send_store_config +FNDA:0,dlt_client_send_default_log_level +FNDA:0,dlt_client_send_message_to_socket +FNDA:2,dlt_client_cleanup_get_log_info +FNDA:0,dlt_client_set_socket_path +FNDA:0,dlt_client_main_loop +FNF:31 +FNH:11 +DA:103,0 +DA:105,0 +DA:106,0 +DA:108,0 +DA:110,0 +DA:111,0 +DA:113,5 +DA:115,5 +DA:116,0 +DA:121,5 +DA:124,5 +DA:125,5 +DA:126,5 +DA:127,5 +DA:128,5 +DA:129,5 +DA:130,5 +DA:131,5 +DA:132,5 +DA:133,5 +DA:134,5 +DA:136,5 +DA:139,0 +DA:147,0 +DA:149,0 +DA:152,0 +DA:153,0 +DA:157,0 +DA:160,0 +DA:164,0 +DA:165,0 +DA:169,0 +DA:172,6 +DA:174,6 +DA:175,6 +DA:185,6 +DA:189,6 +DA:191,6 +DA:194,6 +DA:195,6 +DA:196,6 +DA:198,6 +DA:199,0 +DA:203,3 +DA:206,10 +DA:207,7 +DA:208,0 +DA:211,0 +DA:212,0 +DA:216,7 +DA:218,0 +DA:220,0 +DA:221,0 +DA:222,0 +DA:225,7 +DA:226,7 +DA:227,7 +DA:228,7 +DA:230,7 +DA:231,0 +DA:233,0 +DA:234,0 +DA:236,14 +DA:237,7 +DA:239,7 +DA:240,3 +DA:241,3 +DA:242,3 +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,6 +DA:274,6 +DA:275,3 +DA:279,3 +DA:282,3 +DA:283,1 +DA:291,3 +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,0 +DA:342,0 +DA:343,0 +DA:346,0 +DA:348,0 +DA:352,0 +DA:353,0 +DA:355,0 +DA:358,0 +DA:361,0 +DA:363,0 +DA:366,0 +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,3 +DA:470,0 +DA:471,0 +DA:477,2 +DA:481,2 +DA:482,0 +DA:484,2 +DA:487,2 +DA:488,2 +DA:490,2 +DA:491,0 +DA:495,2 +DA:496,0 +DA:497,0 +DA:500,2 +DA:501,2 +DA:502,2 +DA:505,2 +DA:506,0 +DA:507,0 +DA:510,2 +DA:511,0 +DA:512,0 +DA:517,0 +DA:522,0 +DA:525,0 +DA:529,0 +DA:531,0 +DA:533,0 +DA:535,0 +DA:538,0 +DA:541,0 +DA:542,0 +DA:544,0 +DA:547,0 +DA:548,0 +DA:550,0 +DA:551,0 +DA:552,0 +DA:556,0 +DA:557,0 +DA:560,0 +DA:561,0 +DA:564,0 +DA:565,0 +DA:569,0 +DA:571,0 +DA:572,0 +DA:574,0 +DA:575,0 +DA:578,0 +DA:579,0 +DA:584,0 +DA:588,0 +DA:589,0 +DA:591,0 +DA:592,0 +DA:595,0 +DA:597,0 +DA:599,0 +DA:601,0 +DA:602,0 +DA:603,0 +DA:607,0 +DA:609,0 +DA:610,0 +DA:612,0 +DA:613,0 +DA:616,0 +DA:617,0 +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,5 +DA:1136,5 +DA:1138,5 +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:191 +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_init_ll_set +FNDA:167,dlt_env_adjust_ll_from_env +FNDA:0,dlt_env_extract_ll_item +FNDA:0,dlt_env_increase_ll_set +FNDA:0,dlt_env_extract_ll_set +FNDA:0,dlt_env_ids_match +FNDA:0,dlt_env_extract_symbolic_ll +FNDA:0,dlt_env_extract_id +FNDA:0,dlt_env_helper_to_lower +FNDA:0,dlt_env_extract_ll +FNDA:0,dlt_env_ll_item_get_matching_prio +FNDA:6687,dlt_env_free_ll_set +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,6687 +DA:309,6687 +DA:313,6687 +DA:314,0 +DA:315,0 +DA:318,6687 +DA:319,6687 +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,167 +DA:476,167 +DA:484,167 +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,getFileCreationDate +FNDA:0,stringHash +FNDA:0,dlt_user_log_file_header_alias +FNDA:0,dlt_user_log_file_packagesCount +FNDA:0,doTimeout +FNDA:0,getFileSerialNumber +FNDA:0,getFileCreationDate2 +FNDA:0,checkUserBufferForFreeSpace +FNDA:0,isFile +FNDA:0,dlt_user_log_file_end +FNDA:0,getFilesize +FNDA:0,dlt_user_log_file_header +FNDA:0,dlt_user_log_file_infoAbout +FNDA:0,dlt_user_log_file_errorMessage +FNDA:0,doRemoveFile +FNDA:0,dlt_user_log_file_data +FNDA:0,dlt_user_log_file_complete +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:1589,dlt_unregister_app +FN:1594,dlt_unregister_app_flush_buffered_logs +FN:1616,dlt_unregister_context +FN:1675,dlt_set_application_ll_ts_limit +FN:1725,dlt_get_log_state +FN:1730,dlt_set_log_mode +FN:1753,dlt_set_resend_timeout_atexit +FN:1769,dlt_user_log_write_start_init +FN:1795,dlt_user_log_write_start +FN:1800,dlt_user_log_write_start_id +FN:1808,dlt_user_log_write_start_internal +FN:1871,dlt_user_log_write_start_w_given_buffer +FN:1906,dlt_user_log_write_finish +FN:1920,dlt_user_log_write_finish_w_given_buffer +FN:1932,dlt_user_log_write_raw_internal +FN:2012,dlt_user_log_write_raw +FN:2017,dlt_user_log_write_raw_formatted +FN:2022,dlt_user_log_write_raw_attr +FN:2027,dlt_user_log_write_raw_formatted_attr +FN:2033,dlt_user_log_write_generic_attr +FN:2106,dlt_user_log_write_generic_formatted +FN:2150,dlt_user_log_write_float32 +FN:2159,dlt_user_log_write_float64 +FN:2168,dlt_user_log_write_float32_attr +FN:2178,dlt_user_log_write_float64_attr +FN:2188,dlt_user_log_write_uint +FN:2229,dlt_user_log_write_uint8 +FN:2235,dlt_user_log_write_uint16 +FN:2241,dlt_user_log_write_uint32 +FN:2247,dlt_user_log_write_uint64 +FN:2253,dlt_user_log_write_uint_attr +FN:2294,dlt_user_log_write_uint8_attr +FN:2301,dlt_user_log_write_uint16_attr +FN:2308,dlt_user_log_write_uint32_attr +FN:2315,dlt_user_log_write_uint64_attr +FN:2322,dlt_user_log_write_uint8_formatted +FN:2328,dlt_user_log_write_uint16_formatted +FN:2334,dlt_user_log_write_uint32_formatted +FN:2340,dlt_user_log_write_uint64_formatted +FN:2346,dlt_user_log_write_ptr +FN:2374,dlt_user_log_write_int +FN:2415,dlt_user_log_write_int8 +FN:2421,dlt_user_log_write_int16 +FN:2427,dlt_user_log_write_int32 +FN:2433,dlt_user_log_write_int64 +FN:2439,dlt_user_log_write_int_attr +FN:2480,dlt_user_log_write_int8_attr +FN:2487,dlt_user_log_write_int16_attr +FN:2494,dlt_user_log_write_int32_attr +FN:2501,dlt_user_log_write_int64_attr +FN:2508,dlt_user_log_write_bool +FN:2514,dlt_user_log_write_bool_attr +FN:2521,dlt_user_log_write_string +FN:2526,dlt_user_log_write_string_attr +FN:2531,dlt_user_log_write_sized_string +FN:2536,dlt_user_log_write_sized_string_attr +FN:2541,dlt_user_log_write_constant_string +FN:2547,dlt_user_log_write_constant_string_attr +FN:2553,dlt_user_log_write_sized_constant_string +FN:2559,dlt_user_log_write_sized_constant_string_attr +FN:2565,dlt_user_log_write_utf8_string +FN:2570,dlt_user_log_write_utf8_string_attr +FN:2575,dlt_user_log_write_sized_utf8_string +FN:2580,dlt_user_log_write_sized_utf8_string_attr +FN:2585,dlt_user_log_write_constant_utf8_string +FN:2591,dlt_user_log_write_constant_utf8_string_attr +FN:2597,dlt_user_log_write_sized_constant_utf8_string +FN:2603,dlt_user_log_write_sized_constant_utf8_string_attr +FN:2609,dlt_user_log_write_sized_string_utils_attr +FN:2764,dlt_user_log_write_string_utils_attr +FN:2773,dlt_register_injection_callback_with_id +FN:2864,dlt_register_injection_callback +FN:2875,dlt_register_log_level_changed_callback +FN:2915,check_buffer +FN:2927,dlt_user_trace_network_segmented_start +FN:3024,dlt_user_trace_network_segmented_segment +FN:3107,dlt_user_trace_network_segmented_end +FN:3163,dlt_user_trace_network_segmented_thread +FN:3230,dlt_user_trace_network_segmented_thread_segmenter +FN:3267,dlt_user_trace_network_segmented +FN:3355,dlt_user_trace_network +FN:3365,dlt_user_trace_network_truncated +FN:3517,dlt_log_string +FN:3538,dlt_log_string_int +FN:3560,dlt_log_string_uint +FN:3582,dlt_log_int +FN:3602,dlt_log_uint +FN:3622,dlt_log_raw +FN:3646,dlt_log_marker +FN:3658,dlt_verbose_mode +FN:3673,dlt_nonverbose_mode +FN:3688,dlt_use_extended_header_for_non_verbose +FN:3703,dlt_with_session_id +FN:3718,dlt_with_timestamp +FN:3733,dlt_with_ecu_id +FN:3748,dlt_enable_local_print +FN:3762,dlt_disable_local_print +FN:3777,dlt_user_cleanup_handler +FN:3790,dlt_user_housekeeperthread_function +FN:3867,dlt_user_log_init +FN:3890,dlt_user_log_send_log +FN:4173,dlt_user_log_send_register_application +FN:4216,dlt_user_log_send_unregister_application +FN:4252,dlt_user_log_send_register_context +FN:4311,dlt_user_log_send_unregister_context +FN:4356,dlt_send_app_ll_ts_limit +FN:4403,dlt_user_log_send_log_mode +FN:4440,dlt_user_log_send_marker +FN:4468,dlt_user_print_msg +FN:4505,dlt_user_log_check_user_message +FN:4778,dlt_user_log_resend_buffer +FN:4872,dlt_user_log_reattach_to_daemon +FN:4952,dlt_user_log_send_overflow +FN:4973,dlt_user_check_buffer +FN:5005,dlt_start_threads +FN:5086,dlt_stop_threads +FN:5158,dlt_fork_child_fork_handler +FN:5165,dlt_user_log_out_error_handling +FNDA:7,dlt_user_log_write_float64_attr +FNDA:0,dlt_user_atexit_blow_out_user_buffer +FNDA:7,dlt_user_log_write_uint_attr +FNDA:8,dlt_user_log_write_sized_utf8_string +FNDA:1,dlt_user_log_send_marker +FNDA:6,dlt_user_log_write_int8 +FNDA:0,dlt_user_check_library_version +FNDA:13374,dlt_user_trace_network_segmented_thread +FNDA:167,dlt_unregister_app +FNDA:5,dlt_user_log_write_sized_constant_utf8_string +FNDA:7,dlt_user_log_write_int_attr +FNDA:0,dlt_fork_child_fork_handler +FNDA:42,dlt_user_log_write_int32 +FNDA:3,dlt_user_log_write_sized_constant_string_attr +FNDA:178,dlt_register_context_ll_ts +FNDA:0,dlt_check_library_version +FNDA:1,dlt_log_marker +FNDA:6688,dlt_user_log_check_user_message +FNDA:0,dlt_send_app_ll_ts_limit +FNDA:0,dlt_user_trace_network_segmented_end +FNDA:4,dlt_user_log_send_log_mode +FNDA:21,dlt_user_log_write_utf8_string +FNDA:0,dlt_user_log_resend_buffer +FNDA:35,dlt_user_log_write_uint +FNDA:0,dlt_with_timestamp +FNDA:0,dlt_user_print_msg +FNDA:3,dlt_user_log_write_bool_attr +FNDA:5,dlt_user_log_write_constant_string_attr +FNDA:5,dlt_user_log_write_constant_utf8_string +FNDA:45893,dlt_free +FNDA:25,dlt_log_string_int +FNDA:7,dlt_user_log_write_sized_utf8_string_attr +FNDA:0,dlt_register_injection_callback +FNDA:7,dlt_user_log_write_uint8_attr +FNDA:0,check_buffer +FNDA:237,dlt_user_log_write_start_internal +FNDA:0,dlt_get_appid +FNDA:218,dlt_user_log_write_generic_attr +FNDA:7,dlt_user_log_write_utf8_string_attr +FNDA:103,dlt_user_log_write_sized_string_utils_attr +FNDA:2,dlt_use_extended_header_for_non_verbose +FNDA:7,dlt_user_trace_network_segmented +FNDA:0,dlt_user_log_write_start_w_given_buffer +FNDA:7,dlt_user_log_write_int64_attr +FNDA:167,dlt_unregister_app_util +FNDA:7,dlt_user_log_write_constant_string +FNDA:0,dlt_user_log_send_overflow +FNDA:0,dlt_register_injection_callback_with_id +FNDA:19,dlt_user_log_write_raw_formatted +FNDA:0,dlt_user_log_write_finish_w_given_buffer +FNDA:28,dlt_user_log_write_uint32_formatted +FNDA:28,dlt_user_log_write_uint16_formatted +FNDA:6,dlt_user_log_write_int64 +FNDA:0,dlt_user_trace_network_segmented_thread_segmenter +FNDA:20061,dlt_unlock_mutex +FNDA:1,dlt_user_log_reattach_to_daemon +FNDA:22,dlt_log_int +FNDA:6,dlt_user_log_write_int16 +FNDA:0,dlt_user_log_write_ptr +FNDA:1,dlt_user_atexit_handler +FNDA:166,dlt_user_log_send_unregister_context +FNDA:195,dlt_user_log_send_log +FNDA:0,dlt_enable_local_print +FNDA:0,dlt_user_trace_network_segmented_start +FNDA:22,dlt_log_uint +FNDA:28,dlt_user_log_write_uint8_formatted +FNDA:169,dlt_register_app +FNDA:13374,dlt_lock_mutex +FNDA:7,dlt_user_log_write_uint64_attr +FNDA:4,dlt_user_log_write_uint64 +FNDA:6688,dlt_init_common +FNDA:4,dlt_user_log_write_sized_constant_utf8_string_attr +FNDA:3,dlt_user_log_write_raw_formatted_attr +FNDA:164,dlt_user_log_send_register_application +FNDA:7,dlt_user_log_write_float32 +FNDA:104,dlt_user_log_write_start +FNDA:178,dlt_register_context_ll_ts_llccb +FNDA:167,dlt_user_log_send_register_context +FNDA:6687,dlt_initialize_fifo_connection +FNDA:13,dlt_user_log_write_raw +FNDA:4,dlt_user_log_write_uint16 +FNDA:1,dlt_register_log_level_changed_callback +FNDA:112,dlt_user_log_write_generic_formatted +FNDA:3,dlt_user_log_write_bool +FNDA:0,dlt_init_file +FNDA:1,dlt_get_log_state +FNDA:6,dlt_user_log_write_sized_string_attr +FNDA:7,dlt_user_log_write_float64 +FNDA:10,dlt_nonverbose_mode +FNDA:195,dlt_user_log_write_finish +FNDA:7,dlt_user_log_write_int16_attr +FNDA:165,dlt_register_context +FNDA:7,dlt_user_log_write_uint16_attr +FNDA:40025693,dlt_init +FNDA:0,dlt_init_message_queue +FNDA:4,dlt_user_log_write_constant_utf8_string_attr +FNDA:0,dlt_disable_local_print +FNDA:37,dlt_user_log_write_int +FNDA:0,dlt_with_session_id +FNDA:0,dlt_user_check_buffer +FNDA:166,dlt_unregister_context +FNDA:23,dlt_user_log_write_start_id +FNDA:38,dlt_user_log_write_uint32 +FNDA:38,dlt_user_log_write_raw_internal +FNDA:7,dlt_user_log_write_float32_attr +FNDA:28,dlt_user_log_write_uint64_formatted +FNDA:21,dlt_user_trace_network_truncated +FNDA:0,dlt_set_resend_timeout_atexit +FNDA:0,dlt_with_ecu_id +FNDA:2,dlt_user_log_write_sized_string +FNDA:1,dlt_user_log_write_sized_constant_string +FNDA:11,dlt_log_raw +FNDA:167,dlt_user_log_send_unregister_application +FNDA:25,dlt_log_string_uint +FNDA:0,dlt_unregister_app_flush_buffered_logs +FNDA:10,dlt_verbose_mode +FNDA:0,dlt_set_filesize_max +FNDA:0,dlt_set_application_ll_ts_limit +FNDA:60,dlt_user_log_write_string +FNDA:13374,dlt_user_cleanup_handler +FNDA:522,dlt_user_log_init +FNDA:3,dlt_user_log_write_raw_attr +FNDA:14,dlt_user_log_write_int32_attr +FNDA:6687,dlt_start_threads +FNDA:18,dlt_user_log_write_uint32_attr +FNDA:0,dlt_user_trace_network_segmented_segment +FNDA:13374,dlt_user_housekeeperthread_function +FNDA:7,dlt_user_log_write_string_attr +FNDA:14,dlt_user_trace_network +FNDA:188,dlt_user_log_write_start_init +FNDA:7,dlt_user_log_write_int8_attr +FNDA:18,dlt_log_string +FNDA:4,dlt_set_log_mode +FNDA:852,dlt_user_log_out_error_handling +FNDA:0,dlt_register_context_llccb +FNDA:6687,dlt_stop_threads +FNDA:95,dlt_user_log_write_string_utils_attr +FNDA:4,dlt_user_log_write_uint8 +FNF:138 +FNH:106 +DA:163,13374 +DA:165,13374 +DA:167,13374 +DA:168,0 +DA:171,13374 +DA:173,20061 +DA:175,20061 +DA:176,20061 +DA:229,0 +DA:234,0 +DA:235,0 +DA:237,0 +DA:238,0 +DA:246,0 +DA:390,6687 +DA:397,6687 +DA:399,6687 +DA:400,0 +DA:401,0 +DA:405,6687 +DA:407,1 +DA:411,1 +DA:412,0 +DA:413,0 +DA:418,6687 +DA:421,6687 +DA:423,6687 +DA:425,6687 +DA:426,0 +DA:429,6687 +DA:431,6687 +DA:432,0 +DA:433,0 +DA:436,6687 +DA:438,6687 +DA:439,0 +DA:440,0 +DA:441,0 +DA:445,6687 +DA:447,6687 +DA:451,6687 +DA:458,40025693 +DA:461,40025693 +DA:462,806013 +DA:464,806013 +DA:476,39219680 +DA:481,6687 +DA:484,6687 +DA:485,0 +DA:489,6687 +DA:490,0 +DA:491,0 +DA:494,6687 +DA:495,6687 +DA:496,6687 +DA:498,6687 +DA:499,6687 +DA:525,6687 +DA:528,6687 +DA:532,0 +DA:533,0 +DA:540,6687 +DA:541,6687 +DA:543,6687 +DA:546,6687 +DA:547,0 +DA:548,0 +DA:552,6687 +DA:555,6687 +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,150 +DA:706,6688 +DA:707,0 +DA:722,6688 +DA:723,0 +DA:724,0 +DA:728,6688 +DA:730,6688 +DA:731,6688 +DA:733,6688 +DA:734,6688 +DA:736,6688 +DA:739,6688 +DA:748,6688 +DA:753,6688 +DA:755,6688 +DA:756,0 +DA:757,0 +DA:761,6688 +DA:766,6688 +DA:769,6688 +DA:772,6688 +DA:775,6688 +DA:777,6688 +DA:779,6688 +DA:781,6688 +DA:783,6688 +DA:784,0 +DA:785,0 +DA:786,0 +DA:787,0 +DA:788,0 +DA:789,0 +DA:792,6688 +DA:794,6688 +DA:795,0 +DA:796,0 +DA:802,6688 +DA:803,6688 +DA:804,6688 +DA:805,6688 +DA:808,6688 +DA:809,6688 +DA:810,6688 +DA:812,6688 +DA:813,0 +DA:815,0 +DA:816,0 +DA:823,6688 +DA:824,0 +DA:826,0 +DA:827,0 +DA:834,6688 +DA:835,0 +DA:837,0 +DA:838,0 +DA:846,6688 +DA:847,6688 +DA:849,6688 +DA:850,7 +DA:852,7 +DA:853,0 +DA:854,0 +DA:858,7 +DA:859,7 +DA:865,6688 +DA:866,6687 +DA:867,6687 +DA:869,6687 +DA:870,0 +DA:871,0 +DA:872,0 +DA:873,0 +DA:877,6688 +DA:878,6688 +DA:879,0 +DA:880,0 +DA:883,6688 +DA:887,0 +DA:888,0 +DA:889,0 +DA:892,6688 +DA:894,6688 +DA:896,6688 +DA:897,1 +DA:898,1 +DA:910,1 +DA:913,1 +DA:916,1 +DA:917,1 +DA:919,1 +DA:920,1 +DA:924,0 +DA:926,0 +DA:927,0 +DA:931,0 +DA:935,0 +DA:938,0 +DA:939,0 +DA:944,0 +DA:947,0 +DA:948,0 +DA:949,0 +DA:951,0 +DA:952,0 +DA:953,0 +DA:955,0 +DA:957,0 +DA:958,0 +DA:959,0 +DA:963,0 +DA:968,0 +DA:969,0 +DA:971,0 +DA:972,0 +DA:973,0 +DA:974,0 +DA:976,0 +DA:980,0 +DA:981,0 +DA:982,0 +DA:985,0 +DA:986,0 +DA:987,0 +DA:995,6884 +DA:996,2 +DA:997,6873 +DA:1001,45893 +DA:1002,0 +DA:1011,45893 +DA:1016,45893 +DA:1017,39206 +DA:1018,39206 +DA:1021,6687 +DA:1023,6687 +DA:1027,6687 +DA:1028,6686 +DA:1029,6686 +DA:1030,6686 +DA:1031,6686 +DA:1041,6687 +DA:1103,0 +DA:1105,0 +DA:1106,0 +DA:1108,0 +DA:1112,6687 +DA:1113,6687 +DA:1114,6687 +DA:1117,6687 +DA:1120,6687 +DA:1123,6687 +DA:1124,0 +DA:1125,6687 +DA:1127,6687 +DA:1128,6513 +DA:1129,6500 +DA:1130,1 +DA:1131,1 +DA:1134,6500 +DA:1135,1 +DA:1136,1 +DA:1139,6500 +DA:1140,1 +DA:1141,1 +DA:1144,6500 +DA:1145,0 +DA:1146,0 +DA:1149,6500 +DA:1150,6500 +DA:1153,13 +DA:1154,13 +DA:1155,13 +DA:1156,13 +DA:1159,6687 +DA:1160,6687 +DA:1164,6687 +DA:1170,6687 +DA:1171,0 +DA:1173,6687 +DA:1174,0 +DA:1176,6687 +DA:1177,6687 +DA:1178,0 +DA:1180,6687 +DA:1181,6687 +DA:1183,6687 +DA:1185,6687 +DA:1190,6687 +DA:1192,6687 +DA:1195,0 +DA:1197,0 +DA:1200,169 +DA:1201,0 +DA:1205,169 +DA:1208,169 +DA:1209,1 +DA:1210,0 +DA:1211,0 +DA:1215,169 +DA:1220,165 +DA:1221,2 +DA:1224,163 +DA:1226,2 +DA:1227,0 +DA:1230,161 +DA:1232,2 +DA:1233,0 +DA:1234,0 +DA:1237,159 +DA:1238,1 +DA:1239,1 +DA:1240,1 +DA:1245,164 +DA:1248,164 +DA:1250,164 +DA:1251,0 +DA:1253,164 +DA:1255,164 +DA:1256,164 +DA:1257,164 +DA:1259,164 +DA:1262,0 +DA:1263,0 +DA:1267,164 +DA:1269,164 +DA:1271,164 +DA:1272,0 +DA:1277,165 +DA:1280,165 +DA:1284,159 +DA:1287,159 +DA:1288,0 +DA:1289,0 +DA:1290,0 +DA:1294,159 +DA:1297,151 +DA:1304,178 +DA:1312,0 +DA:1318,178 +DA:1322,171 +DA:1325,171 +DA:1326,2 +DA:1327,2 +DA:1330,169 +DA:1331,2 +DA:1332,2 +DA:1335,167 +DA:1339,167 +DA:1344,167 +DA:1350,167 +DA:1351,14 +DA:1353,14 +DA:1354,0 +DA:1355,0 +DA:1358,14 +DA:1361,7014 +DA:1362,7000 +DA:1366,7000 +DA:1367,7000 +DA:1369,7000 +DA:1370,7000 +DA:1372,7000 +DA:1374,7000 +DA:1375,7000 +DA:1376,7000 +DA:1379,153 +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,167 +DA:1429,167 +DA:1431,167 +DA:1432,0 +DA:1434,167 +DA:1436,167 +DA:1437,167 +DA:1438,167 +DA:1440,167 +DA:1441,0 +DA:1442,0 +DA:1448,167 +DA:1449,167 +DA:1451,167 +DA:1452,0 +DA:1453,0 +DA:1457,167 +DA:1458,167 +DA:1460,167 +DA:1461,0 +DA:1462,0 +DA:1467,167 +DA:1472,167 +DA:1473,0 +DA:1476,167 +DA:1478,16 +DA:1481,167 +DA:1482,15 +DA:1485,167 +DA:1486,167 +DA:1488,167 +DA:1489,167 +DA:1491,167 +DA:1493,167 +DA:1494,167 +DA:1495,167 +DA:1497,167 +DA:1498,167 +DA:1500,167 +DA:1502,167 +DA:1504,167 +DA:1507,178 +DA:1513,178 +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,167 +DA:1554,0 +DA:1558,167 +DA:1561,167 +DA:1562,0 +DA:1563,0 +DA:1567,167 +DA:1569,167 +DA:1571,167 +DA:1572,167 +DA:1573,0 +DA:1576,167 +DA:1578,167 +DA:1579,164 +DA:1581,167 +DA:1584,167 +DA:1586,167 +DA:1589,167 +DA:1591,167 +DA:1594,0 +DA:1599,0 +DA:1602,0 +DA:1603,0 +DA:1604,0 +DA:1607,0 +DA:1609,0 +DA:1610,0 +DA:1613,0 +DA:1616,166 +DA:1617,0 +DA:1622,166 +DA:1625,166 +DA:1626,166 +DA:1628,166 +DA:1631,166 +DA:1633,166 +DA:1634,166 +DA:1636,166 +DA:1638,166 +DA:1640,166 +DA:1641,166 +DA:1643,166 +DA:1644,166 +DA:1646,166 +DA:1647,166 +DA:1648,166 +DA:1651,166 +DA:1652,166 +DA:1653,166 +DA:1656,166 +DA:1658,166 +DA:1659,0 +DA:1660,0 +DA:1663,166 +DA:1664,166 +DA:1667,166 +DA:1670,166 +DA:1672,166 +DA:1675,0 +DA:1676,0 +DA:1680,0 +DA:1683,0 +DA:1684,0 +DA:1685,0 +DA:1688,0 +DA:1689,0 +DA:1690,0 +DA:1693,0 +DA:1694,0 +DA:1695,0 +DA:1696,0 +DA:1700,0 +DA:1702,0 +DA:1703,0 +DA:1704,0 +DA:1708,0 +DA:1709,0 +DA:1710,0 +DA:1712,0 +DA:1713,0 +DA:1715,0 +DA:1716,0 +DA:1719,0 +DA:1722,0 +DA:1725,1 +DA:1727,1 +DA:1730,4 +DA:1735,4 +DA:1738,4 +DA:1739,0 +DA:1740,0 +DA:1743,4 +DA:1744,0 +DA:1745,0 +DA:1746,0 +DA:1750,4 +DA:1753,0 +DA:1756,0 +DA:1759,0 +DA:1760,0 +DA:1763,0 +DA:1764,0 +DA:1769,188 +DA:1777,188 +DA:1780,188 +DA:1781,188 +DA:1782,188 +DA:1783,188 +DA:1784,188 +DA:1786,188 +DA:1795,104 +DA:1797,214 +DA:1800,23 +DA:1805,23 +DA:1808,237 +DA:1817,237 +DA:1821,231 +DA:1829,227 +DA:1830,39 +DA:1831,39 +DA:1834,188 +DA:1835,188 +DA:1837,188 +DA:1839,0 +DA:1840,0 +DA:1844,188 +DA:1847,188 +DA:1848,0 +DA:1849,0 +DA:1854,198 +DA:1855,3 +DA:1860,3 +DA:1871,0 +DA:1881,0 +DA:1885,0 +DA:1889,0 +DA:1893,0 +DA:1896,0 +DA:1897,0 +DA:1898,0 +DA:1899,0 +DA:1900,0 +DA:1906,195 +DA:1910,195 +DA:1913,195 +DA:1920,0 +DA:1924,0 +DA:1927,0 +DA:1929,0 +DA:1932,38 +DA:1935,38 +DA:1939,31 +DA:1940,0 +DA:1941,0 +DA:1944,31 +DA:1945,0 +DA:1946,0 +DA:1949,31 +DA:1951,31 +DA:1952,31 +DA:1955,29 +DA:1956,29 +DA:1958,29 +DA:1959,29 +DA:1960,6 +DA:1961,6 +DA:1963,6 +DA:1965,29 +DA:1966,0 +DA:1970,29 +DA:1971,8 +DA:1972,8 +DA:1974,21 +DA:1976,4 +DA:1977,4 +DA:1980,29 +DA:1981,29 +DA:1984,29 +DA:1985,29 +DA:1987,29 +DA:1988,29 +DA:1992,6 +DA:1993,6 +DA:1997,6 +DA:1998,4 +DA:1999,4 +DA:2004,29 +DA:2005,29 +DA:2007,29 +DA:2009,29 +DA:2012,13 +DA:2014,13 +DA:2017,19 +DA:2019,19 +DA:2022,3 +DA:2024,3 +DA:2027,3 +DA:2029,3 +DA:2033,218 +DA:2035,218 +DA:2038,207 +DA:2039,0 +DA:2040,0 +DA:2044,207 +DA:2047,209 +DA:2053,203 +DA:2054,203 +DA:2055,89 +DA:2056,89 +DA:2058,89 +DA:2059,89 +DA:2060,89 +DA:2061,86 +DA:2062,86 +DA:2065,89 +DA:2067,203 +DA:2068,0 +DA:2070,203 +DA:2071,203 +DA:2073,203 +DA:2077,89 +DA:2078,89 +DA:2079,89 +DA:2080,86 +DA:2081,86 +DA:2086,89 +DA:2087,64 +DA:2088,64 +DA:2090,89 +DA:2091,62 +DA:2092,62 +DA:2097,205 +DA:2098,205 +DA:2100,205 +DA:2102,205 +DA:2106,112 +DA:2108,112 +DA:2112,84 +DA:2113,0 +DA:2114,0 +DA:2117,84 +DA:2118,0 +DA:2119,0 +DA:2123,84 +DA:2126,84 +DA:2127,84 +DA:2128,84 +DA:2132,84 +DA:2133,48 +DA:2135,36 +DA:2136,24 +DA:2138,84 +DA:2139,84 +DA:2142,84 +DA:2143,84 +DA:2145,84 +DA:2147,84 +DA:2150,7 +DA:2156,7 +DA:2159,7 +DA:2165,7 +DA:2168,7 +DA:2174,7 +DA:2175,7 +DA:2178,7 +DA:2184,7 +DA:2185,7 +DA:2188,35 +DA:2190,35 +DA:2193,34 +DA:2194,0 +DA:2195,0 +DA:2209,34 +DA:2211,34 +DA:2229,4 +DA:2232,4 +DA:2235,4 +DA:2238,4 +DA:2241,38 +DA:2244,38 +DA:2247,4 +DA:2250,4 +DA:2253,7 +DA:2255,7 +DA:2258,7 +DA:2259,0 +DA:2260,0 +DA:2274,7 +DA:2276,7 +DA:2294,7 +DA:2297,7 +DA:2298,7 +DA:2301,7 +DA:2304,7 +DA:2305,7 +DA:2308,18 +DA:2311,18 +DA:2312,18 +DA:2315,7 +DA:2318,7 +DA:2319,7 +DA:2322,28 +DA:2325,28 +DA:2328,28 +DA:2331,28 +DA:2334,28 +DA:2337,28 +DA:2340,28 +DA:2343,28 +DA:2346,0 +DA:2348,0 +DA:2351,0 +DA:2352,0 +DA:2353,0 +DA:2362,0 +DA:2363,0 +DA:2374,37 +DA:2376,37 +DA:2379,36 +DA:2380,0 +DA:2381,0 +DA:2395,36 +DA:2397,36 +DA:2415,6 +DA:2418,6 +DA:2421,6 +DA:2424,6 +DA:2427,42 +DA:2430,42 +DA:2433,6 +DA:2436,6 +DA:2439,7 +DA:2441,7 +DA:2444,7 +DA:2445,0 +DA:2446,0 +DA:2460,7 +DA:2462,7 +DA:2480,7 +DA:2483,7 +DA:2484,7 +DA:2487,7 +DA:2490,7 +DA:2491,7 +DA:2494,14 +DA:2497,14 +DA:2498,14 +DA:2501,7 +DA:2504,7 +DA:2505,7 +DA:2508,3 +DA:2511,3 +DA:2514,3 +DA:2517,3 +DA:2518,3 +DA:2521,60 +DA:2523,60 +DA:2526,7 +DA:2528,7 +DA:2531,2 +DA:2533,2 +DA:2536,6 +DA:2538,6 +DA:2541,7 +DA:2544,8 +DA:2547,5 +DA:2550,7 +DA:2553,1 +DA:2556,1 +DA:2559,3 +DA:2562,3 +DA:2565,21 +DA:2567,21 +DA:2570,7 +DA:2572,7 +DA:2575,8 +DA:2577,8 +DA:2580,7 +DA:2582,7 +DA:2585,5 +DA:2588,6 +DA:2591,4 +DA:2594,4 +DA:2597,5 +DA:2600,6 +DA:2603,4 +DA:2606,4 +DA:2609,103 +DA:2611,103 +DA:2614,94 +DA:2615,0 +DA:2616,0 +DA:2619,94 +DA:2621,94 +DA:2623,94 +DA:2625,94 +DA:2627,101 +DA:2628,94 +DA:2629,94 +DA:2630,21 +DA:2631,21 +DA:2633,21 +DA:2642,94 +DA:2646,21 +DA:2648,21 +DA:2650,21 +DA:2651,21 +DA:2652,21 +DA:2653,21 +DA:2654,0 +DA:2655,0 +DA:2660,21 +DA:2661,1 +DA:2662,1 +DA:2666,20 +DA:2668,20 +DA:2674,12 +DA:2677,12 +DA:2679,9 +DA:2682,6 +DA:2685,3 +DA:2689,12 +DA:2690,12 +DA:2694,93 +DA:2695,93 +DA:2696,68 +DA:2697,68 +DA:2698,68 +DA:2699,25 +DA:2700,25 +DA:2701,25 +DA:2707,93 +DA:2708,93 +DA:2711,93 +DA:2712,93 +DA:2714,100 +DA:2715,93 +DA:2719,21 +DA:2720,21 +DA:2724,21 +DA:2725,15 +DA:2726,15 +DA:2731,93 +DA:2732,73 +DA:2735,73 +DA:2737,73 +DA:2738,73 +DA:2739,73 +DA:2741,20 +DA:2744,20 +DA:2745,20 +DA:2748,20 +DA:2749,20 +DA:2750,20 +DA:2759,93 +DA:2761,93 +DA:2764,95 +DA:2766,95 +DA:2769,80 +DA:2770,80 +DA:2773,0 +DA:2775,0 +DA:2782,0 +DA:2785,0 +DA:2790,0 +DA:2793,0 +DA:2795,0 +DA:2796,0 +DA:2797,0 +DA:2801,0 +DA:2804,0 +DA:2805,0 +DA:2806,0 +DA:2811,0 +DA:2818,0 +DA:2819,0 +DA:2820,0 +DA:2822,0 +DA:2823,0 +DA:2824,0 +DA:2829,0 +DA:2830,0 +DA:2832,0 +DA:2833,0 +DA:2834,0 +DA:2835,0 +DA:2838,0 +DA:2839,0 +DA:2842,0 +DA:2846,0 +DA:2848,0 +DA:2849,0 +DA:2850,0 +DA:2851,0 +DA:2854,0 +DA:2855,0 +DA:2856,0 +DA:2859,0 +DA:2861,0 +DA:2864,0 +DA:2869,0 +DA:2875,1 +DA:2880,0 +DA:2884,1 +DA:2889,1 +DA:2892,1 +DA:2894,1 +DA:2895,0 +DA:2896,0 +DA:2900,1 +DA:2903,1 +DA:2905,1 +DA:2907,1 +DA:2915,0 +DA:2918,0 +DA:2920,0 +DA:2927,0 +DA:2934,0 +DA:2939,0 +DA:2942,0 +DA:2943,0 +DA:2944,0 +DA:2947,0 +DA:2950,0 +DA:2952,0 +DA:2955,0 +DA:2956,0 +DA:2958,0 +DA:2959,0 +DA:2960,0 +DA:2964,0 +DA:2965,0 +DA:2966,0 +DA:2968,0 +DA:2969,0 +DA:2972,0 +DA:2974,0 +DA:2978,0 +DA:2980,0 +DA:2984,0 +DA:2986,0 +DA:2990,0 +DA:2992,0 +DA:2996,0 +DA:2999,0 +DA:3002,0 +DA:3004,0 +DA:3008,0 +DA:3010,0 +DA:3014,0 +DA:3018,0 +DA:3024,0 +DA:3034,0 +DA:3035,0 +DA:3036,0 +DA:3039,0 +DA:3041,0 +DA:3042,0 +DA:3043,0 +DA:3044,0 +DA:3047,0 +DA:3050,0 +DA:3051,0 +DA:3053,0 +DA:3057,0 +DA:3058,0 +DA:3060,0 +DA:3061,0 +DA:3062,0 +DA:3066,0 +DA:3067,0 +DA:3068,0 +DA:3071,0 +DA:3073,0 +DA:3077,0 +DA:3079,0 +DA:3083,0 +DA:3085,0 +DA:3089,0 +DA:3091,0 +DA:3094,0 +DA:3099,0 +DA:3103,0 +DA:3104,0 +DA:3107,0 +DA:3109,0 +DA:3112,0 +DA:3113,0 +DA:3114,0 +DA:3117,0 +DA:3120,0 +DA:3122,0 +DA:3126,0 +DA:3127,0 +DA:3129,0 +DA:3130,0 +DA:3131,0 +DA:3135,0 +DA:3136,0 +DA:3137,0 +DA:3140,0 +DA:3142,0 +DA:3146,0 +DA:3148,0 +DA:3151,0 +DA:3156,0 +DA:3163,6687 +DA:3168,6687 +DA:3169,0 +DA:3174,13374 +DA:3180,6687 +DA:3182,10333 +DA:3184,10333 +DA:3187,0 +DA:3189,0 +DA:3192,0 +DA:3193,0 +DA:3196,0 +DA:3197,0 +DA:3198,0 +DA:3199,0 +DA:3202,0 +DA:3205,0 +DA:3209,0 +DA:3210,0 +DA:3213,0 +DA:3216,0 +DA:3218,0 +DA:3219,0 +DA:3222,0 +DA:3223,0 +DA:3224,0 +DA:3230,0 +DA:3240,0 +DA:3241,0 +DA:3246,0 +DA:3249,0 +DA:3250,0 +DA:3253,0 +DA:3257,0 +DA:3258,0 +DA:3259,0 +DA:3262,0 +DA:3263,0 +DA:3264,0 +DA:3267,7 +DA:3275,7 +DA:3279,7 +DA:3280,7 +DA:3283,0 +DA:3285,0 +DA:3288,0 +DA:3290,0 +DA:3291,0 +DA:3292,0 +DA:3295,0 +DA:3297,0 +DA:3298,0 +DA:3299,0 +DA:3300,0 +DA:3304,0 +DA:3305,0 +DA:3306,0 +DA:3308,0 +DA:3312,0 +DA:3319,0 +DA:3320,0 +DA:3321,0 +DA:3322,0 +DA:3323,0 +DA:3324,0 +DA:3328,0 +DA:3329,0 +DA:3330,0 +DA:3331,0 +DA:3332,0 +DA:3334,0 +DA:3338,0 +DA:3340,0 +DA:3341,0 +DA:3343,0 +DA:3344,0 +DA:3345,0 +DA:3346,0 +DA:3347,0 +DA:3355,14 +DA:3362,14 +DA:3365,21 +DA:3374,21 +DA:3376,21 +DA:3379,15 +DA:3380,0 +DA:3381,0 +DA:3384,15 +DA:3387,15 +DA:3388,0 +DA:3392,0 +DA:3393,0 +DA:3395,0 +DA:3396,0 +DA:3397,0 +DA:3401,0 +DA:3402,0 +DA:3403,0 +DA:3405,0 +DA:3409,0 +DA:3411,0 +DA:3413,0 +DA:3417,0 +DA:3419,0 +DA:3423,0 +DA:3425,0 +DA:3432,0 +DA:3435,0 +DA:3437,0 +DA:3443,0 +DA:3445,0 +DA:3448,0 +DA:3452,0 +DA:3454,0 +DA:3458,0 +DA:3463,0 +DA:3517,18 +DA:3519,18 +DA:3522,18 +DA:3528,15 +DA:3529,11 +DA:3531,11 +DA:3538,25 +DA:3540,25 +DA:3543,25 +DA:3549,22 +DA:3550,16 +DA:3551,16 +DA:3553,16 +DA:3560,25 +DA:3562,25 +DA:3565,25 +DA:3571,22 +DA:3572,16 +DA:3573,16 +DA:3575,16 +DA:3582,22 +DA:3584,22 +DA:3587,22 +DA:3592,21 +DA:3593,15 +DA:3595,15 +DA:3596,0 +DA:3602,22 +DA:3604,22 +DA:3607,22 +DA:3612,21 +DA:3613,15 +DA:3615,15 +DA:3616,0 +DA:3622,11 +DA:3624,11 +DA:3627,11 +DA:3633,9 +DA:3634,7 +DA:3636,2 +DA:3639,5 +DA:3640,0 +DA:3646,1 +DA:3648,1 +DA:3649,0 +DA:3650,0 +DA:3651,0 +DA:3655,1 +DA:3658,10 +DA:3660,10 +DA:3661,0 +DA:3662,0 +DA:3663,0 +DA:3668,10 +DA:3670,10 +DA:3673,10 +DA:3675,10 +DA:3676,0 +DA:3677,0 +DA:3678,0 +DA:3683,10 +DA:3685,10 +DA:3688,2 +DA:3690,2 +DA:3691,0 +DA:3692,0 +DA:3693,0 +DA:3698,2 +DA:3700,2 +DA:3703,0 +DA:3705,0 +DA:3706,0 +DA:3707,0 +DA:3708,0 +DA:3713,0 +DA:3715,0 +DA:3718,0 +DA:3720,0 +DA:3721,0 +DA:3722,0 +DA:3723,0 +DA:3728,0 +DA:3730,0 +DA:3733,0 +DA:3735,0 +DA:3736,0 +DA:3737,0 +DA:3738,0 +DA:3743,0 +DA:3745,0 +DA:3748,0 +DA:3750,0 +DA:3751,0 +DA:3752,0 +DA:3753,0 +DA:3757,0 +DA:3759,0 +DA:3762,0 +DA:3764,0 +DA:3765,0 +DA:3766,0 +DA:3767,0 +DA:3771,0 +DA:3773,0 +DA:3777,13374 +DA:3783,13374 +DA:3787,13374 +DA:3788,13374 +DA:3790,6687 +DA:3814,6687 +DA:3815,0 +DA:3821,13374 +DA:3824,6687 +DA:3825,6687 +DA:3826,6687 +DA:3827,0 +DA:3832,6688 +DA:3833,6688 +DA:3835,0 +DA:3838,1 +DA:3841,1 +DA:3842,0 +DA:3857,1 +DA:3858,1 +DA:3859,1 +DA:3867,522 +DA:3871,522 +DA:3874,522 +DA:3875,0 +DA:3877,0 +DA:3878,0 +DA:3879,0 +DA:3881,0 +DA:3885,522 +DA:3886,522 +DA:3887,522 +DA:3890,195 +DA:3898,195 +DA:3899,0 +DA:3900,0 +DA:3903,195 +DA:3904,195 +DA:3905,186 +DA:3906,186 +DA:3911,186 +DA:3914,186 +DA:3917,186 +DA:3919,186 +DA:3922,186 +DA:3923,186 +DA:3926,186 +DA:3927,186 +DA:3930,186 +DA:3931,186 +DA:3934,186 +DA:3935,186 +DA:3936,186 +DA:3939,196 +DA:3941,183 +DA:3944,3 +DA:3945,2 +DA:3951,186 +DA:3954,186 +DA:3957,186 +DA:3958,185 +DA:3961,1 +DA:3964,186 +DA:3968,186 +DA:3970,185 +DA:3971,185 +DA:3972,185 +DA:3974,185 +DA:3975,185 +DA:3977,185 +DA:3978,185 +DA:3979,185 +DA:3981,0 +DA:3983,0 +DA:3984,0 +DA:3985,0 +DA:3996,194 +DA:3997,183 +DA:3999,185 +DA:4000,185 +DA:4001,185 +DA:4003,185 +DA:4004,185 +DA:4008,1 +DA:4012,186 +DA:4014,186 +DA:4015,0 +DA:4016,0 +DA:4019,186 +DA:4022,186 +DA:4024,186 +DA:4025,0 +DA:4029,186 +DA:4030,0 +DA:4036,0 +DA:4037,0 +DA:4042,0 +DA:4043,0 +DA:4044,0 +DA:4045,0 +DA:4046,0 +DA:4049,0 +DA:4053,0 +DA:4055,0 +DA:4056,0 +DA:4060,186 +DA:4061,0 +DA:4062,0 +DA:4063,0 +DA:4070,186 +DA:4071,0 +DA:4073,186 +DA:4101,186 +DA:4104,186 +DA:4105,186 +DA:4111,186 +DA:4112,186 +DA:4115,186 +DA:4116,186 +DA:4117,186 +DA:4119,186 +DA:4120,186 +DA:4121,0 +DA:4123,0 +DA:4124,0 +DA:4128,0 +DA:4134,0 +DA:4137,0 +DA:4138,0 +DA:4148,0 +DA:4149,0 +DA:4151,0 +DA:4153,0 +DA:4156,0 +DA:4158,0 +DA:4160,0 +DA:4162,0 +DA:4165,0 +DA:4173,164 +DA:4180,164 +DA:4184,164 +DA:4188,164 +DA:4189,164 +DA:4191,164 +DA:4192,164 +DA:4194,0 +DA:4196,164 +DA:4199,164 +DA:4202,164 +DA:4205,164 +DA:4206,164 +DA:4210,164 +DA:4211,164 +DA:4216,167 +DA:4222,167 +DA:4226,164 +DA:4230,164 +DA:4231,164 +DA:4233,164 +DA:4236,164 +DA:4241,164 +DA:4242,164 +DA:4252,167 +DA:4258,167 +DA:4261,167 +DA:4264,167 +DA:4268,167 +DA:4272,167 +DA:4273,167 +DA:4274,167 +DA:4275,167 +DA:4277,167 +DA:4278,167 +DA:4280,167 +DA:4281,167 +DA:4283,0 +DA:4285,167 +DA:4288,167 +DA:4290,167 +DA:4296,167 +DA:4299,167 +DA:4300,167 +DA:4304,167 +DA:4305,167 +DA:4311,166 +DA:4317,166 +DA:4320,166 +DA:4323,166 +DA:4327,166 +DA:4331,166 +DA:4332,166 +DA:4333,166 +DA:4335,166 +DA:4338,166 +DA:4345,166 +DA:4346,166 +DA:4356,0 +DA:4362,0 +DA:4363,0 +DA:4364,0 +DA:4367,0 +DA:4368,0 +DA:4369,0 +DA:4372,0 +DA:4376,0 +DA:4380,0 +DA:4381,0 +DA:4382,0 +DA:4384,0 +DA:4387,0 +DA:4392,0 +DA:4393,0 +DA:4403,4 +DA:4409,4 +DA:4410,0 +DA:4411,0 +DA:4415,4 +DA:4419,4 +DA:4421,4 +DA:4424,4 +DA:4429,4 +DA:4430,4 +DA:4440,1 +DA:4446,1 +DA:4449,1 +DA:4453,1 +DA:4457,1 +DA:4458,1 +DA:4468,0 +DA:4475,0 +DA:4479,0 +DA:4480,0 +DA:4481,0 +DA:4484,0 +DA:4485,0 +DA:4487,0 +DA:4488,0 +DA:4489,0 +DA:4492,0 +DA:4496,0 +DA:4497,0 +DA:4498,0 +DA:4500,0 +DA:4502,0 +DA:4505,6688 +DA:4533,6688 +DA:4539,6688 +DA:4541,6688 +DA:4542,6688 +DA:4544,6688 +DA:4546,1 +DA:4547,0 +DA:4548,0 +DA:4549,0 +DA:4552,0 +DA:4558,0 +DA:4565,0 +DA:4568,0 +DA:4571,0 +DA:4573,0 +DA:4576,0 +DA:4577,0 +DA:4581,0 +DA:4582,0 +DA:4583,0 +DA:4586,0 +DA:4587,0 +DA:4589,0 +DA:4594,0 +DA:4597,0 +DA:4598,0 +DA:4600,0 +DA:4601,0 +DA:4602,0 +DA:4603,0 +DA:4604,0 +DA:4605,0 +DA:4607,0 +DA:4608,0 +DA:4611,0 +DA:4612,0 +DA:4613,0 +DA:4615,0 +DA:4616,0 +DA:4619,0 +DA:4620,0 +DA:4624,0 +DA:4628,0 +DA:4629,0 +DA:4631,0 +DA:4632,0 +DA:4635,0 +DA:4641,0 +DA:4644,0 +DA:4649,0 +DA:4650,0 +DA:4653,0 +DA:4655,0 +DA:4656,0 +DA:4657,0 +DA:4662,0 +DA:4664,0 +DA:4666,0 +DA:4667,0 +DA:4668,0 +DA:4669,0 +DA:4671,0 +DA:4677,0 +DA:4684,0 +DA:4689,0 +DA:4691,0 +DA:4695,0 +DA:4696,0 +DA:4697,0 +DA:4703,0 +DA:4706,0 +DA:4708,0 +DA:4711,0 +DA:4713,0 +DA:4716,0 +DA:4723,0 +DA:4727,0 +DA:4729,0 +DA:4730,0 +DA:4735,0 +DA:4738,0 +DA:4743,0 +DA:4744,0 +DA:4747,0 +DA:4753,0 +DA:4755,0 +DA:4757,0 +DA:4760,0 +DA:4769,0 +DA:4770,0 +DA:4778,0 +DA:4779,0 +DA:4784,0 +DA:4786,0 +DA:4787,0 +DA:4788,0 +DA:4792,0 +DA:4793,0 +DA:4795,0 +DA:4797,0 +DA:4798,0 +DA:4800,0 +DA:4801,0 +DA:4804,0 +DA:4805,0 +DA:4806,0 +DA:4809,0 +DA:4811,0 +DA:4812,0 +DA:4816,0 +DA:4819,0 +DA:4823,0 +DA:4824,0 +DA:4846,0 +DA:4850,0 +DA:4851,0 +DA:4854,0 +DA:4856,0 +DA:4857,0 +DA:4861,0 +DA:4862,0 +DA:4866,0 +DA:4872,1 +DA:4878,1 +DA:4879,1 +DA:4899,1 +DA:4900,1 +DA:4902,0 +DA:4905,0 +DA:4917,0 +DA:4920,0 +DA:4923,0 +DA:4926,0 +DA:4928,0 +DA:4930,0 +DA:4931,0 +DA:4932,0 +DA:4936,0 +DA:4938,0 +DA:4939,0 +DA:4941,0 +DA:4946,0 +DA:4948,0 +DA:4952,0 +DA:4958,0 +DA:4961,0 +DA:4965,0 +DA:4966,0 +DA:4968,0 +DA:4973,0 +DA:4974,0 +DA:4975,0 +DA:4978,0 +DA:4984,0 +DA:4985,0 +DA:4988,0 +DA:4989,0 +DA:5005,6687 +DA:5010,6687 +DA:5017,6687 +DA:5018,6687 +DA:5019,6687 +DA:5021,6687 +DA:5025,0 +DA:5026,0 +DA:5029,6687 +DA:5031,6687 +DA:5043,6687 +DA:5044,15221329 +DA:5051,15215210 +DA:5052,15215210 +DA:5053,15215210 +DA:5056,15215210 +DA:5057,15215210 +DA:5061,15215210 +DA:5064,15215210 +DA:5069,6687 +DA:5070,0 +DA:5071,0 +DA:5072,0 +DA:5077,6687 +DA:5079,0 +DA:5080,0 +DA:5086,6687 +DA:5091,6687 +DA:5094,6687 +DA:5105,6687 +DA:5106,0 +DA:5119,6687 +DA:5120,6687 +DA:5121,6687 +DA:5122,6687 +DA:5124,6687 +DA:5126,6687 +DA:5127,0 +DA:5133,6687 +DA:5134,6687 +DA:5136,6687 +DA:5137,0 +DA:5141,6687 +DA:5145,6687 +DA:5146,6687 +DA:5148,6687 +DA:5149,0 +DA:5153,6687 +DA:5156,6687 +DA:5158,0 +DA:5160,0 +DA:5161,0 +DA:5162,0 +DA:5163,0 +DA:5165,852 +DA:5167,0 +DA:5169,852 +DA:5171,852 +DA:5172,852 +DA:5173,852 +DA:5175,852 +DA:5177,852 +DA:5181,0 +DA:5182,0 +DA:5187,852 +DA:5189,852 +LF:1758 +LH:908 +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:6,dlt_logstorage_create_keys +FNDA:4,dlt_logstorage_filter +FNDA:5,dlt_logstorage_store_filters +FNDA:3,dlt_logstorage_device_connected +FNDA:3,dlt_logstorage_check_sync_strategy +FNDA:0,dlt_logstorage_check_general_param +FNDA:6,dlt_logstorage_check_nofiles +FNDA:2,dlt_logstorage_check_ecuid +FNDA:37,dlt_logstorage_list_find +FNDA:52,dlt_logstorage_get_filter_section_value +FNDA:0,dlt_daemon_setup_general_properties +FNDA:0,dlt_logstorage_check_reset_loglevel +FNDA:6,dlt_logstorage_get_config +FNDA:2,dlt_logstorage_device_disconnected +FNDA:11,dlt_logstorage_filter_config_free +FNDA:0,dlt_logstorage_check_disable_network +FNDA:3,dlt_logstorage_write +FNDA:0,dlt_logstorage_create_keys_only_ctid +FNDA:7,dlt_logstorage_check_filesize +FNDA:0,dlt_logstorage_check_overwrite_strategy +FNDA:26,dlt_logstorage_list_add +FNDA:6,dlt_logstorage_check_loglevel +FNDA:4,dlt_logstorage_create_keys_only_apid +FNDA:1,dlt_logstorage_free +FNDA:12,dlt_logstorage_get_keys_list +FNDA:6,dlt_logstorage_prepare_table +FNDA:6,dlt_logstorage_check_apids +FNDA:0,dlt_logstorage_check_specificsize +FNDA:2,dlt_logstorage_create_keys_multi +FNDA:12,dlt_logstorage_read_list_of_names +FNDA:12,dlt_logstorage_set_number +FNDA:4,dlt_logstorage_setup_table +FNDA:9,dlt_logstorage_read_bool +FNDA:6,dlt_logstorage_check_ctids +FNDA:4,dlt_logstorage_load_config +FNDA:7,dlt_logstorage_list_destroy +FNDA:52,dlt_logstorage_get_filter_value +FNDA:4,dlt_daemon_offline_setup_filter_properties +FNDA:13,dlt_logstorage_filter_set_strategy +FNDA:0,dlt_logstorage_create_keys_only_ecu +FNDA:5,dlt_logstorage_set_loglevel +FNDA:6,dlt_logstorage_validate_filter_name +FNDA:13,dlt_logstorage_count_ids +FNDA:0,dlt_logstorage_set_sync_strategy +FNDA:5,dlt_logstorage_get_loglevel_by_key +FNDA:0,dlt_logstorage_check_gzip_compression +FNDA:0,dlt_logstorage_check_maintain_logstorage_loglevel +FNDA:27,dlt_logstorage_list_add_config +FNDA:13,dlt_logstorage_read_number +FNDA:26,dlt_logstorage_check_param +FNDA:2,dlt_logstorage_sync_caches +FNDA:7,dlt_logstorage_check_filename +FNF:52 +FNH:41 +DA:44,11 +DA:49,11 +DA:50,8 +DA:51,8 +DA:54,11 +DA:55,8 +DA:56,8 +DA:59,11 +DA:60,6 +DA:61,6 +DA:64,11 +DA:65,0 +DA:66,0 +DA:69,11 +DA:70,0 +DA:71,0 +DA:74,11 +DA:75,0 +DA:82,11 +DA:83,0 +DA:84,0 +DA:87,11 +DA:89,11 +DA:91,0 +DA:92,0 +DA:93,0 +DA:97,0 +DA:100,11 +DA:113,7 +DA:120,14 +DA:122,7 +DA:123,7 +DA:125,7 +DA:126,7 +DA:129,7 +DA:132,7 +DA:137,7 +DA:139,7 +DA:143,7 +DA:147,7 +DA:150,27 +DA:153,27 +DA:159,27 +DA:160,22 +DA:162,27 +DA:163,22 +DA:165,27 +DA:166,20 +DA:168,27 +DA:169,16 +DA:185,26 +DA:192,38 +DA:193,12 +DA:196,26 +DA:198,26 +DA:201,26 +DA:202,26 +DA:203,26 +DA:205,0 +DA:207,0 +DA:211,26 +DA:212,26 +DA:213,26 +DA:215,26 +DA:216,0 +DA:218,0 +DA:220,0 +DA:223,26 +DA:224,0 +DA:226,0 +DA:228,0 +DA:230,0 +DA:233,26 +DA:235,26 +DA:248,37 +DA:255,130 +DA:256,168 +DA:258,93 +DA:259,93 +DA:262,18 +DA:263,18 +DA:264,18 +DA:267,93 +DA:270,37 +DA:275,13 +DA:278,13 +DA:286,64 +DA:287,52 +DA:288,12 +DA:290,52 +DA:305,1 +DA:307,1 +DA:308,0 +DA:309,0 +DA:312,1 +DA:313,1 +DA:332,12 +DA:340,12 +DA:341,1 +DA:342,1 +DA:346,11 +DA:347,3 +DA:348,3 +DA:351,11 +DA:353,11 +DA:354,0 +DA:356,0 +DA:360,11 +DA:363,11 +DA:365,11 +DA:366,0 +DA:367,0 +DA:370,11 +DA:371,11 +DA:375,31 +DA:376,20 +DA:377,20 +DA:379,20 +DA:381,20 +DA:382,9 +DA:384,20 +DA:386,20 +DA:387,20 +DA:395,12 +DA:397,12 +DA:398,0 +DA:399,0 +DA:402,12 +DA:404,12 +DA:420,13 +DA:426,13 +DA:429,12 +DA:430,12 +DA:433,56 +DA:434,44 +DA:435,0 +DA:436,0 +DA:439,12 +DA:441,12 +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,12 +DA:488,12 +DA:491,12 +DA:494,12 +DA:496,12 +DA:499,12 +DA:501,12 +DA:502,0 +DA:503,0 +DA:506,12 +DA:509,12 +DA:510,0 +DA:511,0 +DA:514,24 +DA:516,12 +DA:517,0 +DA:518,0 +DA:521,12 +DA:523,12 +DA:524,12 +DA:527,12 +DA:529,12 +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,2 +DA:612,2 +DA:615,2 +DA:623,2 +DA:624,2 +DA:627,2 +DA:628,2 +DA:629,2 +DA:631,2 +DA:632,2 +DA:643,0 +DA:645,0 +DA:650,0 +DA:651,0 +DA:681,6 +DA:688,6 +DA:689,6 +DA:690,6 +DA:691,6 +DA:694,6 +DA:698,6 +DA:699,6 +DA:700,0 +DA:701,0 +DA:702,0 +DA:703,0 +DA:706,0 +DA:709,0 +DA:710,0 +DA:713,6 +DA:714,0 +DA:715,0 +DA:719,6 +DA:720,0 +DA:721,0 +DA:725,6 +DA:726,0 +DA:727,0 +DA:728,0 +DA:731,6 +DA:734,6 +DA:737,6 +DA:738,0 +DA:739,0 +DA:740,0 +DA:744,12 +DA:745,6 +DA:747,12 +DA:748,6 +DA:750,6 +DA:751,0 +DA:752,6 +DA:753,4 +DA:755,2 +DA:757,6 +DA:759,6 +DA:764,6 +DA:765,6 +DA:767,6 +DA:779,6 +DA:783,6 +DA:785,6 +DA:790,6 +DA:791,1 +DA:792,1 +DA:795,5 +DA:801,5 +DA:802,0 +DA:803,0 +DA:807,5 +DA:812,0 +DA:813,0 +DA:814,0 +DA:816,0 +DA:819,5 +DA:820,4 +DA:822,0 +DA:823,0 +DA:829,0 +DA:834,0 +DA:835,4 +DA:836,4 +DA:838,0 +DA:841,0 +DA:843,0 +DA:845,4 +DA:846,4 +DA:847,4 +DA:849,4 +DA:850,4 +DA:852,0 +DA:856,5 +DA:858,5 +DA:870,6 +DA:878,6 +DA:881,5 +DA:884,5 +DA:887,7 +DA:888,2 +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,12 +DA:930,12 +DA:931,12 +DA:934,1 +DA:935,1 +DA:936,1 +DA:940,6 +DA:943,6 +DA:944,1 +DA:945,1 +DA:948,5 +DA:951,6 +DA:954,6 +DA:957,5 +DA:960,5 +DA:963,5 +DA:964,5 +DA:965,0 +DA:966,0 +DA:967,0 +DA:972,6 +DA:977,6 +DA:985,5 +DA:988,4 +DA:992,0 +DA:996,0 +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,7 +DA:1064,7 +DA:1065,1 +DA:1066,1 +DA:1069,6 +DA:1070,2 +DA:1071,2 +DA:1074,6 +DA:1076,6 +DA:1077,0 +DA:1079,0 +DA:1083,6 +DA:1084,5 +DA:1086,5 +DA:1087,0 +DA:1089,0 +DA:1092,5 +DA:1095,1 +DA:1097,1 +DA:1100,5 +DA:1103,7 +DA:1106,7 +DA:1109,6 +DA:1112,6 +DA:1115,6 +DA:1118,5 +DA:1121,0 +DA:1124,0 +DA:1127,0 +DA:1129,0 +DA:1130,0 +DA:1132,0 +DA:1135,0 +DA:1138,0 +DA:1141,0 +DA:1144,0 +DA:1147,0 +DA:1149,0 +DA:1151,0 +DA:1153,0 +DA:1154,0 +DA:1172,3 +DA:1175,3 +DA:1178,2 +DA:1179,1 +DA:1180,1 +DA:1184,1 +DA:1185,0 +DA:1187,1 +DA:1188,0 +DA:1190,1 +DA:1191,0 +DA:1193,1 +DA:1194,0 +DA:1196,1 +DA:1197,0 +DA:1199,1 +DA:1200,1 +DA:1202,1 +DA:1203,1 +DA:1222,0 +DA:1225,0 +DA:1228,0 +DA:1229,0 +DA:1230,0 +DA:1231,0 +DA:1233,0 +DA:1235,0 +DA:1236,0 +DA:1254,0 +DA:1257,0 +DA:1260,0 +DA:1261,0 +DA:1262,0 +DA:1263,0 +DA:1265,0 +DA:1267,0 +DA:1268,0 +DA:1283,2 +DA:1288,2 +DA:1291,1 +DA:1292,1 +DA:1293,1 +DA:1296,1 +DA:1297,1 +DA:1299,1 +DA:1302,1 +DA:1304,1 +DA:1523,26 +DA:1527,26 +DA:1530,25 +DA:1531,25 +DA:1536,52 +DA:1543,52 +DA:1546,52 +DA:1547,48 +DA:1551,48 +DA:1552,0 +DA:1555,0 +DA:1558,48 +DA:1559,24 +DA:1561,24 +DA:1571,52 +DA:1581,52 +DA:1585,52 +DA:1588,52 +DA:1592,0 +DA:1595,0 +DA:1599,0 +DA:1602,0 +DA:1607,0 +DA:1614,4 +DA:1621,4 +DA:1623,4 +DA:1625,4 +DA:1626,0 +DA:1630,4 +DA:1637,4 +DA:1642,4 +DA:1646,4 +DA:1650,4 +DA:1652,4 +DA:1654,56 +DA:1655,52 +DA:1657,52 +DA:1660,52 +DA:1661,28 +DA:1664,24 +DA:1666,24 +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,4 +DA:1699,4 +DA:1700,0 +DA:1704,4 +DA:1708,4 +DA:1710,4 +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,5 +DA:1849,5 +DA:1855,5 +DA:1856,1 +DA:1857,1 +DA:1860,4 +DA:1862,4 +DA:1863,0 +DA:1864,0 +DA:1867,4 +DA:1868,4 +DA:1870,8 +DA:1873,4 +DA:1874,0 +DA:1875,0 +DA:1876,0 +DA:1879,4 +DA:1880,0 +DA:1882,0 +DA:1883,0 +DA:1886,4 +DA:1888,4 +DA:1890,4 +DA:1893,4 +DA:1896,0 +DA:1900,0 +DA:1904,4 +DA:1908,0 +DA:1912,4 +DA:1914,4 +DA:1931,4 +DA:1933,4 +DA:1937,4 +DA:1938,3 +DA:1942,3 +DA:1943,0 +DA:1946,0 +DA:1949,3 +DA:1952,3 +DA:1954,0 +DA:1956,0 +DA:1958,3 +DA:1959,3 +DA:1961,3 +DA:1962,0 +DA:1963,0 +DA:1965,3 +DA:1967,0 +DA:1969,0 +DA:1972,3 +DA:1974,3 +DA:1986,3 +DA:1988,3 +DA:1989,1 +DA:1990,1 +DA:1993,2 +DA:1994,0 +DA:1997,0 +DA:2002,2 +DA:2003,2 +DA:2004,2 +DA:2005,2 +DA:2006,2 +DA:2007,2 +DA:2008,2 +DA:2010,2 +DA:2011,2 +DA:2013,2 +DA:2029,2 +DA:2032,2 +DA:2036,1 +DA:2037,0 +DA:2040,1 +DA:2041,1 +DA:2042,1 +DA:2043,1 +DA:2044,1 +DA:2046,1 +DA:2048,0 +DA:2049,0 +DA:2050,0 +DA:2051,0 +DA:2053,0 +DA:2054,0 +DA:2057,0 +DA:2075,5 +DA:2077,5 +DA:2083,5 +DA:2084,5 +DA:2085,4 +DA:2086,4 +DA:2089,4 +DA:2091,4 +DA:2093,0 +DA:2094,0 +DA:2096,4 +DA:2098,4 +DA:2100,4 +DA:2109,0 +DA:2112,0 +DA:2114,0 +DA:2136,6 +DA:2143,6 +DA:2153,6 +DA:2154,5 +DA:2155,5 +DA:2169,5 +DA:2174,5 +DA:2176,0 +DA:2180,0 +DA:2182,0 +DA:2185,5 +DA:2190,5 +DA:2197,5 +DA:2203,5 +DA:2212,5 +DA:2236,36 +DA:2238,32 +DA:2239,32 +DA:2241,32 +DA:2243,32 +DA:2269,4 +DA:2279,4 +DA:2283,3 +DA:2285,3 +DA:2286,0 +DA:2289,0 +DA:2292,12 +DA:2294,9 +DA:2296,0 +DA:2299,0 +DA:2303,9 +DA:2304,6 +DA:2307,6 +DA:2308,6 +DA:2312,3 +DA:2313,3 +DA:2315,0 +DA:2318,0 +DA:2343,3 +DA:2353,3 +DA:2371,3 +DA:2372,2 +DA:2373,2 +DA:2374,2 +DA:2380,2 +DA:2383,2 +DA:2384,2 +DA:2386,2 +DA:2387,2 +DA:2392,2 +DA:2393,2 +DA:2396,2 +DA:2397,0 +DA:2398,0 +DA:2401,2 +DA:2402,2 +DA:2404,2 +DA:2408,2 +DA:2409,2 +DA:2411,2 +DA:2412,0 +DA:2415,0 +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,8 +DA:2443,6 +DA:2445,6 +DA:2448,6 +DA:2453,0 +DA:2455,0 +DA:2458,0 +DA:2462,0 +DA:2463,0 +DA:2464,0 +DA:2465,0 +DA:2468,0 +DA:2472,0 +DA:2474,0 +DA:2477,0 +DA:2480,0 +DA:2481,0 +DA:2482,0 +DA:2487,0 +DA:2490,0 +DA:2491,0 +DA:2493,0 +DA:2497,0 +DA:2498,0 +DA:2501,0 +DA:2504,0 +DA:2506,0 +DA:2507,0 +DA:2510,0 +DA:2511,0 +DA:2514,0 +DA:2515,0 +DA:2518,0 +DA:2519,0 +DA:2521,0 +DA:2527,0 +DA:2528,0 +DA:2529,0 +DA:2531,0 +DA:2532,0 +DA:2536,0 +DA:2537,0 +DA:2547,0 +DA:2555,0 +DA:2557,0 +DA:2558,0 +DA:2559,0 +DA:2560,0 +DA:2562,0 +DA:2563,0 +DA:2568,0 +DA:2573,0 +DA:2574,0 +DA:2578,0 +DA:2580,0 +DA:2584,0 +DA:2589,0 +DA:2591,0 +DA:2593,0 +DA:2594,0 +DA:2598,0 +DA:2615,2 +DA:2619,2 +DA:2622,2 +DA:2624,4 +DA:2625,2 +DA:2626,2 +DA:2628,2 +DA:2630,0 +DA:2635,2 +LF:763 +LH:443 +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:263,dlt_logstorage_get_idx_of_log_file +FN:303,dlt_logstorage_storage_dir_info +FN:492,dlt_logstorage_open_log_output_file +FN:523,dlt_logstorage_open_log_file +FN:755,dlt_logstorage_find_dlt_header +FN:781,dlt_logstorage_find_last_dlt_header +FN:807,dlt_logstorage_write_to_log +FN:829,dlt_logstorage_check_write_ret +FN:878,dlt_logstorage_close_file +FN:906,dlt_logstorage_sync_to_file +FN:1023,dlt_logstorage_prepare_on_msg +FN:1134,dlt_logstorage_write_on_msg +FN:1188,dlt_logstorage_sync_on_msg +FN:1228,dlt_logstorage_prepare_msg_cache +FN:1346,dlt_logstorage_write_msg_cache +FN:1486,dlt_logstorage_sync_msg_cache +FNDA:9,dlt_logstorage_open_log_file +FNDA:3,dlt_logstorage_sync_to_file +FNDA:4,dlt_logstorage_prepare_msg_cache +FNDA:29,dlt_logstorage_concat_logfile_name +FNDA:11,dlt_logstorage_sort_file_name +FNDA:2,dlt_logstorage_check_write_ret +FNDA:11,dlt_logstorage_get_idx_of_log_file +FNDA:5,dlt_logstorage_prepare_on_msg +FNDA:10,dlt_logstorage_storage_dir_info +FNDA:3,dlt_logstorage_rearrange_file_name +FNDA:11,dlt_logstorage_sync_on_msg +FNDA:13,dlt_logstorage_log_file_name +FNDA:5,dlt_logstorage_write_to_log +FNDA:2,dlt_logstorage_write_on_msg +FNDA:4,dlt_logstorage_write_msg_cache +FNDA:5,dlt_logstorage_open_log_output_file +FNDA:2,dlt_logstorage_find_last_dlt_header +FNDA:2,dlt_logstorage_sync_msg_cache +FNDA:2,dlt_logstorage_close_file +FNDA:4,dlt_logstorage_find_dlt_header +FNF:20 +FNH:20 +DA:47,29 +DA:49,29 +DA:50,29 +DA:52,29 +DA:53,29 +DA:56,0 +DA:59,29 +DA:60,0 +DA:62,29 +DA:85,13 +DA:92,13 +DA:95,12 +DA:96,12 +DA:98,12 +DA:105,12 +DA:109,12 +DA:110,12 +DA:114,12 +DA:115,11 +DA:116,11 +DA:117,0 +DA:119,11 +DA:120,0 +DA:130,12 +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,12 +DA:155,12 +DA:156,0 +DA:168,11 +DA:173,11 +DA:176,7 +DA:179,5 +DA:180,5 +DA:184,17 +DA:185,12 +DA:186,12 +DA:188,4 +DA:189,4 +DA:190,4 +DA:195,12 +DA:197,12 +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:263,11 +DA:267,11 +DA:280,10 +DA:281,10 +DA:282,10 +DA:283,10 +DA:285,10 +DA:286,0 +DA:289,10 +DA:303,10 +DA:312,10 +DA:316,10 +DA:317,10 +DA:320,10 +DA:321,10 +DA:322,9 +DA:323,9 +DA:328,9 +DA:330,0 +DA:331,0 +DA:335,0 +DA:336,0 +DA:337,0 +DA:338,0 +DA:340,0 +DA:342,0 +DA:348,9 +DA:350,9 +DA:351,0 +DA:353,0 +DA:356,9 +DA:361,9 +DA:362,9 +DA:363,2 +DA:365,1 +DA:366,1 +DA:368,1 +DA:371,1 +DA:377,9 +DA:386,275 +DA:389,266 +DA:391,266 +DA:393,266 +DA:394,266 +DA:395,5 +DA:397,0 +DA:398,0 +DA:399,0 +DA:402,0 +DA:406,5 +DA:407,5 +DA:410,0 +DA:416,5 +DA:417,4 +DA:419,4 +DA:421,0 +DA:422,0 +DA:425,4 +DA:428,1 +DA:430,2 +DA:431,1 +DA:433,1 +DA:435,1 +DA:437,0 +DA:438,0 +DA:442,5 +DA:443,5 +DA:448,5 +DA:449,5 +DA:450,5 +DA:451,5 +DA:452,5 +DA:456,9 +DA:459,9 +DA:460,9 +DA:469,9 +DA:470,0 +DA:474,275 +DA:475,266 +DA:477,9 +DA:479,9 +DA:492,5 +DA:495,5 +DA:496,5 +DA:497,5 +DA:503,5 +DA:504,5 +DA:506,5 +DA:523,9 +DA:531,9 +DA:532,9 +DA:533,9 +DA:539,9 +DA:542,8 +DA:543,0 +DA:544,0 +DA:550,8 +DA:551,8 +DA:556,8 +DA:558,13 +DA:559,5 +DA:561,5 +DA:564,5 +DA:568,8 +DA:569,4 +DA:572,4 +DA:573,4 +DA:579,4 +DA:580,4 +DA:583,4 +DA:585,4 +DA:586,0 +DA:587,0 +DA:590,4 +DA:591,4 +DA:592,4 +DA:601,4 +DA:602,2 +DA:603,1 +DA:604,1 +DA:606,2 +DA:608,4 +DA:610,4 +DA:615,4 +DA:620,4 +DA:621,4 +DA:622,3 +DA:623,1 +DA:624,1 +DA:631,3 +DA:632,3 +DA:636,3 +DA:638,2 +DA:641,3 +DA:644,3 +DA:645,3 +DA:655,3 +DA:656,3 +DA:657,3 +DA:663,3 +DA:664,1 +DA:665,1 +DA:666,1 +DA:671,3 +DA:673,3 +DA:678,3 +DA:680,3 +DA:681,0 +DA:682,0 +DA:685,3 +DA:686,3 +DA:687,3 +DA:689,3 +DA:692,3 +DA:693,3 +DA:696,3 +DA:701,3 +DA:702,3 +DA:706,3 +DA:708,3 +DA:709,3 +DA:710,3 +DA:712,3 +DA:722,8 +DA:724,0 +DA:725,0 +DA:726,0 +DA:727,0 +DA:729,0 +DA:730,0 +DA:733,0 +DA:734,0 +DA:735,0 +DA:738,0 +DA:739,0 +DA:755,4 +DA:759,4 +DA:760,4 +DA:763,18 +DA:764,17 +DA:765,3 +DA:781,2 +DA:785,2 +DA:786,2 +DA:789,8 +DA:790,7 +DA:791,1 +DA:807,5 +DA:817,5 +DA:829,2 +DA:832,2 +DA:833,0 +DA:835,2 +DA:836,0 +DA:844,0 +DA:845,0 +DA:850,2 +DA:856,2 +DA:857,0 +DA:860,2 +DA:862,0 +DA:863,0 +DA:868,2 +DA:878,2 +DA:887,2 +DA:888,0 +DA:889,0 +DA:891,2 +DA:906,3 +DA:919,3 +DA:920,2 +DA:922,1 +DA:923,1 +DA:926,2 +DA:931,2 +DA:932,2 +DA:934,2 +DA:936,0 +DA:937,0 +DA:940,2 +DA:944,2 +DA:946,2 +DA:949,0 +DA:951,0 +DA:953,0 +DA:954,0 +DA:956,0 +DA:957,0 +DA:959,0 +DA:960,0 +DA:963,0 +DA:964,0 +DA:966,0 +DA:967,0 +DA:972,0 +DA:973,0 +DA:977,2 +DA:978,2 +DA:980,2 +DA:983,2 +DA:985,0 +DA:988,0 +DA:989,0 +DA:992,0 +DA:998,2 +DA:999,2 +DA:1001,2 +DA:1002,2 +DA:1005,2 +DA:1007,2 +DA:1023,5 +DA:1032,5 +DA:1033,4 +DA:1034,1 +DA:1035,1 +DA:1042,4 +DA:1045,4 +DA:1046,2 +DA:1047,2 +DA:1048,1 +DA:1049,1 +DA:1051,2 +DA:1055,4 +DA:1063,0 +DA:1065,0 +DA:1072,0 +DA:1073,0 +DA:1074,0 +DA:1077,0 +DA:1079,0 +DA:1080,0 +DA:1081,0 +DA:1086,0 +DA:1089,0 +DA:1090,0 +DA:1091,0 +DA:1092,0 +DA:1093,0 +DA:1095,0 +DA:1098,0 +DA:1110,0 +DA:1134,2 +DA:1146,2 +DA:1147,1 +DA:1152,1 +DA:1154,1 +DA:1155,0 +DA:1157,1 +DA:1158,1 +DA:1159,0 +DA:1161,1 +DA:1162,1 +DA:1163,0 +DA:1173,1 +DA:1188,11 +DA:1196,11 +DA:1199,10 +DA:1200,1 +DA:1206,1 +DA:1207,0 +DA:1228,4 +DA:1234,4 +DA:1235,3 +DA:1244,3 +DA:1245,1 +DA:1246,0 +DA:1247,0 +DA:1248,0 +DA:1249,0 +DA:1251,1 +DA:1252,1 +DA:1253,1 +DA:1262,3 +DA:1263,0 +DA:1264,0 +DA:1265,0 +DA:1271,3 +DA:1272,0 +DA:1273,0 +DA:1275,0 +DA:1278,0 +DA:1281,3 +DA:1286,1 +DA:1289,0 +DA:1293,1 +DA:1297,1 +DA:1298,1 +DA:1301,0 +DA:1304,0 +DA:1306,1 +DA:1313,1 +DA:1315,1 +DA:1317,0 +DA:1323,1 +DA:1346,4 +DA:1363,4 +DA:1364,3 +DA:1365,3 +DA:1370,3 +DA:1373,0 +DA:1377,3 +DA:1380,3 +DA:1386,3 +DA:1387,3 +DA:1389,3 +DA:1391,3 +DA:1392,3 +DA:1393,3 +DA:1394,3 +DA:1398,3 +DA:1399,3 +DA:1400,3 +DA:1401,3 +DA:1402,3 +DA:1410,3 +DA:1413,0 +DA:1415,0 +DA:1416,0 +DA:1420,0 +DA:1423,0 +DA:1427,0 +DA:1429,0 +DA:1430,0 +DA:1433,0 +DA:1437,0 +DA:1441,0 +DA:1443,0 +DA:1444,0 +DA:1447,0 +DA:1448,0 +DA:1449,0 +DA:1452,0 +DA:1455,0 +DA:1458,0 +DA:1459,0 +DA:1460,0 +DA:1463,0 +DA:1464,0 +DA:1465,0 +DA:1466,0 +DA:1467,0 +DA:1486,2 +DA:1495,2 +DA:1501,1 +DA:1503,1 +DA:1505,0 +DA:1507,0 +DA:1510,1 +DA:1513,0 +DA:1517,1 +DA:1520,1 +DA:1528,1 +DA:1531,1 +DA:1535,0 +DA:1536,0 +DA:1540,0 +DA:1542,0 +DA:1543,0 +DA:1550,0 +DA:1552,0 +DA:1553,0 +DA:1558,1 +DA:1559,1 +DA:1562,0 +DA:1566,1 +DA:1569,0 +DA:1570,0 +LF:467 +LH:316 +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:246,dlt_message_read +FNDA:0,dlt_convert_serial_speed +FNDA:234,dlt_set_storageheader +FNDA:12,dlt_log_set_level +FNDA:10,dlt_buffer_copy +FNDA:12,dlt_getloginfo_conv_ascii_to_int16_t +FNDA:0,dlt_filter_delete +FNDA:14,dlt_getloginfo_conv_ascii_to_uint16_t +FNDA:328,dlt_message_print_hex +FNDA:3,dlt_buffer_get_total_size +FNDA:2,dlt_receiver_free_global_buffer +FNDA:64,dlt_message_free +FNDA:8,dlt_buffer_pull +FNDA:9,dlt_buffer_reset +FNDA:20,dlt_getloginfo_conv_ascii_to_id +FNDA:0,dlt_buffer_init_static_server +FNDA:8,dlt_log_free +FNDA:24692,dlt_buffer_write_block +FNDA:6785,dlt_buffer_free_dynamic +FNDA:2,dlt_get_major_version +FNDA:6687,dlt_check_envvar +FNDA:247,dlt_uptime +FNDA:6702,dlt_receiver_init +FNDA:0,dlt_print_hex +FNDA:6,dlt_filter_init +FNDA:6,dlt_file_set_filter +FNDA:4089,dlt_strnlen_s +FNDA:21,dlt_receiver_remove +FNDA:7,dlt_buffer_minimize_size +FNDA:2,dlt_buffer_status +FNDA:19,dlt_log_init_multiple_logfiles_support +FNDA:3366,dlt_file_read_data +FNDA:6702,dlt_receiver_free +FNDA:2852,dlt_user_printf +FNDA:2,dlt_set_loginfo_parse_service_id +FNDA:0,dlt_file_read_header_raw +FNDA:6,dlt_filter_load +FNDA:12,dlt_filter_find +FNDA:3,dlt_file_quick_parsing +FNDA:147,dlt_clean_string +FNDA:6,dlt_get_version +FNDA:0,dlt_file_read_raw +FNDA:2620,dlt_message_payload +FNDA:0,dlt_filter_save +FNDA:2,dlt_buffer_info +FNDA:5571,dlt_check_storageheader +FNDA:5,dlt_buffer_remove +FNDA:328,dlt_message_print_header +FNDA:2226,dlt_file_read +FNDA:4,dlt_log_init_single_logfile +FNDA:2,dlt_log_free_single_logfile +FNDA:28,dlt_file_init +FNDA:12,dlt_log_multiple_files_write +FNDA:4611,dlt_message_header_flags +FNDA:12,dlt_filter_add +FNDA:32,dlt_file_open +FNDA:0,dlt_file_close +FNDA:1062,dlt_print_mixed_string +FNDA:3,dlt_log_free_multiple_logfiles +FNDA:0,dlt_buffer_init_static_client +FNDA:7,dlt_buffer_increase_size +FNDA:742,dlt_message_filter_check +FNDA:2672,dlt_buffer_get_message_count +FNDA:0,dlt_hex_ascii_to_binary +FNDA:818061,dlt_log +FNDA:3996,dlt_file_read_header_extended +FNDA:0,dlt_setup_serial +FNDA:23443,dlt_set_id +FNDA:852,dlt_buffer_check_size +FNDA:425,dlt_message_set_extraparameters +FNDA:26,dlt_file_free +FNDA:7,dlt_check_rcv_data_size +FNDA:4087,dlt_print_id +FNDA:0,dlt_buffer_free_static +FNDA:1661,dlt_print_char_string +FNDA:2503,dlt_buffer_get_used_size +FNDA:0,dlt_execute_command +FNDA:3261,dlt_file_message +FNDA:751,dlt_message_argument_print +FNDA:11,dlt_getloginfo_conv_ascii_to_string +FNDA:6687,dlt_vnlog +FNDA:2721,dlt_print_hex_string +FNDA:2,dlt_receiver_init_global_buffer +FNDA:494,dlt_message_get_extraparameters +FNDA:37,dlt_is_log_in_multiple_files_active +FNDA:5,get_filename_ext +FNDA:6,dlt_extract_base_name_without_ext +FNDA:9839,dlt_buffer_push3 +FNDA:11,dlt_receiver_move_to_begin +FNDA:2,dlt_get_minor_version +FNDA:4,dlt_log_init_multiple_logfiles +FNDA:1909,dlt_message_header +FNDA:12,dlt_log_init +FNDA:6689,dlt_log_set_fifo_basedir +FNDA:0,dlt_print_with_attributes +FNDA:328,dlt_message_print_mixed_html +FNDA:5592,dlt_file_read_header +FNDA:12,dlt_receiver_receive +FNDA:7516,dlt_buffer_push +FNDA:0,dlt_filter_free +FNDA:2730,dlt_print_hex_string_delim +FNDA:45,dlt_buffer_read_block +FNDA:6811,dlt_buffer_init_dynamic +FNDA:0,dlt_receiver_check_and_get +FNDA:328,dlt_message_print_mixed_plain +FNDA:59,dlt_buffer_get +FNDA:10,dlt_log_set_filename +FNDA:328,dlt_message_print_ascii +FNDA:818423,dlt_vlog +FNDA:252,dlt_message_init +FNF:110 +FNH:94 +DA:124,0 +DA:128,0 +DA:131,0 +DA:132,0 +DA:133,0 +DA:135,0 +DA:139,2730 +DA:143,2730 +DA:147,2727 +DA:148,0 +DA:151,0 +DA:154,36441 +DA:155,33714 +DA:156,31013 +DA:157,31013 +DA:160,33714 +DA:161,33714 +DA:167,2721 +DA:169,2721 +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,4089 +DA:322,4089 +DA:325,17137 +DA:326,16385 +DA:327,3336 +DA:332,4087 +DA:335,4087 +DA:341,4084 +DA:343,4084 +DA:348,23443 +DA:351,23443 +DA:354,23440 +DA:355,23440 +DA:356,23440 +DA:357,23307 +DA:359,23440 +DA:360,9337 +DA:364,9337 +DA:365,9331 +DA:369,9331 +DA:370,9323 +DA:374,9323 +DA:375,9160 +DA:380,147 +DA:384,147 +DA:387,2002 +DA:388,1855 +DA:389,0 +DA:392,6 +DA:394,6 +DA:396,6 +DA:399,6 +DA:401,6 +DA:404,0 +DA:406,0 +DA:408,0 +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,252 +DA:643,252 +DA:645,252 +DA:649,250 +DA:650,250 +DA:652,250 +DA:653,250 +DA:655,250 +DA:656,250 +DA:657,250 +DA:659,250 +DA:661,250 +DA:664,64 +DA:666,64 +DA:668,64 +DA:672,62 +DA:673,48 +DA:674,48 +DA:675,48 +DA:681,1909 +DA:683,1909 +DA:686,4611 +DA:691,4611 +DA:693,4611 +DA:696,4415 +DA:699,4415 +DA:702,4415 +DA:704,4415 +DA:706,2315 +DA:707,2315 +DA:708,2315 +DA:709,2315 +DA:710,2315 +DA:713,4415 +DA:715,2315 +DA:716,136 +DA:718,2179 +DA:721,4415 +DA:723,2315 +DA:725,4415 +DA:727,2315 +DA:728,136 +DA:730,2179 +DA:735,4415 +DA:736,2315 +DA:738,2315 +DA:739,884 +DA:741,1431 +DA:743,2315 +DA:746,4415 +DA:747,2315 +DA:748,884 +DA:750,1431 +DA:752,2315 +DA:756,4415 +DA:757,1924 +DA:758,884 +DA:759,884 +DA:760,884 +DA:763,1924 +DA:764,884 +DA:765,748 +DA:766,748 +DA:768,884 +DA:769,0 +DA:770,0 +DA:772,884 +DA:773,0 +DA:774,0 +DA:776,884 +DA:777,136 +DA:778,136 +DA:780,884 +DA:783,1924 +DA:785,884 +DA:786,748 +DA:788,136 +DA:790,884 +DA:793,1924 +DA:795,884 +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,2620 +DA:832,2620 +DA:834,2620 +DA:835,2561 +DA:838,2430 +DA:839,10 +DA:840,10 +DA:844,2420 +DA:847,2420 +DA:848,526 +DA:851,1894 +DA:852,526 +DA:854,1368 +DA:855,526 +DA:857,842 +DA:858,842 +DA:867,842 +DA:869,534 +DA:870,534 +DA:872,534 +DA:873,0 +DA:875,0 +DA:876,0 +DA:880,534 +DA:881,57 +DA:882,57 +DA:884,0 +DA:885,0 +DA:887,57 +DA:888,57 +DA:891,477 +DA:895,534 +DA:896,1 +DA:897,1 +DA:899,1 +DA:900,0 +DA:902,1 +DA:904,1 +DA:905,1 +DA:909,534 +DA:910,122 +DA:911,122 +DA:915,122 +DA:917,122 +DA:918,6 +DA:919,6 +DA:922,412 +DA:925,534 +DA:934,833 +DA:935,525 +DA:936,231 +DA:937,231 +DA:941,525 +DA:942,525 +DA:945,525 +DA:947,525 +DA:948,525 +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,246 +DA:991,246 +DA:993,246 +DA:997,26 +DA:1000,26 +DA:1004,26 +DA:1006,0 +DA:1007,0 +DA:1008,0 +DA:1012,26 +DA:1014,26 +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,26 +DA:1044,26 +DA:1047,26 +DA:1048,26 +DA:1051,26 +DA:1053,26 +DA:1054,26 +DA:1058,26 +DA:1061,26 +DA:1062,0 +DA:1065,0 +DA:1068,26 +DA:1072,26 +DA:1073,0 +DA:1078,26 +DA:1079,26 +DA:1082,26 +DA:1083,26 +DA:1086,26 +DA:1087,26 +DA:1088,26 +DA:1089,26 +DA:1091,0 +DA:1093,26 +DA:1097,26 +DA:1102,21 +DA:1103,17 +DA:1104,2 +DA:1105,2 +DA:1106,2 +DA:1111,4 +DA:1112,4 +DA:1115,21 +DA:1116,0 +DA:1119,0 +DA:1123,21 +DA:1125,21 +DA:1128,494 +DA:1130,494 +DA:1132,494 +DA:1135,492 +DA:1136,298 +DA:1140,492 +DA:1141,7 +DA:1142,7 +DA:1143,7 +DA:1146,492 +DA:1147,596 +DA:1148,298 +DA:1149,298 +DA:1150,298 +DA:1156,425 +DA:1158,425 +DA:1160,425 +DA:1163,423 +DA:1164,227 +DA:1165,227 +DA:1168,423 +DA:1169,186 +DA:1170,186 +DA:1171,186 +DA:1172,186 +DA:1176,423 +DA:1177,227 +DA:1178,454 +DA:1179,227 +DA:1180,227 +DA:1181,227 +DA:1188,28 +DA:1190,28 +DA:1192,28 +DA:1196,28 +DA:1197,28 +DA:1198,28 +DA:1199,28 +DA:1201,28 +DA:1202,28 +DA:1203,28 +DA:1205,28 +DA:1207,28 +DA:1209,28 +DA:1212,6 +DA:1214,6 +DA:1216,6 +DA:1220,6 +DA:1222,6 +DA:1225,5592 +DA:1227,5592 +DA:1229,5592 +DA:1235,11184 +DA:1238,21 +DA:1239,0 +DA:1241,21 +DA:1243,21 +DA:1247,5571 +DA:1248,5571 +DA:1252,5571 +DA:1254,0 +DA:1257,0 +DA:1258,0 +DA:1268,5571 +DA:1269,5571 +DA:1274,5571 +DA:1277,5571 +DA:1278,0 +DA:1281,0 +DA:1283,5571 +DA:1287,5571 +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,3996 +DA:1396,3996 +DA:1398,3996 +DA:1402,3996 +DA:1403,512 +DA:1406,0 +DA:1407,0 +DA:1410,256 +DA:1414,3996 +DA:1418,1664 +DA:1419,1664 +DA:1422,0 +DA:1423,0 +DA:1427,1664 +DA:1428,1664 +DA:1429,1664 +DA:1430,1664 +DA:1432,0 +DA:1437,3366 +DA:1439,3366 +DA:1441,3366 +DA:1445,3366 +DA:1446,126 +DA:1447,126 +DA:1450,3366 +DA:1452,148 +DA:1453,148 +DA:1456,3366 +DA:1457,0 +DA:1460,0 +DA:1464,6732 +DA:1465,52 +DA:1466,0 +DA:1469,0 +DA:1476,32 +DA:1478,32 +DA:1480,32 +DA:1484,26 +DA:1485,26 +DA:1486,26 +DA:1487,26 +DA:1488,26 +DA:1489,26 +DA:1491,26 +DA:1492,0 +DA:1495,26 +DA:1497,26 +DA:1498,0 +DA:1499,0 +DA:1502,26 +DA:1503,0 +DA:1504,0 +DA:1507,26 +DA:1509,26 +DA:1510,0 +DA:1511,0 +DA:1514,26 +DA:1516,1 +DA:1521,2226 +DA:1526,2226 +DA:1529,2226 +DA:1530,0 +DA:1533,2226 +DA:1534,333 +DA:1536,333 +DA:1539,333 +DA:1540,312 +DA:1541,312 +DA:1544,333 +DA:1548,2226 +DA:1549,0 +DA:1551,0 +DA:1555,2226 +DA:1556,0 +DA:1559,2226 +DA:1561,21 +DA:1562,21 +DA:1565,2205 +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,1575 +DA:1603,1575 +DA:1606,0 +DA:1608,0 +DA:1609,0 +DA:1612,0 +DA:1613,0 +DA:1615,0 +DA:1619,1575 +DA:1620,1575 +DA:1621,1575 +DA:1627,2205 +DA:1630,2205 +DA:1632,2205 +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,3261 +DA:1728,3261 +DA:1730,3261 +DA:1734,3261 +DA:1735,0 +DA:1736,0 +DA:1740,3261 +DA:1741,0 +DA:1742,0 +DA:1743,0 +DA:1747,3261 +DA:1750,3261 +DA:1753,3261 +DA:1757,3261 +DA:1759,3261 +DA:1762,26 +DA:1764,26 +DA:1766,26 +DA:1770,26 +DA:1771,19 +DA:1773,26 +DA:1776,26 +DA:1777,24 +DA:1779,26 +DA:1781,26 +DA:1784,12 +DA:1786,12 +DA:1787,0 +DA:1788,0 +DA:1790,0 +DA:1793,12 +DA:1795,12 +DA:1797,10 +DA:1800,10 +DA:1801,1 +DA:1802,1 +DA:1806,9 +DA:1810,6689 +DA:1813,6689 +DA:1814,6687 +DA:1825,0 +DA:1827,0 +DA:1828,0 +DA:1830,12 +DA:1832,12 +DA:1835,19 +DA:1838,19 +DA:1839,0 +DA:1840,0 +DA:1843,19 +DA:1845,19 +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,8 +DA:1913,8 +DA:1914,5 +DA:1915,3 +DA:1917,2 +DA:1920,8 +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,818061 +DA:1972,818061 +DA:1975,818060 +DA:1978,817992 +DA:1981,817992 +DA:1983,817992 +DA:1984,62 +DA:1986,124 +DA:1987,62 +DA:1988,62 +DA:1990,62 +DA:1992,62 +DA:1993,62 +DA:1994,817893 +DA:1996,1635786 +DA:1997,817893 +DA:1998,817893 +DA:2000,817893 +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,818423 +DA:2041,818423 +DA:2045,818423 +DA:2048,818423 +DA:2051,811258 +DA:2053,811258 +DA:2055,811258 +DA:2057,811258 +DA:2060,6687 +DA:2066,6687 +DA:2069,6687 +DA:2072,6687 +DA:2075,6687 +DA:2077,6687 +DA:2079,6687 +DA:2081,6687 +DA:2084,6687 +DA:2087,6702 +DA:2089,6702 +DA:2092,6702 +DA:2093,6702 +DA:2098,6702 +DA:2099,0 +DA:2100,0 +DA:2103,6702 +DA:2104,6702 +DA:2105,6702 +DA:2106,6702 +DA:2107,6702 +DA:2108,6702 +DA:2109,6702 +DA:2110,6702 +DA:2113,6702 +DA:2114,0 +DA:2115,0 +DA:2118,6702 +DA:2121,6702 +DA:2124,2 +DA:2126,2 +DA:2129,2 +DA:2133,2 +DA:2135,2 +DA:2139,2 +DA:2140,2 +DA:2141,2 +DA:2142,2 +DA:2143,2 +DA:2144,2 +DA:2145,2 +DA:2146,2 +DA:2147,2 +DA:2149,2 +DA:2152,6702 +DA:2155,6702 +DA:2158,6702 +DA:2159,6700 +DA:2161,6702 +DA:2162,0 +DA:2164,6702 +DA:2165,6702 +DA:2166,6702 +DA:2168,6702 +DA:2171,2 +DA:2174,2 +DA:2177,2 +DA:2178,0 +DA:2180,2 +DA:2181,2 +DA:2182,2 +DA:2184,2 +DA:2187,12 +DA:2191,12 +DA:2194,12 +DA:2197,11 +DA:2198,11 +DA:2200,11 +DA:2201,2 +DA:2202,2 +DA:2203,2 +DA:2206,11 +DA:2208,11 +DA:2209,11 +DA:2210,11 +DA:2212,0 +DA:2214,0 +DA:2215,0 +DA:2216,0 +DA:2220,0 +DA:2221,0 +DA:2222,0 +DA:2223,0 +DA:2225,0 +DA:2229,11 +DA:2230,0 +DA:2231,0 +DA:2234,11 +DA:2235,11 +DA:2237,11 +DA:2240,21 +DA:2242,21 +DA:2245,21 +DA:2248,21 +DA:2249,0 +DA:2250,0 +DA:2251,0 +DA:2254,21 +DA:2255,0 +DA:2257,21 +DA:2260,11 +DA:2262,11 +DA:2265,11 +DA:2268,11 +DA:2269,2 +DA:2271,2 +DA:2272,0 +DA:2276,2 +DA:2282,0 +DA:2287,0 +DA:2290,0 +DA:2291,0 +DA:2293,0 +DA:2294,0 +DA:2295,0 +DA:2301,0 +DA:2302,0 +DA:2306,0 +DA:2307,0 +DA:2308,0 +DA:2309,0 +DA:2313,0 +DA:2316,234 +DA:2323,234 +DA:2330,234 +DA:2334,234 +DA:2335,234 +DA:2336,234 +DA:2337,234 +DA:2339,234 +DA:2345,234 +DA:2346,234 +DA:2349,234 +DA:2352,7 +DA:2355,7 +DA:2356,1 +DA:2360,7 +DA:2363,5571 +DA:2365,5571 +DA:2368,11142 +DA:2369,5571 +DA:2370,5571 +DA:2371,5571 +DA:2372,11142 +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,6811 +DA:2434,6811 +DA:2438,6803 +DA:2441,6796 +DA:2444,6796 +DA:2448,6796 +DA:2449,6796 +DA:2450,6796 +DA:2453,6796 +DA:2455,6796 +DA:2456,0 +DA:2459,0 +DA:2464,6796 +DA:2465,6796 +DA:2466,6796 +DA:2467,6796 +DA:2469,6796 +DA:2470,0 +DA:2473,0 +DA:2476,6796 +DA:2478,6796 +DA:2483,6796 +DA:2485,6796 +DA:2488,0 +DA:2491,0 +DA:2494,0 +DA:2496,0 +DA:2497,0 +DA:2503,6785 +DA:2506,6785 +DA:2509,6784 +DA:2511,0 +DA:2512,0 +DA:2515,6784 +DA:2516,6784 +DA:2517,6784 +DA:2519,6784 +DA:2522,24692 +DA:2525,24692 +DA:2526,23673 +DA:2527,23673 +DA:2529,23672 +DA:2530,23672 +DA:2536,1 +DA:2538,1 +DA:2539,1 +DA:2540,1 +DA:2545,0 +DA:2549,1019 +DA:2551,24692 +DA:2553,45 +DA:2556,45 +DA:2557,29 +DA:2559,27 +DA:2560,27 +DA:2566,2 +DA:2568,1 +DA:2569,1 +DA:2570,1 +DA:2575,16 +DA:2577,45 +DA:2579,852 +DA:2581,852 +DA:2584,852 +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,7 +DA:2661,7 +DA:2662,1 +DA:2663,1 +DA:2666,6 +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,9839 +DA:2744,9839 +DA:2747,9771 +DA:2749,0 +DA:2750,0 +DA:2754,9771 +DA:2755,9771 +DA:2756,9771 +DA:2759,9771 +DA:2760,0 +DA:2763,0 +DA:2764,0 +DA:2768,9771 +DA:2769,0 +DA:2770,9771 +DA:2773,9771 +DA:2776,9775 +DA:2778,4 +DA:2784,4 +DA:2785,4 +DA:2788,4 +DA:2789,0 +DA:2790,4 +DA:2793,4 +DA:2799,9771 +DA:2800,9771 +DA:2803,9771 +DA:2805,9771 +DA:2806,9771 +DA:2808,9771 +DA:2809,2257 +DA:2811,9771 +DA:2812,1873 +DA:2815,9771 +DA:2816,9771 +DA:2818,9771 +DA:2822,59 +DA:2826,59 +DA:2830,59 +DA:2833,42 +DA:2835,0 +DA:2836,0 +DA:2840,42 +DA:2841,42 +DA:2842,42 +DA:2845,42 +DA:2846,3 +DA:2849,3 +DA:2850,3 +DA:2854,39 +DA:2855,22 +DA:2856,1 +DA:2859,1 +DA:2862,22 +DA:2866,17 +DA:2867,16 +DA:2869,1 +DA:2872,17 +DA:2873,1 +DA:2876,1 +DA:2877,1 +DA:2881,16 +DA:2884,16 +DA:2885,1 +DA:2886,1 +DA:2887,1 +DA:2890,15 +DA:2891,0 +DA:2892,0 +DA:2893,0 +DA:2897,15 +DA:2898,1 +DA:2901,1 +DA:2902,1 +DA:2906,14 +DA:2907,1 +DA:2913,14 +DA:2915,11 +DA:2917,11 +DA:2919,3 +DA:2922,3 +DA:2924,3 +DA:2925,3 +DA:2927,0 +DA:2931,14 +DA:2932,6 +DA:2934,6 +DA:2936,4 +DA:2939,14 +DA:2942,8 +DA:2944,8 +DA:2947,10 +DA:2949,10 +DA:2952,5 +DA:2954,5 +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,2672 +DA:3030,2672 +DA:3034,2672 +DA:3037,2672 +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,6 +DA:3284,6 +DA:3285,0 +DA:3286,0 +DA:3307,2 +DA:3309,2 +DA:3310,0 +DA:3311,0 +DA:3317,2 +DA:3319,2 +DA:3320,0 +DA:3321,0 +DA:3328,247 +DA:3338,247 +DA:3339,247 +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,751 +DA:3434,751 +DA:3449,736 +DA:3450,736 +DA:3451,736 +DA:3452,736 +DA:3468,736 +DA:3469,147 +DA:3471,147 +DA:3472,147 +DA:3474,147 +DA:3477,147 +DA:3480,0 +DA:3483,147 +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,147 +DA:3509,147 +DA:3512,589 +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,477 +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,477 +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,477 +DA:3637,350 +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,350 +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,350 +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,301 +DA:3773,301 +DA:3776,287 +DA:3778,287 +DA:3781,287 +DA:3787,14 +DA:3789,14 +DA:3792,14 +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,630 +DA:4053,0 +DA:4054,0 +DA:4058,630 +DA:4059,0 +DA:4061,0 +DA:4063,0 +DA:4064,0 +DA:4072,6687 +DA:4074,6687 +DA:4076,6687 +DA:4077,0 +DA:4079,6687 +DA:4081,6687 +DA:4082,0 +DA:4084,0 +DA:4085,0 +DA:4088,6687 +DA:4090,6687 +DA:4091,0 +DA:4093,0 +DA:4094,0 +DA:4098,6687 +DA:4100,6687 +DA:4101,0 +DA:4103,6687 +DA:4114,6687 +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:1099 +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:84,dlt_config_file_find_section +FNDA:64,dlt_config_file_trim_line +FNDA:80,dlt_config_file_get_value +FNDA:8,dlt_config_file_read_file +FNDA:8,dlt_config_file_set_section +FNDA:8,dlt_config_file_init +FNDA:64,dlt_config_file_read_line +FNDA:8,dlt_config_file_get_num_sections +FNDA:8,dlt_config_file_is_section_name +FNDA:4,dlt_config_file_check_section_name_exists +FNDA:56,dlt_config_file_set_section_data +FNDA:8,dlt_config_file_get_section_name_from_string +FNDA:8,dlt_config_file_get_section_name +FNDA:56,dlt_config_file_get_key_value +FNDA:8,dlt_config_file_release +FNF:15 +FNH:15 +DA:51,64 +DA:53,64 +DA:59,1012 +DA:60,948 +DA:62,948 +DA:63,884 +DA:66,64 +DA:79,64 +DA:95,8 +DA:99,8 +DA:102,8 +DA:103,0 +DA:105,0 +DA:121,8 +DA:123,8 +DA:126,8 +DA:127,0 +DA:128,0 +DA:132,8 +DA:133,0 +DA:134,0 +DA:137,8 +DA:140,8 +DA:142,8 +DA:143,0 +DA:144,0 +DA:147,8 +DA:149,8 +DA:150,0 +DA:151,0 +DA:152,0 +DA:153,0 +DA:157,8 +DA:158,8 +DA:171,56 +DA:175,56 +DA:178,56 +DA:179,56 +DA:181,56 +DA:182,0 +DA:183,0 +DA:187,56 +DA:189,56 +DA:191,8 +DA:193,8 +DA:194,0 +DA:195,0 +DA:198,8 +DA:201,48 +DA:203,220 +DA:204,172 +DA:207,48 +DA:209,48 +DA:210,0 +DA:211,0 +DA:215,56 +DA:216,56 +DA:217,56 +DA:219,56 +DA:221,56 +DA:236,64 +DA:251,8 +DA:256,8 +DA:259,92 +DA:260,92 +DA:261,8 +DA:262,84 +DA:265,76 +DA:281,56 +DA:287,56 +DA:290,56 +DA:292,56 +DA:294,56 +DA:299,56 +DA:301,56 +DA:303,56 +DA:308,56 +DA:321,64 +DA:323,64 +DA:333,8 +DA:336,8 +DA:340,56 +DA:341,0 +DA:354,8 +DA:357,8 +DA:358,8 +DA:359,8 +DA:364,80 +DA:365,64 +DA:368,0 +DA:369,0 +DA:372,64 +DA:375,64 +DA:377,64 +DA:378,8 +DA:381,8 +DA:385,56 +DA:387,56 +DA:388,56 +DA:391,0 +DA:392,0 +DA:396,8 +DA:407,84 +DA:412,84 +DA:413,0 +DA:414,0 +DA:417,88 +DA:418,84 +DA:420,84 +DA:421,80 +DA:428,8 +DA:433,8 +DA:434,0 +DA:435,0 +DA:438,8 +DA:440,8 +DA:441,0 +DA:442,0 +DA:445,8 +DA:448,8 +DA:449,0 +DA:450,0 +DA:451,0 +DA:454,8 +DA:457,8 +DA:459,8 +DA:462,8 +DA:466,8 +DA:467,8 +DA:469,16 +DA:470,8 +DA:471,8 +DA:472,8 +DA:474,8 +DA:475,8 +DA:477,64 +DA:479,56 +DA:480,56 +DA:481,56 +DA:482,56 +DA:486,8 +DA:487,8 +DA:489,8 +DA:491,8 +DA:495,8 +DA:498,8 +DA:499,8 +DA:501,8 +DA:504,8 +DA:506,8 +DA:513,8 +DA:515,8 +DA:518,80 +DA:526,80 +DA:532,80 +DA:534,80 +DA:537,80 +DA:539,80 +DA:541,400 +DA:542,372 +DA:543,52 +DA:544,52 +DA:547,320 +DA:551,28 +DA:552,28 +DA:555,4 +DA:560,4 +DA:563,4 +DA:564,4 +DA:565,4 +LF:170 +LH:138 +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:9,multiple_files_buffer_file_name +FNDA:9,multiple_files_buffer_delete_oldest_file +FNDA:53,multiple_files_buffer_get_idx_of_log_file +FNDA:12,multiple_files_buffer_write_chunk +FNDA:12,multiple_files_buffer_rotate_file +FNDA:12,multiple_files_buffer_check_size +FNDA:3,multiple_files_buffer_init +FNDA:12,multiple_files_buffer_write +FNDA:12,multiple_files_buffer_storage_dir_info +FNDA:9,multiple_files_buffer_create_new_file +FNDA:21,multiple_files_buffer_get_total_size +FNDA:3,multiple_files_buffer_free +FNDA:3,multiple_files_buffer_open_file_for_append +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,24 +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:517,dlt_user_log_out3 +FNDA:0,dlt_user_log_out3_with_timeout +FNDA:0,dlt_user_check_userheader +FNDA:4,dlt_user_log_out2_with_timeout +FNDA:339,dlt_user_log_out2 +FNDA:858,dlt_user_set_userheader +FNF:6 +FNH:4 +DA:79,858 +DA:81,858 +DA:84,858 +DA:87,858 +DA:88,858 +DA:89,858 +DA:90,858 +DA:91,858 +DA:93,858 +DA:96,0 +DA:98,0 +DA:101,0 +DA:102,0 +DA:103,0 +DA:104,0 +DA:107,339 +DA:112,339 +DA:116,4 +DA:117,4 +DA:118,4 +DA:119,4 +DA:121,4 +DA:123,4 +DA:124,0 +DA:129,4 +DA:131,4 +DA:136,68 +DA:137,4 +DA:139,4 +DA:140,4 +DA:144,4 +DA:145,4 +DA:151,517 +DA:156,517 +DA:160,0 +DA:161,0 +DA:162,0 +DA:163,0 +DA:164,0 +DA:165,0 +DA:167,0 +DA:169,0 +DA:170,0 +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:27 +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..99e871dad --- /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-09-01 07:46:27Functions: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_deinit3
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_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..ec9506263 --- /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-09-01 07:46:27Functions: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_deinit3
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..649bf7ea2 --- /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-09-01 07:46:27Functions: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           3 : void dlt_gateway_deinit(DltGateway *gateway, int verbose)
+     865             : {
+     866             :     DltPassiveControlMessage *msg;
+     867             :     int i = 0;
+     868             : 
+     869           3 :     if (gateway == NULL) {
+     870           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     871           0 :         return;
+     872             :     }
+     873             : 
+     874           3 :     PRINT_FUNCTION_VERBOSE(verbose);
+     875             : 
+     876           5 :     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           3 :     free(gateway->connections);
+     892           3 :     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..1c65fdea3 --- /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-09-01 07:46:27Functions: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..aecfc770e --- /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-09-01 07:46:27Functions: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..291c3734d --- /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-09-01 07:46:27Functions: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..f63366eb7 --- /dev/null +++ b/dlt_lcov_report/index-sort-f.html @@ -0,0 +1,133 @@ + + + + + + + LCOV - dlt_final_coverage.info + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top levelHitTotalCoverage
Test:dlt_final_coverage.infoLines:50391004150.2 %
Date:2023-09-01 07:46:27Functions:42659971.1 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Directory Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
lib +
42.4%42.4%
+
42.4 %1107 / 260860.1 %119 / 198
daemon +
40.9%40.9%
+
40.9 %1383 / 338461.9 %96 / 155
gateway +
60.8%60.8%
+
60.8 %387 / 63782.1 %23 / 28
offlinelogstorage +
61.7%61.7%
+
61.7 %759 / 123084.7 %61 / 72
shared +
64.3%64.3%
+
64.3 %1403 / 218287.0 %127 / 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..e05f9097d --- /dev/null +++ b/dlt_lcov_report/index-sort-l.html @@ -0,0 +1,133 @@ + + + + + + + LCOV - dlt_final_coverage.info + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top levelHitTotalCoverage
Test:dlt_final_coverage.infoLines:50391004150.2 %
Date:2023-09-01 07:46:27Functions:42659971.1 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Directory Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
daemon +
40.9%40.9%
+
40.9 %1383 / 338461.9 %96 / 155
lib +
42.4%42.4%
+
42.4 %1107 / 260860.1 %119 / 198
gateway +
60.8%60.8%
+
60.8 %387 / 63782.1 %23 / 28
offlinelogstorage +
61.7%61.7%
+
61.7 %759 / 123084.7 %61 / 72
shared +
64.3%64.3%
+
64.3 %1403 / 218287.0 %127 / 146
+
+
+ + + + +
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..ff8a4453d --- /dev/null +++ b/dlt_lcov_report/index.html @@ -0,0 +1,133 @@ + + + + + + + LCOV - dlt_final_coverage.info + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top levelHitTotalCoverage
Test:dlt_final_coverage.infoLines:50391004150.2 %
Date:2023-09-01 07:46:27Functions:42659971.1 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Directory Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
daemon +
40.9%40.9%
+
40.9 %1383 / 338461.9 %96 / 155
gateway +
60.8%60.8%
+
60.8 %387 / 63782.1 %23 / 28
lib +
42.4%42.4%
+
42.4 %1107 / 260860.1 %119 / 198
offlinelogstorage +
61.7%61.7%
+
61.7 %759 / 123084.7 %61 / 72
shared +
64.3%64.3%
+
64.3 %1403 / 218287.0 %127 / 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..cec0898a7 --- /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:19152836.2 %
Date:2023-09-01 07:46:27Functions:113135.5 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_client_free_calloc_failed_get_log_info0
dlt_client_init0
dlt_client_main_loop0
dlt_client_register_fetch_next_message_callback0
dlt_client_register_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_message_to_socket0
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_cleanup2
dlt_client_cleanup_get_log_info2
dlt_client_parse_get_log_info_resp_text2
dlt_client_get_log_info4
dlt_client_get_software_version4
dlt_client_init_port5
dlt_client_set_server_ip5
dlt_client_connect6
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..5b451aee4 --- /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:19152836.2 %
Date:2023-09-01 07:46:27Functions:113135.5 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_client_cleanup2
dlt_client_cleanup_get_log_info2
dlt_client_connect6
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_init0
dlt_client_init_port5
dlt_client_main_loop0
dlt_client_parse_get_log_info_resp_text2
dlt_client_register_fetch_next_message_callback0
dlt_client_register_message_callback0
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_socket0
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_ip5
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..9a4ec97d9 --- /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:19152836.2 %
Date:2023-09-01 07:46:27Functions:113135.5 %
+
+ + + + + + + + +

+
          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           0 : void dlt_client_register_message_callback(int (*registerd_callback)(DltMessage *message, void *data))
+     104             : {
+     105           0 :     message_callback_function = registerd_callback;
+     106           0 : }
+     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           5 : DltReturnValue dlt_client_init_port(DltClient *client, int port, int verbose)
+     114             : {
+     115           5 :     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           5 :     if (client == NULL)
+     122             :         return DLT_RETURN_ERROR;
+     123             : 
+     124           5 :     client->sock = -1;
+     125           5 :     client->servIP = NULL;
+     126           5 :     client->serialDevice = NULL;
+     127           5 :     client->baudrate = DLT_CLIENT_INITIAL_BAUDRATE;
+     128           5 :     client->port = port;
+     129           5 :     client->socketPath = NULL;
+     130           5 :     client->mode = DLT_CLIENT_MODE_TCP;
+     131           5 :     client->receiver.buffer = NULL;
+     132           5 :     client->receiver.buf = NULL;
+     133           5 :     client->receiver.backup_buf = NULL;
+     134           5 :     client->hostip = NULL;
+     135             : 
+     136           5 :     return DLT_RETURN_OK;
+     137             : }
+     138             : 
+     139           0 : 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           0 :     env_daemon_port = getenv(DLT_CLIENT_ENV_DAEMON_TCP_PORT);
+     148             : 
+     149           0 :     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           0 :     if (verbose)
+     165           0 :         dlt_vlog(LOG_INFO,
+     166             :                  "%s: Init dlt client struct with default port: %hu.\n",
+     167             :                  __func__,
+     168             :                  servPort);
+     169           0 :     return dlt_client_init_port(client, servPort, verbose);
+     170             : }
+     171             : 
+     172           6 : DltReturnValue dlt_client_connect(DltClient *client, int verbose)
+     173             : {
+     174           6 :     const int yes = 1;
+     175           6 :     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           6 :     socklen_t m = sizeof(n);
+     186             :     int connect_errno = 0;
+     187             : 
+     188             :     memset(&hints, 0, sizeof(hints));
+     189           6 :     hints.ai_socktype = SOCK_STREAM;
+     190             : 
+     191           6 :     if (client == 0)
+     192             :         return DLT_RETURN_ERROR;
+     193             : 
+     194           6 :     switch (client->mode) {
+     195           6 :     case DLT_CLIENT_MODE_TCP:
+     196           6 :         snprintf(portnumbuffer, 32, "%d", client->port);
+     197             : 
+     198           6 :         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          10 :         for (p = servinfo; p != NULL; p = p->ai_next) {
+     207           7 :             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           7 :             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           7 :             if (connect(client->sock, p->ai_addr, p->ai_addrlen) < 0) {
+     226           7 :                 if (errno == EINPROGRESS) {
+     227           7 :                     pfds[0].fd = client->sock;
+     228           7 :                     pfds[0].events = POLLOUT;
+     229             :                     ret = poll(pfds, 1, 500);
+     230           7 :                     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          14 :                     else if ((pfds[0].revents & POLLOUT) &&
+     237           7 :                             getsockopt(client->sock, SOL_SOCKET,
+     238             :                                     SO_ERROR, (void*)&n, &m) == 0) {
+     239           7 :                         if (n == 0) {
+     240           3 :                             dlt_vlog(LOG_DEBUG, "%s: Already connect\n", __func__);
+     241           3 :                             if(fcntl(client->sock, F_SETFL,
+     242           3 :                                     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           6 :         freeaddrinfo(servinfo);
+     273             : 
+     274           6 :         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           3 :         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           3 :         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           0 :     case DLT_CLIENT_MODE_UNIX:
+     341             : 
+     342           0 :         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           0 :         addr.sun_family = AF_UNIX;
+     353           0 :         memcpy(addr.sun_path, client->socketPath, sizeof(addr.sun_path) - 1);
+     354             : 
+     355           0 :         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           0 :         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           3 :     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           2 : DltReturnValue dlt_client_cleanup(DltClient *client, int verbose)
+     478             : {
+     479             :     int ret = DLT_RETURN_OK;
+     480             : 
+     481           2 :     if (verbose)
+     482           0 :         dlt_vlog(LOG_INFO, "%s: Cleanup dlt client\n", __func__);
+     483             : 
+     484           2 :     if (client == NULL)
+     485             :         return DLT_RETURN_WRONG_PARAMETER;
+     486             : 
+     487           2 :     if (client->sock != -1)
+     488           2 :         close(client->sock);
+     489             : 
+     490           2 :     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           2 :     if (client->serialDevice) {
+     496           0 :         free(client->serialDevice);
+     497           0 :         client->serialDevice = NULL;
+     498             :     }
+     499             : 
+     500           2 :     if (client->servIP) {
+     501           2 :         free(client->servIP);
+     502           2 :         client->servIP = NULL;
+     503             :     }
+     504             : 
+     505           2 :     if (client->socketPath) {
+     506           0 :         free(client->socketPath);
+     507           0 :         client->socketPath = NULL;
+     508             :     }
+     509             : 
+     510           2 :     if (client->hostip) {
+     511           0 :         free(client->hostip);
+     512           0 :         client->hostip = NULL;
+     513             :     }
+     514             :     return ret;
+     515             : }
+     516             : 
+     517           0 : DltReturnValue dlt_client_main_loop(DltClient *client, void *data, int verbose)
+     518             : {
+     519             :     DltMessage msg;
+     520             :     int ret;
+     521             : 
+     522           0 :     if (client == 0)
+     523             :         return DLT_RETURN_ERROR;
+     524             : 
+     525           0 :     if (dlt_message_init(&msg, verbose) == DLT_RETURN_ERROR)
+     526             :         return DLT_RETURN_ERROR;
+     527             : 
+     528             :     bool fetch_next_message = true;
+     529           0 :     while (fetch_next_message) {
+     530             :         /* wait for data from socket or serial connection */
+     531           0 :         ret = dlt_receiver_receive(&(client->receiver));
+     532             : 
+     533           0 :         if (ret <= 0) {
+     534             :             /* No more data to be received */
+     535           0 :             if (dlt_message_free(&msg, verbose) == DLT_RETURN_ERROR)
+     536             :                 return DLT_RETURN_ERROR;
+     537             : 
+     538           0 :             return DLT_RETURN_TRUE;
+     539             :         }
+     540             : 
+     541           0 :         while (dlt_message_read(&msg, (unsigned char *)(client->receiver.buf),
+     542           0 :                                 client->receiver.bytesRcvd,
+     543             :                                 client->resync_serial_header,
+     544           0 :                                 verbose) == DLT_MESSAGE_ERROR_OK)
+     545             :         {
+     546             :             /* Call callback function */
+     547           0 :             if (message_callback_function)
+     548           0 :                 (*message_callback_function)(&msg, data);
+     549             : 
+     550           0 :             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           0 :             else if (dlt_receiver_remove(&(client->receiver),
+     561           0 :                                          (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           0 :         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           0 :         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           0 : DltReturnValue dlt_client_send_message_to_socket(DltClient *client, DltMessage *msg)
+     585             : {
+     586             :     int ret = 0;
+     587             : 
+     588           0 :     if ((client == NULL) || (client->sock < 0)
+     589           0 :         || (msg == NULL) || (msg->databuffer == NULL))
+     590             :     {
+     591           0 :         dlt_log(LOG_ERR, "Invalid parameters\n");
+     592           0 :         return DLT_RETURN_ERROR;
+     593             :     }
+     594             : 
+     595           0 :     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           0 :     ret = send(client->sock,
+     608             :                (const char *)(msg->headerbuffer + sizeof(DltStorageHeader)),
+     609           0 :                msg->headersize - sizeof(DltStorageHeader), 0);
+     610           0 :     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           0 :     ret = send(client->sock, (const char *)msg->databuffer, msg->datasize, 0);
+     617           0 :     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           5 : int dlt_client_set_server_ip(DltClient *client, char *ipaddr)
+    1135             : {
+    1136           5 :     client->servIP = strdup(ipaddr);
+    1137             : 
+    1138           5 :     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..e13120384 --- /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-09-01 07:46:27Functions: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_env167
dlt_env_free_ll_set6687
+
+
+ + + +
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..11a829911 --- /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-09-01 07:46:27Functions:21216.7 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_env_adjust_ll_from_env167
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_set6687
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..f735d30a5 --- /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-09-01 07:46:27Functions: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        6687 : void dlt_env_free_ll_set(dlt_env_ll_set *const ll_set)
+     308             : {
+     309        6687 :     if (!ll_set) {
+     310             :         return;
+     311             :     }
+     312             : 
+     313        6687 :     if (ll_set->item != NULL) {
+     314           0 :         free(ll_set->item);
+     315           0 :         ll_set->item = NULL;
+     316             :     }
+     317             : 
+     318        6687 :     ll_set->array_size = 0u;
+     319        6687 :     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         167 : 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         167 :     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         167 :     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..c30209e78 --- /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-09-01 07:46:27Functions: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..47f7d18c9 --- /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-09-01 07:46:27Functions: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..4aa6c8b46 --- /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-09-01 07:46:27Functions: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..0aead1001 --- /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:908175851.6 %
Date:2023-09-01 07:46:27Functions:10613876.8 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
check_buffer0
dlt_check_library_version0
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_unregister_app_flush_buffered_logs0
dlt_user_atexit_blow_out_user_buffer0
dlt_user_check_buffer0
dlt_user_check_library_version0
dlt_user_log_resend_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_atexit_handler1
dlt_user_log_reattach_to_daemon1
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_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_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_uint3238
dlt_user_log_write_int3242
dlt_user_log_write_string60
dlt_user_log_write_string_utils_attr95
dlt_user_log_write_sized_string_utils_attr103
dlt_user_log_write_start104
dlt_user_log_write_generic_formatted112
dlt_user_log_send_register_application164
dlt_register_context165
dlt_unregister_context166
dlt_user_log_send_unregister_context166
dlt_unregister_app167
dlt_unregister_app_util167
dlt_user_log_send_register_context167
dlt_user_log_send_unregister_application167
dlt_register_app169
dlt_register_context_ll_ts178
dlt_register_context_ll_ts_llccb178
dlt_user_log_write_start_init188
dlt_user_log_send_log195
dlt_user_log_write_finish195
dlt_user_log_write_generic_attr218
dlt_user_log_write_start_internal237
dlt_user_log_init522
dlt_user_log_out_error_handling852
dlt_initialize_fifo_connection6687
dlt_start_threads6687
dlt_stop_threads6687
dlt_init_common6688
dlt_user_log_check_user_message6688
dlt_lock_mutex13374
dlt_user_cleanup_handler13374
dlt_user_housekeeperthread_function13374
dlt_user_trace_network_segmented_thread13374
dlt_unlock_mutex20061
dlt_free45893
dlt_init40025693
+
+
+ + + +
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..aa3331df1 --- /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:908175851.6 %
Date:2023-09-01 07:46:27Functions:10613876.8 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
check_buffer0
dlt_check_library_version0
dlt_disable_local_print0
dlt_enable_local_print0
dlt_fork_child_fork_handler0
dlt_free45893
dlt_get_appid0
dlt_get_log_state1
dlt_init40025693
dlt_init_common6688
dlt_init_file0
dlt_init_message_queue0
dlt_initialize_fifo_connection6687
dlt_lock_mutex13374
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_app169
dlt_register_context165
dlt_register_context_ll_ts178
dlt_register_context_ll_ts_llccb178
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_threads6687
dlt_stop_threads6687
dlt_unlock_mutex20061
dlt_unregister_app167
dlt_unregister_app_flush_buffered_logs0
dlt_unregister_app_util167
dlt_unregister_context166
dlt_use_extended_header_for_non_verbose2
dlt_user_atexit_blow_out_user_buffer0
dlt_user_atexit_handler1
dlt_user_check_buffer0
dlt_user_check_library_version0
dlt_user_cleanup_handler13374
dlt_user_housekeeperthread_function13374
dlt_user_log_check_user_message6688
dlt_user_log_init522
dlt_user_log_out_error_handling852
dlt_user_log_reattach_to_daemon1
dlt_user_log_resend_buffer0
dlt_user_log_send_log195
dlt_user_log_send_log_mode4
dlt_user_log_send_marker1
dlt_user_log_send_overflow0
dlt_user_log_send_register_application164
dlt_user_log_send_register_context167
dlt_user_log_send_unregister_application167
dlt_user_log_send_unregister_context166
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_finish195
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_attr218
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_attr103
dlt_user_log_write_sized_utf8_string8
dlt_user_log_write_sized_utf8_string_attr7
dlt_user_log_write_start104
dlt_user_log_write_start_id23
dlt_user_log_write_start_init188
dlt_user_log_write_start_internal237
dlt_user_log_write_start_w_given_buffer0
dlt_user_log_write_string60
dlt_user_log_write_string_attr7
dlt_user_log_write_string_utils_attr95
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_uint3238
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_thread13374
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..40e543bce --- /dev/null +++ b/dlt_lcov_report/lib/dlt_user.c.gcov.html @@ -0,0 +1,5266 @@ + + + + + + + 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:908175851.6 %
Date:2023-09-01 07:46:27Functions:10613876.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_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       13374 : void dlt_lock_mutex(pthread_mutex_t *mutex)
+     164             : {
+     165       13374 :     int32_t lock_mutex_result = pthread_mutex_lock(mutex);
+     166             : 
+     167       13374 :     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       13374 : }
+     172             : 
+     173       20061 : void dlt_unlock_mutex(pthread_mutex_t *mutex)
+     174             : {
+     175       20061 :     pthread_mutex_unlock(mutex);
+     176       20061 : }
+     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           0 : 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           0 :     dlt_get_major_version(lib_major_version, DLT_USER_MAX_LIB_VERSION_LENGTH);
+     235           0 :     dlt_get_minor_version(lib_minor_version, DLT_USER_MAX_LIB_VERSION_LENGTH);
+     236             : 
+     237           0 :     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        6687 : 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        6687 :     ret = mkdir(dlt_user_dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_ISVTX);
+     398             : 
+     399        6687 :     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        6687 :     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        6687 :     snprintf(filename, DLT_PATH_MAX, "%s/dlt%d", dlt_user_dir, getpid());
+     419             : 
+     420             :     /* Try to delete existing pipe, ignore result of unlink */
+     421        6687 :     unlink(filename);
+     422             : 
+     423        6687 :     ret = mkfifo(filename, S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP);
+     424             : 
+     425        6687 :     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        6687 :     ret = chmod(filename, S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP);
+     430             : 
+     431        6687 :     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        6687 :     dlt_user.dlt_user_handle = open(filename, O_RDWR | O_NONBLOCK | O_CLOEXEC);
+     437             : 
+     438        6687 :     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        6687 :     dlt_user.dlt_log_handle = open(dlt_daemon_fifo, O_WRONLY | O_NONBLOCK | O_CLOEXEC);
+     446             : 
+     447        6687 :     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        6687 :         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    40025693 : DltReturnValue dlt_init(void)
+     459             : {
+     460             :     /* process is exiting. Do not allocate new resources. */
+     461    40025693 :     if (dlt_user_freeing != 0) {
+     462      806013 :         dlt_vlog(LOG_INFO, "%s logging disabled, process is exiting\n", __func__);
+     463             :         /* return negative value, to stop the current log */
+     464      806013 :         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    39219680 :     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        6687 :     dlt_check_envvar();
+     482             : 
+     483             :     /* Check logging mode and internal log file is opened or not*/
+     484        6687 :     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        6687 :     if (dlt_init_common() == DLT_RETURN_ERROR) {
+     490           0 :         dlt_user_init_state = INIT_UNITIALIZED;
+     491           0 :         return DLT_RETURN_ERROR;
+     492             :     }
+     493             : 
+     494        6687 :     dlt_user.dlt_is_file = 0;
+     495        6687 :     dlt_user.filesize_max = UINT_MAX;
+     496        6687 :     dlt_user_file_reach_max = false;
+     497             : 
+     498        6687 :     dlt_user.overflow = 0;
+     499        6687 :     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        6687 :     if (dlt_initialize_fifo_connection() != DLT_RETURN_OK)
+     526             :         return DLT_RETURN_ERROR;
+     527             : 
+     528        6687 :     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        6687 :     dlt_user.dlt_segmented_queue_read_handle = -1;
+     541        6687 :     dlt_user.dlt_segmented_queue_write_handle = -1;
+     542             : 
+     543        6687 :     pthread_cond_init(&mq_init_condition, NULL);
+     544             : #endif
+     545             : 
+     546        6687 :     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        6687 :     pthread_atfork(NULL, NULL, &dlt_fork_child_fork_handler);
+     553             : 
+     554             :     expectedInitState = INIT_IN_PROGRESS;
+     555        6687 :     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         150 :     return (dltuser_verbose_mode == 1) || (log != NULL && log->verbose_mode);
+     704             : }
+     705             : 
+     706        6688 : 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        6688 :     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        6688 :     dlt_user.log_state = -1;
+     729             : 
+     730        6688 :     dlt_user.dlt_log_handle = -1;
+     731        6688 :     dlt_user.dlt_user_handle = DLT_FD_INIT;
+     732             : 
+     733        6688 :     dlt_set_id(dlt_user.ecuID, DLT_USER_DEFAULT_ECU_ID);
+     734        6688 :     dlt_set_id(dlt_user.appID, "");
+     735             : 
+     736        6688 :     dlt_user.application_description = NULL;
+     737             : 
+     738             :     /* Verbose mode is enabled by default */
+     739        6688 :     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        6688 :     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        6688 :             getenv(DLT_USER_ENV_DISABLE_EXTENDED_HEADER_FOR_NONVERBOSE);
+     754             : 
+     755        6688 :     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        6688 :     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        6688 :     dlt_user.with_session_id = DLT_USER_WITH_SESSION_ID;
+     767             : 
+     768             :     /* With timestamp is enabled by default */
+     769        6688 :     dlt_user.with_timestamp = DLT_USER_WITH_TIMESTAMP;
+     770             : 
+     771             :     /* With timestamp is enabled by default */
+     772        6688 :     dlt_user.with_ecu_id = DLT_USER_WITH_ECU_ID;
+     773             : 
+     774             :     /* Local print is disabled by default */
+     775        6688 :     dlt_user.enable_local_print = 0;
+     776             : 
+     777        6688 :     dlt_user.local_print_mode = DLT_PM_UNSET;
+     778             : 
+     779        6688 :     dlt_user.timeout_at_exit_handler = DLT_USER_ATEXIT_RESEND_BUFFER_EXIT_TIMEOUT;
+     780             : 
+     781        6688 :     env_local_print = getenv(DLT_USER_ENV_LOCAL_PRINT_MODE);
+     782             : 
+     783        6688 :     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        6688 :     env_initial_log_level = getenv("DLT_INITIAL_LOG_LEVEL");
+     793             : 
+     794        6688 :     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        6688 :     DLT_SEM_LOCK();
+     803        6688 :     dlt_user.dlt_ll_ts = NULL;
+     804        6688 :     dlt_user.dlt_ll_ts_max_num_entries = 0;
+     805        6688 :     dlt_user.dlt_ll_ts_num_entries = 0;
+     806             : 
+     807             : 
+     808        6688 :     env_buffer_min = getenv(DLT_USER_ENV_BUFFER_MIN_SIZE);
+     809        6688 :     env_buffer_max = getenv(DLT_USER_ENV_BUFFER_MAX_SIZE);
+     810        6688 :     env_buffer_step = getenv(DLT_USER_ENV_BUFFER_STEP_SIZE);
+     811             : 
+     812        6688 :     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        6688 :     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        6688 :     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        6688 :     dlt_user.log_buf_len = DLT_USER_BUF_MAX_SIZE;
+     847        6688 :     env_log_buffer_len = getenv(DLT_USER_ENV_LOG_MSG_BUF_LEN);
+     848             : 
+     849        6688 :     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        6688 :     if (dlt_user.resend_buffer == NULL) {
+     866        6687 :         dlt_user.resend_buffer = calloc(sizeof(unsigned char),
+     867        6687 :                                         (dlt_user.log_buf_len + header_size));
+     868             : 
+     869        6687 :         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        6688 :     dlt_user.disable_injection_msg = 0;
+     878        6688 :     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        6688 :     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        6688 :     DLT_SEM_FREE();
+     893             : 
+     894        6688 :     signal(SIGPIPE, SIG_IGN);                  /* ignore pipe signals */
+     895             : 
+     896        6688 :     if (atexit_registered == 0) {
+     897           1 :         atexit_registered = 1;
+     898           1 :         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           1 : void dlt_user_atexit_handler(void)
+     911             : {
+     912             :     /* parent will do clean-up */
+     913           1 :     if (g_dlt_is_child)
+     914             :         return;
+     915             : 
+     916           1 :     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           0 :     int count = dlt_user_atexit_blow_out_user_buffer();
+     925             : 
+     926           0 :     if (count != 0)
+     927           0 :         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           0 :     dlt_unregister_app_util(false);
+     932             : 
+     933             :     /* Cleanup */
+     934             :     /* Ignore return value */
+     935           0 :     dlt_free();
+     936             : }
+     937             : 
+     938           0 : int dlt_user_atexit_blow_out_user_buffer(void)
+     939           0 : {
+     940             : 
+     941             :     int count, ret;
+     942             :     struct timespec ts;
+     943             : 
+     944           0 :     uint32_t exitTime = dlt_uptime() + dlt_user.timeout_at_exit_handler;
+     945             : 
+     946             :     /* Send content of ringbuffer */
+     947           0 :     DLT_SEM_LOCK();
+     948           0 :     count = dlt_buffer_get_message_count(&(dlt_user.startup_buffer));
+     949           0 :     DLT_SEM_FREE();
+     950             : 
+     951           0 :     if (count > 0) {
+     952           0 :         while (dlt_uptime() < exitTime) {
+     953           0 :             if (dlt_user.dlt_log_handle == -1) {
+     954             :                 /* Reattach to daemon if neccesary */
+     955           0 :                 dlt_user_log_reattach_to_daemon();
+     956             : 
+     957           0 :                 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           0 :             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           0 :             ts.tv_sec = 0;
+     981           0 :             ts.tv_nsec = DLT_USER_ATEXIT_RESEND_BUFFER_SLEEP;
+     982           0 :             nanosleep(&ts, NULL);
+     983             :         }
+     984             : 
+     985           0 :         DLT_SEM_LOCK();
+     986           0 :         count = dlt_buffer_get_message_count(&(dlt_user.startup_buffer));
+     987           0 :         DLT_SEM_FREE();
+     988             :     }
+     989             : 
+     990             :     return count;
+     991             : }
+     992             : 
+     993             : static void dlt_user_free_buffer(unsigned char **buffer)
+     994             : {
+     995        6884 :     if (*buffer) {
+     996           2 :         free(*buffer);
+     997        6873 :         *buffer = NULL;
+     998             :     }
+     999             : }
+    1000             : 
+    1001       45893 : 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       45893 :     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       45893 :     if (!DLT_USER_INITALIZED) {
+    1017       39206 :         dlt_user_freeing = 0;
+    1018       39206 :         return DLT_RETURN_ERROR;
+    1019             :     }
+    1020             : 
+    1021        6687 :     dlt_stop_threads();
+    1022             : 
+    1023        6687 :     dlt_user_init_state = INIT_UNITIALIZED;
+    1024             : 
+    1025             : #ifdef DLT_LIB_USE_FIFO_IPC
+    1026             : 
+    1027        6687 :     if (dlt_user.dlt_user_handle != DLT_FD_INIT) {
+    1028        6686 :         close(dlt_user.dlt_user_handle);
+    1029        6686 :         dlt_user.dlt_user_handle = DLT_FD_INIT;
+    1030        6686 :         snprintf(filename, DLT_PATH_MAX, "%s/dlt%d", dlt_user_dir, getpid());
+    1031        6686 :         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        6687 :     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           0 :         ret = close(dlt_user.dlt_log_handle);
+    1104             : 
+    1105           0 :         if (ret < 0)
+    1106           0 :             dlt_vlog(LOG_WARNING, "%s: close failed: %s\n", __func__, strerror(errno));
+    1107             : 
+    1108           0 :         dlt_user.dlt_log_handle = -1;
+    1109             :     }
+    1110             : 
+    1111             :     /* Ignore return value */
+    1112        6687 :     DLT_SEM_LOCK();
+    1113        6687 :     dlt_receiver_free(&(dlt_user.receiver));
+    1114        6687 :     DLT_SEM_FREE();
+    1115             : 
+    1116             :     /* Ignore return value */
+    1117        6687 :     DLT_SEM_LOCK();
+    1118             : 
+    1119             :     dlt_user_free_buffer(&(dlt_user.resend_buffer));
+    1120        6687 :     dlt_buffer_free_dynamic(&(dlt_user.startup_buffer));
+    1121             : 
+    1122             :     /* Clear and free local stored application information */
+    1123        6687 :     if (dlt_user.application_description != NULL)
+    1124           0 :         free(dlt_user.application_description);
+    1125        6687 :     dlt_user.application_description = NULL;
+    1126             : 
+    1127        6687 :     if (dlt_user.dlt_ll_ts) {
+    1128        6513 :         for (i = 0; i < dlt_user.dlt_ll_ts_max_num_entries; i++) {
+    1129        6500 :             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        6500 :             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        6500 :             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        6500 :             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        6500 :             dlt_user.dlt_ll_ts[i].nrcallbacks = 0;
+    1150        6500 :             dlt_user.dlt_ll_ts[i].log_level_changed_callback = 0;
+    1151             :         }
+    1152             : 
+    1153          13 :         free(dlt_user.dlt_ll_ts);
+    1154          13 :         dlt_user.dlt_ll_ts = NULL;
+    1155          13 :         dlt_user.dlt_ll_ts_max_num_entries = 0;
+    1156          13 :         dlt_user.dlt_ll_ts_num_entries = 0;
+    1157             :     }
+    1158             : 
+    1159        6687 :     dlt_env_free_ll_set(&dlt_user.initial_ll_set);
+    1160        6687 :     DLT_SEM_FREE();
+    1161             : 
+    1162             : #ifdef DLT_NETWORK_TRACE_ENABLE
+    1163             :     char queue_name[NAME_MAX];
+    1164        6687 :     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        6687 :     if (dlt_user.dlt_segmented_queue_write_handle > 0)
+    1171           0 :         mq_close(dlt_user.dlt_segmented_queue_write_handle);
+    1172             : 
+    1173        6687 :     if (dlt_user.dlt_segmented_queue_read_handle > 0)
+    1174           0 :         mq_close(dlt_user.dlt_segmented_queue_read_handle);
+    1175             : 
+    1176        6687 :     if ((dlt_user.dlt_segmented_queue_write_handle > 0) ||
+    1177        6687 :         (dlt_user.dlt_segmented_queue_read_handle > 0))
+    1178           0 :         mq_unlink(queue_name);
+    1179             : 
+    1180        6687 :     dlt_user.dlt_segmented_queue_write_handle = DLT_FD_INIT;
+    1181        6687 :     dlt_user.dlt_segmented_queue_read_handle = DLT_FD_INIT;
+    1182             : 
+    1183        6687 :     pthread_cond_destroy(&mq_init_condition);
+    1184             : #endif /* DLT_NETWORK_TRACE_ENABLE */
+    1185        6687 :     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        6687 :     dlt_user_freeing = 0;
+    1191             : 
+    1192        6687 :     return DLT_RETURN_OK;
+    1193             : }
+    1194             : 
+    1195           0 : DltReturnValue dlt_check_library_version(const char *user_major_version, const char *user_minor_version)
+    1196             : {
+    1197           0 :     return dlt_user_check_library_version(user_major_version, user_minor_version);
+    1198             : }
+    1199             : 
+    1200         169 : 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         169 :     if (g_dlt_is_child)
+    1206             :         return DLT_RETURN_ERROR;
+    1207             : 
+    1208         169 :     if (!DLT_USER_INITALIZED) {
+    1209           1 :         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         169 :     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         165 :     if (apid[1] == 0) {
+    1221           2 :         if (apid[0] == dlt_user.appID[0])
+    1222             :             return DLT_RETURN_OK;
+    1223             :     }
+    1224         163 :     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         161 :     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         159 :     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         164 :     DLT_SEM_LOCK();
+    1246             : 
+    1247             :     /* Store locally application id and application description */
+    1248         164 :     dlt_set_id(dlt_user.appID, apid);
+    1249             : 
+    1250         164 :     if (dlt_user.application_description != NULL)
+    1251           0 :         free(dlt_user.application_description);
+    1252             : 
+    1253         164 :     dlt_user.application_description = NULL;
+    1254             : 
+    1255         164 :     if (description != NULL) {
+    1256         164 :         size_t desc_len = strlen(description);
+    1257         164 :         dlt_user.application_description = malloc(desc_len + 1);
+    1258             : 
+    1259         164 :         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         164 :     DLT_SEM_FREE();
+    1268             : 
+    1269         164 :     ret = dlt_user_log_send_register_application();
+    1270             : 
+    1271         164 :     if ((ret == DLT_RETURN_OK) && (dlt_user.dlt_log_handle != -1))
+    1272           0 :         ret = dlt_user_log_resend_buffer();
+    1273             : 
+    1274             :     return ret;
+    1275             : }
+    1276             : 
+    1277         165 : DltReturnValue dlt_register_context(DltContext *handle, const char *contextid, const char *description)
+    1278             : {
+    1279             :     /* check nullpointer */
+    1280         165 :     if (handle == NULL)
+    1281             :         return DLT_RETURN_WRONG_PARAMETER;
+    1282             : 
+    1283             :     /* forbid dlt usage in child after fork */
+    1284         159 :     if (g_dlt_is_child)
+    1285             :         return DLT_RETURN_ERROR;
+    1286             : 
+    1287         159 :     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         159 :     if ((contextid == NULL) || (contextid[0] == '\0'))
+    1295             :         return DLT_RETURN_WRONG_PARAMETER;
+    1296             : 
+    1297         151 :     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         178 : 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         178 :     if ((handle == NULL) || (contextid == NULL) || (contextid[0] == '\0'))
+    1319             :         return DLT_RETURN_WRONG_PARAMETER;
+    1320             : 
+    1321             :     /* forbid dlt usage in child after fork */
+    1322         171 :     if (g_dlt_is_child)
+    1323             :         return DLT_RETURN_ERROR;
+    1324             : 
+    1325         171 :     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         169 :     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         167 :     if (dlt_user_log_init(handle, &log) < DLT_RETURN_OK)
+    1336             :         return DLT_RETURN_ERROR;
+    1337             : 
+    1338             :     /* Reset message counter */
+    1339         167 :     handle->mcnt = 0;
+    1340             : 
+    1341             :     /* Store context id in log level/trace status field */
+    1342             : 
+    1343             :     /* Check if already registered, else register context */
+    1344         167 :     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         167 :     if (dlt_user.dlt_ll_ts == NULL) {
+    1351          14 :         dlt_user.dlt_ll_ts = (dlt_ll_ts_type *)malloc(sizeof(dlt_ll_ts_type) * DLT_USER_CONTEXT_ALLOC_SIZE);
+    1352             : 
+    1353          14 :         if (dlt_user.dlt_ll_ts == NULL) {
+    1354           0 :             DLT_SEM_FREE();
+    1355           0 :             return DLT_RETURN_ERROR;
+    1356             :         }
+    1357             : 
+    1358          14 :         dlt_user.dlt_ll_ts_max_num_entries = DLT_USER_CONTEXT_ALLOC_SIZE;
+    1359             : 
+    1360             :         /* Initialize new entries */
+    1361        7014 :         for (i = 0; i < dlt_user.dlt_ll_ts_max_num_entries; i++) {
+    1362        7000 :             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        7000 :             dlt_user.dlt_ll_ts[i].log_level = DLT_USER_INITIAL_LOG_LEVEL;
+    1367        7000 :             dlt_user.dlt_ll_ts[i].trace_status = DLT_USER_INITIAL_TRACE_STATUS;
+    1368             : 
+    1369        7000 :             dlt_user.dlt_ll_ts[i].log_level_ptr = 0;
+    1370        7000 :             dlt_user.dlt_ll_ts[i].trace_status_ptr = 0;
+    1371             : 
+    1372        7000 :             dlt_user.dlt_ll_ts[i].context_description = 0;
+    1373             : 
+    1374        7000 :             dlt_user.dlt_ll_ts[i].injection_table = 0;
+    1375        7000 :             dlt_user.dlt_ll_ts[i].nrcallbacks = 0;
+    1376        7000 :             dlt_user.dlt_ll_ts[i].log_level_changed_callback = 0;
+    1377             :         }
+    1378             :     }
+    1379         153 :     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         167 :     ctx_entry = &dlt_user.dlt_ll_ts[dlt_user.dlt_ll_ts_num_entries];
+    1427             : 
+    1428             :     /* Store locally context id and context description */
+    1429         167 :     dlt_set_id(ctx_entry->contextID, contextid);
+    1430             : 
+    1431         167 :     if (ctx_entry->context_description != 0)
+    1432           0 :         free(ctx_entry->context_description);
+    1433             : 
+    1434         167 :     ctx_entry->context_description = 0;
+    1435             : 
+    1436         167 :     if (description != 0) {
+    1437         167 :         size_t desc_len = strlen(description);
+    1438         167 :         ctx_entry->context_description = malloc(desc_len + 1);
+    1439             : 
+    1440         167 :         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         167 :     if (ctx_entry->log_level_ptr == 0) {
+    1449         167 :         ctx_entry->log_level_ptr = malloc(sizeof(int8_t));
+    1450             : 
+    1451         167 :         if (ctx_entry->log_level_ptr == 0) {
+    1452           0 :             DLT_SEM_FREE();
+    1453           0 :             return DLT_RETURN_ERROR;
+    1454             :         }
+    1455             :     }
+    1456             : 
+    1457         167 :     if (ctx_entry->trace_status_ptr == 0) {
+    1458         167 :         ctx_entry->trace_status_ptr = malloc(sizeof(int8_t));
+    1459             : 
+    1460         167 :         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         167 :     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         167 :     if (envLogLevel != DLT_USER_LOG_LEVEL_NOT_SET) {
+    1473           0 :         ctx_entry->log_level = (int8_t) envLogLevel;
+    1474             :         loglevel = envLogLevel;
+    1475             :     }
+    1476         167 :     else if (loglevel != DLT_USER_LOG_LEVEL_NOT_SET)
+    1477             :     {
+    1478          16 :         ctx_entry->log_level = (int8_t) loglevel;
+    1479             :     }
+    1480             : 
+    1481         167 :     if (tracestatus != DLT_USER_TRACE_STATUS_NOT_SET)
+    1482          15 :         ctx_entry->trace_status = (int8_t) tracestatus;
+    1483             : 
+    1484             :     /* Prepare transfer struct */
+    1485         167 :     dlt_set_id(handle->contextID, contextid);
+    1486         167 :     handle->log_level_pos = (int32_t) dlt_user.dlt_ll_ts_num_entries;
+    1487             : 
+    1488         167 :     handle->log_level_ptr = ctx_entry->log_level_ptr;
+    1489         167 :     handle->trace_status_ptr = ctx_entry->trace_status_ptr;
+    1490             : 
+    1491         167 :     log.context_description = ctx_entry->context_description;
+    1492             : 
+    1493         167 :     *(ctx_entry->log_level_ptr) = ctx_entry->log_level;
+    1494         167 :     *(ctx_entry->trace_status_ptr) = ctx_entry->trace_status = (int8_t) tracestatus;
+    1495         167 :     ctx_entry->log_level_changed_callback = dlt_log_level_changed_callback;
+    1496             : 
+    1497         167 :     log.log_level = loglevel;
+    1498         167 :     log.trace_status = tracestatus;
+    1499             : 
+    1500         167 :     dlt_user.dlt_ll_ts_num_entries++;
+    1501             : 
+    1502         167 :     DLT_SEM_FREE();
+    1503             : 
+    1504         167 :     return dlt_user_log_send_register_context(&log);
+    1505             : }
+    1506             : 
+    1507         178 : DltReturnValue dlt_register_context_ll_ts(DltContext *handle,
+    1508             :                                           const char *contextid,
+    1509             :                                           const char *description,
+    1510             :                                           int loglevel,
+    1511             :                                           int tracestatus)
+    1512             : {
+    1513         178 :     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         167 : 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         167 :     if (g_dlt_is_child)
+    1559             :         return DLT_RETURN_ERROR;
+    1560             : 
+    1561         167 :     if (!DLT_USER_INITALIZED) {
+    1562           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_init_state != INIT_DONE\n", __FUNCTION__);
+    1563           0 :         return DLT_RETURN_ERROR;
+    1564             :     }
+    1565             : 
+    1566             :     /* Inform daemon to unregister application and all of its contexts */
+    1567         167 :     ret = dlt_user_log_send_unregister_application();
+    1568             : 
+    1569         167 :     DLT_SEM_LOCK();
+    1570             : 
+    1571         167 :     int count = dlt_buffer_get_message_count(&(dlt_user.startup_buffer));
+    1572         167 :     if (!force_sending_messages ||
+    1573           0 :         (force_sending_messages && count == 0))
+    1574             :     {
+    1575             :         /* Clear and free local stored application information */
+    1576         167 :         dlt_set_id(dlt_user.appID, "");
+    1577             : 
+    1578         167 :         if (dlt_user.application_description != NULL)
+    1579         164 :             free(dlt_user.application_description);
+    1580             : 
+    1581         167 :         dlt_user.application_description = NULL;
+    1582             :     }
+    1583             : 
+    1584         167 :     DLT_SEM_FREE();
+    1585             : 
+    1586         167 :     return ret;
+    1587             : }
+    1588             : 
+    1589         167 : DltReturnValue dlt_unregister_app(void)
+    1590             : {
+    1591         167 :     return dlt_unregister_app_util(false);
+    1592             : }
+    1593             : 
+    1594           0 : DltReturnValue dlt_unregister_app_flush_buffered_logs(void)
+    1595             : {
+    1596             :     DltReturnValue ret = DLT_RETURN_OK;
+    1597             : 
+    1598             :     /* forbid dlt usage in child after fork */
+    1599           0 :     if (g_dlt_is_child)
+    1600             :         return DLT_RETURN_ERROR;
+    1601             : 
+    1602           0 :     if (!DLT_USER_INITALIZED) {
+    1603           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_init_state != INIT_DONE\n", __FUNCTION__);
+    1604           0 :         return DLT_RETURN_ERROR;
+    1605             :     }
+    1606             : 
+    1607           0 :     if (dlt_user.dlt_log_handle != -1) {
+    1608             :         do
+    1609           0 :             ret = dlt_user_log_resend_buffer();
+    1610           0 :         while ((ret != DLT_RETURN_OK) && (dlt_user.dlt_log_handle != -1));
+    1611             :     }
+    1612             : 
+    1613           0 :     return dlt_unregister_app_util(true);
+    1614             : }
+    1615             : 
+    1616         166 : DltReturnValue dlt_unregister_context(DltContext *handle)
+    1617           0 : {
+    1618             :     DltContextData log;
+    1619             :     DltReturnValue ret = DLT_RETURN_OK;
+    1620             : 
+    1621             :     /* forbid dlt usage in child after fork */
+    1622         166 :     if (g_dlt_is_child)
+    1623             :         return DLT_RETURN_ERROR;
+    1624             : 
+    1625         166 :     log.handle = NULL;
+    1626         166 :     log.context_description = NULL;
+    1627             : 
+    1628         166 :     if (dlt_user_log_init(handle, &log) <= DLT_RETURN_ERROR)
+    1629             :         return DLT_RETURN_ERROR;
+    1630             : 
+    1631         166 :     DLT_SEM_LOCK();
+    1632             : 
+    1633         166 :     handle->log_level_ptr = NULL;
+    1634         166 :     handle->trace_status_ptr = NULL;
+    1635             : 
+    1636         166 :     if (dlt_user.dlt_ll_ts != NULL) {
+    1637             :         /* Clear and free local stored context information */
+    1638         166 :         dlt_set_id(dlt_user.dlt_ll_ts[handle->log_level_pos].contextID, "");
+    1639             : 
+    1640         166 :         dlt_user.dlt_ll_ts[handle->log_level_pos].log_level = DLT_USER_INITIAL_LOG_LEVEL;
+    1641         166 :         dlt_user.dlt_ll_ts[handle->log_level_pos].trace_status = DLT_USER_INITIAL_TRACE_STATUS;
+    1642             : 
+    1643         166 :         if (dlt_user.dlt_ll_ts[handle->log_level_pos].context_description != NULL)
+    1644         166 :             free(dlt_user.dlt_ll_ts[handle->log_level_pos].context_description);
+    1645             : 
+    1646         166 :         if (dlt_user.dlt_ll_ts[handle->log_level_pos].log_level_ptr != NULL) {
+    1647         166 :             free(dlt_user.dlt_ll_ts[handle->log_level_pos].log_level_ptr);
+    1648         166 :             dlt_user.dlt_ll_ts[handle->log_level_pos].log_level_ptr = NULL;
+    1649             :         }
+    1650             : 
+    1651         166 :         if (dlt_user.dlt_ll_ts[handle->log_level_pos].trace_status_ptr != NULL) {
+    1652         166 :             free(dlt_user.dlt_ll_ts[handle->log_level_pos].trace_status_ptr);
+    1653         166 :             dlt_user.dlt_ll_ts[handle->log_level_pos].trace_status_ptr = NULL;
+    1654             :         }
+    1655             : 
+    1656         166 :         dlt_user.dlt_ll_ts[handle->log_level_pos].context_description = NULL;
+    1657             : 
+    1658         166 :         if (dlt_user.dlt_ll_ts[handle->log_level_pos].injection_table != NULL) {
+    1659           0 :             free(dlt_user.dlt_ll_ts[handle->log_level_pos].injection_table);
+    1660           0 :             dlt_user.dlt_ll_ts[handle->log_level_pos].injection_table = NULL;
+    1661             :         }
+    1662             : 
+    1663         166 :         dlt_user.dlt_ll_ts[handle->log_level_pos].nrcallbacks = 0;
+    1664         166 :         dlt_user.dlt_ll_ts[handle->log_level_pos].log_level_changed_callback = 0;
+    1665             :     }
+    1666             : 
+    1667         166 :     DLT_SEM_FREE();
+    1668             : 
+    1669             :     /* Inform daemon to unregister context */
+    1670         166 :     ret = dlt_user_log_send_unregister_context(&log);
+    1671             : 
+    1672         166 :     return ret;
+    1673             : }
+    1674             : 
+    1675           0 : DltReturnValue dlt_set_application_ll_ts_limit(DltLogLevelType loglevel, DltTraceStatusType tracestatus)
+    1676           0 : {
+    1677             :     uint32_t i;
+    1678             : 
+    1679             :     /* forbid dlt usage in child after fork */
+    1680           0 :     if (g_dlt_is_child)
+    1681             :         return DLT_RETURN_ERROR;
+    1682             : 
+    1683           0 :     if ((loglevel < DLT_USER_LOG_LEVEL_NOT_SET) || (loglevel >= DLT_LOG_MAX)) {
+    1684           0 :         dlt_vlog(LOG_ERR, "Loglevel %d is outside valid range", loglevel);
+    1685           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    1686             :     }
+    1687             : 
+    1688           0 :     if ((tracestatus < DLT_USER_TRACE_STATUS_NOT_SET) || (tracestatus >= DLT_TRACE_STATUS_MAX)) {
+    1689           0 :         dlt_vlog(LOG_ERR, "Tracestatus %d is outside valid range", tracestatus);
+    1690           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    1691             :     }
+    1692             : 
+    1693           0 :     if (!DLT_USER_INITALIZED) {
+    1694           0 :         if (dlt_init() < 0) {
+    1695           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    1696           0 :             return DLT_RETURN_ERROR;
+    1697             :         }
+    1698             :     }
+    1699             : 
+    1700           0 :     DLT_SEM_LOCK();
+    1701             : 
+    1702           0 :     if (dlt_user.dlt_ll_ts == NULL) {
+    1703           0 :         DLT_SEM_FREE();
+    1704           0 :         return DLT_RETURN_ERROR;
+    1705             :     }
+    1706             : 
+    1707             :     /* Update local structures */
+    1708           0 :     for (i = 0; i < dlt_user.dlt_ll_ts_num_entries; i++) {
+    1709           0 :         dlt_user.dlt_ll_ts[i].log_level = loglevel;
+    1710           0 :         dlt_user.dlt_ll_ts[i].trace_status = tracestatus;
+    1711             : 
+    1712           0 :         if (dlt_user.dlt_ll_ts[i].log_level_ptr)
+    1713           0 :             *(dlt_user.dlt_ll_ts[i].log_level_ptr) = loglevel;
+    1714             : 
+    1715           0 :         if (dlt_user.dlt_ll_ts[i].trace_status_ptr)
+    1716           0 :             *(dlt_user.dlt_ll_ts[i].trace_status_ptr) = tracestatus;
+    1717             :     }
+    1718             : 
+    1719           0 :     DLT_SEM_FREE();
+    1720             : 
+    1721             :     /* Inform DLT server about update */
+    1722           0 :     return dlt_send_app_ll_ts_limit(dlt_user.appID, loglevel, tracestatus);
+    1723             : }
+    1724             : 
+    1725           1 : int dlt_get_log_state()
+    1726             : {
+    1727           1 :     return dlt_user.log_state;
+    1728             : }
+    1729             : 
+    1730           4 : DltReturnValue dlt_set_log_mode(DltUserLogMode mode)
+    1731             : {
+    1732             :     DLT_UNUSED(mode);
+    1733             : 
+    1734             :     /* forbid dlt usage in child after fork */
+    1735           4 :     if (g_dlt_is_child)
+    1736             :         return DLT_RETURN_ERROR;
+    1737             : 
+    1738           4 :     if ((mode < DLT_USER_MODE_UNDEFINED) || (mode >= DLT_USER_MODE_MAX)) {
+    1739           0 :         dlt_vlog(LOG_ERR, "User log mode %d is outside valid range", mode);
+    1740           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    1741             :     }
+    1742             : 
+    1743           4 :     if (!DLT_USER_INITALIZED) {
+    1744           0 :         if (dlt_init() < 0) {
+    1745           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    1746           0 :             return DLT_RETURN_ERROR;
+    1747             :         }
+    1748             :     }
+    1749             : 
+    1750           4 :     return dlt_user_log_send_log_mode(mode);
+    1751             : }
+    1752             : 
+    1753           0 : int dlt_set_resend_timeout_atexit(uint32_t timeout_in_milliseconds)
+    1754             : {
+    1755             :     /* forbid dlt usage in child after fork */
+    1756           0 :     if (g_dlt_is_child)
+    1757             :         return DLT_RETURN_ERROR;
+    1758             : 
+    1759           0 :     if (DLT_USER_INITALIZED == 0)
+    1760           0 :         if (dlt_init() < 0)
+    1761             :             return -1;
+    1762             : 
+    1763           0 :     dlt_user.timeout_at_exit_handler = timeout_in_milliseconds * 10;
+    1764           0 :     return 0;
+    1765             : }
+    1766             : 
+    1767             : /* ********************************************************************************************* */
+    1768             : 
+    1769         188 : DltReturnValue dlt_user_log_write_start_init(DltContext *handle,
+    1770             :                                                     DltContextData *log,
+    1771             :                                                     DltLogLevelType loglevel,
+    1772             :                                                     bool is_verbose)
+    1773             : {
+    1774             :     DLT_LOG_FATAL_RESET_TRAP(loglevel);
+    1775             : 
+    1776             :     /* initialize values */
+    1777         188 :     if ((dlt_user_log_init(handle, log) < DLT_RETURN_OK) || (dlt_user.dlt_ll_ts == NULL))
+    1778             :         return DLT_RETURN_ERROR;
+    1779             : 
+    1780         188 :     log->args_num = 0;
+    1781         188 :     log->log_level = loglevel;
+    1782         188 :     log->size = 0;
+    1783         188 :     log->use_timestamp = DLT_AUTO_TIMESTAMP;
+    1784         188 :     log->verbose_mode = is_verbose;
+    1785             : 
+    1786         188 :     return DLT_RETURN_TRUE;
+    1787             : }
+    1788             : 
+    1789             : static DltReturnValue dlt_user_log_write_start_internal(DltContext *handle,
+    1790             :                                                         DltContextData *log,
+    1791             :                                                         DltLogLevelType loglevel,
+    1792             :                                                         uint32_t messageid,
+    1793             :                                                         bool is_verbose);
+    1794             : 
+    1795         104 : inline DltReturnValue dlt_user_log_write_start(DltContext *handle, DltContextData *log, DltLogLevelType loglevel)
+    1796             : {
+    1797         214 :     return dlt_user_log_write_start_internal(handle, log, loglevel, DLT_USER_DEFAULT_MSGID, true);
+    1798             : }
+    1799             : 
+    1800          23 : DltReturnValue dlt_user_log_write_start_id(DltContext *handle,
+    1801             :                                            DltContextData *log,
+    1802             :                                            DltLogLevelType loglevel,
+    1803             :                                            uint32_t messageid)
+    1804             : {
+    1805          23 :     return dlt_user_log_write_start_internal(handle, log, loglevel, messageid, false);
+    1806             : }
+    1807             : 
+    1808         237 : DltReturnValue dlt_user_log_write_start_internal(DltContext *handle,
+    1809             :                                            DltContextData *log,
+    1810             :                                            DltLogLevelType loglevel,
+    1811             :                                            uint32_t messageid,
+    1812             :                                            bool is_verbose)
+    1813             : {
+    1814             :     int ret = DLT_RETURN_TRUE;
+    1815             : 
+    1816             :     /* check nullpointer */
+    1817         237 :     if ((handle == NULL) || (log == NULL))
+    1818             :         return DLT_RETURN_WRONG_PARAMETER;
+    1819             : 
+    1820             :     /* forbid dlt usage in child after fork */
+    1821         231 :     if (g_dlt_is_child)
+    1822             :         return DLT_RETURN_ERROR;
+    1823             : 
+    1824             :     /* check log levels */
+    1825             :     ret = dlt_user_is_logLevel_enabled(handle, loglevel);
+    1826             : 
+    1827             :     if (ret == DLT_RETURN_WRONG_PARAMETER) {
+    1828             :         return DLT_RETURN_WRONG_PARAMETER;
+    1829         227 :     } else if (ret == DLT_RETURN_LOGGING_DISABLED) {
+    1830          39 :         log->handle = NULL;
+    1831          39 :         return DLT_RETURN_OK;
+    1832             :     }
+    1833             : 
+    1834         188 :     ret = dlt_user_log_write_start_init(handle, log, loglevel, is_verbose);
+    1835         188 :     if (ret == DLT_RETURN_TRUE) {
+    1836             :         /* initialize values */
+    1837         188 :         if ((NULL != log->buffer))
+    1838             :         {
+    1839           0 :             free(log->buffer);
+    1840           0 :             log->buffer = NULL;
+    1841             :         }
+    1842             :         else
+    1843             :         {
+    1844         188 :             log->buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
+    1845             :         }
+    1846             : 
+    1847         188 :         if (log->buffer == NULL) {
+    1848           0 :             dlt_vlog(LOG_ERR, "Cannot allocate buffer for DLT Log message\n");
+    1849           0 :             return DLT_RETURN_ERROR;
+    1850             :         }
+    1851             :         else
+    1852             :         {
+    1853             :             /* In non-verbose mode, insert message id */
+    1854         198 :             if (!is_verbose_mode(dlt_user.verbose_mode, log)) {
+    1855           3 :                 if ((sizeof(uint32_t)) > dlt_user.log_buf_len)
+    1856             :                     return DLT_RETURN_USER_BUFFER_FULL;
+    1857             : 
+    1858             :                 /* Write message id */
+    1859             :                 memcpy(log->buffer, &(messageid), sizeof(uint32_t));
+    1860           3 :                 log->size = sizeof(uint32_t);
+    1861             : 
+    1862             :                 /* as the message id is part of each message in non-verbose mode,
+    1863             :                 * it doesn't increment the argument counter in extended header (if used) */
+    1864             :             }
+    1865             :         }
+    1866             :     }
+    1867             : 
+    1868             :     return ret;
+    1869             : }
+    1870             : 
+    1871           0 : DltReturnValue dlt_user_log_write_start_w_given_buffer(DltContext *handle,
+    1872             :                                                        DltContextData *log,
+    1873             :                                                        DltLogLevelType loglevel,
+    1874             :                                                        char *buffer,
+    1875             :                                                        size_t size,
+    1876             :                                                        int32_t args_num)
+    1877             : {
+    1878             :     int ret = DLT_RETURN_TRUE;
+    1879             : 
+    1880             :     /* check nullpointer */
+    1881           0 :     if ((handle == NULL) || (log == NULL) || (buffer == NULL))
+    1882             :         return DLT_RETURN_WRONG_PARAMETER;
+    1883             : 
+    1884             :     /* discard unexpected parameters */
+    1885           0 :     if ((size <= 0) || (size > dlt_user.log_buf_len) || (args_num <= 0))
+    1886             :         return DLT_RETURN_WRONG_PARAMETER;
+    1887             : 
+    1888             :     /* forbid dlt usage in child after fork */
+    1889           0 :     if (g_dlt_is_child)
+    1890             :         return DLT_RETURN_ERROR;
+    1891             : 
+    1892             :     /* discard non-verbose mode */
+    1893           0 :     if (dlt_user.verbose_mode == 0)
+    1894             :         return DLT_RETURN_ERROR;
+    1895             : 
+    1896           0 :     ret = dlt_user_log_write_start_init(handle, log, loglevel, true);
+    1897           0 :     if (ret == DLT_RETURN_TRUE) {
+    1898           0 :         log->buffer = (unsigned char *)buffer;
+    1899           0 :         log->size = size;
+    1900           0 :         log->args_num = args_num;
+    1901             :     }
+    1902             : 
+    1903             :     return ret;
+    1904             :  }
+    1905             : 
+    1906         195 : DltReturnValue dlt_user_log_write_finish(DltContextData *log)
+    1907             : {
+    1908             :     int ret = DLT_RETURN_ERROR;
+    1909             : 
+    1910         195 :     if (log == NULL)
+    1911             :         return DLT_RETURN_WRONG_PARAMETER;
+    1912             : 
+    1913         195 :     ret = dlt_user_log_send_log(log, DLT_TYPE_LOG);
+    1914             : 
+    1915             :     dlt_user_free_buffer(&(log->buffer));
+    1916             : 
+    1917             :     return ret;
+    1918             : }
+    1919             : 
+    1920           0 : DltReturnValue dlt_user_log_write_finish_w_given_buffer(DltContextData *log)
+    1921             : {
+    1922             :     int ret = DLT_RETURN_ERROR;
+    1923             : 
+    1924           0 :     if (log == NULL)
+    1925             :         return DLT_RETURN_WRONG_PARAMETER;
+    1926             : 
+    1927           0 :     ret = dlt_user_log_send_log(log, DLT_TYPE_LOG);
+    1928             : 
+    1929           0 :     return ret;
+    1930             : }
+    1931             : 
+    1932          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)
+    1933             : {
+    1934             :     /* check nullpointer */
+    1935          38 :     if ((log == NULL) || ((data == NULL) && (length != 0)))
+    1936             :         return DLT_RETURN_WRONG_PARAMETER;
+    1937             : 
+    1938             :     /* Have to cast type to signed type because some compilers assume that DltFormatType is unsigned and issue a warning */
+    1939          31 :     if (((int16_t)type < DLT_FORMAT_DEFAULT) || (type >= DLT_FORMAT_MAX)) {
+    1940           0 :         dlt_vlog(LOG_ERR, "Format type %u is outside valid range", type);
+    1941           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    1942             :     }
+    1943             : 
+    1944          31 :     if (!DLT_USER_INITALIZED) {
+    1945           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_init_state != INIT_DONE\n", __FUNCTION__);
+    1946           0 :         return DLT_RETURN_ERROR;
+    1947             :     }
+    1948             : 
+    1949          31 :     const uint16_t name_size = (name != NULL) ? strlen(name)+1 : 0;
+    1950             : 
+    1951          31 :     size_t needed_size = length + sizeof(uint16_t);
+    1952          31 :     if ((log->size + needed_size) > dlt_user.log_buf_len)
+    1953             :         return DLT_RETURN_USER_BUFFER_FULL;
+    1954             : 
+    1955          29 :     if (is_verbose_mode(dlt_user.verbose_mode, log)) {
+    1956          29 :         uint32_t type_info = DLT_TYPE_INFO_RAWD;
+    1957             : 
+    1958          29 :         needed_size += sizeof(uint32_t);  // Type Info field
+    1959          29 :         if (with_var_info) {
+    1960           6 :             needed_size += sizeof(uint16_t);  // length of name
+    1961           6 :             needed_size += name_size;  // the name itself
+    1962             : 
+    1963           6 :             type_info |= DLT_TYPE_INFO_VARI;
+    1964             :         }
+    1965          29 :         if ((log->size + needed_size) > dlt_user.log_buf_len)
+    1966           0 :             return DLT_RETURN_USER_BUFFER_FULL;
+    1967             : 
+    1968             :         // Genivi extension: put formatting hints into the unused (for RAWD) TYLE + SCOD fields.
+    1969             :         // The SCOD field holds the base (hex or bin); the TYLE field holds the column width (8bit..64bit).
+    1970          29 :         if ((type >= DLT_FORMAT_HEX8) && (type <= DLT_FORMAT_HEX64)) {
+    1971           8 :             type_info |= DLT_SCOD_HEX;
+    1972           8 :             type_info += type;
+    1973             :         }
+    1974          21 :         else if ((type >= DLT_FORMAT_BIN8) && (type <= DLT_FORMAT_BIN16))
+    1975             :         {
+    1976           4 :             type_info |= DLT_SCOD_BIN;
+    1977           4 :             type_info += type - DLT_FORMAT_BIN8 + 1;
+    1978             :         }
+    1979             : 
+    1980          29 :         memcpy(log->buffer + log->size, &type_info, sizeof(uint32_t));
+    1981          29 :         log->size += sizeof(uint32_t);
+    1982             :     }
+    1983             : 
+    1984          29 :     memcpy(log->buffer + log->size, &length, sizeof(uint16_t));
+    1985          29 :     log->size += sizeof(uint16_t);
+    1986             : 
+    1987          29 :     if (is_verbose_mode(dlt_user.verbose_mode, log)) {
+    1988          29 :         if (with_var_info) {
+    1989             :             // Write length of "name" attribute.
+    1990             :             // We assume that the protocol allows zero-sized strings here (which this code will create
+    1991             :             // when the input pointer is NULL).
+    1992           6 :             memcpy(log->buffer + log->size, &name_size, sizeof(uint16_t));
+    1993           6 :             log->size += sizeof(uint16_t);
+    1994             : 
+    1995             :             // Write name string itself.
+    1996             :             // Must not use NULL as source pointer for memcpy. This check assures that.
+    1997           6 :             if (name_size != 0) {
+    1998           4 :                 memcpy(log->buffer + log->size, name, name_size);
+    1999           4 :                 log->size += name_size;
+    2000             :             }
+    2001             :         }
+    2002             :     }
+    2003             : 
+    2004          29 :     memcpy(log->buffer + log->size, data, length);
+    2005          29 :     log->size += length;
+    2006             : 
+    2007          29 :     log->args_num++;
+    2008             : 
+    2009          29 :     return DLT_RETURN_OK;
+    2010             : }
+    2011             : 
+    2012          13 : DltReturnValue dlt_user_log_write_raw(DltContextData *log, void *data, uint16_t length)
+    2013             : {
+    2014          13 :     return dlt_user_log_write_raw_internal(log, data, length, DLT_FORMAT_DEFAULT, NULL, false);
+    2015             : }
+    2016             : 
+    2017          19 : DltReturnValue dlt_user_log_write_raw_formatted(DltContextData *log, void *data, uint16_t length, DltFormatType type)
+    2018             : {
+    2019          19 :     return dlt_user_log_write_raw_internal(log, data, length, type, NULL, false);
+    2020             : }
+    2021             : 
+    2022           3 : DltReturnValue dlt_user_log_write_raw_attr(DltContextData *log, const void *data, uint16_t length, const char *name)
+    2023             : {
+    2024           3 :     return dlt_user_log_write_raw_internal(log, data, length, DLT_FORMAT_DEFAULT, name, true);
+    2025             : }
+    2026             : 
+    2027           3 : DltReturnValue dlt_user_log_write_raw_formatted_attr(DltContextData *log, const void *data, uint16_t length, DltFormatType type, const char *name)
+    2028             : {
+    2029           3 :     return dlt_user_log_write_raw_internal(log, data, length, type, name, true);
+    2030             : }
+    2031             : 
+    2032             : // Generic implementation for all "simple" types, possibly with attributes
+    2033         218 : static DltReturnValue dlt_user_log_write_generic_attr(DltContextData *log, const void *datap, size_t datalen, uint32_t type_info, const VarInfo *varinfo)
+    2034             : {
+    2035         218 :     if (log == NULL)
+    2036             :         return DLT_RETURN_WRONG_PARAMETER;
+    2037             : 
+    2038         207 :     if (!DLT_USER_INITALIZED) {
+    2039           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_init_state != INIT_DONE\n", __FUNCTION__);
+    2040           0 :         return DLT_RETURN_ERROR;
+    2041             :     }
+    2042             : 
+    2043             :     size_t needed_size = datalen;
+    2044         207 :     if ((log->size + needed_size) > dlt_user.log_buf_len)
+    2045             :         return DLT_RETURN_USER_BUFFER_FULL;
+    2046             : 
+    2047         209 :     if (is_verbose_mode(dlt_user.verbose_mode, log)) {
+    2048             :         bool with_var_info = (varinfo != NULL);
+    2049             : 
+    2050             :         uint16_t name_size;
+    2051             :         uint16_t unit_size;
+    2052             : 
+    2053         203 :         needed_size += sizeof(uint32_t);  // Type Info field
+    2054         203 :         if (with_var_info) {
+    2055          89 :             name_size = (varinfo->name != NULL) ? strlen(varinfo->name)+1 : 0;
+    2056          89 :             unit_size = (varinfo->unit != NULL) ? strlen(varinfo->unit)+1 : 0;
+    2057             : 
+    2058          89 :             needed_size += sizeof(uint16_t);      // length of name
+    2059          89 :             needed_size += name_size;             // the name itself
+    2060          89 :             if (varinfo->with_unit) {
+    2061          86 :                 needed_size += sizeof(uint16_t);  // length of unit
+    2062          86 :                 needed_size += unit_size;         // the unit itself
+    2063             :             }
+    2064             : 
+    2065          89 :             type_info |= DLT_TYPE_INFO_VARI;
+    2066             :         }
+    2067         203 :         if ((log->size + needed_size) > dlt_user.log_buf_len)
+    2068           0 :             return DLT_RETURN_USER_BUFFER_FULL;
+    2069             : 
+    2070         203 :         memcpy(log->buffer + log->size, &type_info, sizeof(uint32_t));
+    2071         203 :         log->size += sizeof(uint32_t);
+    2072             : 
+    2073         203 :         if (with_var_info) {
+    2074             :             // Write lengths of name/unit strings
+    2075             :             // We assume here that the protocol allows zero-sized strings here (which occur
+    2076             :             // when the input pointers are NULL).
+    2077          89 :             memcpy(log->buffer + log->size, &name_size, sizeof(uint16_t));
+    2078          89 :             log->size += sizeof(uint16_t);
+    2079          89 :             if (varinfo->with_unit) {
+    2080          86 :                 memcpy(log->buffer + log->size, &unit_size, sizeof(uint16_t));
+    2081          86 :                 log->size += sizeof(uint16_t);
+    2082             :             }
+    2083             : 
+    2084             :             // Write name/unit strings themselves
+    2085             :             // Must not use NULL as source pointer for memcpy.
+    2086          89 :             if (name_size != 0) {
+    2087          64 :                 memcpy(log->buffer + log->size, varinfo->name, name_size);
+    2088          64 :                 log->size += name_size;
+    2089             :             }
+    2090          89 :             if (unit_size != 0) {
+    2091          62 :                 memcpy(log->buffer + log->size, varinfo->unit, unit_size);
+    2092          62 :                 log->size += unit_size;
+    2093             :             }
+    2094             :         }
+    2095             :     }
+    2096             : 
+    2097         205 :     memcpy(log->buffer + log->size, datap, datalen);
+    2098         205 :     log->size += datalen;
+    2099             : 
+    2100         205 :     log->args_num++;
+    2101             : 
+    2102         205 :     return DLT_RETURN_OK;
+    2103             : }
+    2104             : 
+    2105             : // Generic implementation for all "simple" types
+    2106         112 : static DltReturnValue dlt_user_log_write_generic_formatted(DltContextData *log, const void *datap, size_t datalen, uint32_t type_info, DltFormatType type)
+    2107             : {
+    2108         112 :     if (log == NULL)
+    2109             :         return DLT_RETURN_WRONG_PARAMETER;
+    2110             : 
+    2111             :     /* Have to cast type to signed type because some compilers assume that DltFormatType is unsigned and issue a warning */
+    2112          84 :     if (((int16_t)type < DLT_FORMAT_DEFAULT) || (type >= DLT_FORMAT_MAX)) {
+    2113           0 :         dlt_vlog(LOG_ERR, "Format type %d is outside valid range", type);
+    2114           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    2115             :     }
+    2116             : 
+    2117          84 :     if (!DLT_USER_INITALIZED) {
+    2118           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_init_state != INIT_DONE\n", __FUNCTION__);
+    2119           0 :         return DLT_RETURN_ERROR;
+    2120             :     }
+    2121             : 
+    2122             :     size_t needed_size = datalen;
+    2123          84 :     if ((log->size + needed_size) > dlt_user.log_buf_len)
+    2124             :         return DLT_RETURN_USER_BUFFER_FULL;
+    2125             : 
+    2126          84 :     if (is_verbose_mode(dlt_user.verbose_mode, log)) {
+    2127          84 :         needed_size += sizeof(uint32_t);  // Type Info field
+    2128          84 :         if ((log->size + needed_size) > dlt_user.log_buf_len)
+    2129             :             return DLT_RETURN_USER_BUFFER_FULL;
+    2130             : 
+    2131             :         // Genivi extension: put formatting hints into the unused (for SINT/UINT/FLOA) SCOD field.
+    2132          84 :         if ((type >= DLT_FORMAT_HEX8) && (type <= DLT_FORMAT_HEX64))
+    2133          48 :             type_info |= DLT_SCOD_HEX;
+    2134             : 
+    2135          36 :         else if ((type >= DLT_FORMAT_BIN8) && (type <= DLT_FORMAT_BIN16))
+    2136          24 :             type_info |= DLT_SCOD_BIN;
+    2137             : 
+    2138          84 :         memcpy(log->buffer + log->size, &type_info, sizeof(uint32_t));
+    2139          84 :         log->size += sizeof(uint32_t);
+    2140             :     }
+    2141             : 
+    2142          84 :     memcpy(log->buffer + log->size, datap, datalen);
+    2143          84 :     log->size += datalen;
+    2144             : 
+    2145          84 :     log->args_num++;
+    2146             : 
+    2147          84 :     return DLT_RETURN_OK;
+    2148             : }
+    2149             : 
+    2150           7 : DltReturnValue dlt_user_log_write_float32(DltContextData *log, float32_t data)
+    2151             : {
+    2152             :     if (sizeof(float32_t) != 4)
+    2153             :         return DLT_RETURN_ERROR;
+    2154             : 
+    2155             :     uint32_t type_info = DLT_TYPE_INFO_FLOA | DLT_TYLE_32BIT;
+    2156           7 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(float32_t), type_info, NULL);
+    2157             : }
+    2158             : 
+    2159           7 : DltReturnValue dlt_user_log_write_float64(DltContextData *log, float64_t data)
+    2160             : {
+    2161             :     if (sizeof(float64_t) != 8)
+    2162             :         return DLT_RETURN_ERROR;
+    2163             : 
+    2164             :     uint32_t type_info = DLT_TYPE_INFO_FLOA | DLT_TYLE_64BIT;
+    2165           7 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(float64_t), type_info, NULL);
+    2166             : }
+    2167             : 
+    2168           7 : DltReturnValue dlt_user_log_write_float32_attr(DltContextData *log, float32_t data, const char *name, const char *unit)
+    2169             : {
+    2170             :     if (sizeof(float32_t) != 4)
+    2171             :         return DLT_RETURN_ERROR;
+    2172             : 
+    2173             :     uint32_t type_info = DLT_TYPE_INFO_FLOA | DLT_TYLE_32BIT;
+    2174           7 :     const VarInfo var_info = { name, unit, true };
+    2175           7 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(float32_t), type_info, &var_info);
+    2176             : }
+    2177             : 
+    2178           7 : DltReturnValue dlt_user_log_write_float64_attr(DltContextData *log, float64_t data, const char *name, const char *unit)
+    2179             : {
+    2180             :     if (sizeof(float64_t) != 8)
+    2181             :         return DLT_RETURN_ERROR;
+    2182             : 
+    2183             :     uint32_t type_info = DLT_TYPE_INFO_FLOA | DLT_TYLE_64BIT;
+    2184           7 :     const VarInfo var_info = { name, unit, true };
+    2185           7 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(float64_t), type_info, &var_info);
+    2186             : }
+    2187             : 
+    2188          35 : DltReturnValue dlt_user_log_write_uint(DltContextData *log, unsigned int data)
+    2189             : {
+    2190          35 :     if (log == NULL)
+    2191             :         return DLT_RETURN_WRONG_PARAMETER;
+    2192             : 
+    2193          34 :     if (!DLT_USER_INITALIZED) {
+    2194           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_init_state != INIT_DONE\n", __FUNCTION__);
+    2195           0 :         return DLT_RETURN_ERROR;
+    2196             :     }
+    2197             : 
+    2198             :     switch (sizeof(unsigned int)) {
+    2199             :     case 1:
+    2200             :     {
+    2201             :         return dlt_user_log_write_uint8(log, (uint8_t)data);
+    2202             :         break;
+    2203             :     }
+    2204             :     case 2:
+    2205             :     {
+    2206             :         return dlt_user_log_write_uint16(log, (uint16_t)data);
+    2207             :         break;
+    2208             :     }
+    2209          34 :     case 4:
+    2210             :     {
+    2211          34 :         return dlt_user_log_write_uint32(log, (uint32_t)data);
+    2212             :         break;
+    2213             :     }
+    2214             :     case 8:
+    2215             :     {
+    2216             :         return dlt_user_log_write_uint64(log, (uint64_t)data);
+    2217             :         break;
+    2218             :     }
+    2219             :     default:
+    2220             :     {
+    2221             :         return DLT_RETURN_ERROR;
+    2222             :         break;
+    2223             :     }
+    2224             :     }
+    2225             : 
+    2226             :     return DLT_RETURN_OK;
+    2227             : }
+    2228             : 
+    2229           4 : DltReturnValue dlt_user_log_write_uint8(DltContextData *log, uint8_t data)
+    2230             : {
+    2231             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_8BIT;
+    2232           4 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(uint8_t), type_info, NULL);
+    2233             : }
+    2234             : 
+    2235           4 : DltReturnValue dlt_user_log_write_uint16(DltContextData *log, uint16_t data)
+    2236             : {
+    2237             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_16BIT;
+    2238           4 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(uint16_t), type_info, NULL);
+    2239             : }
+    2240             : 
+    2241          38 : DltReturnValue dlt_user_log_write_uint32(DltContextData *log, uint32_t data)
+    2242             : {
+    2243             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_32BIT;
+    2244          38 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(uint32_t), type_info, NULL);
+    2245             : }
+    2246             : 
+    2247           4 : DltReturnValue dlt_user_log_write_uint64(DltContextData *log, uint64_t data)
+    2248             : {
+    2249             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_64BIT;
+    2250           4 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(uint64_t), type_info, NULL);
+    2251             : }
+    2252             : 
+    2253           7 : DltReturnValue dlt_user_log_write_uint_attr(DltContextData *log, unsigned int data, const char *name, const char *unit)
+    2254             : {
+    2255           7 :     if (log == NULL)
+    2256             :         return DLT_RETURN_WRONG_PARAMETER;
+    2257             : 
+    2258           7 :     if (!DLT_USER_INITALIZED) {
+    2259           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
+    2260           0 :         return DLT_RETURN_ERROR;
+    2261             :     }
+    2262             : 
+    2263             :     switch (sizeof(unsigned int)) {
+    2264             :     case 1:
+    2265             :     {
+    2266             :         return dlt_user_log_write_uint8_attr(log, (uint8_t)data, name, unit);
+    2267             :         break;
+    2268             :     }
+    2269             :     case 2:
+    2270             :     {
+    2271             :         return dlt_user_log_write_uint16_attr(log, (uint16_t)data, name, unit);
+    2272             :         break;
+    2273             :     }
+    2274           7 :     case 4:
+    2275             :     {
+    2276           7 :         return dlt_user_log_write_uint32_attr(log, (uint32_t)data, name, unit);
+    2277             :         break;
+    2278             :     }
+    2279             :     case 8:
+    2280             :     {
+    2281             :         return dlt_user_log_write_uint64_attr(log, (uint64_t)data, name, unit);
+    2282             :         break;
+    2283             :     }
+    2284             :     default:
+    2285             :     {
+    2286             :         return DLT_RETURN_ERROR;
+    2287             :         break;
+    2288             :     }
+    2289             :     }
+    2290             : 
+    2291             :     return DLT_RETURN_OK;
+    2292             : }
+    2293             : 
+    2294           7 : DltReturnValue dlt_user_log_write_uint8_attr(DltContextData *log, uint8_t data, const char *name, const char *unit)
+    2295             : {
+    2296             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_8BIT;
+    2297           7 :     const VarInfo var_info = { name, unit, true };
+    2298           7 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(uint8_t), type_info, &var_info);
+    2299             : }
+    2300             : 
+    2301           7 : DltReturnValue dlt_user_log_write_uint16_attr(DltContextData *log, uint16_t data, const char *name, const char *unit)
+    2302             : {
+    2303             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_16BIT;
+    2304           7 :     const VarInfo var_info = { name, unit, true };
+    2305           7 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(uint16_t), type_info, &var_info);
+    2306             : }
+    2307             : 
+    2308          18 : DltReturnValue dlt_user_log_write_uint32_attr(DltContextData *log, uint32_t data, const char *name, const char *unit)
+    2309             : {
+    2310             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_32BIT;
+    2311          18 :     const VarInfo var_info = { name, unit, true };
+    2312          18 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(uint32_t), type_info, &var_info);
+    2313             : }
+    2314             : 
+    2315           7 : DltReturnValue dlt_user_log_write_uint64_attr(DltContextData *log, uint64_t data, const char *name, const char *unit)
+    2316             : {
+    2317             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_64BIT;
+    2318           7 :     const VarInfo var_info = { name, unit, true };
+    2319           7 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(uint64_t), type_info, &var_info);
+    2320             : }
+    2321             : 
+    2322          28 : DltReturnValue dlt_user_log_write_uint8_formatted(DltContextData *log, uint8_t data, DltFormatType type)
+    2323             : {
+    2324             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_8BIT;
+    2325          28 :     return dlt_user_log_write_generic_formatted(log, &data, sizeof(uint8_t), type_info, type);
+    2326             : }
+    2327             : 
+    2328          28 : DltReturnValue dlt_user_log_write_uint16_formatted(DltContextData *log, uint16_t data, DltFormatType type)
+    2329             : {
+    2330             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_16BIT;
+    2331          28 :     return dlt_user_log_write_generic_formatted(log, &data, sizeof(uint16_t), type_info, type);
+    2332             : }
+    2333             : 
+    2334          28 : DltReturnValue dlt_user_log_write_uint32_formatted(DltContextData *log, uint32_t data, DltFormatType type)
+    2335             : {
+    2336             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_32BIT;
+    2337          28 :     return dlt_user_log_write_generic_formatted(log, &data, sizeof(uint32_t), type_info, type);
+    2338             : }
+    2339             : 
+    2340          28 : DltReturnValue dlt_user_log_write_uint64_formatted(DltContextData *log, uint64_t data, DltFormatType type)
+    2341             : {
+    2342             :     uint32_t type_info = DLT_TYPE_INFO_UINT | DLT_TYLE_64BIT;
+    2343          28 :     return dlt_user_log_write_generic_formatted(log, &data, sizeof(uint64_t), type_info, type);
+    2344             : }
+    2345             : 
+    2346           0 : DltReturnValue dlt_user_log_write_ptr(DltContextData *log, void *data)
+    2347             : {
+    2348           0 :     if (log == NULL)
+    2349             :         return DLT_RETURN_WRONG_PARAMETER;
+    2350             : 
+    2351           0 :     if (!DLT_USER_INITALIZED) {
+    2352           0 :         dlt_vlog(LOG_WARNING, "%s user_initialised false\n", __FUNCTION__);
+    2353           0 :         return DLT_RETURN_ERROR;
+    2354             :     }
+    2355             : 
+    2356             :     switch (sizeof(void *)) {
+    2357             :     case 4:
+    2358             :         return dlt_user_log_write_uint32_formatted(log,
+    2359             :                                                    (uintptr_t) data,
+    2360             :                                                    DLT_FORMAT_HEX32);
+    2361             :         break;
+    2362           0 :     case 8:
+    2363           0 :         return dlt_user_log_write_uint64_formatted(log,
+    2364             :                                                    (uintptr_t) data,
+    2365             :                                                    DLT_FORMAT_HEX64);
+    2366             :         break;
+    2367             :     default:
+    2368             :         ;     /* skip */
+    2369             :     }
+    2370             : 
+    2371             :     return DLT_RETURN_OK;
+    2372             : }
+    2373             : 
+    2374          37 : DltReturnValue dlt_user_log_write_int(DltContextData *log, int data)
+    2375             : {
+    2376          37 :     if (log == NULL)
+    2377             :         return DLT_RETURN_WRONG_PARAMETER;
+    2378             : 
+    2379          36 :     if (!DLT_USER_INITALIZED) {
+    2380           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_init_state != INIT_DONE\n", __FUNCTION__);
+    2381           0 :         return DLT_RETURN_ERROR;
+    2382             :     }
+    2383             : 
+    2384             :     switch (sizeof(int)) {
+    2385             :     case 1:
+    2386             :     {
+    2387             :         return dlt_user_log_write_int8(log, (int8_t)data);
+    2388             :         break;
+    2389             :     }
+    2390             :     case 2:
+    2391             :     {
+    2392             :         return dlt_user_log_write_int16(log, (int16_t)data);
+    2393             :         break;
+    2394             :     }
+    2395          36 :     case 4:
+    2396             :     {
+    2397          36 :         return dlt_user_log_write_int32(log, (int32_t)data);
+    2398             :         break;
+    2399             :     }
+    2400             :     case 8:
+    2401             :     {
+    2402             :         return dlt_user_log_write_int64(log, (int64_t)data);
+    2403             :         break;
+    2404             :     }
+    2405             :     default:
+    2406             :     {
+    2407             :         return DLT_RETURN_ERROR;
+    2408             :         break;
+    2409             :     }
+    2410             :     }
+    2411             : 
+    2412             :     return DLT_RETURN_OK;
+    2413             : }
+    2414             : 
+    2415           6 : DltReturnValue dlt_user_log_write_int8(DltContextData *log, int8_t data)
+    2416             : {
+    2417             :     uint32_t type_info = DLT_TYPE_INFO_SINT | DLT_TYLE_8BIT;
+    2418           6 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(int8_t), type_info, NULL);
+    2419             : }
+    2420             : 
+    2421           6 : DltReturnValue dlt_user_log_write_int16(DltContextData *log, int16_t data)
+    2422             : {
+    2423             :     uint32_t type_info = DLT_TYPE_INFO_SINT | DLT_TYLE_16BIT;
+    2424           6 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(int16_t), type_info, NULL);
+    2425             : }
+    2426             : 
+    2427          42 : DltReturnValue dlt_user_log_write_int32(DltContextData *log, int32_t data)
+    2428             : {
+    2429             :     uint32_t type_info = DLT_TYPE_INFO_SINT | DLT_TYLE_32BIT;
+    2430          42 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(int32_t), type_info, NULL);
+    2431             : }
+    2432             : 
+    2433           6 : DltReturnValue dlt_user_log_write_int64(DltContextData *log, int64_t data)
+    2434             : {
+    2435             :     uint32_t type_info = DLT_TYPE_INFO_SINT | DLT_TYLE_64BIT;
+    2436           6 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(int64_t), type_info, NULL);
+    2437             : }
+    2438             : 
+    2439           7 : DltReturnValue dlt_user_log_write_int_attr(DltContextData *log, int data, const char *name, const char *unit)
+    2440             : {
+    2441           7 :     if (log == NULL)
+    2442             :         return DLT_RETURN_WRONG_PARAMETER;
+    2443             : 
+    2444           7 :     if (!DLT_USER_INITALIZED) {
+    2445           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_initialised false\n", __FUNCTION__);
+    2446           0 :         return DLT_RETURN_ERROR;
+    2447             :     }
+    2448             : 
+    2449             :     switch (sizeof(int)) {
+    2450             :     case 1:
+    2451             :     {
+    2452             :         return dlt_user_log_write_int8_attr(log, (int8_t)data, name, unit);
+    2453             :         break;
+    2454             :     }
+    2455             :     case 2:
+    2456             :     {
+    2457             :         return dlt_user_log_write_int16_attr(log, (int16_t)data, name, unit);
+    2458             :         break;
+    2459             :     }
+    2460           7 :     case 4:
+    2461             :     {
+    2462           7 :         return dlt_user_log_write_int32_attr(log, (int32_t)data, name, unit);
+    2463             :         break;
+    2464             :     }
+    2465             :     case 8:
+    2466             :     {
+    2467             :         return dlt_user_log_write_int64_attr(log, (int64_t)data, name, unit);
+    2468             :         break;
+    2469             :     }
+    2470             :     default:
+    2471             :     {
+    2472             :         return DLT_RETURN_ERROR;
+    2473             :         break;
+    2474             :     }
+    2475             :     }
+    2476             : 
+    2477             :     return DLT_RETURN_OK;
+    2478             : }
+    2479             : 
+    2480           7 : DltReturnValue dlt_user_log_write_int8_attr(DltContextData *log, int8_t data, const char *name, const char *unit)
+    2481             : {
+    2482             :     uint32_t type_info = DLT_TYPE_INFO_SINT | DLT_TYLE_8BIT;
+    2483           7 :     const VarInfo var_info = { name, unit, true };
+    2484           7 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(int8_t), type_info, &var_info);
+    2485             : }
+    2486             : 
+    2487           7 : DltReturnValue dlt_user_log_write_int16_attr(DltContextData *log, int16_t data, const char *name, const char *unit)
+    2488             : {
+    2489             :     uint32_t type_info = DLT_TYPE_INFO_SINT | DLT_TYLE_16BIT;
+    2490           7 :     const VarInfo var_info = { name, unit, true };
+    2491           7 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(int16_t), type_info, &var_info);
+    2492             : }
+    2493             : 
+    2494          14 : DltReturnValue dlt_user_log_write_int32_attr(DltContextData *log, int32_t data, const char *name, const char *unit)
+    2495             : {
+    2496             :     uint32_t type_info = DLT_TYPE_INFO_SINT | DLT_TYLE_32BIT;
+    2497          14 :     const VarInfo var_info = { name, unit, true };
+    2498          14 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(int32_t), type_info, &var_info);
+    2499             : }
+    2500             : 
+    2501           7 : DltReturnValue dlt_user_log_write_int64_attr(DltContextData *log, int64_t data, const char *name, const char *unit)
+    2502             : {
+    2503             :     uint32_t type_info = DLT_TYPE_INFO_SINT | DLT_TYLE_64BIT;
+    2504           7 :     const VarInfo var_info = { name, unit, true };
+    2505           7 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(int64_t), type_info, &var_info);
+    2506             : }
+    2507             : 
+    2508           3 : DltReturnValue dlt_user_log_write_bool(DltContextData *log, uint8_t data)
+    2509             : {
+    2510             :     uint32_t type_info = DLT_TYPE_INFO_BOOL | DLT_TYLE_8BIT;
+    2511           3 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(uint8_t), type_info, NULL);
+    2512             : }
+    2513             : 
+    2514           3 : DltReturnValue dlt_user_log_write_bool_attr(DltContextData *log, uint8_t data, const char *name)
+    2515             : {
+    2516             :     uint32_t type_info = DLT_TYPE_INFO_BOOL | DLT_TYLE_8BIT;
+    2517           3 :     const VarInfo var_info = { name, NULL, false };
+    2518           3 :     return dlt_user_log_write_generic_attr(log, &data, sizeof(uint8_t), type_info, &var_info);
+    2519             : }
+    2520             : 
+    2521          60 : DltReturnValue dlt_user_log_write_string(DltContextData *log, const char *text)
+    2522             : {
+    2523          60 :     return dlt_user_log_write_string_utils_attr(log, text, ASCII_STRING, NULL, false);
+    2524             : }
+    2525             : 
+    2526           7 : DltReturnValue dlt_user_log_write_string_attr(DltContextData *log, const char *text, const char *name)
+    2527             : {
+    2528           7 :     return dlt_user_log_write_string_utils_attr(log, text, ASCII_STRING, name, true);
+    2529             : }
+    2530             : 
+    2531           2 : DltReturnValue dlt_user_log_write_sized_string(DltContextData *log, const char *text, uint16_t length)
+    2532             : {
+    2533           2 :     return dlt_user_log_write_sized_string_utils_attr(log, text, length, ASCII_STRING, NULL, false);
+    2534             : }
+    2535             : 
+    2536           6 : DltReturnValue dlt_user_log_write_sized_string_attr(DltContextData *log, const char *text, uint16_t length, const char *name)
+    2537             : {
+    2538           6 :     return dlt_user_log_write_sized_string_utils_attr(log, text, length, ASCII_STRING, name, true);
+    2539             : }
+    2540             : 
+    2541           7 : DltReturnValue dlt_user_log_write_constant_string(DltContextData *log, const char *text)
+    2542             : {
+    2543             :     /* Send parameter only in verbose mode */
+    2544           8 :     return is_verbose_mode(dlt_user.verbose_mode, log) ? dlt_user_log_write_string(log, text) : DLT_RETURN_OK;
+    2545             : }
+    2546             : 
+    2547           5 : DltReturnValue dlt_user_log_write_constant_string_attr(DltContextData *log, const char *text, const char *name)
+    2548             : {
+    2549             :     /* Send parameter only in verbose mode */
+    2550           7 :     return is_verbose_mode(dlt_user.verbose_mode, log) ? dlt_user_log_write_string_attr(log, text, name) : DLT_RETURN_OK;
+    2551             : }
+    2552             : 
+    2553           1 : DltReturnValue dlt_user_log_write_sized_constant_string(DltContextData *log, const char *text, uint16_t length)
+    2554             : {
+    2555             :     /* Send parameter only in verbose mode */
+    2556           1 :     return is_verbose_mode(dlt_user.verbose_mode, log) ? dlt_user_log_write_sized_string(log, text, length) : DLT_RETURN_OK;
+    2557             : }
+    2558             : 
+    2559           3 : DltReturnValue dlt_user_log_write_sized_constant_string_attr(DltContextData *log, const char *text, uint16_t length, const char *name)
+    2560             : {
+    2561             :     /* Send parameter only in verbose mode */
+    2562           3 :     return is_verbose_mode(dlt_user.verbose_mode, log) ? dlt_user_log_write_sized_string_attr(log, text, length, name) : DLT_RETURN_OK;
+    2563             : }
+    2564             : 
+    2565          21 : DltReturnValue dlt_user_log_write_utf8_string(DltContextData *log, const char *text)
+    2566             : {
+    2567          21 :     return dlt_user_log_write_string_utils_attr(log, text, UTF8_STRING, NULL, false);
+    2568             : }
+    2569             : 
+    2570           7 : DltReturnValue dlt_user_log_write_utf8_string_attr(DltContextData *log, const char *text, const char *name)
+    2571             : {
+    2572           7 :     return dlt_user_log_write_string_utils_attr(log, text, UTF8_STRING, name, true);
+    2573             : }
+    2574             : 
+    2575           8 : DltReturnValue dlt_user_log_write_sized_utf8_string(DltContextData *log, const char *text, uint16_t length)
+    2576             : {
+    2577           8 :     return dlt_user_log_write_sized_string_utils_attr(log, text, length, UTF8_STRING, NULL, false);
+    2578             : }
+    2579             : 
+    2580           7 : DltReturnValue dlt_user_log_write_sized_utf8_string_attr(DltContextData *log, const char *text, uint16_t length, const char *name)
+    2581             : {
+    2582           7 :     return dlt_user_log_write_sized_string_utils_attr(log, text, length, UTF8_STRING, name, true);
+    2583             : }
+    2584             : 
+    2585           5 : DltReturnValue dlt_user_log_write_constant_utf8_string(DltContextData *log, const char *text)
+    2586             : {
+    2587             :     /* Send parameter only in verbose mode */
+    2588           6 :     return is_verbose_mode(dlt_user.verbose_mode, log) ? dlt_user_log_write_utf8_string(log, text) : DLT_RETURN_OK;
+    2589             : }
+    2590             : 
+    2591           4 : DltReturnValue dlt_user_log_write_constant_utf8_string_attr(DltContextData *log, const char *text, const char *name)
+    2592             : {
+    2593             :     /* Send parameter only in verbose mode */
+    2594           4 :     return is_verbose_mode(dlt_user.verbose_mode, log) ? dlt_user_log_write_utf8_string_attr(log, text, name) : DLT_RETURN_OK;
+    2595             : }
+    2596             : 
+    2597           5 : DltReturnValue dlt_user_log_write_sized_constant_utf8_string(DltContextData *log, const char *text, uint16_t length)
+    2598             : {
+    2599             :     /* Send parameter only in verbose mode */
+    2600           6 :     return is_verbose_mode(dlt_user.verbose_mode, log) ? dlt_user_log_write_sized_utf8_string(log, text, length) : DLT_RETURN_OK;
+    2601             : }
+    2602             : 
+    2603           4 : DltReturnValue dlt_user_log_write_sized_constant_utf8_string_attr(DltContextData *log, const char *text, uint16_t length, const char *name)
+    2604             : {
+    2605             :     /* Send parameter only in verbose mode */
+    2606           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;
+    2607             : }
+    2608             : 
+    2609         103 : 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)
+    2610             : {
+    2611         103 :     if ((log == NULL) || (text == NULL))
+    2612             :         return DLT_RETURN_WRONG_PARAMETER;
+    2613             : 
+    2614          94 :     if (!DLT_USER_INITALIZED) {
+    2615           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_init_state != INIT_DONE\n", __FUNCTION__);
+    2616           0 :         return DLT_RETURN_ERROR;
+    2617             :     }
+    2618             : 
+    2619          94 :     const uint16_t name_size = (name != NULL) ? strlen(name)+1 : 0;
+    2620             : 
+    2621          94 :     size_t arg_size = (size_t) (length + 1);
+    2622             : 
+    2623          94 :     size_t new_log_size = log->size + arg_size + sizeof(uint16_t);
+    2624             : 
+    2625          94 :     uint32_t type_info = 0;
+    2626             : 
+    2627         101 :     if (is_verbose_mode(dlt_user.verbose_mode, log)) {
+    2628          94 :         new_log_size += sizeof(uint32_t);
+    2629          94 :         if (with_var_info) {
+    2630          21 :             new_log_size += sizeof(uint16_t);  // length of "name" attribute
+    2631          21 :             new_log_size += name_size;  // the "name" attribute itself
+    2632             : 
+    2633          21 :             type_info |= DLT_TYPE_INFO_VARI;
+    2634             :         }
+    2635             :     }
+    2636             : 
+    2637             :     size_t str_truncate_message_length = strlen(STR_TRUNCATED_MESSAGE) + 1;
+    2638             :     size_t max_payload_str_msg;
+    2639             :     DltReturnValue ret = DLT_RETURN_OK;
+    2640             : 
+    2641             :     /* Check log size condition */
+    2642          94 :     if (new_log_size > dlt_user.log_buf_len) {
+    2643             :         ret = DLT_RETURN_USER_BUFFER_FULL;
+    2644             : 
+    2645             :         /* Re-calculate arg_size */
+    2646          21 :         arg_size = (size_t) (dlt_user.log_buf_len - log->size - sizeof(uint16_t));
+    2647             : 
+    2648          21 :         size_t min_payload_str_truncate_msg = log->size + str_truncate_message_length + sizeof(uint16_t);
+    2649             : 
+    2650          21 :         if (is_verbose_mode(dlt_user.verbose_mode, log)) {
+    2651          21 :             min_payload_str_truncate_msg += sizeof(uint32_t);
+    2652          21 :             arg_size -= (size_t) sizeof(uint32_t);
+    2653          21 :             if (with_var_info) {
+    2654           0 :                 min_payload_str_truncate_msg += sizeof(uint16_t) + name_size;
+    2655           0 :                 arg_size -= sizeof(uint16_t) + name_size;
+    2656             :             }
+    2657             :         }
+    2658             : 
+    2659             :         /* Return when dlt_user.log_buf_len does not have enough space for min_payload_str_truncate_msg */
+    2660          21 :         if (min_payload_str_truncate_msg > dlt_user.log_buf_len) {
+    2661           1 :             dlt_vlog(LOG_WARNING, "%s not enough minimum space to store data\n", __FUNCTION__);
+    2662           1 :             return ret;
+    2663             :         }
+    2664             : 
+    2665             :         /* Calculate the maximum size of string will be copied after truncate */
+    2666          20 :         max_payload_str_msg = dlt_user.log_buf_len - min_payload_str_truncate_msg;
+    2667             : 
+    2668          20 :         if (type == UTF8_STRING) {
+    2669             :             /**
+    2670             :              * Adjust the lengh to truncate one utf8 character corectly
+    2671             :              * refer: https://en.wikipedia.org/wiki/UTF-8
+    2672             :              * one utf8 character will have maximum 4 bytes then maximum bytes will be truncate additional is 3
+    2673             :              */
+    2674          12 :             const char *tmp = (text + max_payload_str_msg - 3);
+    2675             :             uint16_t reduce_size = 0;
+    2676             : 
+    2677          12 :             if (tmp[2] & 0x80) {
+    2678             :                 /* Is the last byte of truncated text is the first byte in multi-byte sequence (utf8 2 bytes) */
+    2679           9 :                 if (tmp[2] & 0x40)
+    2680             :                     reduce_size = 1;
+    2681             :                 /* Is the next to last byte of truncated text is the first byte in multi-byte sequence (utf8 3 bytes) */
+    2682           6 :                 else if ((tmp[1] & 0xe0) == 0xe0)
+    2683             :                     reduce_size = 2;
+    2684             :                 /* utf8 4 bytes */
+    2685           3 :                 else if ((tmp[0] & 0xf0) == 0xf0)
+    2686             :                     reduce_size = 3;
+    2687             :             }
+    2688             : 
+    2689          12 :             max_payload_str_msg -= reduce_size;
+    2690          12 :             arg_size -= (size_t) reduce_size;
+    2691             :         }
+    2692             :     }
+    2693             : 
+    2694          93 :     if (is_verbose_mode(dlt_user.verbose_mode, log)) {
+    2695          93 :         switch (type) {
+    2696          68 :         case ASCII_STRING:
+    2697          68 :             type_info |= DLT_TYPE_INFO_STRG | DLT_SCOD_ASCII;
+    2698          68 :             break;
+    2699          25 :         case UTF8_STRING:
+    2700          25 :             type_info |= DLT_TYPE_INFO_STRG | DLT_SCOD_UTF8;
+    2701          25 :             break;
+    2702             :         default:
+    2703             :             /* Do nothing */
+    2704             :             break;
+    2705             :         }
+    2706             : 
+    2707          93 :         memcpy(log->buffer + log->size, &type_info, sizeof(uint32_t));
+    2708          93 :         log->size += sizeof(uint32_t);
+    2709             :     }
+    2710             : 
+    2711          93 :     memcpy(log->buffer + log->size, &arg_size, sizeof(uint16_t));
+    2712          93 :     log->size += sizeof(uint16_t);
+    2713             : 
+    2714         100 :     if (is_verbose_mode(dlt_user.verbose_mode, log)) {
+    2715          93 :         if (with_var_info) {
+    2716             :             // Write length of "name" attribute.
+    2717             :             // We assume that the protocol allows zero-sized strings here (which this code will create
+    2718             :             // when the input pointer is NULL).
+    2719          21 :             memcpy(log->buffer + log->size, &name_size, sizeof(uint16_t));
+    2720          21 :             log->size += sizeof(uint16_t);
+    2721             : 
+    2722             :             // Write name string itself.
+    2723             :             // Must not use NULL as source pointer for memcpy. This check assures that.
+    2724          21 :             if (name_size != 0) {
+    2725          15 :                 memcpy(log->buffer + log->size, name, name_size);
+    2726          15 :                 log->size += name_size;
+    2727             :             }
+    2728             :         }
+    2729             :     }
+    2730             : 
+    2731          93 :     switch (ret) {
+    2732          73 :     case DLT_RETURN_OK:
+    2733             :     {
+    2734             :         /* Whole string will be copied */
+    2735          73 :         memcpy(log->buffer + log->size, text, length);
+    2736             :         /* The input string might not be null-terminated, so we're doing that by ourselves */
+    2737          73 :         log->buffer[log->size + length] = '\0';
+    2738          73 :         log->size += arg_size;
+    2739          73 :         break;
+    2740             :     }
+    2741          20 :     case DLT_RETURN_USER_BUFFER_FULL:
+    2742             :     {
+    2743             :         /* Only copy partial string */
+    2744          20 :         memcpy(log->buffer + log->size, text, max_payload_str_msg);
+    2745          20 :         log->size += max_payload_str_msg;
+    2746             : 
+    2747             :         /* Append string truncate the input string */
+    2748          20 :         memcpy(log->buffer + log->size, STR_TRUNCATED_MESSAGE, str_truncate_message_length);
+    2749          20 :         log->size += str_truncate_message_length;
+    2750          20 :         break;
+    2751             :     }
+    2752             :     default:
+    2753             :     {
+    2754             :         /* Do nothing */
+    2755             :         break;
+    2756             :     }
+    2757             :     }
+    2758             : 
+    2759          93 :     log->args_num++;
+    2760             : 
+    2761          93 :     return ret;
+    2762             : }
+    2763             : 
+    2764          95 : 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)
+    2765             : {
+    2766          95 :     if ((log == NULL) || (text == NULL))
+    2767             :         return DLT_RETURN_WRONG_PARAMETER;
+    2768             : 
+    2769          80 :     size_t length = strlen(text);
+    2770          80 :     return dlt_user_log_write_sized_string_utils_attr(log, text, length, type, name, with_var_info);
+    2771             : }
+    2772             : 
+    2773           0 : DltReturnValue dlt_register_injection_callback_with_id(DltContext *handle, uint32_t service_id,
+    2774             :                                                        dlt_injection_callback_id dlt_injection_cbk, void *priv)
+    2775           0 : {
+    2776             :     DltContextData log;
+    2777             :     uint32_t i, j, k;
+    2778             :     int found = 0;
+    2779             : 
+    2780             :     DltUserInjectionCallback *old;
+    2781             : 
+    2782           0 :     if (dlt_user_log_init(handle, &log) < DLT_RETURN_OK)
+    2783             :         return DLT_RETURN_ERROR;
+    2784             : 
+    2785           0 :     if (service_id < DLT_USER_INJECTION_MIN)
+    2786             :         return DLT_RETURN_WRONG_PARAMETER;
+    2787             : 
+    2788             :     /* This function doesn't make sense storing to local file is choosen;
+    2789             :      * so terminate this function */
+    2790           0 :     if (dlt_user.dlt_is_file)
+    2791             :         return DLT_RETURN_OK;
+    2792             : 
+    2793           0 :     DLT_SEM_LOCK();
+    2794             : 
+    2795           0 :     if (dlt_user.dlt_ll_ts == NULL) {
+    2796           0 :         DLT_SEM_FREE();
+    2797           0 :         return DLT_RETURN_OK;
+    2798             :     }
+    2799             : 
+    2800             :     /* Insert callback in corresponding table */
+    2801           0 :     i = (uint32_t) handle->log_level_pos;
+    2802             : 
+    2803             :     /* Insert each service_id only once */
+    2804           0 :     for (k = 0; k < dlt_user.dlt_ll_ts[i].nrcallbacks; k++)
+    2805           0 :         if ((dlt_user.dlt_ll_ts[i].injection_table) &&
+    2806           0 :             (dlt_user.dlt_ll_ts[i].injection_table[k].service_id == service_id)) {
+    2807             :             found = 1;
+    2808             :             break;
+    2809             :         }
+    2810             : 
+    2811           0 :     if (found) {
+    2812             :         j = k;
+    2813             :     }
+    2814             :     else {
+    2815             :         j = dlt_user.dlt_ll_ts[i].nrcallbacks;
+    2816             : 
+    2817             :         /* Allocate or expand injection table */
+    2818           0 :         if (dlt_user.dlt_ll_ts[i].injection_table == NULL) {
+    2819           0 :             dlt_user.dlt_ll_ts[i].injection_table =
+    2820           0 :                 (DltUserInjectionCallback *)malloc(sizeof(DltUserInjectionCallback));
+    2821             : 
+    2822           0 :             if (dlt_user.dlt_ll_ts[i].injection_table == NULL) {
+    2823           0 :                 DLT_SEM_FREE();
+    2824           0 :                 return DLT_RETURN_ERROR;
+    2825             :             }
+    2826             :         }
+    2827             :         else {
+    2828             :             old = dlt_user.dlt_ll_ts[i].injection_table;
+    2829           0 :             dlt_user.dlt_ll_ts[i].injection_table = (DltUserInjectionCallback *)malloc(
+    2830           0 :                 sizeof(DltUserInjectionCallback) * (j + 1));
+    2831             : 
+    2832           0 :             if (dlt_user.dlt_ll_ts[i].injection_table == NULL) {
+    2833           0 :                 dlt_user.dlt_ll_ts[i].injection_table = old;
+    2834           0 :                 DLT_SEM_FREE();
+    2835           0 :                 return DLT_RETURN_ERROR;
+    2836             :             }
+    2837             : 
+    2838           0 :             memcpy(dlt_user.dlt_ll_ts[i].injection_table, old, sizeof(DltUserInjectionCallback) * j);
+    2839           0 :             free(old);
+    2840             :         }
+    2841             : 
+    2842           0 :         dlt_user.dlt_ll_ts[i].nrcallbacks++;
+    2843             :     }
+    2844             : 
+    2845             :     /* Store service_id and corresponding function pointer for callback function */
+    2846           0 :     dlt_user.dlt_ll_ts[i].injection_table[j].service_id = service_id;
+    2847             : 
+    2848           0 :     if (priv == NULL) {
+    2849           0 :         dlt_user.dlt_ll_ts[i].injection_table[j].injection_callback = (dlt_injection_callback)(void*)dlt_injection_cbk;
+    2850           0 :         dlt_user.dlt_ll_ts[i].injection_table[j].injection_callback_with_id = NULL;
+    2851           0 :         dlt_user.dlt_ll_ts[i].injection_table[j].data = NULL;
+    2852             :     }
+    2853             :     else {
+    2854           0 :         dlt_user.dlt_ll_ts[i].injection_table[j].injection_callback = NULL;
+    2855           0 :         dlt_user.dlt_ll_ts[i].injection_table[j].injection_callback_with_id = dlt_injection_cbk;
+    2856           0 :         dlt_user.dlt_ll_ts[i].injection_table[j].data = priv;
+    2857             :     }
+    2858             : 
+    2859           0 :     DLT_SEM_FREE();
+    2860             : 
+    2861           0 :     return DLT_RETURN_OK;
+    2862             : }
+    2863             : 
+    2864           0 : DltReturnValue dlt_register_injection_callback(DltContext *handle, uint32_t service_id,
+    2865             :                                                int (*dlt_injection_callback)(uint32_t service_id,
+    2866             :                                                                              void *data,
+    2867             :                                                                              uint32_t length))
+    2868             : {
+    2869           0 :     return dlt_register_injection_callback_with_id(handle,
+    2870             :                                                    service_id,
+    2871             :                                                    (dlt_injection_callback_id)(void*)dlt_injection_callback,
+    2872             :                                                    NULL);
+    2873             : }
+    2874             : 
+    2875           1 : DltReturnValue dlt_register_log_level_changed_callback(DltContext *handle,
+    2876             :                                                        void (*dlt_log_level_changed_callback)(
+    2877             :                                                            char context_id[DLT_ID_SIZE],
+    2878             :                                                            uint8_t log_level,
+    2879             :                                                            uint8_t trace_status))
+    2880           0 : {
+    2881             :     DltContextData log;
+    2882             :     uint32_t i;
+    2883             : 
+    2884           1 :     if (dlt_user_log_init(handle, &log) < DLT_RETURN_OK)
+    2885             :         return DLT_RETURN_ERROR;
+    2886             : 
+    2887             :     /* This function doesn't make sense storing to local file is choosen;
+    2888             :      * so terminate this function */
+    2889           1 :     if (dlt_user.dlt_is_file)
+    2890             :         return DLT_RETURN_OK;
+    2891             : 
+    2892           1 :     DLT_SEM_LOCK();
+    2893             : 
+    2894           1 :     if (dlt_user.dlt_ll_ts == NULL) {
+    2895           0 :         DLT_SEM_FREE();
+    2896           0 :         return DLT_RETURN_OK;
+    2897             :     }
+    2898             : 
+    2899             :     /* Insert callback in corresponding table */
+    2900           1 :     i = (uint32_t) handle->log_level_pos;
+    2901             : 
+    2902             :     /* Store new callback function */
+    2903           1 :     dlt_user.dlt_ll_ts[i].log_level_changed_callback = dlt_log_level_changed_callback;
+    2904             : 
+    2905           1 :     DLT_SEM_FREE();
+    2906             : 
+    2907           1 :     return DLT_RETURN_OK;
+    2908             : }
+    2909             : 
+    2910             : /**
+    2911             :  * NW Trace related
+    2912             :  */
+    2913             : 
+    2914             : #ifdef DLT_NETWORK_TRACE_ENABLE
+    2915           0 : int check_buffer(void)
+    2916             : {
+    2917             :     int total_size, used_size;
+    2918           0 :     dlt_user_check_buffer(&total_size, &used_size);
+    2919             : 
+    2920           0 :     return (total_size - used_size < total_size / 2) ? -1 : 1;
+    2921             : }
+    2922             : 
+    2923             : /**
+    2924             :  * Send the start of a segment chain.
+    2925             :  * Returns DLT_RETURN_ERROR on failure
+    2926             :  */
+    2927           0 : DltReturnValue dlt_user_trace_network_segmented_start(uint32_t *id,
+    2928             :                                                       DltContext *handle,
+    2929             :                                                       DltNetworkTraceType nw_trace_type,
+    2930             :                                                       uint16_t header_len,
+    2931             :                                                       void *header,
+    2932             :                                                       uint16_t payload_len)
+    2933             : {
+    2934           0 :     DltContextData log = { 0 };
+    2935             :     struct timeval tv;
+    2936             :     int ret = DLT_RETURN_ERROR;
+    2937             : 
+    2938             :     /* check null pointer */
+    2939           0 :     if (id == NULL)
+    2940             :         return DLT_RETURN_WRONG_PARAMETER;
+    2941             : 
+    2942           0 :     if ((nw_trace_type < DLT_NW_TRACE_IPC) || (nw_trace_type >= DLT_NW_TRACE_MAX)) {
+    2943           0 :         dlt_vlog(LOG_ERR, "Network trace type %u is outside valid range", nw_trace_type);
+    2944           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    2945             :     }
+    2946             : 
+    2947           0 :     if (dlt_user.dlt_ll_ts == NULL)
+    2948             :         return DLT_RETURN_ERROR;
+    2949             : 
+    2950           0 :     if (handle->trace_status_ptr && (*(handle->trace_status_ptr) == DLT_TRACE_STATUS_ON)) {
+    2951             :         /* initialize values */
+    2952           0 :         if (dlt_user_log_init(handle, &log) < DLT_RETURN_OK)
+    2953             :             return DLT_RETURN_ERROR;
+    2954             : 
+    2955           0 :         if (log.buffer == NULL) {
+    2956           0 :             log.buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
+    2957             : 
+    2958           0 :             if (log.buffer == NULL) {
+    2959           0 :                 dlt_vlog(LOG_ERR, "Cannot allocate buffer for DLT Log message\n");
+    2960           0 :                 return DLT_RETURN_ERROR;
+    2961             :             }
+    2962             :         }
+    2963             : 
+    2964           0 :         log.args_num = 0;
+    2965           0 :         log.trace_status = nw_trace_type;
+    2966           0 :         log.size = 0;
+    2967             : 
+    2968           0 :         gettimeofday(&tv, NULL);
+    2969           0 :         *id = (uint32_t) tv.tv_usec;
+    2970             : 
+    2971             :         /* Write identifier */
+    2972           0 :         if (dlt_user_log_write_string(&log, DLT_TRACE_NW_START) < 0) {
+    2973             :             dlt_user_free_buffer(&(log.buffer));
+    2974           0 :             return DLT_RETURN_ERROR;
+    2975             :         }
+    2976             : 
+    2977             :         /* Write stream handle */
+    2978           0 :         if (dlt_user_log_write_uint32(&log, *id) < 0) {
+    2979             :             dlt_user_free_buffer(&(log.buffer));
+    2980           0 :             return DLT_RETURN_ERROR;
+    2981             :         }
+    2982             : 
+    2983             :         /* Write header */
+    2984           0 :         if (dlt_user_log_write_raw(&log, header, header_len) < 0) {
+    2985             :             dlt_user_free_buffer(&(log.buffer));
+    2986           0 :             return DLT_RETURN_ERROR;
+    2987             :         }
+    2988             : 
+    2989             :         /* Write size of payload */
+    2990           0 :         if (dlt_user_log_write_uint32(&log, payload_len) < 0) {
+    2991             :             dlt_user_free_buffer(&(log.buffer));
+    2992           0 :             return DLT_RETURN_ERROR;
+    2993             :         }
+    2994             : 
+    2995             :         /* Write expected segment count */
+    2996           0 :         uint16_t segment_count = (uint16_t) (payload_len / DLT_MAX_TRACE_SEGMENT_SIZE + 1);
+    2997             : 
+    2998             :         /* If segments align perfectly with segment size, avoid sending empty segment */
+    2999           0 :         if ((payload_len % DLT_MAX_TRACE_SEGMENT_SIZE) == 0)
+    3000             :             segment_count--;
+    3001             : 
+    3002           0 :         if (dlt_user_log_write_uint16(&log, segment_count) < 0) {
+    3003             :             dlt_user_free_buffer(&(log.buffer));
+    3004           0 :             return DLT_RETURN_ERROR;
+    3005             :         }
+    3006             : 
+    3007             :         /* Write length of one segment */
+    3008           0 :         if (dlt_user_log_write_uint16(&log, DLT_MAX_TRACE_SEGMENT_SIZE) < 0) {
+    3009             :             dlt_user_free_buffer(&(log.buffer));
+    3010           0 :             return DLT_RETURN_ERROR;
+    3011             :         }
+    3012             : 
+    3013             :         /* Send log */
+    3014           0 :         ret = dlt_user_log_send_log(&log, DLT_TYPE_NW_TRACE);
+    3015             : 
+    3016             :         dlt_user_free_buffer(&(log.buffer));
+    3017             : 
+    3018           0 :         return ret;
+    3019             :     }
+    3020             : 
+    3021             :     return DLT_RETURN_OK;
+    3022             : }
+    3023             : 
+    3024           0 : DltReturnValue dlt_user_trace_network_segmented_segment(uint32_t id,
+    3025             :                                                         DltContext *handle,
+    3026             :                                                         DltNetworkTraceType nw_trace_type,
+    3027             :                                                         int sequence,
+    3028             :                                                         uint16_t payload_len,
+    3029             :                                                         void *payload)
+    3030             : {
+    3031             :     int ret = DLT_RETURN_ERROR;
+    3032             :     struct timespec ts;
+    3033             : 
+    3034           0 :     if ((nw_trace_type < DLT_NW_TRACE_IPC) || (nw_trace_type >= DLT_NW_TRACE_MAX)) {
+    3035           0 :         dlt_vlog(LOG_ERR, "Network trace type %u is outside valid range", nw_trace_type);
+    3036           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    3037             :     }
+    3038             : 
+    3039           0 :     while (check_buffer() < 0) {
+    3040             :         /* Wait 50ms */
+    3041           0 :         ts.tv_sec = 0;
+    3042           0 :         ts.tv_nsec = 1000000 * 50;
+    3043           0 :         nanosleep(&ts, NULL);
+    3044           0 :         dlt_user_log_resend_buffer();
+    3045             :     }
+    3046             : 
+    3047           0 :     if (dlt_user.dlt_ll_ts == NULL)
+    3048             :         return DLT_RETURN_ERROR;
+    3049             : 
+    3050           0 :     if (handle->trace_status_ptr && (*(handle->trace_status_ptr) == DLT_TRACE_STATUS_ON)) {
+    3051           0 :         DltContextData log = { 0 };
+    3052             : 
+    3053           0 :         if (dlt_user_log_init(handle, &log) < DLT_RETURN_OK)
+    3054             :             return DLT_RETURN_ERROR;
+    3055             : 
+    3056             :         /* initialize values */
+    3057           0 :         if (log.buffer == NULL) {
+    3058           0 :             log.buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
+    3059             : 
+    3060           0 :             if (log.buffer == NULL) {
+    3061           0 :                 dlt_vlog(LOG_ERR, "Cannot allocate buffer for DLT Log message\n");
+    3062           0 :                 return DLT_RETURN_ERROR;
+    3063             :             }
+    3064             :         }
+    3065             : 
+    3066           0 :         log.args_num = 0;
+    3067           0 :         log.trace_status = nw_trace_type;
+    3068           0 :         log.size = 0;
+    3069             : 
+    3070             :         /* Write identifier */
+    3071           0 :         if (dlt_user_log_write_string(&log, DLT_TRACE_NW_SEGMENT) < DLT_RETURN_OK) {
+    3072             :             dlt_user_free_buffer(&(log.buffer));
+    3073           0 :             return DLT_RETURN_ERROR;
+    3074             :         }
+    3075             : 
+    3076             :         /* Write stream handle */
+    3077           0 :         if (dlt_user_log_write_uint32(&log, id) < DLT_RETURN_OK) {
+    3078             :             dlt_user_free_buffer(&(log.buffer));
+    3079           0 :             return DLT_RETURN_ERROR;
+    3080             :         }
+    3081             : 
+    3082             :         /* Write segment sequence number */
+    3083           0 :         if (dlt_user_log_write_uint16(&log, (uint16_t) sequence) < DLT_RETURN_OK) {
+    3084             :             dlt_user_free_buffer(&(log.buffer));
+    3085           0 :             return DLT_RETURN_ERROR;
+    3086             :         }
+    3087             : 
+    3088             :         /* Write data */
+    3089           0 :         if (dlt_user_log_write_raw(&log, payload, payload_len) < DLT_RETURN_OK) {
+    3090             :             dlt_user_free_buffer(&(log.buffer));
+    3091           0 :             return DLT_RETURN_ERROR;
+    3092             :         }
+    3093             : 
+    3094           0 :         ret = dlt_user_log_send_log(&log, DLT_TYPE_NW_TRACE);
+    3095             :         /* Send log */
+    3096             : 
+    3097             :         dlt_user_free_buffer(&(log.buffer));
+    3098             : 
+    3099           0 :         return ret;
+    3100             :     }
+    3101             : 
+    3102             :     /* Allow other threads to log between chunks */
+    3103           0 :     sched_yield();
+    3104           0 :     return DLT_RETURN_OK;
+    3105             : }
+    3106             : 
+    3107           0 : DltReturnValue dlt_user_trace_network_segmented_end(uint32_t id, DltContext *handle, DltNetworkTraceType nw_trace_type)
+    3108             : {
+    3109           0 :     DltContextData log = { 0 };
+    3110             :     int ret = DLT_RETURN_ERROR;
+    3111             : 
+    3112           0 :     if ((nw_trace_type < DLT_NW_TRACE_IPC) || (nw_trace_type >= DLT_NW_TRACE_MAX)) {
+    3113           0 :         dlt_vlog(LOG_ERR, "Network trace type %u is outside valid range", nw_trace_type);
+    3114           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    3115             :     }
+    3116             : 
+    3117           0 :     if (dlt_user.dlt_ll_ts == NULL)
+    3118             :         return DLT_RETURN_ERROR;
+    3119             : 
+    3120           0 :     if (handle->trace_status_ptr && (*(handle->trace_status_ptr) == DLT_TRACE_STATUS_ON)) {
+    3121             :         /* initialize values */
+    3122           0 :         if (dlt_user_log_init(handle, &log) < DLT_RETURN_OK)
+    3123             :             return DLT_RETURN_ERROR;
+    3124             : 
+    3125             :         /* initialize values */
+    3126           0 :         if (log.buffer == NULL) {
+    3127           0 :             log.buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
+    3128             : 
+    3129           0 :             if (log.buffer == NULL) {
+    3130           0 :                 dlt_vlog(LOG_ERR, "Cannot allocate buffer for DLT Log message\n");
+    3131           0 :                 return DLT_RETURN_ERROR;
+    3132             :             }
+    3133             :         }
+    3134             : 
+    3135           0 :         log.args_num = 0;
+    3136           0 :         log.trace_status = nw_trace_type;
+    3137           0 :         log.size = 0;
+    3138             : 
+    3139             :         /* Write identifier */
+    3140           0 :         if (dlt_user_log_write_string(&log, DLT_TRACE_NW_END) < DLT_RETURN_OK) {
+    3141             :             dlt_user_free_buffer(&(log.buffer));
+    3142           0 :             return DLT_RETURN_ERROR;
+    3143             :         }
+    3144             : 
+    3145             :         /* Write stream handle */
+    3146           0 :         if (dlt_user_log_write_uint32(&log, id) < DLT_RETURN_OK) {
+    3147             :             dlt_user_free_buffer(&(log.buffer));
+    3148           0 :             return DLT_RETURN_ERROR;
+    3149             :         }
+    3150             : 
+    3151           0 :         ret = dlt_user_log_send_log(&log, DLT_TYPE_NW_TRACE);
+    3152             :         /* Send log */
+    3153             : 
+    3154             :         dlt_user_free_buffer(&(log.buffer));
+    3155             : 
+    3156           0 :         return ret;
+    3157             : 
+    3158             :     }
+    3159             : 
+    3160             :     return DLT_RETURN_OK;
+    3161             : }
+    3162             : 
+    3163        6687 : void dlt_user_trace_network_segmented_thread(void *unused)
+    3164             : {
+    3165             :     /* Unused on purpose. */
+    3166             :     (void)unused;
+    3167             : #ifdef DLT_USE_PTHREAD_SETNAME_NP
+    3168        6687 :     if (pthread_setname_np(dlt_user.dlt_segmented_nwt_handle, "dlt_segmented"))
+    3169           0 :         dlt_log(LOG_WARNING, "Failed to rename segmented thread!\n");
+    3170             : #elif linux
+    3171             :     if (prctl(PR_SET_NAME, "dlt_segmented", 0, 0, 0) < 0)
+    3172             :         dlt_log(LOG_WARNING, "Failed to rename segmented thread!\n");
+    3173             : #endif
+    3174       13374 :     pthread_cleanup_push(dlt_user_cleanup_handler, NULL);
+    3175             : 
+    3176             :     s_segmented_data *data;
+    3177             : 
+    3178             :     while (1) {
+    3179             :         /* Wait until message queue is initialized */
+    3180        6687 :         dlt_lock_mutex(&mq_mutex);
+    3181             : 
+    3182       10333 :         while (dlt_user.dlt_segmented_queue_read_handle < 0)
+    3183             :         {
+    3184       10333 :             pthread_cond_wait(&mq_init_condition, &mq_mutex);
+    3185             :         }
+    3186             : 
+    3187           0 :         dlt_unlock_mutex(&mq_mutex);
+    3188             : 
+    3189           0 :         ssize_t read = mq_receive(dlt_user.dlt_segmented_queue_read_handle, (char *)&data,
+    3190             :                                   sizeof(s_segmented_data *), NULL);
+    3191             : 
+    3192           0 :         if (read < 0) {
+    3193           0 :             if (errno != EINTR) {
+    3194             :                 struct timespec req;
+    3195             :                 long sec = (DLT_USER_MQ_ERROR_RETRY_INTERVAL / 1000000);
+    3196           0 :                 dlt_vlog(LOG_WARNING, "NWTSegmented: Error while reading queue: %s\n", strerror(errno));
+    3197           0 :                 req.tv_sec = sec;
+    3198           0 :                 req.tv_nsec = (DLT_USER_MQ_ERROR_RETRY_INTERVAL - sec * 1000000) * 1000;
+    3199           0 :                 nanosleep(&req, NULL);
+    3200             :             }
+    3201             : 
+    3202           0 :             continue;
+    3203             :         }
+    3204             : 
+    3205           0 :         if (read != sizeof(s_segmented_data *)) {
+    3206             :             /* This case will not happen. */
+    3207             :             /* When this thread is interrupted by signal, mq_receive() will not return */
+    3208             :             /* partial read length and will return -1. And also no data is removed from mq. */
+    3209           0 :             dlt_vlog(LOG_WARNING, "NWTSegmented: Could not read data fully from queue: %zd\n", read);
+    3210           0 :             continue;
+    3211             :         }
+    3212             : 
+    3213           0 :         dlt_user_trace_network_segmented_thread_segmenter(data);
+    3214             : 
+    3215             :         /* Send the end message */
+    3216           0 :         DltReturnValue err = dlt_user_trace_network_segmented_end(data->id, data->handle, data->nw_trace_type);
+    3217             : 
+    3218           0 :         if ((err == DLT_RETURN_BUFFER_FULL) || (err == DLT_RETURN_ERROR))
+    3219           0 :             dlt_log(LOG_WARNING, "NWTSegmented: Could not send end segment.\n");
+    3220             : 
+    3221             :         /* Free resources */
+    3222           0 :         free(data->header);
+    3223           0 :         free(data->payload);
+    3224           0 :         free(data);
+    3225             :     }
+    3226             : 
+    3227             :     pthread_cleanup_pop(1);
+    3228             : }
+    3229             : 
+    3230           0 : void dlt_user_trace_network_segmented_thread_segmenter(s_segmented_data *data)
+    3231             : {
+    3232             :     /* Segment the data and send the chunks */
+    3233             :     void *ptr = NULL;
+    3234             :     uint32_t offset = 0;
+    3235             :     uint16_t sequence = 0;
+    3236             : 
+    3237             :     do {
+    3238             :         uint16_t len = 0;
+    3239             : 
+    3240           0 :         if (offset + DLT_MAX_TRACE_SEGMENT_SIZE > data->payload_len)
+    3241           0 :             len = (uint16_t) (data->payload_len - offset);
+    3242             :         else
+    3243             :             len = DLT_MAX_TRACE_SEGMENT_SIZE;
+    3244             : 
+    3245             :         /* If payload size aligns perfectly with segment size, avoid sending empty segment */
+    3246           0 :         if (len == 0)
+    3247             :             break;
+    3248             : 
+    3249           0 :         ptr = data->payload + offset;
+    3250           0 :         DltReturnValue err = dlt_user_trace_network_segmented_segment(data->id,
+    3251             :                                                                       data->handle,
+    3252             :                                                                       data->nw_trace_type,
+    3253           0 :                                                                       sequence++,
+    3254             :                                                                       len,
+    3255             :                                                                       ptr);
+    3256             : 
+    3257           0 :         if ((err == DLT_RETURN_BUFFER_FULL) || (err == DLT_RETURN_ERROR)) {
+    3258           0 :             dlt_log(LOG_ERR, "NWTSegmented: Could not send segment. Aborting.\n");
+    3259           0 :             break;             /* loop */
+    3260             :         }
+    3261             : 
+    3262           0 :         offset += len;
+    3263           0 :     } while (ptr < data->payload + data->payload_len);
+    3264           0 : }
+    3265             : 
+    3266             : 
+    3267           7 : DltReturnValue dlt_user_trace_network_segmented(DltContext *handle,
+    3268             :                                                 DltNetworkTraceType nw_trace_type,
+    3269             :                                                 uint16_t header_len,
+    3270             :                                                 void *header,
+    3271             :                                                 uint16_t payload_len,
+    3272             :                                                 void *payload)
+    3273             : {
+    3274             :     /* forbid dlt usage in child after fork */
+    3275           7 :     if (g_dlt_is_child)
+    3276             :         return DLT_RETURN_ERROR;
+    3277             : 
+    3278             :     /* Send as normal trace if possible */
+    3279           7 :     if (header_len + payload_len + sizeof(uint16_t) < dlt_user.log_buf_len)
+    3280           7 :         return dlt_user_trace_network(handle, nw_trace_type, header_len, header, payload_len, payload);
+    3281             : 
+    3282             :     /* Allocate Memory */
+    3283           0 :     s_segmented_data *thread_data = malloc(sizeof(s_segmented_data));
+    3284             : 
+    3285           0 :     if (thread_data == NULL)
+    3286             :         return DLT_RETURN_ERROR;
+    3287             : 
+    3288           0 :     thread_data->header = malloc(header_len);
+    3289             : 
+    3290           0 :     if (thread_data->header == NULL) {
+    3291           0 :         free(thread_data);
+    3292           0 :         return DLT_RETURN_ERROR;
+    3293             :     }
+    3294             : 
+    3295           0 :     thread_data->payload = malloc(payload_len);
+    3296             : 
+    3297           0 :     if (thread_data->payload == NULL) {
+    3298           0 :         free(thread_data->header);
+    3299           0 :         free(thread_data);
+    3300           0 :         return DLT_RETURN_ERROR;
+    3301             :     }
+    3302             : 
+    3303             :     /* Copy data */
+    3304           0 :     thread_data->handle = handle;
+    3305           0 :     thread_data->nw_trace_type = nw_trace_type;
+    3306           0 :     thread_data->header_len = header_len;
+    3307             :     memcpy(thread_data->header, header, header_len);
+    3308           0 :     thread_data->payload_len = payload_len;
+    3309             :     memcpy(thread_data->payload, payload, payload_len);
+    3310             : 
+    3311             :     /* Send start message */
+    3312           0 :     DltReturnValue err = dlt_user_trace_network_segmented_start(&(thread_data->id),
+    3313             :                                                                 thread_data->handle,
+    3314             :                                                                 thread_data->nw_trace_type,
+    3315             :                                                                 (uint16_t) thread_data->header_len,
+    3316             :                                                                 thread_data->header,
+    3317             :                                                                 (uint16_t) thread_data->payload_len);
+    3318             : 
+    3319           0 :     if ((err == DLT_RETURN_BUFFER_FULL) || (err == DLT_RETURN_ERROR)) {
+    3320           0 :         dlt_log(LOG_ERR, "NWTSegmented: Could not send start segment. Aborting.\n");
+    3321           0 :         free(thread_data->header);
+    3322           0 :         free(thread_data->payload);
+    3323           0 :         free(thread_data);
+    3324           0 :         return DLT_RETURN_ERROR;
+    3325             :     }
+    3326             : 
+    3327             :     /* Open queue if it is not open */
+    3328           0 :     if (dlt_init_message_queue() < 0) {
+    3329           0 :         dlt_log(LOG_ERR, "NWTSegmented: Could not open queue.\n");
+    3330           0 :         free(thread_data->header);
+    3331           0 :         free(thread_data->payload);
+    3332           0 :         free(thread_data);
+    3333             : 
+    3334           0 :         return DLT_RETURN_ERROR;
+    3335             :     }
+    3336             : 
+    3337             :     /* Add to queue */
+    3338           0 :     if (mq_send(dlt_user.dlt_segmented_queue_write_handle,
+    3339             :                 (char *)&thread_data, sizeof(s_segmented_data *), 1) < 0) {
+    3340           0 :         if (errno == EAGAIN)
+    3341           0 :             dlt_log(LOG_WARNING, "NWTSegmented: Queue full. Message discarded.\n");
+    3342             : 
+    3343           0 :         free(thread_data->header);
+    3344           0 :         free(thread_data->payload);
+    3345           0 :         free(thread_data);
+    3346           0 :         dlt_vnlog(LOG_WARNING, 256, "NWTSegmented: Could not write into queue: %s \n", strerror(errno));
+    3347           0 :         return DLT_RETURN_ERROR;
+    3348             :     }
+    3349             : 
+    3350             :     /*thread_data will be freed by the receiver function */
+    3351             :     /*coverity[leaked_storage] */
+    3352             :     return DLT_RETURN_OK;
+    3353             : }
+    3354             : 
+    3355          14 : DltReturnValue dlt_user_trace_network(DltContext *handle,
+    3356             :                                       DltNetworkTraceType nw_trace_type,
+    3357             :                                       uint16_t header_len,
+    3358             :                                       void *header,
+    3359             :                                       uint16_t payload_len,
+    3360             :                                       void *payload)
+    3361             : {
+    3362          14 :     return dlt_user_trace_network_truncated(handle, nw_trace_type, header_len, header, payload_len, payload, 1);
+    3363             : }
+    3364             : 
+    3365          21 : DltReturnValue dlt_user_trace_network_truncated(DltContext *handle,
+    3366             :                                                 DltNetworkTraceType nw_trace_type,
+    3367             :                                                 uint16_t header_len,
+    3368             :                                                 void *header,
+    3369             :                                                 uint16_t payload_len,
+    3370             :                                                 void *payload,
+    3371             :                                                 int allow_truncate)
+    3372             : {
+    3373             :     int ret = DLT_RETURN_ERROR;
+    3374          21 :     DltContextData log = { 0 };
+    3375             : 
+    3376          21 :     if ((payload == NULL) && (payload_len > 0))
+    3377             :         return DLT_RETURN_WRONG_PARAMETER;
+    3378             : 
+    3379          15 :     if ((nw_trace_type < DLT_NW_TRACE_IPC) || (nw_trace_type >= DLT_NW_TRACE_MAX)) {
+    3380           0 :         dlt_vlog(LOG_ERR, "Network trace type %u is outside valid range", nw_trace_type);
+    3381           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    3382             :     }
+    3383             : 
+    3384          15 :     if (dlt_user.dlt_ll_ts == NULL)
+    3385             :         return DLT_RETURN_ERROR;
+    3386             : 
+    3387          15 :     if (handle->trace_status_ptr && (*(handle->trace_status_ptr) == DLT_TRACE_STATUS_ON)) {
+    3388           0 :         if ((dlt_user_log_init(handle, &log) < DLT_RETURN_OK) || (dlt_user.dlt_ll_ts == NULL))
+    3389             :             return DLT_RETURN_ERROR;
+    3390             : 
+    3391             :         /* initialize values */
+    3392           0 :         if (log.buffer == NULL) {
+    3393           0 :             log.buffer = calloc(sizeof(unsigned char), dlt_user.log_buf_len);
+    3394             : 
+    3395           0 :             if (log.buffer == NULL) {
+    3396           0 :                 dlt_vlog(LOG_ERR, "Cannot allocate buffer for DLT Log message\n");
+    3397           0 :                 return DLT_RETURN_ERROR;
+    3398             :             }
+    3399             :         }
+    3400             : 
+    3401           0 :         log.args_num = 0;
+    3402           0 :         log.trace_status = nw_trace_type;
+    3403           0 :         log.size = 0;
+    3404             : 
+    3405           0 :         if (header == NULL)
+    3406             :             header_len = 0;
+    3407             : 
+    3408             :         /* If truncation is allowed, check if we must do it */
+    3409           0 :         if ((allow_truncate > 0) && ((header_len + payload_len + sizeof(uint16_t)) > dlt_user.log_buf_len)) {
+    3410             :             /* Identify as truncated */
+    3411           0 :             if (dlt_user_log_write_string(&log, DLT_TRACE_NW_TRUNCATED) < DLT_RETURN_OK) {
+    3412             :                 dlt_user_free_buffer(&(log.buffer));
+    3413           0 :                 return DLT_RETURN_ERROR;
+    3414             :             }
+    3415             : 
+    3416             :             /* Write header and its length */
+    3417           0 :             if (dlt_user_log_write_raw(&log, header, header_len) < DLT_RETURN_OK) {
+    3418             :                 dlt_user_free_buffer(&(log.buffer));
+    3419           0 :                 return DLT_RETURN_ERROR;
+    3420             :             }
+    3421             : 
+    3422             :             /* Write original size of payload */
+    3423           0 :             if (dlt_user_log_write_uint32(&log, payload_len) < DLT_RETURN_OK) {
+    3424             :                 dlt_user_free_buffer(&(log.buffer));
+    3425           0 :                 return DLT_RETURN_ERROR;
+    3426             :             }
+    3427             : 
+    3428             :             /**
+    3429             :              *  Calculate maximum available space in sending buffer after headers.
+    3430             :              */
+    3431             : 
+    3432           0 :             uint16_t truncated_payload_len = (uint16_t) (dlt_user.log_buf_len - log.size - sizeof(uint16_t) - sizeof(uint32_t));
+    3433             : 
+    3434             :             /* Write truncated payload */
+    3435           0 :             if (dlt_user_log_write_raw(&log, payload, truncated_payload_len) < DLT_RETURN_OK) {
+    3436             :                 dlt_user_free_buffer(&(log.buffer));
+    3437           0 :                 return DLT_RETURN_ERROR;
+    3438             :             }
+    3439             :         }
+    3440             :         else { /* Truncation not allowed or data short enough */
+    3441             : 
+    3442             :             /* Write header and its length */
+    3443           0 :             if (dlt_user_log_write_raw(&log, header, header_len) < DLT_RETURN_OK) {
+    3444             :                 dlt_user_free_buffer(&(log.buffer));
+    3445           0 :                 return DLT_RETURN_ERROR;
+    3446             :             }
+    3447             : 
+    3448           0 :             if (payload == NULL)
+    3449             :                 payload_len = 0;
+    3450             : 
+    3451             :             /* Write payload and its length */
+    3452           0 :             if (dlt_user_log_write_raw(&log, payload, payload_len) < DLT_RETURN_OK) {
+    3453             :                 dlt_user_free_buffer(&(log.buffer));
+    3454           0 :                 return DLT_RETURN_ERROR;
+    3455             :             }
+    3456             :         }
+    3457             : 
+    3458           0 :         ret = dlt_user_log_send_log(&log, DLT_TYPE_NW_TRACE);
+    3459             : 
+    3460             :         dlt_user_free_buffer(&(log.buffer));
+    3461             : 
+    3462             :         /* Send log */
+    3463           0 :         return ret;
+    3464             :     }
+    3465             : 
+    3466             :     return DLT_RETURN_OK;
+    3467             : }
+    3468             : #else  /* DLT_NETWORK_TRACE_ENABLE not set */
+    3469             : DltReturnValue dlt_user_trace_network_segmented(DltContext *handle,
+    3470             :                                                 DltNetworkTraceType nw_trace_type,
+    3471             :                                                 uint16_t header_len,
+    3472             :                                                 void *header,
+    3473             :                                                 uint16_t payload_len,
+    3474             :                                                 void *payload)
+    3475             : {
+    3476             :     /**
+    3477             :      *  vsomeip uses the DLT_TRACE_NETWORK_SEGMENTED macro that calls this function.
+    3478             :      *  It's not possible to rewrite this macro directly to a no-op,
+    3479             :      *  because the macro is used on vsomeip side and there our defines are not set.
+    3480             :      *  Add an empty function to the dlt-lib to avoid a broken build.
+    3481             :      */
+    3482             :     (void)handle;
+    3483             :     (void)nw_trace_type;
+    3484             :     (void)header_len;
+    3485             :     (void)header;
+    3486             :     (void)payload_len;
+    3487             :     (void)payload;
+    3488             :     return DLT_RETURN_LOGGING_DISABLED;
+    3489             : }
+    3490             : 
+    3491             : DltReturnValue dlt_user_trace_network_truncated(DltContext *handle,
+    3492             :                                                 DltNetworkTraceType nw_trace_type,
+    3493             :                                                 uint16_t header_len,
+    3494             :                                                 void *header,
+    3495             :                                                 uint16_t payload_len,
+    3496             :                                                 void *payload,
+    3497             :                                                 int allow_truncate)
+    3498             : {
+    3499             :     /**
+    3500             :      *  vsomeip uses the DLT_TRACE_NETWORK_TRUNCATED macro that calls this function.
+    3501             :      *  It's not possible to rewrite this macro directly to a no-op,
+    3502             :      *  because the macro is used on vsomeip side and there our defines are not set.
+    3503             :      *  Add an empty function to the dlt-lib to avoid a broken build.
+    3504             :      */
+    3505             :     (void)handle;
+    3506             :     (void)nw_trace_type;
+    3507             :     (void)header_len;
+    3508             :     (void)header;
+    3509             :     (void)payload_len;
+    3510             :     (void)payload;
+    3511             :     (void)allow_truncate;
+    3512             :     return DLT_RETURN_LOGGING_DISABLED;
+    3513             : }
+    3514             : 
+    3515             : #endif /* DLT_NETWORK_TRACE_ENABLE */
+    3516             : 
+    3517          18 : DltReturnValue dlt_log_string(DltContext *handle, DltLogLevelType loglevel, const char *text)
+    3518             : {
+    3519          18 :     if (!is_verbose_mode(dlt_user.verbose_mode, NULL))
+    3520             :         return DLT_RETURN_ERROR;
+    3521             : 
+    3522          18 :     if ((handle == NULL) || (text == NULL))
+    3523             :         return DLT_RETURN_WRONG_PARAMETER;
+    3524             : 
+    3525             :     DltReturnValue ret = DLT_RETURN_OK;
+    3526             :     DltContextData log;
+    3527             : 
+    3528          15 :     if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE) {
+    3529          11 :         ret = dlt_user_log_write_string(&log, text);
+    3530             : 
+    3531          11 :         if (dlt_user_log_write_finish(&log) < DLT_RETURN_OK)
+    3532             :             ret = DLT_RETURN_ERROR;
+    3533             :     }
+    3534             : 
+    3535             :     return ret;
+    3536             : }
+    3537             : 
+    3538          25 : DltReturnValue dlt_log_string_int(DltContext *handle, DltLogLevelType loglevel, const char *text, int data)
+    3539             : {
+    3540          25 :     if (!is_verbose_mode(dlt_user.verbose_mode, NULL))
+    3541             :         return DLT_RETURN_ERROR;
+    3542             : 
+    3543          25 :     if ((handle == NULL) || (text == NULL))
+    3544             :         return DLT_RETURN_WRONG_PARAMETER;
+    3545             : 
+    3546             :     DltReturnValue ret = DLT_RETURN_OK;
+    3547             :     DltContextData log;
+    3548             : 
+    3549          22 :     if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE) {
+    3550          16 :         ret = dlt_user_log_write_string(&log, text);
+    3551          16 :         dlt_user_log_write_int(&log, data);
+    3552             : 
+    3553          16 :         if (dlt_user_log_write_finish(&log) < DLT_RETURN_OK)
+    3554             :             ret = DLT_RETURN_ERROR;
+    3555             :     }
+    3556             : 
+    3557             :     return ret;
+    3558             : }
+    3559             : 
+    3560          25 : DltReturnValue dlt_log_string_uint(DltContext *handle, DltLogLevelType loglevel, const char *text, unsigned int data)
+    3561             : {
+    3562          25 :     if (!is_verbose_mode(dlt_user.verbose_mode, NULL))
+    3563             :         return DLT_RETURN_ERROR;
+    3564             : 
+    3565          25 :     if ((handle == NULL) || (text == NULL))
+    3566             :         return DLT_RETURN_WRONG_PARAMETER;
+    3567             : 
+    3568             :     DltReturnValue ret = DLT_RETURN_OK;
+    3569             :     DltContextData log;
+    3570             : 
+    3571          22 :     if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE) {
+    3572          16 :         ret = dlt_user_log_write_string(&log, text);
+    3573          16 :         dlt_user_log_write_uint(&log, data);
+    3574             : 
+    3575          16 :         if (dlt_user_log_write_finish(&log) < DLT_RETURN_OK)
+    3576             :             ret = DLT_RETURN_ERROR;
+    3577             :     }
+    3578             : 
+    3579             :     return ret;
+    3580             : }
+    3581             : 
+    3582          22 : DltReturnValue dlt_log_int(DltContext *handle, DltLogLevelType loglevel, int data)
+    3583             : {
+    3584          22 :     if (!is_verbose_mode(dlt_user.verbose_mode, NULL))
+    3585             :         return DLT_RETURN_ERROR;
+    3586             : 
+    3587          22 :     if (handle == NULL)
+    3588             :         return DLT_RETURN_ERROR;
+    3589             : 
+    3590             :     DltContextData log;
+    3591             : 
+    3592          21 :     if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE) {
+    3593          15 :         dlt_user_log_write_int(&log, data);
+    3594             : 
+    3595          15 :         if (dlt_user_log_write_finish(&log) < DLT_RETURN_OK)
+    3596           0 :             return DLT_RETURN_ERROR;
+    3597             :     }
+    3598             : 
+    3599             :     return DLT_RETURN_OK;
+    3600             : }
+    3601             : 
+    3602          22 : DltReturnValue dlt_log_uint(DltContext *handle, DltLogLevelType loglevel, unsigned int data)
+    3603             : {
+    3604          22 :     if (!is_verbose_mode(dlt_user.verbose_mode, NULL))
+    3605             :         return DLT_RETURN_ERROR;
+    3606             : 
+    3607          22 :     if (handle == NULL)
+    3608             :         return DLT_RETURN_WRONG_PARAMETER;
+    3609             : 
+    3610             :     DltContextData log;
+    3611             : 
+    3612          21 :     if (dlt_user_log_write_start(handle, &log, loglevel) == DLT_RETURN_TRUE) {
+    3613          15 :         dlt_user_log_write_uint(&log, data);
+    3614             : 
+    3615          15 :         if (dlt_user_log_write_finish(&log) < DLT_RETURN_OK)
+    3616           0 :             return DLT_RETURN_ERROR;
+    3617             :     }
+    3618             : 
+    3619             :     return DLT_RETURN_OK;
+    3620             : }
+    3621             : 
+    3622          11 : DltReturnValue dlt_log_raw(DltContext *handle, DltLogLevelType loglevel, void *data, uint16_t length)
+    3623             : {
+    3624          11 :     if (!is_verbose_mode(dlt_user.verbose_mode, NULL))
+    3625             :         return DLT_RETURN_ERROR;
+    3626             : 
+    3627          11 :     if (handle == NULL)
+    3628             :         return DLT_RETURN_WRONG_PARAMETER;
+    3629             : 
+    3630             :     DltContextData log;
+    3631             :     DltReturnValue ret = DLT_RETURN_OK;
+    3632             : 
+    3633           9 :     if (dlt_user_log_write_start(handle, &log, loglevel) > 0) {
+    3634           7 :         if ((ret = dlt_user_log_write_raw(&log, data, length)) < DLT_RETURN_OK) {
+    3635             :             dlt_user_free_buffer(&(log.buffer));
+    3636           2 :             return ret;
+    3637             :         }
+    3638             : 
+    3639           5 :         if (dlt_user_log_write_finish(&log) < DLT_RETURN_OK)
+    3640           0 :             return DLT_RETURN_ERROR;
+    3641             :     }
+    3642             : 
+    3643             :     return DLT_RETURN_OK;
+    3644             : }
+    3645             : 
+    3646           1 : DltReturnValue dlt_log_marker()
+    3647             : {
+    3648           1 :     if (!DLT_USER_INITALIZED) {
+    3649           0 :         if (dlt_init() < DLT_RETURN_OK) {
+    3650           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    3651           0 :             return DLT_RETURN_ERROR;
+    3652             :         }
+    3653             :     }
+    3654             : 
+    3655           1 :     return dlt_user_log_send_marker();
+    3656             : }
+    3657             : 
+    3658          10 : DltReturnValue dlt_verbose_mode(void)
+    3659             : {
+    3660          10 :     if (!DLT_USER_INITALIZED) {
+    3661           0 :         if (dlt_init() < DLT_RETURN_OK) {
+    3662           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    3663           0 :             return DLT_RETURN_ERROR;
+    3664             :         }
+    3665             :     }
+    3666             : 
+    3667             :     /* Switch to verbose mode */
+    3668          10 :     dlt_user.verbose_mode = 1;
+    3669             : 
+    3670          10 :     return DLT_RETURN_OK;
+    3671             : }
+    3672             : 
+    3673          10 : DltReturnValue dlt_nonverbose_mode(void)
+    3674             : {
+    3675          10 :     if (!DLT_USER_INITALIZED) {
+    3676           0 :         if (dlt_init() < DLT_RETURN_OK) {
+    3677           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    3678           0 :             return DLT_RETURN_ERROR;
+    3679             :         }
+    3680             :     }
+    3681             : 
+    3682             :     /* Switch to non-verbose mode */
+    3683          10 :     dlt_user.verbose_mode = 0;
+    3684             : 
+    3685          10 :     return DLT_RETURN_OK;
+    3686             : }
+    3687             : 
+    3688           2 : DltReturnValue dlt_use_extended_header_for_non_verbose(int8_t use_extended_header_for_non_verbose)
+    3689             : {
+    3690           2 :     if (!DLT_USER_INITALIZED) {
+    3691           0 :         if (dlt_init() < DLT_RETURN_OK) {
+    3692           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    3693           0 :             return DLT_RETURN_ERROR;
+    3694             :         }
+    3695             :     }
+    3696             : 
+    3697             :     /* Set use_extended_header_for_non_verbose */
+    3698           2 :     dlt_user.use_extended_header_for_non_verbose = use_extended_header_for_non_verbose;
+    3699             : 
+    3700           2 :     return DLT_RETURN_OK;
+    3701             : }
+    3702             : 
+    3703           0 : DltReturnValue dlt_with_session_id(int8_t with_session_id)
+    3704             : {
+    3705           0 :     if (!DLT_USER_INITALIZED) {
+    3706           0 :         if (dlt_init() < DLT_RETURN_OK) {
+    3707           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    3708           0 :             return DLT_RETURN_ERROR;
+    3709             :         }
+    3710             :     }
+    3711             : 
+    3712             :     /* Set use_extended_header_for_non_verbose */
+    3713           0 :     dlt_user.with_session_id = with_session_id;
+    3714             : 
+    3715           0 :     return DLT_RETURN_OK;
+    3716             : }
+    3717             : 
+    3718           0 : DltReturnValue dlt_with_timestamp(int8_t with_timestamp)
+    3719             : {
+    3720           0 :     if (!DLT_USER_INITALIZED) {
+    3721           0 :         if (dlt_init() < DLT_RETURN_OK) {
+    3722           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    3723           0 :             return DLT_RETURN_ERROR;
+    3724             :         }
+    3725             :     }
+    3726             : 
+    3727             :     /* Set with_timestamp */
+    3728           0 :     dlt_user.with_timestamp = with_timestamp;
+    3729             : 
+    3730           0 :     return DLT_RETURN_OK;
+    3731             : }
+    3732             : 
+    3733           0 : DltReturnValue dlt_with_ecu_id(int8_t with_ecu_id)
+    3734             : {
+    3735           0 :     if (!DLT_USER_INITALIZED) {
+    3736           0 :         if (dlt_init() < DLT_RETURN_OK) {
+    3737           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    3738           0 :             return DLT_RETURN_ERROR;
+    3739             :         }
+    3740             :     }
+    3741             : 
+    3742             :     /* Set with_timestamp */
+    3743           0 :     dlt_user.with_ecu_id = with_ecu_id;
+    3744             : 
+    3745           0 :     return DLT_RETURN_OK;
+    3746             : }
+    3747             : 
+    3748           0 : DltReturnValue dlt_enable_local_print(void)
+    3749             : {
+    3750           0 :     if (!DLT_USER_INITALIZED) {
+    3751           0 :         if (dlt_init() < DLT_RETURN_OK) {
+    3752           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    3753           0 :             return DLT_RETURN_ERROR;
+    3754             :         }
+    3755             :     }
+    3756             : 
+    3757           0 :     dlt_user.enable_local_print = 1;
+    3758             : 
+    3759           0 :     return DLT_RETURN_OK;
+    3760             : }
+    3761             : 
+    3762           0 : DltReturnValue dlt_disable_local_print(void)
+    3763             : {
+    3764           0 :     if (!DLT_USER_INITALIZED) {
+    3765           0 :         if (dlt_init() < DLT_RETURN_OK) {
+    3766           0 :             dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    3767           0 :             return DLT_RETURN_ERROR;
+    3768             :         }
+    3769             :     }
+    3770             : 
+    3771           0 :     dlt_user.enable_local_print = 0;
+    3772             : 
+    3773           0 :     return DLT_RETURN_OK;
+    3774             : }
+    3775             : 
+    3776             : /* Cleanup on thread cancellation, thread may hold lock release it here */
+    3777       13374 : static void dlt_user_cleanup_handler(void *arg)
+    3778             : {
+    3779             :     DLT_UNUSED(arg); /* Satisfy compiler */
+    3780             : 
+    3781             : #ifdef DLT_NETWORK_TRACE_ENABLE
+    3782             :     /* unlock the message queue */
+    3783       13374 :     dlt_unlock_mutex(&mq_mutex);
+    3784             : #endif
+    3785             : 
+    3786             :     /* unlock DLT (dlt_mutex) */
+    3787       13374 :     DLT_SEM_FREE();
+    3788       13374 : }
+    3789             : 
+    3790        6687 : void dlt_user_housekeeperthread_function(void *ptr)
+    3791             : {
+    3792             :     struct timespec ts;
+    3793             :     bool in_loop = true;
+    3794             :     int signal_status = 0;
+    3795             :     atomic_bool* dlt_housekeeper_running = (atomic_bool*)ptr;
+    3796             : 
+    3797             : #ifdef __ANDROID_API__
+    3798             :     sigset_t set;
+    3799             :     sigset_t pset;
+    3800             :     /*
+    3801             :      * bionic is not supporting pthread_cancel so
+    3802             :      * use SIGUSR1 to kill thread properly.
+    3803             :      */
+    3804             :     sigemptyset(&set);
+    3805             :     sigaddset(&set, SIGUSR1);
+    3806             :     if (pthread_sigmask(SIG_BLOCK, &set, NULL) != 0) {
+    3807             :         dlt_vlog(LOG_ERR, "Failed to block signal with error [%s]\n",
+    3808             :                 strerror(errno));
+    3809             :         in_loop = false;
+    3810             :     }
+    3811             : #endif
+    3812             : 
+    3813             : #ifdef DLT_USE_PTHREAD_SETNAME_NP
+    3814        6687 :     if (pthread_setname_np(dlt_housekeeperthread_handle, "dlt_housekeeper"))
+    3815           0 :         dlt_log(LOG_WARNING, "Failed to rename housekeeper thread!\n");
+    3816             : #elif linux
+    3817             :     if (prctl(PR_SET_NAME, "dlt_housekeeper", 0, 0, 0) < 0)
+    3818             :         dlt_log(LOG_WARNING, "Failed to rename housekeeper thread!\n");
+    3819             : #endif
+    3820             : 
+    3821       13374 :     pthread_cleanup_push(dlt_user_cleanup_handler, NULL);
+    3822             : 
+    3823             :     // signal dlt thread to be running
+    3824        6687 :     *dlt_housekeeper_running = true;
+    3825        6687 :     signal_status = pthread_cond_signal(&dlt_housekeeper_running_cond);
+    3826        6687 :     if (signal_status != 0) {
+    3827           0 :         dlt_log(LOG_CRIT, "Housekeeper thread failed to signal running state\n");
+    3828             :     }
+    3829             : 
+    3830             :     while (in_loop) {
+    3831             :         /* Check for new messages from DLT daemon */
+    3832        6688 :         if (!dlt_user.disable_injection_msg)
+    3833        6688 :             if (dlt_user_log_check_user_message() < DLT_RETURN_OK)
+    3834             :                 /* Critical error */
+    3835           0 :                 dlt_log(LOG_CRIT, "Housekeeper thread encountered error condition\n");
+    3836             : 
+    3837             :         /* Reattach to daemon if neccesary */
+    3838           1 :         dlt_user_log_reattach_to_daemon();
+    3839             : 
+    3840             :         /* flush buffer to DLT daemon if possible */
+    3841           1 :         if (dlt_user.dlt_log_handle != DLT_FD_INIT)
+    3842           0 :             dlt_user_log_resend_buffer();
+    3843             : 
+    3844             : #ifdef __ANDROID_API__
+    3845             :         if (sigpending(&pset)) {
+    3846             :             dlt_vlog(LOG_ERR, "sigpending failed with error [%s]!\n", strerror(errno));
+    3847             :             break;
+    3848             :         }
+    3849             : 
+    3850             :         if (sigismember(&pset, SIGUSR1)) {
+    3851             :             dlt_log(LOG_NOTICE, "Received SIGUSR1! Stop thread\n");
+    3852             :             break;
+    3853             :         }
+    3854             : #endif
+    3855             : 
+    3856             :         /* delay */
+    3857           1 :         ts.tv_sec = 0;
+    3858           1 :         ts.tv_nsec = DLT_USER_RECEIVE_NDELAY;
+    3859           1 :         nanosleep(&ts, NULL);
+    3860             :     }
+    3861             : 
+    3862             :     pthread_cleanup_pop(1);
+    3863             : }
+    3864             : 
+    3865             : /* Private functions of user library */
+    3866             : 
+    3867         522 : DltReturnValue dlt_user_log_init(DltContext *handle, DltContextData *log)
+    3868             : {
+    3869             :     int ret = DLT_RETURN_OK;
+    3870             : 
+    3871         522 :     if ((handle == NULL) || (log == NULL))
+    3872             :         return DLT_RETURN_WRONG_PARAMETER;
+    3873             : 
+    3874         522 :     if (!DLT_USER_INITALIZED) {
+    3875           0 :         ret = dlt_init();
+    3876             : 
+    3877           0 :         if (ret < DLT_RETURN_OK) {
+    3878           0 :             if (ret != DLT_RETURN_LOGGING_DISABLED)
+    3879           0 :                 dlt_vlog(LOG_ERR, "%s Failed to initialise dlt", __FUNCTION__);
+    3880             : 
+    3881           0 :             return ret;
+    3882             :         }
+    3883             :     }
+    3884             : 
+    3885         522 :     log->handle = handle;
+    3886         522 :     log->buffer = NULL;
+    3887         522 :     return ret;
+    3888             : }
+    3889             : 
+    3890         195 : DltReturnValue dlt_user_log_send_log(DltContextData *log, int mtype)
+    3891             : {
+    3892             :     DltMessage msg;
+    3893             :     DltUserHeader userheader;
+    3894             :     int32_t len;
+    3895             : 
+    3896             :     DltReturnValue ret = DLT_RETURN_OK;
+    3897             : 
+    3898         195 :     if (!DLT_USER_INITALIZED) {
+    3899           0 :         dlt_vlog(LOG_WARNING, "%s dlt_user_init_state != INIT_DONE\n", __FUNCTION__);
+    3900           0 :         return DLT_RETURN_ERROR;
+    3901             :     }
+    3902             : 
+    3903         195 :     if ((log == NULL) ||
+    3904         195 :         (log->handle == NULL) ||
+    3905         186 :         (log->handle->contextID[0] == '\0') ||
+    3906         186 :         (mtype < DLT_TYPE_LOG) || (mtype > DLT_TYPE_CONTROL)
+    3907             :         )
+    3908             :         return DLT_RETURN_WRONG_PARAMETER;
+    3909             : 
+    3910             :     /* also for Trace messages */
+    3911         186 :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_LOG) < DLT_RETURN_OK)
+    3912             :         return DLT_RETURN_ERROR;
+    3913             : 
+    3914         186 :     if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+    3915             :         return DLT_RETURN_ERROR;
+    3916             : 
+    3917         186 :     msg.storageheader = (DltStorageHeader *)msg.headerbuffer;
+    3918             : 
+    3919         186 :     if (dlt_set_storageheader(msg.storageheader, dlt_user.ecuID) == DLT_RETURN_ERROR)
+    3920             :         return DLT_RETURN_ERROR;
+    3921             : 
+    3922         186 :     msg.standardheader = (DltStandardHeader *)(msg.headerbuffer + sizeof(DltStorageHeader));
+    3923         186 :     msg.standardheader->htyp = DLT_HTYP_PROTOCOL_VERSION1;
+    3924             : 
+    3925             :     /* send ecu id */
+    3926         186 :     if (dlt_user.with_ecu_id)
+    3927         186 :         msg.standardheader->htyp |= DLT_HTYP_WEID;
+    3928             : 
+    3929             :     /* send timestamp */
+    3930         186 :     if (dlt_user.with_timestamp)
+    3931         186 :         msg.standardheader->htyp |= DLT_HTYP_WTMS;
+    3932             : 
+    3933             :     /* send session id */
+    3934         186 :     if (dlt_user.with_session_id) {
+    3935         186 :         msg.standardheader->htyp |= DLT_HTYP_WSID;
+    3936         186 :         msg.headerextra.seid = (uint32_t) getpid();
+    3937             :     }
+    3938             : 
+    3939         196 :     if (is_verbose_mode(dlt_user.verbose_mode, log))
+    3940             :         /* In verbose mode, send extended header */
+    3941         183 :         msg.standardheader->htyp = (msg.standardheader->htyp | DLT_HTYP_UEH);
+    3942             :     else
+    3943             :         /* In non-verbose, send extended header if desired */
+    3944           3 :         if (dlt_user.use_extended_header_for_non_verbose)
+    3945           2 :             msg.standardheader->htyp = (msg.standardheader->htyp | DLT_HTYP_UEH);
+    3946             : 
+    3947             : #if (BYTE_ORDER == BIG_ENDIAN)
+    3948             :     msg.standardheader->htyp = (msg.standardheader->htyp | DLT_HTYP_MSBF);
+    3949             : #endif
+    3950             : 
+    3951         186 :     msg.standardheader->mcnt = log->handle->mcnt++;
+    3952             : 
+    3953             :     /* Set header extra parameters */
+    3954         186 :     dlt_set_id(msg.headerextra.ecu, dlt_user.ecuID);
+    3955             : 
+    3956             :     /*msg.headerextra.seid = 0; */
+    3957         186 :     if (log->use_timestamp == DLT_AUTO_TIMESTAMP) {
+    3958         185 :         msg.headerextra.tmsp = dlt_uptime();
+    3959             :     }
+    3960             :     else {
+    3961           1 :         msg.headerextra.tmsp = log->user_timestamp;
+    3962             :     }
+    3963             : 
+    3964         186 :     if (dlt_message_set_extraparameters(&msg, 0) == DLT_RETURN_ERROR)
+    3965             :         return DLT_RETURN_ERROR;
+    3966             : 
+    3967             :     /* Fill out extended header, if extended header should be provided */
+    3968         186 :     if (DLT_IS_HTYP_UEH(msg.standardheader->htyp)) {
+    3969             :         /* with extended header */
+    3970         185 :         msg.extendedheader =
+    3971         185 :             (DltExtendedHeader *)(msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+    3972         185 :                                   DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp));
+    3973             : 
+    3974         185 :         switch (mtype) {
+    3975         185 :         case DLT_TYPE_LOG:
+    3976             :         {
+    3977         185 :             msg.extendedheader->msin = (uint8_t) (DLT_TYPE_LOG << DLT_MSIN_MSTP_SHIFT |
+    3978         185 :                 ((log->log_level << DLT_MSIN_MTIN_SHIFT) & DLT_MSIN_MTIN));
+    3979         185 :             break;
+    3980             :         }
+    3981           0 :         case DLT_TYPE_NW_TRACE:
+    3982             :         {
+    3983           0 :             msg.extendedheader->msin = (uint8_t) (DLT_TYPE_NW_TRACE << DLT_MSIN_MSTP_SHIFT |
+    3984           0 :                 ((log->trace_status << DLT_MSIN_MTIN_SHIFT) & DLT_MSIN_MTIN));
+    3985           0 :             break;
+    3986             :         }
+    3987             :         default:
+    3988             :         {
+    3989             :             /* This case should not occur */
+    3990             :             return DLT_RETURN_ERROR;
+    3991             :             break;
+    3992             :         }
+    3993             :         }
+    3994             : 
+    3995             :         /* If in verbose mode, set flag in header for verbose mode */
+    3996         194 :         if (is_verbose_mode(dlt_user.verbose_mode, log))
+    3997         183 :             msg.extendedheader->msin |= DLT_MSIN_VERB;
+    3998             : 
+    3999         185 :         msg.extendedheader->noar = (uint8_t) log->args_num;              /* number of arguments */
+    4000         185 :         dlt_set_id(msg.extendedheader->apid, dlt_user.appID);       /* application id */
+    4001         185 :         dlt_set_id(msg.extendedheader->ctid, log->handle->contextID);   /* context id */
+    4002             : 
+    4003         185 :         msg.headersize = (uint32_t) (sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) +
+    4004         185 :             DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp));
+    4005             :     }
+    4006             :     else {
+    4007             :         /* without extended header */
+    4008           1 :         msg.headersize = (uint32_t) (sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + DLT_STANDARD_HEADER_EXTRA_SIZE(
+    4009             :             msg.standardheader->htyp));
+    4010             :     }
+    4011             : 
+    4012         186 :     len = (int32_t) (msg.headersize - sizeof(DltStorageHeader) + log->size);
+    4013             : 
+    4014         186 :     if (len > UINT16_MAX) {
+    4015           0 :         dlt_log(LOG_WARNING, "Huge message discarded!\n");
+    4016           0 :         return DLT_RETURN_ERROR;
+    4017             :     }
+    4018             : 
+    4019         186 :     msg.standardheader->len = DLT_HTOBE_16(len);
+    4020             : 
+    4021             :     /* print to std out, if enabled */
+    4022         186 :     if ((dlt_user.local_print_mode != DLT_PM_FORCE_OFF) &&
+    4023             :         (dlt_user.local_print_mode != DLT_PM_AUTOMATIC)) {
+    4024         186 :         if ((dlt_user.enable_local_print) || (dlt_user.local_print_mode == DLT_PM_FORCE_ON))
+    4025           0 :             if (dlt_user_print_msg(&msg, log) == DLT_RETURN_ERROR)
+    4026             :                 return DLT_RETURN_ERROR;
+    4027             :     }
+    4028             : 
+    4029         186 :     if (dlt_user.dlt_is_file) {
+    4030           0 :         if (dlt_user_file_reach_max) {
+    4031             :             return DLT_RETURN_FILESZERR;
+    4032             :         }
+    4033             :         else {
+    4034             :             /* Get file size */
+    4035             :             struct stat st;
+    4036           0 :             fstat(dlt_user.dlt_log_handle, &st);
+    4037           0 :             dlt_vlog(LOG_DEBUG, "%s: Current file size=[%ld]\n", __func__,
+    4038             :                      st.st_size);
+    4039             : 
+    4040             :             /* Check filesize */
+    4041             :             /* Return error if the file size has reached to maximum */
+    4042           0 :             unsigned int msg_size = st.st_size + (unsigned int) msg.headersize +
+    4043           0 :                                     (unsigned int) log->size;
+    4044           0 :             if (msg_size > dlt_user.filesize_max) {
+    4045           0 :                 dlt_user_file_reach_max = true;
+    4046           0 :                 dlt_vlog(LOG_ERR,
+    4047             :                          "%s: File size (%ld bytes) reached to defined maximum size (%d bytes)\n",
+    4048             :                          __func__, st.st_size, dlt_user.filesize_max);
+    4049           0 :                 return DLT_RETURN_FILESZERR;
+    4050             :             }
+    4051             :             else {
+    4052             :                 /* log to file */
+    4053           0 :                 ret = dlt_user_log_out2(dlt_user.dlt_log_handle,
+    4054             :                                         msg.headerbuffer, msg.headersize,
+    4055           0 :                                         log->buffer, log->size);
+    4056           0 :                 return ret;
+    4057             :             }
+    4058             :         }
+    4059             :     } else {
+    4060         186 :         if (dlt_user.overflow_counter) {
+    4061           0 :             if (dlt_user_log_send_overflow() == DLT_RETURN_OK) {
+    4062           0 :                 dlt_vnlog(LOG_WARNING, DLT_USER_BUFFER_LENGTH, "%u messages discarded!\n", dlt_user.overflow_counter);
+    4063           0 :                 dlt_user.overflow_counter = 0;
+    4064             :             }
+    4065             :         }
+    4066             : 
+    4067             :         /* try to resent old data first */
+    4068             :         ret = DLT_RETURN_OK;
+    4069             : 
+    4070         186 :         if ((dlt_user.dlt_log_handle != -1) && (dlt_user.appID[0] != '\0'))
+    4071           0 :             ret = dlt_user_log_resend_buffer();
+    4072             : 
+    4073         186 :         if ((ret == DLT_RETURN_OK) && (dlt_user.appID[0] != '\0')) {
+    4074             :             /* resend ok or nothing to resent */
+    4075             : #ifdef DLT_SHM_ENABLE
+    4076             : 
+    4077             :             if (dlt_user.dlt_log_handle != -1)
+    4078             :                 dlt_shm_push(&dlt_user.dlt_shm, msg.headerbuffer + sizeof(DltStorageHeader),
+    4079             :                              msg.headersize - sizeof(DltStorageHeader),
+    4080             :                              log->buffer, log->size, 0, 0);
+    4081             : 
+    4082             :             ret = dlt_user_log_out3(dlt_user.dlt_log_handle,
+    4083             :                                     &(userheader), sizeof(DltUserHeader),
+    4084             :                                     0, 0,
+    4085             :                                     0, 0);
+    4086             : #else
+    4087             : #   ifdef DLT_TEST_ENABLE
+    4088             : 
+    4089             :             if (dlt_user.corrupt_user_header) {
+    4090             :                 userheader.pattern[0] = (char) 0xff;
+    4091             :                 userheader.pattern[1] = (char) 0xff;
+    4092             :                 userheader.pattern[2] = (char) 0xff;
+    4093             :                 userheader.pattern[3] = (char) 0xff;
+    4094             :             }
+    4095             : 
+    4096             :             if (dlt_user.corrupt_message_size)
+    4097             :                 msg.standardheader->len = DLT_HTOBE_16(dlt_user.corrupt_message_size_size);
+    4098             : 
+    4099             : #   endif
+    4100             : 
+    4101         186 :             ret = dlt_user_log_out3(dlt_user.dlt_log_handle,
+    4102             :                                     &(userheader), sizeof(DltUserHeader),
+    4103             :                                     msg.headerbuffer + sizeof(DltStorageHeader),
+    4104         186 :                                     msg.headersize - sizeof(DltStorageHeader),
+    4105         186 :                                     log->buffer, log->size);
+    4106             : #endif
+    4107             :         }
+    4108             : 
+    4109             :         DltReturnValue process_error_ret = DLT_RETURN_OK;
+    4110             :         /* store message in ringbuffer, if an error has occured */
+    4111         186 :         if ((ret != DLT_RETURN_OK) || (dlt_user.appID[0] == '\0'))
+    4112         186 :             process_error_ret = dlt_user_log_out_error_handling(&(userheader),
+    4113             :                                                   sizeof(DltUserHeader),
+    4114             :                                                   msg.headerbuffer + sizeof(DltStorageHeader),
+    4115         186 :                                                   msg.headersize - sizeof(DltStorageHeader),
+    4116         186 :                                                   log->buffer,
+    4117         186 :                                                   log->size);
+    4118             : 
+    4119         186 :         if (process_error_ret == DLT_RETURN_OK)
+    4120         186 :             return DLT_RETURN_OK;
+    4121           0 :         if (process_error_ret == DLT_RETURN_BUFFER_FULL) {
+    4122             :             /* Buffer full */
+    4123           0 :             dlt_user.overflow_counter += 1;
+    4124           0 :             return DLT_RETURN_BUFFER_FULL;
+    4125             :         }
+    4126             : 
+    4127             :         /* handle return value of function dlt_user_log_out3() when process_error_ret < 0*/
+    4128           0 :         switch (ret) {
+    4129             :             case DLT_RETURN_PIPE_FULL:
+    4130             :             {
+    4131             :                 /* data could not be written */
+    4132             :                 return DLT_RETURN_PIPE_FULL;
+    4133             :             }
+    4134           0 :             case DLT_RETURN_PIPE_ERROR:
+    4135             :             {
+    4136             :                 /* handle not open or pipe error */
+    4137           0 :                 close(dlt_user.dlt_log_handle);
+    4138           0 :                 dlt_user.dlt_log_handle = -1;
+    4139             : #if defined DLT_LIB_USE_UNIX_SOCKET_IPC || defined DLT_LIB_USE_VSOCK_IPC
+    4140             :             dlt_user.connection_state = DLT_USER_RETRY_CONNECT;
+    4141             : #endif
+    4142             : 
+    4143             :     #ifdef DLT_SHM_ENABLE
+    4144             :             /* free shared memory */
+    4145             :             dlt_shm_free_client(&dlt_user.dlt_shm);
+    4146             :     #endif
+    4147             : 
+    4148           0 :             if (dlt_user.local_print_mode == DLT_PM_AUTOMATIC)
+    4149           0 :                 dlt_user_print_msg(&msg, log);
+    4150             : 
+    4151           0 :             return DLT_RETURN_PIPE_ERROR;
+    4152             :         }
+    4153           0 :         case DLT_RETURN_ERROR:
+    4154             :         {
+    4155             :             /* other error condition */
+    4156           0 :             return DLT_RETURN_ERROR;
+    4157             :         }
+    4158           0 :         case DLT_RETURN_OK:
+    4159             :         {
+    4160           0 :             return DLT_RETURN_OK;
+    4161             :         }
+    4162           0 :         default:
+    4163             :         {
+    4164             :             /* This case should never occur. */
+    4165           0 :             return DLT_RETURN_ERROR;
+    4166             :         }
+    4167             :         }
+    4168             :     }
+    4169             : 
+    4170             :     return DLT_RETURN_OK;
+    4171             : }
+    4172             : 
+    4173         164 : DltReturnValue dlt_user_log_send_register_application(void)
+    4174             : {
+    4175             :     DltUserHeader userheader;
+    4176             :     DltUserControlMsgRegisterApplication usercontext;
+    4177             : 
+    4178             :     DltReturnValue ret;
+    4179             : 
+    4180         164 :     if (dlt_user.appID[0] == '\0')
+    4181             :         return DLT_RETURN_ERROR;
+    4182             : 
+    4183             :     /* set userheader */
+    4184         164 :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_REGISTER_APPLICATION) < DLT_RETURN_OK)
+    4185             :         return DLT_RETURN_ERROR;
+    4186             : 
+    4187             :     /* set usercontext */
+    4188         164 :     dlt_set_id(usercontext.apid, dlt_user.appID);       /* application id */
+    4189         164 :     usercontext.pid = getpid();
+    4190             : 
+    4191         164 :     if (dlt_user.application_description != NULL)
+    4192         164 :         usercontext.description_length = (uint32_t) strlen(dlt_user.application_description);
+    4193             :     else
+    4194           0 :         usercontext.description_length = 0;
+    4195             : 
+    4196         164 :     if (dlt_user.dlt_is_file)
+    4197             :         return DLT_RETURN_OK;
+    4198             : 
+    4199         164 :     ret = dlt_user_log_out3(dlt_user.dlt_log_handle,
+    4200             :                             &(userheader), sizeof(DltUserHeader),
+    4201             :                             &(usercontext), sizeof(DltUserControlMsgRegisterApplication),
+    4202         164 :                             dlt_user.application_description, usercontext.description_length);
+    4203             : 
+    4204             :     /* store message in ringbuffer, if an error has occured */
+    4205         164 :     if (ret < DLT_RETURN_OK)
+    4206         164 :         return dlt_user_log_out_error_handling(&(userheader),
+    4207             :                                                sizeof(DltUserHeader),
+    4208             :                                                &(usercontext),
+    4209             :                                                sizeof(DltUserControlMsgRegisterApplication),
+    4210         164 :                                                dlt_user.application_description,
+    4211         164 :                                                usercontext.description_length);
+    4212             : 
+    4213             :     return DLT_RETURN_OK;
+    4214             : }
+    4215             : 
+    4216         167 : DltReturnValue dlt_user_log_send_unregister_application(void)
+    4217             : {
+    4218             :     DltUserHeader userheader;
+    4219             :     DltUserControlMsgUnregisterApplication usercontext;
+    4220             :     DltReturnValue ret = DLT_RETURN_OK;
+    4221             : 
+    4222         167 :     if (dlt_user.appID[0] == '\0')
+    4223             :         return DLT_RETURN_ERROR;
+    4224             : 
+    4225             :     /* set userheader */
+    4226         164 :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_UNREGISTER_APPLICATION) < DLT_RETURN_OK)
+    4227             :         return DLT_RETURN_ERROR;
+    4228             : 
+    4229             :     /* set usercontext */
+    4230         164 :     dlt_set_id(usercontext.apid, dlt_user.appID);       /* application id */
+    4231         164 :     usercontext.pid = getpid();
+    4232             : 
+    4233         164 :     if (dlt_user.dlt_is_file)
+    4234             :         return DLT_RETURN_OK;
+    4235             : 
+    4236         164 :     ret = dlt_user_log_out2(dlt_user.dlt_log_handle,
+    4237             :                             &(userheader), sizeof(DltUserHeader),
+    4238             :                             &(usercontext), sizeof(DltUserControlMsgUnregisterApplication));
+    4239             : 
+    4240             :     /* store message in ringbuffer, if an error has occured */
+    4241         164 :     if (ret < DLT_RETURN_OK)
+    4242         164 :         return dlt_user_log_out_error_handling(&(userheader),
+    4243             :                                                sizeof(DltUserHeader),
+    4244             :                                                &(usercontext),
+    4245             :                                                sizeof(DltUserControlMsgUnregisterApplication),
+    4246             :                                                NULL,
+    4247             :                                                0);
+    4248             : 
+    4249             :     return DLT_RETURN_OK;
+    4250             : }
+    4251             : 
+    4252         167 : DltReturnValue dlt_user_log_send_register_context(DltContextData *log)
+    4253             : {
+    4254             :     DltUserHeader userheader;
+    4255             :     DltUserControlMsgRegisterContext usercontext;
+    4256             :     DltReturnValue ret = DLT_RETURN_ERROR;
+    4257             : 
+    4258         167 :     if (log == NULL)
+    4259             :         return DLT_RETURN_WRONG_PARAMETER;
+    4260             : 
+    4261         167 :     if (log->handle == NULL)
+    4262             :         return DLT_RETURN_ERROR;
+    4263             : 
+    4264         167 :     if (log->handle->contextID[0] == '\0')
+    4265             :         return DLT_RETURN_ERROR;
+    4266             : 
+    4267             :     /* set userheader */
+    4268         167 :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_REGISTER_CONTEXT) < DLT_RETURN_OK)
+    4269             :         return DLT_RETURN_ERROR;
+    4270             : 
+    4271             :     /* set usercontext */
+    4272         167 :     dlt_set_id(usercontext.apid, dlt_user.appID);       /* application id */
+    4273         167 :     dlt_set_id(usercontext.ctid, log->handle->contextID);       /* context id */
+    4274         167 :     usercontext.log_level_pos = log->handle->log_level_pos;
+    4275         167 :     usercontext.pid = getpid();
+    4276             : 
+    4277         167 :     usercontext.log_level = (int8_t) log->log_level;
+    4278         167 :     usercontext.trace_status = (int8_t) log->trace_status;
+    4279             : 
+    4280         167 :     if (log->context_description != NULL)
+    4281         167 :         usercontext.description_length = (uint32_t) strlen(log->context_description);
+    4282             :     else
+    4283           0 :         usercontext.description_length = 0;
+    4284             : 
+    4285         167 :     if (dlt_user.dlt_is_file)
+    4286             :         return DLT_RETURN_OK;
+    4287             : 
+    4288         167 :     if (dlt_user.appID[0] != '\0')
+    4289             :         ret =
+    4290         167 :             dlt_user_log_out3(dlt_user.dlt_log_handle,
+    4291             :                               &(userheader),
+    4292             :                               sizeof(DltUserHeader),
+    4293             :                               &(usercontext),
+    4294             :                               sizeof(DltUserControlMsgRegisterContext),
+    4295             :                               log->context_description,
+    4296         167 :                               usercontext.description_length);
+    4297             : 
+    4298             :     /* store message in ringbuffer, if an error has occured */
+    4299         167 :     if ((ret != DLT_RETURN_OK) || (dlt_user.appID[0] == '\0'))
+    4300         167 :         return dlt_user_log_out_error_handling(&(userheader),
+    4301             :                                                sizeof(DltUserHeader),
+    4302             :                                                &(usercontext),
+    4303             :                                                sizeof(DltUserControlMsgRegisterContext),
+    4304         167 :                                                log->context_description,
+    4305         167 :                                                usercontext.description_length);
+    4306             : 
+    4307             :     return DLT_RETURN_OK;
+    4308             : 
+    4309             : }
+    4310             : 
+    4311         166 : DltReturnValue dlt_user_log_send_unregister_context(DltContextData *log)
+    4312             : {
+    4313             :     DltUserHeader userheader;
+    4314             :     DltUserControlMsgUnregisterContext usercontext;
+    4315             :     DltReturnValue ret;
+    4316             : 
+    4317         166 :     if (log == NULL)
+    4318             :         return DLT_RETURN_WRONG_PARAMETER;
+    4319             : 
+    4320         166 :     if (log->handle == NULL)
+    4321             :         return DLT_RETURN_WRONG_PARAMETER;
+    4322             : 
+    4323         166 :     if (log->handle->contextID[0] == '\0')
+    4324             :         return DLT_RETURN_ERROR;
+    4325             : 
+    4326             :     /* set userheader */
+    4327         166 :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_UNREGISTER_CONTEXT) < DLT_RETURN_OK)
+    4328             :         return DLT_RETURN_ERROR;
+    4329             : 
+    4330             :     /* set usercontext */
+    4331         166 :     dlt_set_id(usercontext.apid, dlt_user.appID);       /* application id */
+    4332         166 :     dlt_set_id(usercontext.ctid, log->handle->contextID);       /* context id */
+    4333         166 :     usercontext.pid = getpid();
+    4334             : 
+    4335         166 :     if (dlt_user.dlt_is_file)
+    4336             :         return DLT_RETURN_OK;
+    4337             : 
+    4338         166 :     ret = dlt_user_log_out2(dlt_user.dlt_log_handle,
+    4339             :                             &(userheader),
+    4340             :                             sizeof(DltUserHeader),
+    4341             :                             &(usercontext),
+    4342             :                             sizeof(DltUserControlMsgUnregisterContext));
+    4343             : 
+    4344             :     /* store message in ringbuffer, if an error has occured */
+    4345         166 :     if (ret < DLT_RETURN_OK)
+    4346         166 :         return dlt_user_log_out_error_handling(&(userheader),
+    4347             :                                                sizeof(DltUserHeader),
+    4348             :                                                &(usercontext),
+    4349             :                                                sizeof(DltUserControlMsgUnregisterContext),
+    4350             :                                                NULL,
+    4351             :                                                0);
+    4352             : 
+    4353             :     return DLT_RETURN_OK;
+    4354             : }
+    4355             : 
+    4356           0 : DltReturnValue dlt_send_app_ll_ts_limit(const char *apid, DltLogLevelType loglevel, DltTraceStatusType tracestatus)
+    4357             : {
+    4358             :     DltUserHeader userheader;
+    4359             :     DltUserControlMsgAppLogLevelTraceStatus usercontext;
+    4360             :     DltReturnValue ret;
+    4361             : 
+    4362           0 :     if ((loglevel < DLT_USER_LOG_LEVEL_NOT_SET) || (loglevel >= DLT_LOG_MAX)) {
+    4363           0 :         dlt_vlog(LOG_ERR, "Loglevel %d is outside valid range", loglevel);
+    4364           0 :         return DLT_RETURN_ERROR;
+    4365             :     }
+    4366             : 
+    4367           0 :     if ((tracestatus < DLT_USER_TRACE_STATUS_NOT_SET) || (tracestatus >= DLT_TRACE_STATUS_MAX)) {
+    4368           0 :         dlt_vlog(LOG_ERR, "Tracestatus %d is outside valid range", tracestatus);
+    4369           0 :         return DLT_RETURN_ERROR;
+    4370             :     }
+    4371             : 
+    4372           0 :     if ((apid == NULL) || (apid[0] == '\0'))
+    4373             :         return DLT_RETURN_ERROR;
+    4374             : 
+    4375             :     /* set userheader */
+    4376           0 :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_APP_LL_TS) < DLT_RETURN_OK)
+    4377             :         return DLT_RETURN_ERROR;
+    4378             : 
+    4379             :     /* set usercontext */
+    4380           0 :     dlt_set_id(usercontext.apid, apid);       /* application id */
+    4381           0 :     usercontext.log_level = loglevel;
+    4382           0 :     usercontext.trace_status = tracestatus;
+    4383             : 
+    4384           0 :     if (dlt_user.dlt_is_file)
+    4385             :         return DLT_RETURN_OK;
+    4386             : 
+    4387           0 :     ret = dlt_user_log_out2(dlt_user.dlt_log_handle,
+    4388             :                             &(userheader), sizeof(DltUserHeader),
+    4389             :                             &(usercontext), sizeof(DltUserControlMsgAppLogLevelTraceStatus));
+    4390             : 
+    4391             :     /* store message in ringbuffer, if an error has occured */
+    4392           0 :     if (ret < DLT_RETURN_OK)
+    4393           0 :         return dlt_user_log_out_error_handling(&(userheader),
+    4394             :                                                sizeof(DltUserHeader),
+    4395             :                                                &(usercontext),
+    4396             :                                                sizeof(DltUserControlMsgAppLogLevelTraceStatus),
+    4397             :                                                NULL,
+    4398             :                                                0);
+    4399             : 
+    4400             :     return DLT_RETURN_OK;
+    4401             : }
+    4402             : 
+    4403           4 : DltReturnValue dlt_user_log_send_log_mode(DltUserLogMode mode)
+    4404             : {
+    4405             :     DltUserHeader userheader;
+    4406             :     DltUserControlMsgLogMode logmode;
+    4407             :     DltReturnValue ret;
+    4408             : 
+    4409           4 :     if ((mode < DLT_USER_MODE_UNDEFINED) || (mode >= DLT_USER_MODE_MAX)) {
+    4410           0 :         dlt_vlog(LOG_ERR, "User log mode %d is outside valid range", mode);
+    4411           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    4412             :     }
+    4413             : 
+    4414             :     /* set userheader */
+    4415           4 :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_LOG_MODE) < DLT_RETURN_OK)
+    4416             :         return DLT_RETURN_ERROR;
+    4417             : 
+    4418             :     /* set data */
+    4419           4 :     logmode.log_mode = (unsigned char)mode;
+    4420             : 
+    4421           4 :     if (dlt_user.dlt_is_file)
+    4422             :         return DLT_RETURN_OK;
+    4423             : 
+    4424           4 :     ret = dlt_user_log_out2(dlt_user.dlt_log_handle,
+    4425             :                             &(userheader), sizeof(DltUserHeader),
+    4426             :                             &(logmode), sizeof(DltUserControlMsgLogMode));
+    4427             : 
+    4428             :     /* store message in ringbuffer, if an error has occured */
+    4429           4 :     if (ret < DLT_RETURN_OK)
+    4430           4 :         return dlt_user_log_out_error_handling(&(userheader),
+    4431             :                                                sizeof(DltUserHeader),
+    4432             :                                                &(logmode),
+    4433             :                                                sizeof(DltUserControlMsgLogMode),
+    4434             :                                                NULL,
+    4435             :                                                0);
+    4436             : 
+    4437             :     return DLT_RETURN_OK;
+    4438             : }
+    4439             : 
+    4440           1 : DltReturnValue dlt_user_log_send_marker()
+    4441             : {
+    4442             :     DltUserHeader userheader;
+    4443             :     DltReturnValue ret;
+    4444             : 
+    4445             :     /* set userheader */
+    4446           1 :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_MARKER) < DLT_RETURN_OK)
+    4447             :         return DLT_RETURN_ERROR;
+    4448             : 
+    4449           1 :     if (dlt_user.dlt_is_file)
+    4450             :         return DLT_RETURN_OK;
+    4451             : 
+    4452             :     /* log to FIFO */
+    4453           1 :     ret = dlt_user_log_out2(dlt_user.dlt_log_handle,
+    4454             :                             &(userheader), sizeof(DltUserHeader), 0, 0);
+    4455             : 
+    4456             :     /* store message in ringbuffer, if an error has occured */
+    4457           1 :     if (ret < DLT_RETURN_OK)
+    4458           1 :         return dlt_user_log_out_error_handling(&(userheader),
+    4459             :                                                sizeof(DltUserHeader),
+    4460             :                                                NULL,
+    4461             :                                                0,
+    4462             :                                                NULL,
+    4463             :                                                0);
+    4464             : 
+    4465             :     return DLT_RETURN_OK;
+    4466             : }
+    4467             : 
+    4468           0 : DltReturnValue dlt_user_print_msg(DltMessage *msg, DltContextData *log)
+    4469             : {
+    4470             :     uint8_t *databuffer_tmp;
+    4471             :     uint32_t datasize_tmp;
+    4472             :     uint32_t databuffersize_tmp;
+    4473             :     static char text[DLT_USER_TEXT_LENGTH];
+    4474             : 
+    4475           0 :     if ((msg == NULL) || (log == NULL))
+    4476             :         return DLT_RETURN_WRONG_PARAMETER;
+    4477             : 
+    4478             :     /* Save variables before print */
+    4479           0 :     databuffer_tmp = msg->databuffer;
+    4480           0 :     datasize_tmp = msg->datasize;
+    4481           0 :     databuffersize_tmp = msg->databuffersize;
+    4482             : 
+    4483             :     /* Act like a receiver, convert header back to host format */
+    4484           0 :     msg->standardheader->len = DLT_BETOH_16(msg->standardheader->len);
+    4485           0 :     dlt_message_get_extraparameters(msg, 0);
+    4486             : 
+    4487           0 :     msg->databuffer = log->buffer;
+    4488           0 :     msg->datasize = (uint32_t) log->size;
+    4489           0 :     msg->databuffersize = (uint32_t) log->size;
+    4490             : 
+    4491             :     /* Print message as ASCII */
+    4492           0 :     if (dlt_message_print_ascii(msg, text, DLT_USER_TEXT_LENGTH, 0) == DLT_RETURN_ERROR)
+    4493             :         return DLT_RETURN_ERROR;
+    4494             : 
+    4495             :     /* Restore variables and set len to BE*/
+    4496           0 :     msg->databuffer = databuffer_tmp;
+    4497           0 :     msg->databuffersize = databuffersize_tmp;
+    4498           0 :     msg->datasize = datasize_tmp;
+    4499             : 
+    4500           0 :     msg->standardheader->len = DLT_HTOBE_16(msg->standardheader->len);
+    4501             : 
+    4502           0 :     return DLT_RETURN_OK;
+    4503             : }
+    4504             : 
+    4505        6688 : DltReturnValue dlt_user_log_check_user_message(void)
+    4506             : {
+    4507             :     int offset = 0;
+    4508             :     int leave_while = 0;
+    4509             :     int ret = 0;
+    4510             : 
+    4511             :     uint32_t i;
+    4512             :     int fd;
+    4513             :     struct pollfd nfd[1];
+    4514             : 
+    4515             :     DltUserHeader *userheader;
+    4516             :     DltReceiver *receiver = &(dlt_user.receiver);
+    4517             : 
+    4518             :     DltUserControlMsgLogLevel *usercontextll;
+    4519             :     DltUserControlMsgInjection *usercontextinj;
+    4520             :     DltUserControlMsgLogState *userlogstate;
+    4521             :     unsigned char *userbuffer;
+    4522             : 
+    4523             :     /* For delayed calling of injection callback, to avoid deadlock */
+    4524             :     DltUserInjectionCallback delayed_injection_callback;
+    4525             :     DltUserLogLevelChangedCallback delayed_log_level_changed_callback;
+    4526             :     unsigned char *delayed_inject_buffer = 0;
+    4527             :     uint32_t delayed_inject_data_length = 0;
+    4528             : 
+    4529             :     /* Ensure that callback is null before searching for it */
+    4530             :     delayed_injection_callback.injection_callback = 0;
+    4531             :     delayed_injection_callback.injection_callback_with_id = 0;
+    4532             :     delayed_injection_callback.service_id = 0;
+    4533        6688 :     delayed_log_level_changed_callback.log_level_changed_callback = 0;
+    4534             :     delayed_injection_callback.data = 0;
+    4535             : 
+    4536             : #if defined DLT_LIB_USE_UNIX_SOCKET_IPC || defined DLT_LIB_USE_VSOCK_IPC
+    4537             :     fd = dlt_user.dlt_log_handle;
+    4538             : #else /* DLT_LIB_USE_FIFO_IPC */
+    4539        6688 :     fd = dlt_user.dlt_user_handle;
+    4540             : #endif
+    4541        6688 :     nfd[0].events = POLLIN;
+    4542        6688 :     nfd[0].fd = fd;
+    4543             : 
+    4544        6688 :     if (fd >= 0) {
+    4545             :         ret = poll(nfd, 1, DLT_USER_RECEIVE_MDELAY);
+    4546           1 :         if (ret) {
+    4547           0 :             if (nfd[0].revents & (POLLHUP | POLLNVAL | POLLERR)) {
+    4548           0 :                 dlt_user.dlt_log_handle = DLT_FD_INIT;
+    4549           0 :                 return DLT_RETURN_ERROR;
+    4550             :             }
+    4551             : 
+    4552           0 :             if (dlt_receiver_receive(receiver) <= 0)
+    4553             :                 /* No new message available */
+    4554             :                 return DLT_RETURN_OK;
+    4555             : 
+    4556             :             /* look through buffer as long as data is in there */
+    4557             :             while (1) {
+    4558           0 :                 if (receiver->bytesRcvd < (int32_t) sizeof(DltUserHeader))
+    4559             :                     break;
+    4560             : 
+    4561             :                 /* resync if necessary */
+    4562             :                 offset = 0;
+    4563             : 
+    4564             :                 do {
+    4565           0 :                     userheader = (DltUserHeader *)(receiver->buf + offset);
+    4566             : 
+    4567             :                     /* Check for user header pattern */
+    4568           0 :                     if (dlt_user_check_userheader(userheader))
+    4569             :                         break;
+    4570             : 
+    4571           0 :                     offset++;
+    4572             : 
+    4573           0 :                 } while (((int32_t) (sizeof(DltUserHeader)) + offset) <= receiver->bytesRcvd);
+    4574             : 
+    4575             :                 /* Check for user header pattern */
+    4576           0 :                 if ((dlt_user_check_userheader(userheader) < 0) ||
+    4577           0 :                     (dlt_user_check_userheader(userheader) == 0))
+    4578             :                     break;
+    4579             : 
+    4580             :                 /* Set new start offset */
+    4581           0 :                 if (offset > 0) {
+    4582           0 :                     receiver->buf += offset;
+    4583           0 :                     receiver->bytesRcvd -= offset;
+    4584             :                 }
+    4585             : 
+    4586           0 :                 switch (userheader->message) {
+    4587           0 :                 case DLT_USER_MESSAGE_LOG_LEVEL:
+    4588             :                 {
+    4589           0 :                     if (receiver->bytesRcvd < (int32_t) (sizeof(DltUserHeader) + sizeof(DltUserControlMsgLogLevel))) {
+    4590             :                         leave_while = 1;
+    4591             :                         break;
+    4592             :                     }
+    4593             : 
+    4594           0 :                     usercontextll = (DltUserControlMsgLogLevel *)(receiver->buf + sizeof(DltUserHeader));
+    4595             : 
+    4596             :                     /* Update log level and trace status */
+    4597           0 :                     if (usercontextll != NULL) {
+    4598           0 :                         DLT_SEM_LOCK();
+    4599             : 
+    4600           0 :                         if ((usercontextll->log_level_pos >= 0) &&
+    4601           0 :                             (usercontextll->log_level_pos < (int32_t)dlt_user.dlt_ll_ts_num_entries)) {
+    4602           0 :                             if (dlt_user.dlt_ll_ts) {
+    4603           0 :                                 dlt_user.dlt_ll_ts[usercontextll->log_level_pos].log_level = (int8_t) usercontextll->log_level;
+    4604           0 :                                 dlt_user.dlt_ll_ts[usercontextll->log_level_pos].trace_status =
+    4605           0 :                                     (int8_t) usercontextll->trace_status;
+    4606             : 
+    4607           0 :                                 if (dlt_user.dlt_ll_ts[usercontextll->log_level_pos].log_level_ptr)
+    4608           0 :                                     *(dlt_user.dlt_ll_ts[usercontextll->log_level_pos].log_level_ptr) =
+    4609             :                                         (int8_t) usercontextll->log_level;
+    4610             : 
+    4611           0 :                                 if (dlt_user.dlt_ll_ts[usercontextll->log_level_pos].trace_status_ptr)
+    4612           0 :                                     *(dlt_user.dlt_ll_ts[usercontextll->log_level_pos].trace_status_ptr) =
+    4613           0 :                                         (int8_t) usercontextll->trace_status;
+    4614             : 
+    4615           0 :                                 delayed_log_level_changed_callback.log_level_changed_callback =
+    4616           0 :                                     dlt_user.dlt_ll_ts[usercontextll->log_level_pos].log_level_changed_callback;
+    4617             :                                 memcpy(delayed_log_level_changed_callback.contextID,
+    4618             :                                        dlt_user.dlt_ll_ts[usercontextll->log_level_pos].contextID, DLT_ID_SIZE);
+    4619           0 :                                 delayed_log_level_changed_callback.log_level = (int8_t) usercontextll->log_level;
+    4620           0 :                                 delayed_log_level_changed_callback.trace_status = (int8_t) usercontextll->trace_status;
+    4621             :                             }
+    4622             :                         }
+    4623             : 
+    4624           0 :                         DLT_SEM_FREE();
+    4625             :                     }
+    4626             : 
+    4627             :                     /* call callback outside of semaphore */
+    4628           0 :                     if (delayed_log_level_changed_callback.log_level_changed_callback != 0)
+    4629           0 :                         delayed_log_level_changed_callback.log_level_changed_callback(
+    4630             :                             delayed_log_level_changed_callback.contextID,
+    4631           0 :                             (uint8_t) delayed_log_level_changed_callback.log_level,
+    4632           0 :                             (uint8_t) delayed_log_level_changed_callback.trace_status);
+    4633             : 
+    4634             :                     /* keep not read data in buffer */
+    4635           0 :                     if (dlt_receiver_remove(receiver,
+    4636             :                                             sizeof(DltUserHeader) + sizeof(DltUserControlMsgLogLevel)) ==
+    4637             :                         DLT_RETURN_ERROR)
+    4638             :                         return DLT_RETURN_ERROR;
+    4639             :                 }
+    4640             :                 break;
+    4641           0 :                 case DLT_USER_MESSAGE_INJECTION:
+    4642             :                 {
+    4643             :                     /* At least, user header, user context, and service id and data_length of injected message is available */
+    4644           0 :                     if (receiver->bytesRcvd < (int32_t) (sizeof(DltUserHeader) + sizeof(DltUserControlMsgInjection))) {
+    4645             :                         leave_while = 1;
+    4646             :                         break;
+    4647             :                     }
+    4648             : 
+    4649           0 :                     usercontextinj = (DltUserControlMsgInjection *)(receiver->buf + sizeof(DltUserHeader));
+    4650           0 :                     userbuffer =
+    4651             :                         (unsigned char *)(receiver->buf + sizeof(DltUserHeader) + sizeof(DltUserControlMsgInjection));
+    4652             : 
+    4653           0 :                     if (userbuffer != NULL) {
+    4654             : 
+    4655           0 :                         if (receiver->bytesRcvd <
+    4656           0 :                             (int32_t) (sizeof(DltUserHeader) + sizeof(DltUserControlMsgInjection) +
+    4657           0 :                                       usercontextinj->data_length_inject)) {
+    4658             :                             leave_while = 1;
+    4659             :                             break;
+    4660             :                         }
+    4661             : 
+    4662           0 :                         DLT_SEM_LOCK();
+    4663             : 
+    4664           0 :                         if ((usercontextinj->data_length_inject > 0) && (dlt_user.dlt_ll_ts))
+    4665             :                             /* Check if injection callback is registered for this context */
+    4666           0 :                             for (i = 0; i < dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].nrcallbacks; i++)
+    4667           0 :                                 if ((dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table) &&
+    4668           0 :                                     (dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].service_id ==
+    4669           0 :                                      usercontextinj->service_id)) {
+    4670             :                                     /* Prepare delayed injection callback call */
+    4671           0 :                                     if (dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].
+    4672             :                                         injection_callback != NULL) {
+    4673             :                                         delayed_injection_callback.injection_callback =
+    4674             :                                             dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].
+    4675             :                                             injection_callback;
+    4676             :                                     }
+    4677           0 :                                     else if (dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].
+    4678             :                                              injection_callback_with_id != NULL)
+    4679             :                                     {
+    4680             :                                         delayed_injection_callback.injection_callback_with_id =
+    4681             :                                             dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].
+    4682             :                                             injection_callback_with_id;
+    4683             :                                         delayed_injection_callback.data =
+    4684           0 :                                             dlt_user.dlt_ll_ts[usercontextinj->log_level_pos].injection_table[i].data;
+    4685             :                                     }
+    4686             : 
+    4687             :                                     delayed_injection_callback.service_id = usercontextinj->service_id;
+    4688             :                                     delayed_inject_data_length = usercontextinj->data_length_inject;
+    4689           0 :                                     delayed_inject_buffer = malloc(delayed_inject_data_length);
+    4690             : 
+    4691           0 :                                     if (delayed_inject_buffer != NULL) {
+    4692             :                                         memcpy(delayed_inject_buffer, userbuffer, delayed_inject_data_length);
+    4693             :                                     }
+    4694             :                                     else {
+    4695           0 :                                         DLT_SEM_FREE();
+    4696           0 :                                         dlt_log(LOG_WARNING, "malloc failed!\n");
+    4697           0 :                                         return DLT_RETURN_ERROR;
+    4698             :                                     }
+    4699             : 
+    4700             :                                     break;
+    4701             :                                 }
+    4702             : 
+    4703           0 :                         DLT_SEM_FREE();
+    4704             : 
+    4705             :                         /* Delayed injection callback call */
+    4706           0 :                         if ((delayed_inject_buffer != NULL) &&
+    4707             :                             (delayed_injection_callback.injection_callback != NULL)) {
+    4708           0 :                             delayed_injection_callback.injection_callback(delayed_injection_callback.service_id,
+    4709             :                                                                           delayed_inject_buffer,
+    4710             :                                                                           delayed_inject_data_length);
+    4711           0 :                             delayed_injection_callback.injection_callback = NULL;
+    4712             :                         }
+    4713           0 :                         else if ((delayed_inject_buffer != NULL) &&
+    4714             :                                  (delayed_injection_callback.injection_callback_with_id != NULL))
+    4715             :                         {
+    4716           0 :                             delayed_injection_callback.injection_callback_with_id(delayed_injection_callback.service_id,
+    4717             :                                                                                   delayed_inject_buffer,
+    4718             :                                                                                   delayed_inject_data_length,
+    4719             :                                                                                   delayed_injection_callback.data);
+    4720             :                             delayed_injection_callback.injection_callback_with_id = NULL;
+    4721             :                         }
+    4722             : 
+    4723           0 :                         free(delayed_inject_buffer);
+    4724             :                         delayed_inject_buffer = NULL;
+    4725             : 
+    4726             :                         /* keep not read data in buffer */
+    4727           0 :                         if (dlt_receiver_remove(receiver,
+    4728             :                                                 (int) (sizeof(DltUserHeader) +
+    4729           0 :                                                  sizeof(DltUserControlMsgInjection) +
+    4730           0 :                                                  usercontextinj->data_length_inject)) != DLT_RETURN_OK)
+    4731             :                             return DLT_RETURN_ERROR;
+    4732             :                     }
+    4733             :                 }
+    4734             :                 break;
+    4735           0 :                 case DLT_USER_MESSAGE_LOG_STATE:
+    4736             :                 {
+    4737             :                     /* At least, user header, user context, and service id and data_length of injected message is available */
+    4738           0 :                     if (receiver->bytesRcvd < (int32_t) (sizeof(DltUserHeader) + sizeof(DltUserControlMsgLogState))) {
+    4739             :                         leave_while = 1;
+    4740             :                         break;
+    4741             :                     }
+    4742             : 
+    4743           0 :                     userlogstate = (DltUserControlMsgLogState *)(receiver->buf + sizeof(DltUserHeader));
+    4744           0 :                     dlt_user.log_state = userlogstate->log_state;
+    4745             : 
+    4746             :                     /* keep not read data in buffer */
+    4747           0 :                     if (dlt_receiver_remove(receiver,
+    4748             :                                             (sizeof(DltUserHeader) + sizeof(DltUserControlMsgLogState))) ==
+    4749             :                         DLT_RETURN_ERROR)
+    4750             :                         return DLT_RETURN_ERROR;
+    4751             :                 }
+    4752             :                 break;
+    4753           0 :                 default:
+    4754             :                 {
+    4755           0 :                     dlt_log(LOG_WARNING, "Invalid user message type received!\n");
+    4756             :                     /* Ignore result */
+    4757           0 :                     dlt_receiver_remove(receiver, sizeof(DltUserHeader));
+    4758             :                     /* In next invocation of while loop, a resync will be triggered if additional data was received */
+    4759             :                 }
+    4760           0 :                 break;
+    4761             :                 } /* switch() */
+    4762             : 
+    4763             :                 if (leave_while == 1) {
+    4764             :                     leave_while = 0;
+    4765             :                     break;
+    4766             :                 }
+    4767             :             } /* while buffer*/
+    4768             : 
+    4769           0 :             if (dlt_receiver_move_to_begin(receiver) == DLT_RETURN_ERROR)
+    4770           0 :                 return DLT_RETURN_ERROR;
+    4771             :         } /* while receive */
+    4772             : 
+    4773             :     } /* if */
+    4774             : 
+    4775             :     return DLT_RETURN_OK;
+    4776             : }
+    4777             : 
+    4778           0 : DltReturnValue dlt_user_log_resend_buffer(void)
+    4779           0 : {
+    4780             :     int num, count;
+    4781             :     int size;
+    4782             :     DltReturnValue ret;
+    4783             : 
+    4784           0 :     DLT_SEM_LOCK();
+    4785             : 
+    4786           0 :     if (dlt_user.appID[0] == '\0') {
+    4787           0 :         DLT_SEM_FREE();
+    4788           0 :         return 0;
+    4789             :     }
+    4790             : 
+    4791             :     /* Send content of ringbuffer */
+    4792           0 :     count = dlt_buffer_get_message_count(&(dlt_user.startup_buffer));
+    4793           0 :     DLT_SEM_FREE();
+    4794             : 
+    4795           0 :     for (num = 0; num < count; num++) {
+    4796             : 
+    4797           0 :         DLT_SEM_LOCK();
+    4798           0 :         size = dlt_buffer_copy(&(dlt_user.startup_buffer), dlt_user.resend_buffer, dlt_user.log_buf_len);
+    4799             : 
+    4800           0 :         if (size > 0) {
+    4801           0 :             DltUserHeader *userheader = (DltUserHeader *)(dlt_user.resend_buffer);
+    4802             : 
+    4803             :             /* Add application id to the messages of needed*/
+    4804           0 :             if (dlt_user_check_userheader(userheader)) {
+    4805           0 :                 switch (userheader->message) {
+    4806           0 :                 case DLT_USER_MESSAGE_REGISTER_CONTEXT:
+    4807             :                 {
+    4808             :                     DltUserControlMsgRegisterContext *usercontext =
+    4809           0 :                         (DltUserControlMsgRegisterContext *)(dlt_user.resend_buffer + sizeof(DltUserHeader));
+    4810             : 
+    4811           0 :                     if ((usercontext != 0) && (usercontext->apid[0] == '\0'))
+    4812           0 :                         dlt_set_id(usercontext->apid, dlt_user.appID);
+    4813             : 
+    4814             :                     break;
+    4815             :                 }
+    4816           0 :                 case DLT_USER_MESSAGE_LOG:
+    4817             :                 {
+    4818             :                     DltExtendedHeader *extendedHeader =
+    4819           0 :                         (DltExtendedHeader *)(dlt_user.resend_buffer + sizeof(DltUserHeader) +
+    4820             :                                               sizeof(DltStandardHeader) +
+    4821             :                                               sizeof(DltStandardHeaderExtra));
+    4822             : 
+    4823           0 :                     if (((extendedHeader) != 0) && (extendedHeader->apid[0] == '\0')) /* if application id is empty, add it */
+    4824           0 :                         dlt_set_id(extendedHeader->apid, dlt_user.appID);
+    4825             : 
+    4826             :                     break;
+    4827             :                 }
+    4828             :                 default:
+    4829             :                 {
+    4830             :                     break;
+    4831             :                 }
+    4832             :                 }
+    4833             :             }
+    4834             : 
+    4835             : #ifdef DLT_SHM_ENABLE
+    4836             :             dlt_shm_push(&dlt_user.dlt_shm,
+    4837             :                          dlt_user.resend_buffer + sizeof(DltUserHeader),
+    4838             :                          size - sizeof(DltUserHeader),
+    4839             :                          0,
+    4840             :                          0,
+    4841             :                          0,
+    4842             :                          0);
+    4843             : 
+    4844             :             ret = dlt_user_log_out3(dlt_user.dlt_log_handle, dlt_user.resend_buffer, sizeof(DltUserHeader), 0, 0, 0, 0);
+    4845             : #else
+    4846           0 :             ret = dlt_user_log_out3(dlt_user.dlt_log_handle, dlt_user.resend_buffer, (size_t) size, 0, 0, 0, 0);
+    4847             : #endif
+    4848             : 
+    4849             :             /* in case of error, keep message in ringbuffer */
+    4850           0 :             if (ret == DLT_RETURN_OK) {
+    4851           0 :                 dlt_buffer_remove(&(dlt_user.startup_buffer));
+    4852             :             }
+    4853             :             else {
+    4854           0 :                 if (ret == DLT_RETURN_PIPE_ERROR) {
+    4855             :                     /* handle not open or pipe error */
+    4856           0 :                     close(dlt_user.dlt_log_handle);
+    4857           0 :                     dlt_user.dlt_log_handle = -1;
+    4858             :                 }
+    4859             : 
+    4860             :                 /* keep message in ringbuffer */
+    4861           0 :                 DLT_SEM_FREE();
+    4862           0 :                 return ret;
+    4863             :             }
+    4864             :         }
+    4865             : 
+    4866           0 :         DLT_SEM_FREE();
+    4867             :     }
+    4868             : 
+    4869             :     return DLT_RETURN_OK;
+    4870             : }
+    4871             : 
+    4872           1 : void dlt_user_log_reattach_to_daemon(void)
+    4873             : {
+    4874             :     uint32_t num;
+    4875             :     DltContext handle;
+    4876             :     DltContextData log_new;
+    4877             : 
+    4878           1 :     if (dlt_user.dlt_log_handle < 0) {
+    4879           1 :         dlt_user.dlt_log_handle = DLT_FD_INIT;
+    4880             : 
+    4881             : #ifdef DLT_LIB_USE_UNIX_SOCKET_IPC
+    4882             :         /* try to open connection to dlt daemon */
+    4883             :         dlt_initialize_socket_connection();
+    4884             : 
+    4885             :         if (dlt_user.connection_state != DLT_USER_CONNECTED)
+    4886             :             /* return if not connected */
+    4887             :             return;
+    4888             : 
+    4889             : #elif defined DLT_LIB_USE_VSOCK_IPC
+    4890             :         dlt_initialize_vsock_connection();
+    4891             : 
+    4892             :         if (dlt_user.connection_state != DLT_USER_CONNECTED)
+    4893             :             return;
+    4894             : 
+    4895             : #else /* DLT_LIB_USE_FIFO_IPC */
+    4896             :         /* try to open pipe to dlt daemon */
+    4897             :         int fd = open(dlt_daemon_fifo, O_WRONLY | O_NONBLOCK);
+    4898             : 
+    4899           1 :         if (fd < 0)
+    4900           1 :             return;
+    4901             : 
+    4902           0 :         dlt_user.dlt_log_handle = fd;
+    4903             : #endif
+    4904             : 
+    4905           0 :         if (dlt_user_log_init(&handle, &log_new) < DLT_RETURN_OK)
+    4906             :             return;
+    4907             : 
+    4908             : #ifdef DLT_SHM_ENABLE
+    4909             : 
+    4910             :         /* init shared memory */
+    4911             :         if (dlt_shm_init_client(&dlt_user.dlt_shm, dltShmName) < DLT_RETURN_OK)
+    4912             :             dlt_vnlog(LOG_WARNING, DLT_USER_BUFFER_LENGTH, "Logging disabled,"
+    4913             :                       " Shared memory %s cannot be created!\n", dltShmName);
+    4914             : 
+    4915             : #endif
+    4916             : 
+    4917           0 :         dlt_log(LOG_NOTICE, "Logging (re-)enabled!\n");
+    4918             : 
+    4919             :         /* Re-register application */
+    4920           0 :         if (dlt_user_log_send_register_application() < DLT_RETURN_ERROR)
+    4921             :             return;
+    4922             : 
+    4923           0 :         DLT_SEM_LOCK();
+    4924             : 
+    4925             :         /* Re-register all stored contexts */
+    4926           0 :         for (num = 0; num < dlt_user.dlt_ll_ts_num_entries; num++)
+    4927             :             /* Re-register stored context */
+    4928           0 :             if ((dlt_user.appID[0] != '\0') && (dlt_user.dlt_ll_ts) && (dlt_user.dlt_ll_ts[num].contextID[0] != '\0')) {
+    4929             :                 /*dlt_set_id(log_new.appID, dlt_user.appID); */
+    4930           0 :                 dlt_set_id(handle.contextID, dlt_user.dlt_ll_ts[num].contextID);
+    4931           0 :                 handle.log_level_pos = (int32_t) num;
+    4932           0 :                 log_new.context_description = dlt_user.dlt_ll_ts[num].context_description;
+    4933             : 
+    4934             :                 /* Release the mutex for sending context registration: */
+    4935             :                 /* function  dlt_user_log_send_register_context() can take the mutex to write to the DLT buffer. => dead lock */
+    4936           0 :                 DLT_SEM_FREE();
+    4937             : 
+    4938           0 :                 log_new.log_level = DLT_USER_LOG_LEVEL_NOT_SET;
+    4939           0 :                 log_new.trace_status = DLT_USER_TRACE_STATUS_NOT_SET;
+    4940             : 
+    4941           0 :                 if (dlt_user_log_send_register_context(&log_new) < DLT_RETURN_ERROR)
+    4942             :                     return;
+    4943             : 
+    4944             :                 /* Lock again the mutex */
+    4945             :                 /* it is necessary in the for(;;) test, in order to have coherent dlt_user data all over the critical section. */
+    4946           0 :                 DLT_SEM_LOCK();
+    4947             :             }
+    4948           0 :         DLT_SEM_FREE();
+    4949             :     }
+    4950             : }
+    4951             : 
+    4952           0 : DltReturnValue dlt_user_log_send_overflow(void)
+    4953             : {
+    4954             :     DltUserHeader userheader;
+    4955             :     DltUserControlMsgBufferOverflow userpayload;
+    4956             : 
+    4957             :     /* set userheader */
+    4958           0 :     if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_OVERFLOW) < DLT_RETURN_OK)
+    4959             :         return DLT_RETURN_ERROR;
+    4960             : 
+    4961           0 :     if (dlt_user.dlt_is_file)
+    4962             :         return DLT_RETURN_OK;
+    4963             : 
+    4964             :     /* set user message parameters */
+    4965           0 :     userpayload.overflow_counter = dlt_user.overflow_counter;
+    4966           0 :     dlt_set_id(userpayload.apid, dlt_user.appID);
+    4967             : 
+    4968           0 :     return dlt_user_log_out2(dlt_user.dlt_log_handle,
+    4969             :                              &(userheader), sizeof(DltUserHeader),
+    4970             :                              &(userpayload), sizeof(DltUserControlMsgBufferOverflow));
+    4971             : }
+    4972             : 
+    4973           0 : DltReturnValue dlt_user_check_buffer(int *total_size, int *used_size)
+    4974           0 : {
+    4975           0 :     if ((total_size == NULL) || (used_size == NULL))
+    4976             :         return DLT_RETURN_WRONG_PARAMETER;
+    4977             : 
+    4978           0 :     DLT_SEM_LOCK();
+    4979             : 
+    4980             : #ifdef DLT_SHM_ENABLE
+    4981             :     *total_size = dlt_shm_get_total_size(&(dlt_user.dlt_shm));
+    4982             :     *used_size = dlt_shm_get_used_size(&(dlt_user.dlt_shm));
+    4983             : #else
+    4984           0 :     *total_size = (int) dlt_buffer_get_total_size(&(dlt_user.startup_buffer));
+    4985           0 :     *used_size = dlt_buffer_get_used_size(&(dlt_user.startup_buffer));
+    4986             : #endif
+    4987             : 
+    4988           0 :     DLT_SEM_FREE();
+    4989           0 :     return DLT_RETURN_OK; /* ok */
+    4990             : }
+    4991             : 
+    4992             : #ifdef DLT_TEST_ENABLE
+    4993             : void dlt_user_test_corrupt_user_header(int enable)
+    4994             : {
+    4995             :     dlt_user.corrupt_user_header = enable;
+    4996             : }
+    4997             : void dlt_user_test_corrupt_message_size(int enable, int16_t size)
+    4998             : {
+    4999             :     dlt_user.corrupt_message_size = enable;
+    5000             :     dlt_user.corrupt_message_size_size = size;
+    5001             : }
+    5002             : #endif
+    5003             : 
+    5004             : 
+    5005        6687 : int dlt_start_threads()
+    5006             : {
+    5007             :     struct timespec time_to_wait, single_wait;
+    5008             :     struct timespec now;
+    5009             :     int signal_status = 1;
+    5010        6687 :     atomic_bool dlt_housekeeper_running = false;
+    5011             : 
+    5012             :     /*
+    5013             :     * Configure the condition varibale to use CLOCK_MONOTONIC.
+    5014             :     * This makes sure we're protected against changes in the system clock
+    5015             :      */
+    5016             :     pthread_condattr_t attr;
+    5017        6687 :     pthread_condattr_init(&attr);
+    5018        6687 :     pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
+    5019        6687 :     pthread_cond_init(&dlt_housekeeper_running_cond, &attr);
+    5020             : 
+    5021        6687 :     if (pthread_create(&(dlt_housekeeperthread_handle),
+    5022             :                        0,
+    5023             :                        (void *)&dlt_user_housekeeperthread_function,
+    5024             :                        &dlt_housekeeper_running) != 0) {
+    5025           0 :         dlt_log(LOG_CRIT, "Can't create housekeeper thread!\n");
+    5026           0 :         return -1;
+    5027             :     }
+    5028             : 
+    5029        6687 :     clock_gettime(CLOCK_MONOTONIC, &now);
+    5030             :     /* wait at most 10s */
+    5031        6687 :     time_to_wait.tv_sec = now.tv_sec + 10;
+    5032             :     time_to_wait.tv_nsec = now.tv_nsec;
+    5033             : 
+    5034             :     /*
+    5035             :     * wait until the house keeper is up and running
+    5036             :     * Even though the condition variable and the while are
+    5037             :     * using the same time out the while loop is not a no op.
+    5038             :     * This is due to the fact that the pthread_cond_timedwait
+    5039             :     * can be woken before time is up and dlt_housekeeper_running is not true yet.
+    5040             :     * (spurious wakeup)
+    5041             :     * To protect against this, a while loop with a timeout is added
+    5042             :     * */
+    5043        6687 :     while (!dlt_housekeeper_running
+    5044    15221329 :            && now.tv_sec <= time_to_wait.tv_sec) {
+    5045             : 
+    5046             :         /*
+    5047             :         * wait 500ms at a time
+    5048             :         * this makes sure we don't block too long
+    5049             :         * even if we missed the signal
+    5050             :          */
+    5051    15215210 :         clock_gettime(CLOCK_MONOTONIC, &now);
+    5052    15215210 :         single_wait.tv_sec = now.tv_sec;
+    5053    15215210 :         single_wait.tv_nsec = now.tv_nsec + 500000000;
+    5054             : 
+    5055             :         // pthread_cond_timedwait has to be called on a locked mutex
+    5056    15215210 :         pthread_mutex_lock(&dlt_housekeeper_running_mutex);
+    5057    15215210 :         signal_status = pthread_cond_timedwait(
+    5058             :             &dlt_housekeeper_running_cond,
+    5059             :             &dlt_housekeeper_running_mutex,
+    5060             :             &single_wait);
+    5061    15215210 :         pthread_mutex_unlock(&dlt_housekeeper_running_mutex);
+    5062             : 
+    5063             :         /* otherwise it might be a spurious wakeup, try again until the time is over */
+    5064    15215210 :         if (signal_status == 0) {
+    5065             :             break;
+    5066             :         }
+    5067             :      }
+    5068             : 
+    5069        6687 :      if (signal_status != 0 && !dlt_housekeeper_running) {
+    5070           0 :          dlt_log(LOG_CRIT, "Failed to wait for house keeper thread!\n");
+    5071           0 :          dlt_stop_threads();
+    5072           0 :          return -1;
+    5073             :      }
+    5074             : 
+    5075             : #ifdef DLT_NETWORK_TRACE_ENABLE
+    5076             :     /* Start the segmented thread */
+    5077        6687 :     if (pthread_create(&(dlt_user.dlt_segmented_nwt_handle), NULL,
+    5078             :                        (void *)dlt_user_trace_network_segmented_thread, NULL)) {
+    5079           0 :         dlt_log(LOG_CRIT, "Can't start segmented thread!\n");
+    5080           0 :         return -1;
+    5081             :     }
+    5082             : #endif
+    5083             :     return 0;
+    5084             : }
+    5085             : 
+    5086        6687 : void dlt_stop_threads()
+    5087             : {
+    5088             :     int dlt_housekeeperthread_result = 0;
+    5089             :     int joined = 0;
+    5090             : 
+    5091        6687 :     if (dlt_housekeeperthread_handle) {
+    5092             :         /* do not ignore return value */
+    5093             : #ifndef __ANDROID_API__
+    5094        6687 :         dlt_housekeeperthread_result = pthread_cancel(dlt_housekeeperthread_handle);
+    5095             : #else
+    5096             : 
+    5097             : #ifdef DLT_NETWORK_TRACE_ENABLE
+    5098             :         dlt_lock_mutex(&mq_mutex);
+    5099             : #endif /* DLT_NETWORK_TRACE_ENABLE */
+    5100             :         dlt_housekeeperthread_result = pthread_kill(dlt_housekeeperthread_handle, SIGUSR1);
+    5101             :         dlt_user_cleanup_handler(NULL);
+    5102             : #endif
+    5103             : 
+    5104             : 
+    5105        6687 :         if (dlt_housekeeperthread_result != 0)
+    5106           0 :             dlt_vlog(LOG_ERR,
+    5107             :                      "ERROR %s(dlt_housekeeperthread_handle): %s\n",
+    5108             : #ifndef __ANDROID_API__
+    5109             :                      "pthread_cancel",
+    5110             : #else
+    5111             :                      "pthread_kill",
+    5112             : #endif
+    5113             :                      strerror(dlt_housekeeperthread_result));
+    5114             :     }
+    5115             : 
+    5116             : #ifdef DLT_NETWORK_TRACE_ENABLE
+    5117             :     int dlt_segmented_nwt_result = 0;
+    5118             : 
+    5119        6687 :     if (dlt_user.dlt_segmented_nwt_handle) {
+    5120        6687 :         dlt_lock_mutex(&mq_mutex);
+    5121        6687 :         pthread_cond_signal(&mq_init_condition);
+    5122        6687 :         dlt_unlock_mutex(&mq_mutex);
+    5123             : 
+    5124        6687 :         dlt_segmented_nwt_result = pthread_cancel(dlt_user.dlt_segmented_nwt_handle);
+    5125             : 
+    5126        6687 :         if (dlt_segmented_nwt_result != 0)
+    5127           0 :             dlt_vlog(LOG_ERR,
+    5128             :                      "ERROR pthread_cancel(dlt_user.dlt_segmented_nwt_handle): %s\n",
+    5129             :                      strerror(dlt_segmented_nwt_result));
+    5130             :     }
+    5131             : #endif /* DLT_NETWORK_TRACE_ENABLE */
+    5132             :     /* make sure that the threads really finished working */
+    5133        6687 :     if ((dlt_housekeeperthread_result == 0) && dlt_housekeeperthread_handle) {
+    5134        6687 :         joined = pthread_join(dlt_housekeeperthread_handle, NULL);
+    5135             : 
+    5136        6687 :         if (joined != 0)
+    5137           0 :             dlt_vlog(LOG_ERR,
+    5138             :                      "ERROR pthread_join(dlt_housekeeperthread_handle, NULL): %s\n",
+    5139             :                      strerror(joined));
+    5140             : 
+    5141        6687 :         dlt_housekeeperthread_handle = 0; /* set to invalid */
+    5142             :     }
+    5143             : 
+    5144             : #ifdef DLT_NETWORK_TRACE_ENABLE
+    5145        6687 :     if ((dlt_segmented_nwt_result == 0) && dlt_user.dlt_segmented_nwt_handle) {
+    5146        6687 :         joined = pthread_join(dlt_user.dlt_segmented_nwt_handle, NULL);
+    5147             : 
+    5148        6687 :         if (joined != 0)
+    5149           0 :             dlt_vlog(LOG_ERR,
+    5150             :                      "ERROR pthread_join(dlt_user.dlt_segmented_nwt_handle, NULL): %s\n",
+    5151             :                      strerror(joined));
+    5152             : 
+    5153        6687 :         dlt_user.dlt_segmented_nwt_handle = 0; /* set to invalid */
+    5154             :     }
+    5155             : #endif /* DLT_NETWORK_TRACE_ENABLE */
+    5156        6687 : }
+    5157             : 
+    5158           0 : static void dlt_fork_child_fork_handler()
+    5159             : {
+    5160           0 :     g_dlt_is_child = 1;
+    5161           0 :     dlt_user_init_state = INIT_UNITIALIZED;
+    5162           0 :     dlt_user.dlt_log_handle = -1;
+    5163           0 : }
+    5164             : 
+    5165         852 : DltReturnValue dlt_user_log_out_error_handling(void *ptr1, size_t len1, void *ptr2, size_t len2, void *ptr3,
+    5166             :                                                size_t len3)
+    5167           0 : {
+    5168             :     DltReturnValue ret = DLT_RETURN_ERROR;
+    5169         852 :     size_t msg_size = len1 + len2 + len3;
+    5170             : 
+    5171         852 :     DLT_SEM_LOCK();
+    5172         852 :     ret = dlt_buffer_check_size(&(dlt_user.startup_buffer), (int)msg_size);
+    5173         852 :     DLT_SEM_FREE();
+    5174             : 
+    5175         852 :     DLT_SEM_LOCK();
+    5176             : 
+    5177         852 :     if (dlt_buffer_push3(&(dlt_user.startup_buffer),
+    5178             :                          ptr1, (unsigned int)len1,
+    5179             :                          ptr2, (unsigned int)len2,
+    5180             :                          ptr3, (unsigned int)len3) == DLT_RETURN_ERROR) {
+    5181           0 :         if (dlt_user.overflow_counter == 0)
+    5182           0 :             dlt_log(LOG_WARNING, "Buffer full! Messages will be discarded.\n");
+    5183             : 
+    5184             :         ret = DLT_RETURN_BUFFER_FULL;
+    5185             :     }
+    5186             : 
+    5187         852 :     DLT_SEM_FREE();
+    5188             : 
+    5189         852 :     return ret;
+    5190             : }
+
+
+
+ + + + +
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..3a000c98e --- /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:1107260842.4 %
Date:2023-09-01 07:46:27Functions:11919860.1 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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 +
36.2%36.2%
+
36.2 %191 / 52835.5 %11 / 31
dlt_user.c +
51.6%51.6%
+
51.6 %908 / 175876.8 %106 / 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..c00745f18 --- /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:1107260842.4 %
Date:2023-09-01 07:46:27Functions:11919860.1 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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 +
36.2%36.2%
+
36.2 %191 / 52835.5 %11 / 31
dlt_user.c +
51.6%51.6%
+
51.6 %908 / 175876.8 %106 / 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..8d1247f5c --- /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:1107260842.4 %
Date:2023-09-01 07:46:27Functions:11919860.1 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_client.c +
36.2%36.2%
+
36.2 %191 / 52835.5 %11 / 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 +
51.6%51.6%
+
51.6 %908 / 175876.8 %106 / 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..972dc8a20 --- /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:44376358.1 %
Date:2023-09-01 07:46:27Functions:415278.8 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_setup_general_properties0
dlt_logstorage_check_disable_network0
dlt_logstorage_check_general_param0
dlt_logstorage_check_gzip_compression0
dlt_logstorage_check_maintain_logstorage_loglevel0
dlt_logstorage_check_overwrite_strategy0
dlt_logstorage_check_reset_loglevel0
dlt_logstorage_check_specificsize0
dlt_logstorage_create_keys_only_ctid0
dlt_logstorage_create_keys_only_ecu0
dlt_logstorage_set_sync_strategy0
dlt_logstorage_free1
dlt_logstorage_check_ecuid2
dlt_logstorage_create_keys_multi2
dlt_logstorage_device_disconnected2
dlt_logstorage_sync_caches2
dlt_logstorage_check_sync_strategy3
dlt_logstorage_device_connected3
dlt_logstorage_write3
dlt_daemon_offline_setup_filter_properties4
dlt_logstorage_create_keys_only_apid4
dlt_logstorage_filter4
dlt_logstorage_load_config4
dlt_logstorage_setup_table4
dlt_logstorage_get_loglevel_by_key5
dlt_logstorage_set_loglevel5
dlt_logstorage_store_filters5
dlt_logstorage_check_apids6
dlt_logstorage_check_ctids6
dlt_logstorage_check_loglevel6
dlt_logstorage_check_nofiles6
dlt_logstorage_create_keys6
dlt_logstorage_get_config6
dlt_logstorage_prepare_table6
dlt_logstorage_validate_filter_name6
dlt_logstorage_check_filename7
dlt_logstorage_check_filesize7
dlt_logstorage_list_destroy7
dlt_logstorage_read_bool9
dlt_logstorage_filter_config_free11
dlt_logstorage_get_keys_list12
dlt_logstorage_read_list_of_names12
dlt_logstorage_set_number12
dlt_logstorage_count_ids13
dlt_logstorage_filter_set_strategy13
dlt_logstorage_read_number13
dlt_logstorage_check_param26
dlt_logstorage_list_add26
dlt_logstorage_list_add_config27
dlt_logstorage_list_find37
dlt_logstorage_get_filter_section_value52
dlt_logstorage_get_filter_value52
+
+
+ + + +
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..e1ecbad75 --- /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:44376358.1 %
Date:2023-09-01 07:46:27Functions:415278.8 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_offline_setup_filter_properties4
dlt_daemon_setup_general_properties0
dlt_logstorage_check_apids6
dlt_logstorage_check_ctids6
dlt_logstorage_check_disable_network0
dlt_logstorage_check_ecuid2
dlt_logstorage_check_filename7
dlt_logstorage_check_filesize7
dlt_logstorage_check_general_param0
dlt_logstorage_check_gzip_compression0
dlt_logstorage_check_loglevel6
dlt_logstorage_check_maintain_logstorage_loglevel0
dlt_logstorage_check_nofiles6
dlt_logstorage_check_overwrite_strategy0
dlt_logstorage_check_param26
dlt_logstorage_check_reset_loglevel0
dlt_logstorage_check_specificsize0
dlt_logstorage_check_sync_strategy3
dlt_logstorage_count_ids13
dlt_logstorage_create_keys6
dlt_logstorage_create_keys_multi2
dlt_logstorage_create_keys_only_apid4
dlt_logstorage_create_keys_only_ctid0
dlt_logstorage_create_keys_only_ecu0
dlt_logstorage_device_connected3
dlt_logstorage_device_disconnected2
dlt_logstorage_filter4
dlt_logstorage_filter_config_free11
dlt_logstorage_filter_set_strategy13
dlt_logstorage_free1
dlt_logstorage_get_config6
dlt_logstorage_get_filter_section_value52
dlt_logstorage_get_filter_value52
dlt_logstorage_get_keys_list12
dlt_logstorage_get_loglevel_by_key5
dlt_logstorage_list_add26
dlt_logstorage_list_add_config27
dlt_logstorage_list_destroy7
dlt_logstorage_list_find37
dlt_logstorage_load_config4
dlt_logstorage_prepare_table6
dlt_logstorage_read_bool9
dlt_logstorage_read_list_of_names12
dlt_logstorage_read_number13
dlt_logstorage_set_loglevel5
dlt_logstorage_set_number12
dlt_logstorage_set_sync_strategy0
dlt_logstorage_setup_table4
dlt_logstorage_store_filters5
dlt_logstorage_sync_caches2
dlt_logstorage_validate_filter_name6
dlt_logstorage_write3
+
+
+ + + +
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..8e807e44c --- /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:44376358.1 %
Date:2023-09-01 07:46:27Functions:415278.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             :  *
+       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          11 : DLT_STATIC void dlt_logstorage_filter_config_free(DltLogStorageFilterConfig *data)
+      45             : {
+      46             :     DltLogStorageFileList *n = NULL;
+      47             :     DltLogStorageFileList *n1 = NULL;
+      48             : 
+      49          11 :     if (data->apids) {
+      50           8 :         free(data->apids);
+      51           8 :         data->apids = NULL;
+      52             :     }
+      53             : 
+      54          11 :     if (data->ctids) {
+      55           8 :         free(data->ctids);
+      56           8 :         data->ctids = NULL;
+      57             :     }
+      58             : 
+      59          11 :     if (data->file_name) {
+      60           6 :         free(data->file_name);
+      61           6 :         data->file_name = NULL;
+      62             :     }
+      63             : 
+      64          11 :     if (data->working_file_name) {
+      65           0 :         free(data->working_file_name);
+      66           0 :         data->working_file_name = NULL;
+      67             :     }
+      68             : 
+      69          11 :     if (data->ecuid != NULL) {
+      70           0 :         free(data->ecuid);
+      71           0 :         data->ecuid = NULL;
+      72             :     }
+      73             : 
+      74          11 :     if (data->log != NULL)
+      75           0 :         fclose(data->log);
+      76             : 
+      77             : #ifdef DLT_LOGSTORAGE_USE_GZIP
+      78             :     if (data->gzlog != NULL)
+      79             :         gzclose(data->gzlog);
+      80             : #endif
+      81             : 
+      82          11 :     if (data->cache != NULL) {
+      83           0 :         free(data->cache);
+      84           0 :         data->cache = NULL;
+      85             :     }
+      86             : 
+      87          11 :     n = data->records;
+      88             : 
+      89          11 :     while (n) {
+      90             :         n1 = n;
+      91           0 :         n = n->next;
+      92           0 :         if (n1->name) {
+      93           0 :             free(n1->name);
+      94             :             n1->name = NULL;
+      95             :         }
+      96             : 
+      97           0 :         free(n1);
+      98             :         n1 = NULL;
+      99             :     }
+     100          11 : }
+     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           7 : 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          14 :     while (*(list) != NULL) {
+     121             :         tmp = *list;
+     122           7 :         *list = (*list)->next;
+     123           7 :         if (tmp->key_list != NULL)
+     124             :         {
+     125           7 :             free(tmp->key_list);
+     126           7 :             tmp->key_list = NULL;
+     127             :         }
+     128             : 
+     129           7 :         if (tmp->data != NULL) {
+     130             :             /* sync data if necessary */
+     131             :             /* ignore return value */
+     132           7 :             tmp->data->dlt_logstorage_sync(tmp->data,
+     133             :                                            uconfig,
+     134             :                                            dev_path,
+     135             :                                            reason);
+     136             : 
+     137           7 :             dlt_logstorage_filter_config_free(tmp->data);
+     138             : 
+     139           7 :             free(tmp->data);
+     140             :             tmp->data = NULL;
+     141             :         }
+     142             : 
+     143           7 :         free(tmp);
+     144             :         tmp = NULL;
+     145             :     }
+     146             : 
+     147           7 :     return 0;
+     148             : }
+     149             : 
+     150          27 : DLT_STATIC int dlt_logstorage_list_add_config(DltLogStorageFilterConfig *data,
+     151             :                                               DltLogStorageFilterConfig **listdata)
+     152             : {
+     153          27 :     if (*(listdata) == NULL)
+     154             :         return -1;
+     155             : 
+     156             :     /* copy the data to list */
+     157             :     memcpy(*listdata, data, sizeof(DltLogStorageFilterConfig));
+     158             : 
+     159          27 :     if (data->apids != NULL)
+     160          22 :         (*listdata)->apids = strdup(data->apids);
+     161             : 
+     162          27 :     if (data->ctids != NULL)
+     163          22 :         (*listdata)->ctids = strdup(data->ctids);
+     164             : 
+     165          27 :     if (data->file_name != NULL)
+     166          20 :         (*listdata)->file_name = strdup(data->file_name);
+     167             : 
+     168          27 :     if (data->ecuid != NULL)
+     169          16 :         (*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          26 : 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          38 :     while (*(list) != NULL) {
+     193          12 :         list = &(*list)->next;
+     194             :     }
+     195             : 
+     196          26 :     tmp = calloc(1, sizeof(DltLogStorageFilterList));
+     197             : 
+     198          26 :     if (tmp == NULL)
+     199             :         return -1;
+     200             : 
+     201          26 :     tmp->key_list = (char *)calloc(
+     202          26 :                 (num_keys * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN), sizeof(char));
+     203          26 :     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          26 :     tmp->num_keys = num_keys;
+     212          26 :     tmp->next = NULL;
+     213          26 :     tmp->data = calloc(1, sizeof(DltLogStorageFilterConfig));
+     214             : 
+     215          26 :     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          26 :     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          26 :     *list = tmp;
+     234             : 
+     235          26 :     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          37 : 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         130 :     while (*(list) != NULL) {
+     256         168 :         for (i = 0; i < (*list)->num_keys; i++)
+     257             :         {
+     258          93 :             if (strncmp(((*list)->key_list
+     259          93 :                         + (i * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN)),
+     260             :                         key, DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN) == 0)
+     261             :             {
+     262          18 :                 config[num] = (*list)->data;
+     263          18 :                 num++;
+     264          18 :                 break;
+     265             :             }
+     266             :         }
+     267          93 :         list = &(*list)->next;
+     268             :     }
+     269             : 
+     270          37 :     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          64 :     while (p[i] != 0) {
+     287          52 :         if (p[i] == ',')
+     288          12 :             num++;
+     289             : 
+     290          52 :         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           1 : void dlt_logstorage_free(DltLogStorage *handle, int reason)
+     306             : {
+     307           1 :     if (handle == NULL) {
+     308           0 :         dlt_vlog(LOG_ERR, "%s failed: handle is NULL\n", __func__);
+     309           0 :         return;
+     310             :     }
+     311             : 
+     312           1 :     dlt_logstorage_list_destroy(&(handle->config_list), &handle->uconfig,
+     313           1 :                                 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          12 : 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          12 :     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          11 :     if (*names != NULL) {
+     347           3 :         free(*names);
+     348           3 :         *names = NULL;
+     349             :     }
+     350             : 
+     351          11 :     len = strlen(value);
+     352             : 
+     353          11 :     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          11 :     *names = (char *)calloc(num * 5, sizeof(char));
+     364             : 
+     365          11 :     if (*names == NULL) {
+     366           0 :         dlt_vlog(LOG_ERR, "%s: Cannot allocate memory\n", __func__);
+     367           0 :         return -1;
+     368             :     }
+     369             : 
+     370          11 :     tok = strdup(value);
+     371          11 :     tok = strtok(tok, ",");
+     372             : 
+     373             :     i = 1;
+     374             : 
+     375          31 :     while (tok != NULL) {
+     376          20 :         len = strlen(tok);
+     377          20 :         len = DLT_OFFLINE_LOGSTORAGE_MIN(len, 4);
+     378             : 
+     379          20 :         strncpy((*names + y), tok, len);
+     380             : 
+     381          20 :         if ((num > 1) && (i < num))
+     382           9 :             strncpy((*names + y + len), ",", 2);
+     383             : 
+     384          20 :         y += len + 1;
+     385             : 
+     386          20 :         i++;
+     387          20 :         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          12 :     *number = value;
+     403             : 
+     404          12 :     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          13 : 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          13 :     if (value == NULL)
+     427             :         return -1;
+     428             : 
+     429          12 :     *number = 0;
+     430          12 :     len = strlen(value);
+     431             : 
+     432             :     /* check if string consists of digits only */
+     433          56 :     for (i = 0; i < len; i++)
+     434          44 :         if (!isdigit(value[i])) {
+     435           0 :             dlt_log(LOG_ERR, "Invalid, is not a number \n");
+     436           0 :             return -1;
+     437             :         }
+     438             : 
+     439          12 :     size = strtoul(value, NULL, 10);
+     440             : 
+     441          12 :     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          12 : DLT_STATIC int dlt_logstorage_get_keys_list(char *ids, char *sep, char **list,
+     485             :                                             int *numids)
+     486             : {
+     487             :     char *token = NULL;
+     488          12 :     char *tmp_token = NULL;
+     489             :     char *ids_local = NULL;
+     490             : 
+     491          12 :     *numids = 0;
+     492             : 
+     493             :     /* Duplicate the ids passed for using in strtok_r() */
+     494          12 :     ids_local = strdup(ids);
+     495             : 
+     496          12 :     if (ids_local == NULL)
+     497             :         return -1;
+     498             : 
+     499          12 :     token = strtok_r(ids_local, sep, &tmp_token);
+     500             : 
+     501          12 :     if (token == NULL) {
+     502           0 :         free(ids_local);
+     503           0 :         return -1;
+     504             :     }
+     505             : 
+     506          12 :     *list = (char *)calloc(DLT_OFFLINE_LOGSTORAGE_MAXIDS * (DLT_ID_SIZE + 1),
+     507             :                            sizeof(char));
+     508             : 
+     509          12 :     if (*(list) == NULL) {
+     510           0 :         free(ids_local);
+     511           0 :         return -1;
+     512             :     }
+     513             : 
+     514          24 :     while (token != NULL) {
+     515             :         /* If it reached the max then other ids are ignored */
+     516          12 :         if (*numids >= DLT_OFFLINE_LOGSTORAGE_MAXIDS) {
+     517           0 :             free(ids_local);
+     518           0 :             return 0;
+     519             :         }
+     520             : 
+     521          12 :         strncpy(((*list) + ((*numids) * (DLT_ID_SIZE + 1))), token,
+     522             :                 DLT_ID_SIZE);
+     523          12 :         *numids = *numids + 1;
+     524          12 :         token = strtok_r(NULL, sep, &tmp_token);
+     525             :     }
+     526             : 
+     527          12 :     free(ids_local);
+     528             : 
+     529          12 :     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           2 : DLT_STATIC void dlt_logstorage_create_keys_multi(char *ecuid, char *apid,
+     610             :                                                  char *ctid, char *key)
+     611             : {
+     612           2 :     char curr_str[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = { 0 };
+     613             :     int curr_len = 0;
+     614             : 
+     615           2 :     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           2 :     curr_len = strlen(apid);
+     624           2 :     strncat(curr_str, apid, curr_len);
+     625             :     strncat(curr_str, ":", 1);
+     626             : 
+     627           2 :     curr_len = strlen(ctid);
+     628           2 :     strncat(curr_str, ctid, curr_len);
+     629           2 :     curr_len = strlen(curr_str);
+     630             : 
+     631           2 :     strncpy(key, curr_str, curr_len);
+     632           2 : }
+     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           6 : 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           6 :     int num_apids = 0;
+     689           6 :     int num_ctids = 0;
+     690           6 :     char *apid_list = NULL;
+     691           6 :     char *ctid_list = NULL;
+     692             :     char *curr_apid = NULL;
+     693             :     char *curr_ctid = NULL;
+     694           6 :     char curr_key[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = { 0 };
+     695             :     int num_currkey = 0;
+     696             : 
+     697             :     /* Handle ecuid alone case here */
+     698           6 :     if (((apids == NULL) && (ctids == NULL) && (ecuid != NULL)) ||
+     699           6 :         ((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           6 :     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           6 :     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           6 :     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           6 :     *(num_keys) = num_apids * num_ctids;
+     732             : 
+     733             :     /* allocate memory for needed number of keys */
+     734           6 :     *(keys) = (char *)calloc(*num_keys * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN,
+     735             :                              sizeof(char));
+     736             : 
+     737           6 :     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          12 :     for (i = 0; i < num_apids; i++) {
+     745           6 :         curr_apid = apid_list + (i * (DLT_ID_SIZE + 1));
+     746             : 
+     747          12 :         for (j = 0; j < num_ctids; j++) {
+     748           6 :             curr_ctid = ctid_list + (j * (DLT_ID_SIZE + 1));
+     749             : 
+     750           6 :             if (strncmp(curr_apid, ".*", 2) == 0) /* only context id matters */
+     751           0 :                 dlt_logstorage_create_keys_only_ctid(ecuid, curr_ctid, curr_key);
+     752           6 :             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           2 :                 dlt_logstorage_create_keys_multi(ecuid, curr_apid, curr_ctid, curr_key);
+     756             : 
+     757           6 :             strncpy((*keys + (num_currkey * DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN)),
+     758             :                     curr_key, strlen(curr_key));
+     759           6 :             num_currkey += 1;
+     760             :             memset(&curr_key[0], 0, sizeof(curr_key));
+     761             :         }
+     762             :     }
+     763             : 
+     764           6 :     free(apid_list);
+     765           6 :     free(ctid_list);
+     766             : 
+     767           6 :     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           6 : DLT_STATIC int dlt_logstorage_prepare_table(DltLogStorage *handle,
+     780             :                                             DltLogStorageFilterConfig *data)
+     781             : {
+     782             :     int ret = 0;
+     783           6 :     int num_keys = 0;
+     784             :     int found = 0;
+     785           6 :     char *keys = NULL;
+     786             :     DltNewestFileName *tmp = NULL;
+     787             :     DltNewestFileName *prev_tmp = NULL;
+     788             :     DltNewestFileName *new_tmp = NULL;
+     789             : 
+     790           6 :     if ((handle == NULL) || (data == NULL)) {
+     791           1 :         dlt_vlog(LOG_ERR, "Invalid parameters in %s\n", __func__);
+     792           1 :         return -1;
+     793             :     }
+     794             : 
+     795           5 :     ret = dlt_logstorage_create_keys(data->apids,
+     796             :                                      data->ctids,
+     797             :                                      data->ecuid,
+     798             :                                      &keys,
+     799             :                                      &num_keys);
+     800             : 
+     801           5 :     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           5 :     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           5 :     if (data->file_name) {
+     820           4 :         if (handle->newest_file_list != NULL) {
+     821             :             tmp = handle->newest_file_list;
+     822           0 :             while (tmp) {
+     823           0 :                 if (strcmp(tmp->file_name, data->file_name) == 0) {
+     824             :                     found = 1;
+     825             :                     break;
+     826             :                 }
+     827             :                 else {
+     828             :                     prev_tmp = tmp;
+     829           0 :                     tmp = tmp->next;
+     830             :                 }
+     831             :             }
+     832             :         }
+     833             : 
+     834           0 :         if (!found) {
+     835           4 :             new_tmp = calloc(1, sizeof(DltNewestFileName));
+     836           4 :             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           4 :             new_tmp->file_name = strdup(data->file_name);
+     846           4 :             new_tmp->newest_file = NULL;
+     847           4 :             new_tmp->next = NULL;
+     848             : 
+     849           4 :             if (handle->newest_file_list == NULL)
+     850           4 :                 handle->newest_file_list = new_tmp;
+     851             :             else
+     852           0 :                 prev_tmp->next = new_tmp;
+     853             :         }
+     854             :     }
+     855             : 
+     856           5 :     free(keys);
+     857             :     keys = NULL;
+     858           5 :     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           6 : 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           6 :     if (name == NULL)
+     879             :         return -1;
+     880             : 
+     881           5 :     len = strlen(name);
+     882             : 
+     883             :     /* Check if section header is of format "FILTER" followed by a number */
+     884           5 :     if (strncmp(name,
+     885             :                 DLT_OFFLINE_LOGSTORAGE_CONFIG_SECTION,
+     886             :                 config_sec_len) == 0) {
+     887           7 :         for (idx = config_sec_len; idx < len - 1; idx++)
+     888           2 :             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          12 :         config->dlt_logstorage_prepare = &dlt_logstorage_prepare_on_msg;
+     930          12 :         config->dlt_logstorage_write = &dlt_logstorage_write_on_msg;
+     931          12 :         config->dlt_logstorage_sync = &dlt_logstorage_sync_on_msg;
+     932             :     }
+     933             :     else { /* cache based */
+     934           1 :         config->dlt_logstorage_prepare = &dlt_logstorage_prepare_msg_cache;
+     935           1 :         config->dlt_logstorage_write = &dlt_logstorage_write_msg_cache;
+     936           1 :         config->dlt_logstorage_sync = &dlt_logstorage_sync_msg_cache;
+     937             :     }
+     938             : }
+     939             : 
+     940           6 : DLT_STATIC int dlt_logstorage_check_apids(DltLogStorageFilterConfig *config,
+     941             :                                           char *value)
+     942             : {
+     943           6 :     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           5 :     return dlt_logstorage_read_list_of_names(&config->apids, value);
+     949             : }
+     950             : 
+     951           6 : DLT_STATIC int dlt_logstorage_check_ctids(DltLogStorageFilterConfig *config,
+     952             :                                           char *value)
+     953             : {
+     954           6 :     if ((config == NULL) || (value == NULL))
+     955             :         return -1;
+     956             : 
+     957           5 :     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           5 :     *log_level = value;
+     964           5 :     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           6 : DLT_STATIC int dlt_logstorage_check_loglevel(DltLogStorageFilterConfig *config,
+     973             :                                              char *value)
+     974             : {
+     975             :     int ll = -1;
+     976             : 
+     977           6 :     if ((config == NULL) || (value == NULL))
+     978             :         return -1;
+     979             : 
+     980             :     if (value == NULL) {
+     981             :         config->log_level = 0;
+     982             :         return -1;
+     983             :     }
+     984             : 
+     985           5 :     if (strcmp(value, "DLT_LOG_FATAL") == 0) {
+     986             :         ll = 1;
+     987             :     }
+     988           4 :     else if (strcmp(value, "DLT_LOG_ERROR") == 0)
+     989             :     {
+     990             :         ll = 2;
+     991             :     }
+     992           0 :     else if (strcmp(value, "DLT_LOG_WARN") == 0)
+     993             :     {
+     994             :         ll = 3;
+     995             :     }
+     996           0 :     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           7 : DLT_STATIC int dlt_logstorage_check_filename(DltLogStorageFilterConfig *config,
+    1060             :                                              char *value)
+    1061             : {
+    1062             :     int len;
+    1063             : 
+    1064           7 :     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           6 :     if (config->file_name != NULL) {
+    1070           2 :         free(config->file_name);
+    1071           2 :         config->file_name = NULL;
+    1072             :     }
+    1073             : 
+    1074           6 :     len = strlen(value);
+    1075             : 
+    1076           6 :     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           6 :     if (strstr(value, "..") == NULL) {
+    1084           5 :         config->file_name = calloc((len + 1), sizeof(char));
+    1085             : 
+    1086           5 :         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           5 :         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           5 :     return 0;
+    1101             : }
+    1102             : 
+    1103           7 : DLT_STATIC int dlt_logstorage_check_filesize(DltLogStorageFilterConfig *config,
+    1104             :                                              char *value)
+    1105             : {
+    1106           7 :     if ((config == NULL) || (value == NULL))
+    1107             :         return -1;
+    1108             : 
+    1109           6 :     return dlt_logstorage_read_number(&config->file_size, value);
+    1110             : }
+    1111             : 
+    1112           6 : DLT_STATIC int dlt_logstorage_check_nofiles(DltLogStorageFilterConfig *config,
+    1113             :                                             char *value)
+    1114             : {
+    1115           6 :     if ((config == NULL) || (value == NULL))
+    1116             :         return -1;
+    1117             : 
+    1118           5 :     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           0 : DLT_STATIC int dlt_logstorage_check_specificsize(DltLogStorageFilterConfig *config,
+    1136             :                                                  char *value)
+    1137             : {
+    1138           0 :     if ((config == NULL) || (value == NULL))
+    1139             :         return -1;
+    1140             : 
+    1141           0 :     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           3 : DLT_STATIC int dlt_logstorage_check_sync_strategy(DltLogStorageFilterConfig *config,
+    1173             :                                                   char *value)
+    1174             : {
+    1175           3 :     if ((config == NULL) || (value == NULL))
+    1176             :         return -1;
+    1177             : 
+    1178           2 :     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           1 :         if (strcasestr(value, "ON_DAEMON_EXIT") != NULL)
+    1185           0 :             config->sync |= DLT_LOGSTORAGE_SYNC_ON_DAEMON_EXIT;
+    1186             : 
+    1187           1 :         if (strcasestr(value, "ON_DEMAND") != NULL)
+    1188           0 :             config->sync |= DLT_LOGSTORAGE_SYNC_ON_DEMAND;
+    1189             : 
+    1190           1 :         if (strcasestr(value, "ON_DEVICE_DISCONNECT") != NULL)
+    1191           0 :             config->sync |= DLT_LOGSTORAGE_SYNC_ON_DEVICE_DISCONNECT;
+    1192             : 
+    1193           1 :         if (strcasestr(value, "ON_SPECIFIC_SIZE") != NULL)
+    1194           0 :             config->sync |= DLT_LOGSTORAGE_SYNC_ON_SPECIFIC_SIZE;
+    1195             : 
+    1196           1 :         if (strcasestr(value, "ON_FILE_SIZE") != NULL)
+    1197           0 :             config->sync |= DLT_LOGSTORAGE_SYNC_ON_FILE_SIZE;
+    1198             : 
+    1199           1 :         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           0 : DLT_STATIC int dlt_logstorage_check_overwrite_strategy(DltLogStorageFilterConfig *config,
+    1223             :                                                   char *value)
+    1224             : {
+    1225           0 :     if ((config == NULL) || (value == NULL))
+    1226             :         return -1;
+    1227             : 
+    1228           0 :     if (strcasestr(value, "DISCARD_OLD") != NULL) {
+    1229           0 :         config->overwrite = DLT_LOGSTORAGE_OVERWRITE_DISCARD_OLD;
+    1230           0 :     } else if (strcasestr(value, "DISCARD_NEW") != NULL) {
+    1231           0 :         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           0 : DLT_STATIC int dlt_logstorage_check_disable_network(DltLogStorageFilterConfig *config,
+    1255             :                                                   char *value)
+    1256             : {
+    1257           0 :     if ((config == NULL) || (value == NULL))
+    1258             :         return -1;
+    1259             : 
+    1260           0 :     if (strcasestr(value, "ON") != NULL) {
+    1261           0 :         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           2 : DLT_STATIC int dlt_logstorage_check_ecuid(DltLogStorageFilterConfig *config,
+    1284             :                                           char *value)
+    1285             : {
+    1286             :     int len;
+    1287             : 
+    1288           2 :     if ((config == NULL) || (value == NULL) || (value[0] == '\0'))
+    1289             :         return -1;
+    1290             : 
+    1291           1 :     if (config->ecuid != NULL) {
+    1292           1 :         free(config->ecuid);
+    1293           1 :         config->ecuid = NULL;
+    1294             :     }
+    1295             : 
+    1296           1 :     len = strlen(value);
+    1297           1 :     config->ecuid = calloc((len + 1), sizeof(char));
+    1298             : 
+    1299           1 :     if (config->ecuid == NULL)
+    1300             :         return -1;
+    1301             : 
+    1302           1 :     strncpy(config->ecuid, value, len);
+    1303             : 
+    1304           1 :     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          52 : 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          52 :     if ((config_file == NULL) || (sec_name == NULL))
+    1544             :         return DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR;
+    1545             : 
+    1546          52 :     if (entry.key != NULL) {
+    1547          48 :         ret = dlt_config_file_get_value(config_file, sec_name,
+    1548             :                                         entry.key,
+    1549             :                                         value);
+    1550             : 
+    1551          48 :         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          48 :         if ((ret != 0) && (entry.is_opt == 1)) {
+    1559          24 :             dlt_vlog(LOG_DEBUG, "Optional parameter %s not specified\n",
+    1560             :                      entry.key);
+    1561          24 :             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          52 : 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          52 :     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          52 :     if (strncmp(sec_name,
+    1586             :                 DLT_OFFLINE_LOGSTORAGE_CONFIG_SECTION,
+    1587             :                 config_sec_len) == 0) {
+    1588          52 :         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           4 : 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           4 :     dlt_logstorage_filter_set_strategy(tmp_data, tmp_data->sync);
+    1622             : 
+    1623           4 :     ret = dlt_logstorage_prepare_table(handle, tmp_data);
+    1624             : 
+    1625           4 :     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           4 :     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           4 : 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           4 :     char value[DLT_CONFIG_FILE_ENTRY_MAX_LEN + 1] = { '\0' };
+    1643             :     int i = 0;
+    1644             :     int ret = 0;
+    1645             : 
+    1646           4 :     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           4 :     tmp_data.log_level = DLT_LOG_VERBOSE;
+    1651             :     tmp_data.reset_log_level = DLT_LOG_OFF;
+    1652           4 :     tmp_data.disable_network_routing = DLT_LOGSTORAGE_DISABLE_NW_OFF;
+    1653             : 
+    1654          56 :     for (i = 0; i < DLT_LOGSTORAGE_FILTER_CONF_COUNT; i++) {
+    1655          52 :         ret = dlt_logstorage_get_filter_value(config_file, sec_name, i, value);
+    1656             : 
+    1657          52 :         if (ret == DLT_OFFLINE_LOGSTORAGE_FILTER_ERROR)
+    1658             :             return ret;
+    1659             : 
+    1660          52 :         if (ret == DLT_OFFLINE_LOGSTORAGE_FILTER_CONTINUE)
+    1661          28 :             continue;
+    1662             : 
+    1663             :         /* check value and store temporary */
+    1664          24 :         ret = dlt_logstorage_check_param(&tmp_data, i, value);
+    1665             : 
+    1666          24 :         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           4 :     ret = dlt_logstorage_setup_table(handle, &tmp_data);
+    1698             : 
+    1699           4 :     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           4 :         handle->num_configs += 1;
+    1705             :     }
+    1706             : 
+    1707             :     /* free tmp_data */
+    1708           4 :     dlt_logstorage_filter_config_free(&tmp_data);
+    1709             : 
+    1710           4 :     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           5 : DLT_STATIC int dlt_logstorage_store_filters(DltLogStorage *handle,
+    1845             :                                             char *config_file_name)
+    1846             : {
+    1847             :     DltConfigFile *config = NULL;
+    1848             :     int sec = 0;
+    1849           5 :     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           5 :     if (config_file_name == NULL) {
+    1856           1 :         dlt_vlog(LOG_ERR, "%s unexpected parameter received\n", __func__);
+    1857           1 :         return -1;
+    1858             :     }
+    1859             : 
+    1860           4 :     config = dlt_config_file_init(config_file_name);
+    1861             : 
+    1862           4 :     if (config == NULL) {
+    1863           0 :         dlt_log(LOG_CRIT, "Failed to open filter configuration file\n");
+    1864           0 :         return -1;
+    1865             :     }
+    1866             : 
+    1867           4 :     handle->maintain_logstorage_loglevel = DLT_MAINTAIN_LOGSTORAGE_LOGLEVEL_UNDEF;
+    1868           4 :     dlt_config_file_get_num_sections(config, &num_sec);
+    1869             : 
+    1870           8 :     for (sec = 0; sec < num_sec; sec++) {
+    1871             :         char sec_name[DLT_CONFIG_FILE_ENTRY_MAX_LEN + 1];
+    1872             : 
+    1873           4 :         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           4 :         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           4 :         else if (dlt_logstorage_validate_filter_name(sec_name) == 0)
+    1887             :         {
+    1888           4 :             ret = dlt_daemon_offline_setup_filter_properties(handle, config, sec_name);
+    1889             : 
+    1890           4 :             if (ret == DLT_OFFLINE_LOGSTORAGE_STORE_FILTER_ERROR) {
+    1891             :                 break;
+    1892             :             }
+    1893           4 :             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           4 :             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           4 :     dlt_config_file_release(config);
+    1913             : 
+    1914           4 :     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           4 : DLT_STATIC int dlt_logstorage_load_config(DltLogStorage *handle)
+    1932             : {
+    1933           4 :     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           4 :     if ((handle == NULL) ||
+    1938           3 :         (handle->connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED))
+    1939             :         return -1;
+    1940             : 
+    1941             :     /* Check if this device config was already setup */
+    1942           3 :     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           3 :     if (snprintf(config_file_name,
+    1950             :                  PATH_MAX,
+    1951             :                  "%s/%s",
+    1952           3 :                  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           3 :     config_file_name[PATH_MAX - 1] = 0;
+    1959           3 :     ret = dlt_logstorage_store_filters(handle, config_file_name);
+    1960             : 
+    1961           3 :     if (ret == 1) {
+    1962           0 :         handle->config_status = DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE;
+    1963           0 :         return 1;
+    1964             :     }
+    1965           3 :     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           3 :     handle->config_status = DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE;
+    1973             : 
+    1974           3 :     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           3 : int dlt_logstorage_device_connected(DltLogStorage *handle, const char *mount_point)
+    1987             : {
+    1988           3 :     if ((handle == NULL) || (mount_point == NULL)) {
+    1989           1 :         dlt_log(LOG_ERR, "Handle error \n");
+    1990           1 :         return -1;
+    1991             :     }
+    1992             : 
+    1993           2 :     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           2 :     strncpy(handle->device_mount_point, mount_point, DLT_MOUNT_PATH_MAX);
+    2003           2 :     handle->device_mount_point[DLT_MOUNT_PATH_MAX] = 0;
+    2004           2 :     handle->connection_type = DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED;
+    2005           2 :     handle->config_status = 0;
+    2006           2 :     handle->write_errors = 0;
+    2007           2 :     handle->num_configs = 0;
+    2008           2 :     handle->newest_file_list = NULL;
+    2009             : 
+    2010           2 :     switch (handle->config_mode) {
+    2011           2 :       case DLT_LOGSTORAGE_CONFIG_FILE:
+    2012             :         /* Setup logstorage with config file settings */
+    2013           2 :         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           2 : int dlt_logstorage_device_disconnected(DltLogStorage *handle, int reason)
+    2030             : {
+    2031             :     DltNewestFileName *tmp = NULL;
+    2032           2 :     if (handle == NULL)
+    2033             :         return -1;
+    2034             : 
+    2035             :     /* If configuration loading was done, free it */
+    2036           1 :     if (handle->config_status == DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE)
+    2037           0 :         dlt_logstorage_free(handle, reason);
+    2038             : 
+    2039             :     /* Reset all device status */
+    2040           1 :     memset(handle->device_mount_point, 0, sizeof(char) * (DLT_MOUNT_PATH_MAX + 1));
+    2041           1 :     handle->connection_type = DLT_OFFLINE_LOGSTORAGE_DEVICE_DISCONNECTED;
+    2042           1 :     handle->config_status = 0;
+    2043           1 :     handle->write_errors = 0;
+    2044           1 :     handle->num_configs = 0;
+    2045             : 
+    2046           1 :     while (handle->newest_file_list) {
+    2047             :         tmp = handle->newest_file_list;
+    2048           0 :         handle->newest_file_list = tmp->next;
+    2049           0 :         if (tmp->file_name) {
+    2050           0 :             free(tmp->file_name);
+    2051           0 :             tmp->file_name = NULL;
+    2052             :         }
+    2053           0 :         if (tmp->newest_file) {
+    2054           0 :             free(tmp->newest_file);
+    2055             :             tmp->newest_file = NULL;
+    2056             :         }
+    2057           0 :         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           5 : int dlt_logstorage_get_loglevel_by_key(DltLogStorage *handle, char *key)
+    2076             : {
+    2077           5 :     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           5 :     if ((handle == NULL) ||
+    2084           5 :         (key == NULL) ||
+    2085           4 :         (handle->connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) ||
+    2086           4 :         (handle->config_status != DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE))
+    2087             :         return -1;
+    2088             : 
+    2089           4 :     num_configs = dlt_logstorage_list_find(key, &(handle->config_list), config);
+    2090             : 
+    2091           4 :     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           4 :     else if (num_configs == 1)
+    2097             :     {
+    2098           4 :         if (config[0] != NULL)
+    2099             :         {
+    2100           4 :             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           6 : 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           6 :     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           6 :     if ((handle == NULL) || (config == NULL) ||
+    2154           5 :         (handle->connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) ||
+    2155           5 :         (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           5 :     ecuid_len = strlen(ecuid);
+    2170             : 
+    2171             :     if (ecuid_len > DLT_ID_SIZE)
+    2172             :         ecuid_len = DLT_ID_SIZE;
+    2173             : 
+    2174           5 :     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           5 :     apid_len = strlen(apid);
+    2186             : 
+    2187             :     if (apid_len > DLT_ID_SIZE)
+    2188             :         apid_len = DLT_ID_SIZE;
+    2189             : 
+    2190           5 :     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           5 :     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           5 :     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           5 :     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          36 :     for (i = 0; i < DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_KEYS; i++)
+    2237             :     {
+    2238          32 :         cur_config_ptr = &config[num_configs];
+    2239          32 :         num = dlt_logstorage_list_find(key[i], &(handle->config_list),
+    2240             :                                        cur_config_ptr);
+    2241          32 :         num_configs += num;
+    2242             :         /* If all filter configurations matched, stop and return */
+    2243          32 :         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           4 : 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           4 :     if ((handle == NULL) || (config == NULL) || (ecuid == NULL))
+    2280             :         return -1;
+    2281             : 
+    2282             :     /* filter on names: find DltLogStorageFilterConfig structures */
+    2283           3 :     num = dlt_logstorage_get_config(handle, config, apid, ctid, ecuid);
+    2284             : 
+    2285           3 :     if (num == 0) {
+    2286           0 :         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           0 :         return 0;
+    2290             :     }
+    2291             : 
+    2292          12 :     for (i = 0 ; i < num ; i++)
+    2293             :     {
+    2294           9 :         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           9 :         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           3 :         if (config[i]->ecuid != NULL) {
+    2313           3 :             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           3 : 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           3 :     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           3 :     if ((handle == NULL) || (uconfig == NULL) ||
+    2372           2 :         (data1 == NULL) || (data2 == NULL) || (data3 == NULL) ||
+    2373           2 :         (handle->connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) ||
+    2374           2 :         (handle->config_status != DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE))
+    2375             :         return 0;
+    2376             : 
+    2377             :     /* Calculate real length of DltStandardHeaderExtra */
+    2378             :     standardHeader = (DltStandardHeader *)data2;
+    2379             : 
+    2380           2 :     if (!DLT_IS_HTYP_WEID(standardHeader->htyp))
+    2381             :         standardHeaderExtraLen -= DLT_ID_SIZE;
+    2382             : 
+    2383           2 :     if (!DLT_IS_HTYP_WSID(standardHeader->htyp))
+    2384           2 :         standardHeaderExtraLen -= DLT_SIZE_WSID;
+    2385             : 
+    2386           2 :     if (!DLT_IS_HTYP_WTMS(standardHeader->htyp))
+    2387           2 :         standardHeaderExtraLen -= DLT_SIZE_WTMS;
+    2388             : 
+    2389             :     extraHeader = (DltStandardHeaderExtra *)(data2
+    2390             :                                              + sizeof(DltStandardHeader));
+    2391             : 
+    2392           2 :     if (DLT_IS_HTYP_UEH(standardHeader->htyp)) {
+    2393           2 :         header_len = sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) + standardHeaderExtraLen;
+    2394             : 
+    2395             :         /* check if size2 is big enough to contain expected DLT message header */
+    2396           2 :         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           2 :         extendedHeader = (DltExtendedHeader *)(data2
+    2402           2 :                                                + sizeof(DltStandardHeader) + standardHeaderExtraLen);
+    2403             : 
+    2404           2 :         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           2 :         num = dlt_logstorage_filter(handle, config, extendedHeader->apid,
+    2409           2 :                                     extendedHeader->ctid, extraHeader->ecu, log_level);
+    2410             : 
+    2411           2 :         if ((num == 0) || (num == -1)) {
+    2412           0 :             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           0 :             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           8 :     for (i = 0; i < num; i++)
+    2442             :     {
+    2443           6 :         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           0 :         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           0 :         if ((config[i]->disable_network_routing & DLT_LOGSTORAGE_DISABLE_NW_ON) > 0) {
+    2463           0 :             *disable_nw = 1;
+    2464           0 :             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           0 :                 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           0 :         if (config[i]->skip == 1)
+    2473             :         {
+    2474           0 :             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           0 :             continue;
+    2478             :         }
+    2479             : 
+    2480           0 :         tmp = handle->newest_file_list;
+    2481           0 :         while (tmp) {
+    2482           0 :             if (strcmp(tmp->file_name, config[i]->file_name) == 0) {
+    2483             :                 found = 1;
+    2484             :                 break;
+    2485             :             }
+    2486             :             else {
+    2487           0 :                 tmp = tmp->next;
+    2488             :             }
+    2489             :         }
+    2490           0 :         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           0 :         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           0 :             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           0 :         ret = config[i]->dlt_logstorage_prepare(config[i],
+    2505             :                                                 uconfig,
+    2506           0 :                                                 handle->device_mount_point,
+    2507           0 :                                                 size1 + size2 + size3,
+    2508             :                                                 tmp);
+    2509             : 
+    2510           0 :         if (ret == 0 && config[i]->skip == 1) {
+    2511           0 :             continue;
+    2512             :         }
+    2513             : 
+    2514           0 :         if ((ret == 0) &&
+    2515           0 :             (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           0 :             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           0 :                 if (tmp->newest_file) {
+    2528           0 :                     free(tmp->newest_file);
+    2529           0 :                     tmp->newest_file = NULL;
+    2530             :                 }
+    2531           0 :                 tmp->newest_file = strdup(config[i]->working_file_name);
+    2532           0 :                 tmp->wrap_id = config[i]->wrap_id;
+    2533             :             }
+    2534             :         }
+    2535             : 
+    2536           0 :         if (ret == 0) { /* log data (write) */
+    2537           0 :             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           0 :             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           0 :                 if (config[i]->sync != DLT_LOGSTORAGE_SYNC_ON_MSG &&
+    2556             :                         config[i]->sync != DLT_LOGSTORAGE_SYNC_UNSET) {
+    2557           0 :                     if (config[i]->working_file_name) {
+    2558           0 :                         if (tmp->newest_file) {
+    2559           0 :                             free(tmp->newest_file);
+    2560           0 :                             tmp->newest_file = NULL;
+    2561             :                         }
+    2562           0 :                         tmp->newest_file = strdup(config[i]->working_file_name);
+    2563           0 :                         tmp->wrap_id = config[i]->wrap_id;
+    2564             :                     }
+    2565             :                 }
+    2566             : 
+    2567             :                 /* flush to be sure log is stored on device */
+    2568           0 :                 ret = config[i]->dlt_logstorage_sync(config[i],
+    2569             :                                                      uconfig,
+    2570             :                                                      handle->device_mount_point,
+    2571             :                                                      DLT_LOGSTORAGE_SYNC_ON_MSG);
+    2572             : 
+    2573           0 :                 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           0 :             handle->prepare_errors += 1;
+    2590             : 
+    2591           0 :             if (handle->prepare_errors >=
+    2592             :                 DLT_OFFLINE_LOGSTORAGE_MAX_ERRORS) {
+    2593           0 :                 config[i]->skip = 1;
+    2594           0 :                 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           0 :                 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           2 : int dlt_logstorage_sync_caches(DltLogStorage *handle)
+    2616             : {
+    2617             :     DltLogStorageFilterList **tmp = NULL;
+    2618             : 
+    2619           2 :     if (handle == NULL)
+    2620             :         return -1;
+    2621             : 
+    2622           2 :     tmp = &(handle->config_list);
+    2623             : 
+    2624           4 :     while (*(tmp) != NULL) {
+    2625           2 :         if ((*tmp)->data != NULL) {
+    2626           2 :             if ((*tmp)->data->dlt_logstorage_sync((*tmp)->data,
+    2627             :                                                   &handle->uconfig,
+    2628           2 :                                                   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           2 :         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..94b9a6a9b --- /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:31646767.7 %
Date:2023-09-01 07:46:27Functions:2020100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_logstorage_check_write_ret2
dlt_logstorage_close_file2
dlt_logstorage_find_last_dlt_header2
dlt_logstorage_sync_msg_cache2
dlt_logstorage_write_on_msg2
dlt_logstorage_rearrange_file_name3
dlt_logstorage_sync_to_file3
dlt_logstorage_find_dlt_header4
dlt_logstorage_prepare_msg_cache4
dlt_logstorage_write_msg_cache4
dlt_logstorage_open_log_output_file5
dlt_logstorage_prepare_on_msg5
dlt_logstorage_write_to_log5
dlt_logstorage_open_log_file9
dlt_logstorage_storage_dir_info10
dlt_logstorage_get_idx_of_log_file11
dlt_logstorage_sort_file_name11
dlt_logstorage_sync_on_msg11
dlt_logstorage_log_file_name13
dlt_logstorage_concat_logfile_name29
+
+
+ + + +
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..3db21d176 --- /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:31646767.7 %
Date:2023-09-01 07:46:27Functions:2020100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_offline_logstorage.c +
58.1%58.1%
+
58.1 %443 / 76378.8 %41 / 52
dlt_offline_logstorage_behavior.c +
67.7%67.7%
+
67.7 %316 / 467100.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..779854ed6 --- /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:759123061.7 %
Date:2023-09-01 07:46:27Functions:617284.7 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_offline_logstorage.c +
58.1%58.1%
+
58.1 %443 / 76378.8 %41 / 52
dlt_offline_logstorage_behavior.c +
67.7%67.7%
+
67.7 %316 / 467100.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..90942aa23 --- /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:759123061.7 %
Date:2023-09-01 07:46:27Functions:617284.7 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_offline_logstorage.c +
58.1%58.1%
+
58.1 %443 / 76378.8 %41 / 52
dlt_offline_logstorage_behavior.c +
67.7%67.7%
+
67.7 %316 / 467100.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..8a63c6850 --- /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:1099175262.7 %
Date:2023-09-01 07:46:27Functions:9411085.5 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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_free0
dlt_filter_save0
dlt_hex_ascii_to_binary0
dlt_print_hex0
dlt_print_with_attributes0
dlt_receiver_check_and_get0
dlt_setup_serial0
dlt_buffer_info2
dlt_buffer_status2
dlt_get_major_version2
dlt_get_minor_version2
dlt_log_free_single_logfile2
dlt_receiver_free_global_buffer2
dlt_receiver_init_global_buffer2
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
dlt_buffer_remove5
get_filename_ext5
dlt_extract_base_name_without_ext6
dlt_file_set_filter6
dlt_filter_init6
dlt_filter_load6
dlt_get_version6
dlt_buffer_increase_size7
dlt_buffer_minimize_size7
dlt_check_rcv_data_size7
dlt_buffer_pull8
dlt_log_free8
dlt_buffer_reset9
dlt_buffer_copy10
dlt_log_set_filename10
dlt_getloginfo_conv_ascii_to_string11
dlt_receiver_move_to_begin11
dlt_filter_add12
dlt_filter_find12
dlt_getloginfo_conv_ascii_to_int16_t12
dlt_log_init12
dlt_log_multiple_files_write12
dlt_log_set_level12
dlt_receiver_receive12
dlt_getloginfo_conv_ascii_to_uint16_t14
dlt_log_init_multiple_logfiles_support19
dlt_getloginfo_conv_ascii_to_id20
dlt_receiver_remove21
dlt_file_free26
dlt_file_init28
dlt_file_open32
dlt_is_log_in_multiple_files_active37
dlt_buffer_read_block45
dlt_buffer_get59
dlt_message_free64
dlt_clean_string147
dlt_set_storageheader234
dlt_message_read246
dlt_uptime247
dlt_message_init252
dlt_message_print_ascii328
dlt_message_print_header328
dlt_message_print_hex328
dlt_message_print_mixed_html328
dlt_message_print_mixed_plain328
dlt_message_set_extraparameters425
dlt_message_get_extraparameters494
dlt_message_filter_check742
dlt_message_argument_print751
dlt_buffer_check_size852
dlt_print_mixed_string1062
dlt_print_char_string1661
dlt_message_header1909
dlt_file_read2226
dlt_buffer_get_used_size2503
dlt_message_payload2620
dlt_buffer_get_message_count2672
dlt_print_hex_string2721
dlt_print_hex_string_delim2730
dlt_user_printf2852
dlt_file_message3261
dlt_file_read_data3366
dlt_file_read_header_extended3996
dlt_print_id4087
dlt_strnlen_s4089
dlt_message_header_flags4611
dlt_check_storageheader5571
dlt_file_read_header5592
dlt_check_envvar6687
dlt_vnlog6687
dlt_log_set_fifo_basedir6689
dlt_receiver_free6702
dlt_receiver_init6702
dlt_buffer_free_dynamic6785
dlt_buffer_init_dynamic6811
dlt_buffer_push7516
dlt_buffer_push39839
dlt_set_id23443
dlt_buffer_write_block24692
dlt_log818061
dlt_vlog818423
+
+
+ + + +
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..ee5d6097b --- /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:1099175262.7 %
Date:2023-09-01 07:46:27Functions:9411085.5 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_buffer_check_size852
dlt_buffer_copy10
dlt_buffer_free_dynamic6785
dlt_buffer_free_static0
dlt_buffer_get59
dlt_buffer_get_message_count2672
dlt_buffer_get_total_size3
dlt_buffer_get_used_size2503
dlt_buffer_increase_size7
dlt_buffer_info2
dlt_buffer_init_dynamic6811
dlt_buffer_init_static_client0
dlt_buffer_init_static_server0
dlt_buffer_minimize_size7
dlt_buffer_pull8
dlt_buffer_push7516
dlt_buffer_push39839
dlt_buffer_read_block45
dlt_buffer_remove5
dlt_buffer_reset9
dlt_buffer_status2
dlt_buffer_write_block24692
dlt_check_envvar6687
dlt_check_rcv_data_size7
dlt_check_storageheader5571
dlt_clean_string147
dlt_convert_serial_speed0
dlt_execute_command0
dlt_extract_base_name_without_ext6
dlt_file_close0
dlt_file_free26
dlt_file_init28
dlt_file_message3261
dlt_file_open32
dlt_file_quick_parsing3
dlt_file_read2226
dlt_file_read_data3366
dlt_file_read_header5592
dlt_file_read_header_extended3996
dlt_file_read_header_raw0
dlt_file_read_raw0
dlt_file_set_filter6
dlt_filter_add12
dlt_filter_delete0
dlt_filter_find12
dlt_filter_free0
dlt_filter_init6
dlt_filter_load6
dlt_filter_save0
dlt_get_major_version2
dlt_get_minor_version2
dlt_get_version6
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_log818061
dlt_log_free8
dlt_log_free_multiple_logfiles3
dlt_log_free_single_logfile2
dlt_log_init12
dlt_log_init_multiple_logfiles4
dlt_log_init_multiple_logfiles_support19
dlt_log_init_single_logfile4
dlt_log_multiple_files_write12
dlt_log_set_fifo_basedir6689
dlt_log_set_filename10
dlt_log_set_level12
dlt_message_argument_print751
dlt_message_filter_check742
dlt_message_free64
dlt_message_get_extraparameters494
dlt_message_header1909
dlt_message_header_flags4611
dlt_message_init252
dlt_message_payload2620
dlt_message_print_ascii328
dlt_message_print_header328
dlt_message_print_hex328
dlt_message_print_mixed_html328
dlt_message_print_mixed_plain328
dlt_message_read246
dlt_message_set_extraparameters425
dlt_print_char_string1661
dlt_print_hex0
dlt_print_hex_string2721
dlt_print_hex_string_delim2730
dlt_print_id4087
dlt_print_mixed_string1062
dlt_print_with_attributes0
dlt_receiver_check_and_get0
dlt_receiver_free6702
dlt_receiver_free_global_buffer2
dlt_receiver_init6702
dlt_receiver_init_global_buffer2
dlt_receiver_move_to_begin11
dlt_receiver_receive12
dlt_receiver_remove21
dlt_set_id23443
dlt_set_loginfo_parse_service_id2
dlt_set_storageheader234
dlt_setup_serial0
dlt_strnlen_s4089
dlt_uptime247
dlt_user_printf2852
dlt_vlog818423
dlt_vnlog6687
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..54703d065 --- /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:1099175262.7 %
Date:2023-09-01 07:46:27Functions:9411085.5 %
+
+ + + + + + + + +

+
          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        2730 : static DltReturnValue dlt_print_hex_string_delim(char *text, int textlength, uint8_t *ptr, int size, char delim)
+     140             : {
+     141             :     int num;
+     142             : 
+     143        2730 :     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        2727 :     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       36441 :     for (num = 0; num < size; num++) {
+     155       33714 :         if (num > 0) {
+     156       31013 :             snprintf(text, 2, "%c", delim);
+     157       31013 :             text++;
+     158             :         }
+     159             : 
+     160       33714 :         snprintf(text, 3, "%.2x", ((uint8_t *)ptr)[num]);
+     161       33714 :         text += 2; /* 2 chars */
+     162             :     }
+     163             : 
+     164             :     return DLT_RETURN_OK;
+     165             : }
+     166             : 
+     167        2721 : DltReturnValue dlt_print_hex_string(char *text, int textlength, uint8_t *ptr, int size)
+     168             : {
+     169        2721 :     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        4089 : size_t dlt_strnlen_s(const char* str, size_t maxsize)
+     321             : {
+     322        4089 :     if (str == NULL)
+     323             :         return 0;
+     324             : 
+     325       17137 :     for (size_t i = 0; i < maxsize; ++i) {
+     326       16385 :         if (str[i] == '\0')
+     327        3336 :             return i;
+     328             :     }
+     329             :     return maxsize;
+     330             : }
+     331             : 
+     332        4087 : void dlt_print_id(char *text, const char *id)
+     333             : {
+     334             :     /* check nullpointer */
+     335        4087 :     if ((text == NULL) || (id == NULL))
+     336             :         return;
+     337             : 
+     338             :     /* Initialize text */
+     339             :     memset(text, '-', DLT_ID_SIZE);
+     340             : 
+     341        4084 :     text[DLT_ID_SIZE] = 0;
+     342             : 
+     343        4084 :     size_t len = dlt_strnlen_s(id, DLT_ID_SIZE);
+     344             : 
+     345             :     memcpy(text, id, len);
+     346             : }
+     347             : 
+     348       23443 : void dlt_set_id(char *id, const char *text)
+     349             : {
+     350             :     /* check nullpointer */
+     351       23443 :     if ((id == NULL) || (text == NULL))
+     352             :         return;
+     353             : 
+     354       23440 :     id[0] = 0;
+     355       23440 :     id[1] = 0;
+     356       23440 :     id[2] = 0;
+     357       23307 :     id[3] = 0;
+     358             : 
+     359       23440 :     if (text[0] != 0)
+     360        9337 :         id[0] = text[0];
+     361             :     else
+     362             :         return;
+     363             : 
+     364        9337 :     if (text[1] != 0)
+     365        9331 :         id[1] = text[1];
+     366             :     else
+     367             :         return;
+     368             : 
+     369        9331 :     if (text[2] != 0)
+     370        9323 :         id[2] = text[2];
+     371             :     else
+     372             :         return;
+     373             : 
+     374        9323 :     if (text[3] != 0)
+     375        9160 :         id[3] = text[3];
+     376             :     else
+     377             :         return;
+     378             : }
+     379             : 
+     380         147 : void dlt_clean_string(char *text, int length)
+     381             : {
+     382             :     int num;
+     383             : 
+     384         147 :     if (text == NULL)
+     385             :         return;
+     386             : 
+     387        2002 :     for (num = 0; num < length; num++)
+     388        1855 :         if ((text[num] == '\r') || (text[num] == '\n'))
+     389           0 :             text[num] = ' ';
+     390             : }
+     391             : 
+     392           6 : DltReturnValue dlt_filter_init(DltFilter *filter, int verbose)
+     393             : {
+     394           6 :     PRINT_FUNCTION_VERBOSE(verbose);
+     395             : 
+     396           6 :     if (filter == NULL)
+     397             :         return DLT_RETURN_WRONG_PARAMETER;
+     398             : 
+     399           6 :     filter->counter = 0;
+     400             : 
+     401           6 :     return DLT_RETURN_OK;
+     402             : }
+     403             : 
+     404           0 : DltReturnValue dlt_filter_free(DltFilter *filter, int verbose)
+     405             : {
+     406           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+     407             : 
+     408           0 :     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         252 : DltReturnValue dlt_message_init(DltMessage *msg, int verbose)
+     642             : {
+     643         252 :     PRINT_FUNCTION_VERBOSE(verbose);
+     644             : 
+     645         252 :     if (msg == NULL)
+     646             :         return DLT_RETURN_WRONG_PARAMETER;
+     647             : 
+     648             :     /* initalise structure parameters */
+     649         250 :     msg->headersize = 0;
+     650         250 :     msg->datasize = 0;
+     651             : 
+     652         250 :     msg->databuffer = NULL;
+     653         250 :     msg->databuffersize = 0;
+     654             : 
+     655         250 :     msg->storageheader = NULL;
+     656         250 :     msg->standardheader = NULL;
+     657         250 :     msg->extendedheader = NULL;
+     658             : 
+     659         250 :     msg->found_serialheader = 0;
+     660             : 
+     661         250 :     return DLT_RETURN_OK;
+     662             : }
+     663             : 
+     664          64 : DltReturnValue dlt_message_free(DltMessage *msg, int verbose)
+     665             : {
+     666          64 :     PRINT_FUNCTION_VERBOSE(verbose);
+     667             : 
+     668          64 :     if (msg == NULL)
+     669             :         return DLT_RETURN_WRONG_PARAMETER;
+     670             : 
+     671             :     /* delete databuffer if exists */
+     672          62 :     if (msg->databuffer) {
+     673          48 :         free(msg->databuffer);
+     674          48 :         msg->databuffer = NULL;
+     675          48 :         msg->databuffersize = 0;
+     676             :     }
+     677             : 
+     678             :     return DLT_RETURN_OK;
+     679             : }
+     680             : 
+     681        1909 : DltReturnValue dlt_message_header(DltMessage *msg, char *text, size_t textlength, int verbose)
+     682             : {
+     683        1909 :     return dlt_message_header_flags(msg, text, textlength, DLT_HEADER_SHOW_ALL, verbose);
+     684             : }
+     685             : 
+     686        4611 : 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        4611 :     PRINT_FUNCTION_VERBOSE(verbose);
+     692             : 
+     693        4611 :     if ((msg == NULL) || (text == NULL) || (textlength <= 0))
+     694             :         return DLT_RETURN_WRONG_PARAMETER;
+     695             : 
+     696        4415 :     if ((DLT_IS_HTYP_UEH(msg->standardheader->htyp)) && (msg->extendedheader == NULL))
+     697             :         return DLT_RETURN_WRONG_PARAMETER;
+     698             : 
+     699        4415 :     if ((flags < DLT_HEADER_SHOW_NONE) || (flags > DLT_HEADER_SHOW_ALL))
+     700             :         return DLT_RETURN_WRONG_PARAMETER;
+     701             : 
+     702        4415 :     text[0] = 0;
+     703             : 
+     704        4415 :     if ((flags & DLT_HEADER_SHOW_TIME) == DLT_HEADER_SHOW_TIME) {
+     705             :         /* print received time */
+     706        2315 :         time_t tt = msg->storageheader->seconds;
+     707        2315 :         tzset();
+     708        2315 :         localtime_r(&tt, &timeinfo);
+     709        2315 :         strftime (buffer, sizeof(buffer), "%Y/%m/%d %H:%M:%S", &timeinfo);
+     710        2315 :         snprintf(text, textlength, "%s.%.6d ", buffer, msg->storageheader->microseconds);
+     711             :     }
+     712             : 
+     713        4415 :     if ((flags & DLT_HEADER_SHOW_TMSTP) == DLT_HEADER_SHOW_TMSTP) {
+     714             :         /* print timestamp if available */
+     715        2315 :         if (DLT_IS_HTYP_WTMS(msg->standardheader->htyp))
+     716         136 :             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        4415 :     if ((flags & DLT_HEADER_SHOW_MSGCNT) == DLT_HEADER_SHOW_MSGCNT)
+     722             :         /* print message counter */
+     723        2315 :         snprintf(text + strlen(text), textlength - strlen(text), "%.3d ", msg->standardheader->mcnt);
+     724             : 
+     725        4415 :     if ((flags & DLT_HEADER_SHOW_ECUID) == DLT_HEADER_SHOW_ECUID) {
+     726             :         /* print ecu id, use header extra if available, else storage header value */
+     727        2315 :         if (DLT_IS_HTYP_WEID(msg->standardheader->htyp))
+     728         136 :             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        4415 :     if ((flags & DLT_HEADER_SHOW_APID) == DLT_HEADER_SHOW_APID) {
+     736        2315 :         snprintf(text + strlen(text), textlength - strlen(text), " ");
+     737             : 
+     738        2315 :         if ((DLT_IS_HTYP_UEH(msg->standardheader->htyp)) && (msg->extendedheader->apid[0] != 0))
+     739         884 :             dlt_print_id(text + strlen(text), msg->extendedheader->apid);
+     740             :         else
+     741        1431 :             snprintf(text + strlen(text), textlength - strlen(text), "----");
+     742             : 
+     743        2315 :         snprintf(text + strlen(text), textlength - strlen(text), " ");
+     744             :     }
+     745             : 
+     746        4415 :     if ((flags & DLT_HEADER_SHOW_CTID) == DLT_HEADER_SHOW_CTID) {
+     747        2315 :         if ((DLT_IS_HTYP_UEH(msg->standardheader->htyp)) && (msg->extendedheader->ctid[0] != 0))
+     748         884 :             dlt_print_id(text + strlen(text), msg->extendedheader->ctid);
+     749             :         else
+     750        1431 :             snprintf(text + strlen(text), textlength - strlen(text), "----");
+     751             : 
+     752        2315 :         snprintf(text + strlen(text), textlength - strlen(text), " ");
+     753             :     }
+     754             : 
+     755             :     /* print info about message type and length */
+     756        4415 :     if (DLT_IS_HTYP_UEH(msg->standardheader->htyp)) {
+     757        1924 :         if ((flags & DLT_HEADER_SHOW_MSGTYPE) == DLT_HEADER_SHOW_MSGTYPE) {
+     758         884 :             snprintf(text + strlen(text), textlength - strlen(text), "%s",
+     759         884 :                      message_type[DLT_GET_MSIN_MSTP(msg->extendedheader->msin)]);
+     760         884 :             snprintf(text + strlen(text), textlength - strlen(text), " ");
+     761             :         }
+     762             : 
+     763        1924 :         if ((flags & DLT_HEADER_SHOW_MSGSUBTYPE) == DLT_HEADER_SHOW_MSGSUBTYPE) {
+     764         884 :             if ((DLT_GET_MSIN_MSTP(msg->extendedheader->msin)) == DLT_TYPE_LOG)
+     765         748 :                 snprintf(text + strlen(text), textlength - strlen(text), "%s",
+     766         748 :                          log_info[DLT_GET_MSIN_MTIN(msg->extendedheader->msin)]);
+     767             : 
+     768         884 :             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         884 :             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         884 :             if ((DLT_GET_MSIN_MSTP(msg->extendedheader->msin)) == DLT_TYPE_CONTROL)
+     777         136 :                 snprintf(text + strlen(text), textlength - strlen(text), "%s",
+     778         136 :                          control_type[DLT_GET_MSIN_MTIN(msg->extendedheader->msin)]);
+     779             : 
+     780         884 :             snprintf(text + strlen(text), textlength - strlen(text), " ");
+     781             :         }
+     782             : 
+     783        1924 :         if ((flags & DLT_HEADER_SHOW_VNVSTATUS) == DLT_HEADER_SHOW_VNVSTATUS) {
+     784             :             /* print verbose status pf message */
+     785         884 :             if (DLT_IS_MSIN_VERB(msg->extendedheader->msin))
+     786         748 :                 snprintf(text + strlen(text), textlength - strlen(text), "V");
+     787             :             else
+     788         136 :                 snprintf(text + strlen(text), textlength - strlen(text), "N");
+     789             : 
+     790         884 :             snprintf(text + strlen(text), textlength - strlen(text), " ");
+     791             :         }
+     792             : 
+     793        1924 :         if ((flags & DLT_HEADER_SHOW_NOARG) == DLT_HEADER_SHOW_NOARG)
+     794             :             /* print number of arguments */
+     795         884 :             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        2620 : 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        2620 :     PRINT_FUNCTION_VERBOSE(verbose);
+     833             : 
+     834        2620 :     if ((msg == NULL) || (msg->databuffer == NULL) || (text == NULL) ||
+     835        2561 :         (type < DLT_OUTPUT_HEX) || (type > DLT_OUTPUT_ASCII_LIMITED))
+     836             :         return DLT_RETURN_WRONG_PARAMETER;
+     837             : 
+     838        2430 :     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        2420 :     text[0] = 0;
+     845             : 
+     846             :     /* print payload only as hex */
+     847        2420 :     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        1894 :     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        1368 :     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         842 :     ptr = msg->databuffer;
+     858         842 :     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         842 :     if (DLT_MSG_IS_NONVERBOSE(msg)) {
+     868             : 
+     869         534 :         DLT_MSG_READ_VALUE(id_tmp, ptr, datalength, uint32_t);
+     870         534 :         id = DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp);
+     871             : 
+     872         534 :         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         534 :         if (DLT_MSG_IS_CONTROL(msg)) {
+     881          57 :             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           0 :             else if (!(DLT_MSG_IS_CONTROL_TIME(msg)))
+     885           0 :                 snprintf(text + strlen(text), textlength - strlen(text), "service(%u)", id); /* service id */
+     886             : 
+     887          57 :             if (datalength > 0)
+     888          57 :                 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         534 :         if (DLT_MSG_IS_CONTROL_RESPONSE(msg)) {
+     896           1 :             if (datalength > 0) {
+     897           1 :                 DLT_MSG_READ_VALUE(retval, ptr, datalength, uint8_t); /* No endian conversion necessary */
+     898             : 
+     899           1 :                 if ((retval < DLT_SERVICE_RESPONSE_LAST) || (retval == 8))
+     900           0 :                     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           1 :                 if (datalength >= 1)
+     905           1 :                     snprintf(text + strlen(text), textlength - strlen(text), ", ");
+     906             :             }
+     907             :         }
+     908             : 
+     909         534 :         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         412 :             ret = dlt_print_hex_string(text + strlen(text), (int)(textlength - strlen(text)), ptr, datalength);
+     923             :         }
+     924             : 
+     925         534 :         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         833 :     for (num = 0; num < (int)(msg->extendedheader->noar); num++) {
+     935         525 :         if (num != 0) {
+     936         231 :             text_offset = (int)strlen(text);
+     937         231 :             snprintf(text + text_offset, textlength - (size_t)text_offset, " ");
+     938             :         }
+     939             : 
+     940             :         /* first read the type info of the argument */
+     941         525 :         DLT_MSG_READ_VALUE(type_info_tmp, ptr, datalength, uint32_t);
+     942         525 :         type_info = DLT_ENDIAN_GET_32(msg->standardheader->htyp, type_info_tmp);
+     943             : 
+     944             :         /* print out argument */
+     945         525 :         text_offset = (int)strlen(text);
+     946             : 
+     947         525 :         if (dlt_message_argument_print(msg, type_info, pptr, pdatalength,
+     948         525 :                                        (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         246 : 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         246 :     PRINT_FUNCTION_VERBOSE(verbose);
+     992             : 
+     993         246 :     if ((msg == NULL) || (buffer == NULL) || (length <= 0))
+     994             :         return DLT_MESSAGE_ERROR_UNKNOWN;
+     995             : 
+     996             :     /* initialize resync_offset */
+     997          26 :     msg->resync_offset = 0;
+     998             : 
+     999             :     /* check if message contains serial header, smaller than standard header */
+    1000          26 :     if (length < sizeof(dltSerialHeader))
+    1001             :         /* dlt_log(LOG_ERR, "Length smaller than serial header!\n"); */
+    1002             :         return DLT_MESSAGE_ERROR_SIZE;
+    1003             : 
+    1004          26 :     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          26 :         msg->found_serialheader = 0;
+    1013             : 
+    1014          26 :         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          26 :     if (length < sizeof(DltStandardHeader))
+    1041             :         /* dlt_log(LOG_ERR, "Length smaller than standard header!\n"); */
+    1042             :         return DLT_MESSAGE_ERROR_SIZE;
+    1043             : 
+    1044          26 :     memcpy(msg->headerbuffer + sizeof(DltStorageHeader), buffer, sizeof(DltStandardHeader));
+    1045             : 
+    1046             :     /* set ptrs to structures */
+    1047          26 :     msg->storageheader = (DltStorageHeader *)msg->headerbuffer;
+    1048          26 :     msg->standardheader = (DltStandardHeader *)(msg->headerbuffer + sizeof(DltStorageHeader));
+    1049             : 
+    1050             :     /* calculate complete size of headers */
+    1051          26 :     extra_size = (uint32_t) (DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp) +
+    1052             :         (DLT_IS_HTYP_UEH(msg->standardheader->htyp) ? sizeof(DltExtendedHeader) : 0));
+    1053          26 :     msg->headersize = (uint32_t) (sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + extra_size);
+    1054          26 :     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          26 :     temp_datasize = DLT_BETOH_16(msg->standardheader->len) - (int32_t) msg->headersize + (int32_t) sizeof(DltStorageHeader);
+    1059             : 
+    1060             :     /* check data size */
+    1061          26 :     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          26 :         msg->datasize = (uint32_t) temp_datasize;
+    1069             :     }
+    1070             : 
+    1071             :     /* check if verbose mode is on*/
+    1072          26 :     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          26 :     if (extra_size > 0) {
+    1079          26 :         if (length < (msg->headersize - sizeof(DltStorageHeader)))
+    1080             :             return DLT_MESSAGE_ERROR_SIZE;
+    1081             : 
+    1082          26 :         memcpy(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader),
+    1083          26 :                buffer + sizeof(DltStandardHeader), (size_t)extra_size);
+    1084             : 
+    1085             :         /* set extended header ptr and get standard header extra parameters */
+    1086          26 :         if (DLT_IS_HTYP_UEH(msg->standardheader->htyp))
+    1087          26 :             msg->extendedheader =
+    1088          26 :                 (DltExtendedHeader *)(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+    1089          26 :                                       DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp));
+    1090             :         else
+    1091           0 :             msg->extendedheader = NULL;
+    1092             : 
+    1093          26 :         dlt_message_get_extraparameters(msg, verbose);
+    1094             :     }
+    1095             : 
+    1096             :     /* check if payload fits length */
+    1097          26 :     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          21 :     if (msg->databuffer) {
+    1103          17 :         if (msg->datasize > msg->databuffersize) {
+    1104           2 :             free(msg->databuffer);
+    1105           2 :             msg->databuffer = (uint8_t *)malloc(msg->datasize);
+    1106           2 :             msg->databuffersize = msg->datasize;
+    1107             :         }
+    1108             :     }
+    1109             :     else {
+    1110             :         /* get new memory for buffer */
+    1111           4 :         msg->databuffer = (uint8_t *)malloc(msg->datasize);
+    1112           4 :         msg->databuffersize = msg->datasize;
+    1113             :     }
+    1114             : 
+    1115          21 :     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          21 :     memcpy(msg->databuffer, buffer + (msg->headersize - sizeof(DltStorageHeader)), msg->datasize);
+    1124             : 
+    1125          21 :     return DLT_MESSAGE_ERROR_OK;
+    1126             : }
+    1127             : 
+    1128         494 : DltReturnValue dlt_message_get_extraparameters(DltMessage *msg, int verbose)
+    1129             : {
+    1130         494 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1131             : 
+    1132         494 :     if (msg == NULL)
+    1133             :         return DLT_RETURN_WRONG_PARAMETER;
+    1134             : 
+    1135         492 :     if (DLT_IS_HTYP_WEID(msg->standardheader->htyp))
+    1136         298 :         memcpy(msg->headerextra.ecu,
+    1137             :                msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader),
+    1138             :                DLT_ID_SIZE);
+    1139             : 
+    1140         492 :     if (DLT_IS_HTYP_WSID(msg->standardheader->htyp)) {
+    1141           7 :         memcpy(&(msg->headerextra.seid), msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader)
+    1142           7 :                + (DLT_IS_HTYP_WEID(msg->standardheader->htyp) ? DLT_SIZE_WEID : 0), DLT_SIZE_WSID);
+    1143           7 :         msg->headerextra.seid = DLT_BETOH_32(msg->headerextra.seid);
+    1144             :     }
+    1145             : 
+    1146         492 :     if (DLT_IS_HTYP_WTMS(msg->standardheader->htyp)) {
+    1147         596 :         memcpy(&(msg->headerextra.tmsp), msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader)
+    1148         298 :                + (DLT_IS_HTYP_WEID(msg->standardheader->htyp) ? DLT_SIZE_WEID : 0)
+    1149         298 :                + (DLT_IS_HTYP_WSID(msg->standardheader->htyp) ? DLT_SIZE_WSID : 0), DLT_SIZE_WTMS);
+    1150         298 :         msg->headerextra.tmsp = DLT_BETOH_32(msg->headerextra.tmsp);
+    1151             :     }
+    1152             : 
+    1153             :     return DLT_RETURN_OK;
+    1154             : }
+    1155             : 
+    1156         425 : DltReturnValue dlt_message_set_extraparameters(DltMessage *msg, int verbose)
+    1157             : {
+    1158         425 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1159             : 
+    1160         425 :     if (msg == NULL)
+    1161             :         return DLT_RETURN_WRONG_PARAMETER;
+    1162             : 
+    1163         423 :     if (DLT_IS_HTYP_WEID(msg->standardheader->htyp))
+    1164         227 :         memcpy(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader),
+    1165         227 :                msg->headerextra.ecu,
+    1166             :                DLT_ID_SIZE);
+    1167             : 
+    1168         423 :     if (DLT_IS_HTYP_WSID(msg->standardheader->htyp)) {
+    1169         186 :         msg->headerextra.seid = DLT_HTOBE_32(msg->headerextra.seid);
+    1170         186 :         memcpy(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader)
+    1171         186 :                + (DLT_IS_HTYP_WEID(msg->standardheader->htyp) ? DLT_SIZE_WEID : 0),
+    1172         186 :                &(msg->headerextra.seid),
+    1173             :                DLT_SIZE_WSID);
+    1174             :     }
+    1175             : 
+    1176         423 :     if (DLT_IS_HTYP_WTMS(msg->standardheader->htyp)) {
+    1177         227 :         msg->headerextra.tmsp = DLT_HTOBE_32(msg->headerextra.tmsp);
+    1178         454 :         memcpy(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader)
+    1179         227 :                + (DLT_IS_HTYP_WEID(msg->standardheader->htyp) ? DLT_SIZE_WEID : 0)
+    1180         227 :                + (DLT_IS_HTYP_WSID(msg->standardheader->htyp) ? DLT_SIZE_WSID : 0),
+    1181         227 :                &(msg->headerextra.tmsp),
+    1182             :                DLT_SIZE_WTMS);
+    1183             :     }
+    1184             : 
+    1185             :     return DLT_RETURN_OK;
+    1186             : }
+    1187             : 
+    1188          28 : DltReturnValue dlt_file_init(DltFile *file, int verbose)
+    1189             : {
+    1190          28 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1191             : 
+    1192          28 :     if (file == NULL)
+    1193             :         return DLT_RETURN_WRONG_PARAMETER;
+    1194             : 
+    1195             :     /* initalise structure parameters */
+    1196          28 :     file->handle = NULL;
+    1197          28 :     file->counter = 0;
+    1198          28 :     file->counter_total = 0;
+    1199          28 :     file->index = NULL;
+    1200             : 
+    1201          28 :     file->filter = NULL;
+    1202          28 :     file->filter_counter = 0;
+    1203          28 :     file->file_position = 0;
+    1204             : 
+    1205          28 :     file->position = 0;
+    1206             : 
+    1207          28 :     file->error_messages = 0;
+    1208             : 
+    1209          28 :     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        5592 : DltReturnValue dlt_file_read_header(DltFile *file, int verbose)
+    1226             : {
+    1227        5592 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1228             : 
+    1229        5592 :     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       11184 :         if (fread(file->msg.headerbuffer,
+    1236             :                   sizeof(DltStorageHeader) + sizeof(DltStandardHeader), 1,
+    1237             :                   file->handle) != 1) {
+    1238          21 :             if (!feof(file->handle))
+    1239           0 :                 dlt_log(LOG_WARNING, "Cannot read header from file!\n");
+    1240             :             else
+    1241          21 :                 dlt_log(LOG_DEBUG, "Reached end of file\n");
+    1242             : 
+    1243          21 :             return DLT_RETURN_ERROR;
+    1244             :         }
+    1245             : 
+    1246             :         /* set ptrs to structures */
+    1247        5571 :         file->msg.storageheader = (DltStorageHeader *)file->msg.headerbuffer;
+    1248        5571 :         file->msg.standardheader = (DltStandardHeader *)(file->msg.headerbuffer +
+    1249             :                                                          sizeof(DltStorageHeader));
+    1250             : 
+    1251             :         /* check id of storage header */
+    1252        5571 :         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        5571 :     file->msg.headersize = (uint32_t) (sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+    1269        5571 :         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        5571 :     temp_datasize = DLT_BETOH_16(file->msg.standardheader->len) + (int32_t) sizeof(DltStorageHeader) - (int32_t) file->msg.headersize;
+    1275             : 
+    1276             :     /* check data size */
+    1277        5571 :     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        5571 :         file->msg.datasize = (uint32_t) temp_datasize;
+    1284             :     }
+    1285             : 
+    1286             :     /* check if verbose mode is on */
+    1287        5571 :     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        3996 : DltReturnValue dlt_file_read_header_extended(DltFile *file, int verbose)
+    1395             : {
+    1396        3996 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1397             : 
+    1398        3996 :     if (file == NULL)
+    1399             :         return DLT_RETURN_WRONG_PARAMETER;
+    1400             : 
+    1401             :     /* load standard header extra parameters if used */
+    1402        3996 :     if (DLT_STANDARD_HEADER_EXTRA_SIZE(file->msg.standardheader->htyp)) {
+    1403         512 :         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         256 :         dlt_message_get_extraparameters(&(file->msg), verbose);
+    1411             :     }
+    1412             : 
+    1413             :     /* load Extended header if used */
+    1414        3996 :     if (DLT_IS_HTYP_UEH(file->msg.standardheader->htyp) == 0)
+    1415             :         /* there is nothing to be loaded */
+    1416             :         return DLT_RETURN_OK;
+    1417             : 
+    1418        1664 :     if (fread(file->msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+    1419        1664 :               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        1664 :     if (DLT_IS_HTYP_UEH(file->msg.standardheader->htyp))
+    1428        1664 :         file->msg.extendedheader =
+    1429        1664 :             (DltExtendedHeader *)(file->msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+    1430        1664 :                                   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        3366 : DltReturnValue dlt_file_read_data(DltFile *file, int verbose)
+    1438             : {
+    1439        3366 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1440             : 
+    1441        3366 :     if (file == NULL)
+    1442             :         return DLT_RETURN_WRONG_PARAMETER;
+    1443             : 
+    1444             :     /* free last used memory for buffer */
+    1445        3366 :     if (file->msg.databuffer && (file->msg.databuffersize < file->msg.datasize)) {
+    1446         126 :         free(file->msg.databuffer);
+    1447         126 :         file->msg.databuffer = NULL;
+    1448             :     }
+    1449             : 
+    1450        3366 :     if (file->msg.databuffer == NULL) {
+    1451             :         /* get new memory for buffer */
+    1452         148 :         file->msg.databuffer = (uint8_t *)malloc(file->msg.datasize);
+    1453         148 :         file->msg.databuffersize = file->msg.datasize;
+    1454             :     }
+    1455             : 
+    1456        3366 :     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        6732 :     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          32 : DltReturnValue dlt_file_open(DltFile *file, const char *filename, int verbose)
+    1477             : {
+    1478          32 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1479             : 
+    1480          32 :     if ((file == NULL) || (filename == NULL))
+    1481             :         return DLT_RETURN_WRONG_PARAMETER;
+    1482             : 
+    1483             :     /* reset counters */
+    1484          26 :     file->counter = 0;
+    1485          26 :     file->counter_total = 0;
+    1486          26 :     file->position = 0;
+    1487          26 :     file->file_position = 0;
+    1488          26 :     file->file_length = 0;
+    1489          26 :     file->error_messages = 0;
+    1490             : 
+    1491          26 :     if (file->handle)
+    1492           0 :         fclose(file->handle);
+    1493             : 
+    1494             :     /* open dlt file */
+    1495          26 :     file->handle = fopen(filename, "rb");
+    1496             : 
+    1497          26 :     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          26 :     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          26 :     file->file_length = ftell(file->handle);
+    1508             : 
+    1509          26 :     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          26 :     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        2226 : DltReturnValue dlt_file_read(DltFile *file, int verbose)
+    1522             : {
+    1523             :     long *ptr;
+    1524             :     int found = DLT_RETURN_OK;
+    1525             : 
+    1526        2226 :     if (file == NULL)
+    1527             :         return DLT_RETURN_WRONG_PARAMETER;
+    1528             : 
+    1529        2226 :     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        2226 :     if (file->counter % DLT_COMMON_INDEX_ALLOC == 0) {
+    1534         333 :         ptr = (long *)malloc(((file->counter / DLT_COMMON_INDEX_ALLOC) + 1) * DLT_COMMON_INDEX_ALLOC * sizeof(long));
+    1535             : 
+    1536         333 :         if (ptr == NULL)
+    1537             :             return DLT_RETURN_ERROR;
+    1538             : 
+    1539         333 :         if (file->index) {
+    1540         312 :             memcpy(ptr, file->index, (size_t)(file->counter) * sizeof(long));
+    1541         312 :             free(file->index);
+    1542             :         }
+    1543             : 
+    1544         333 :         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        2226 :     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        2226 :     if (verbose)
+    1556           0 :         dlt_vlog(LOG_INFO, "Position in file: %" PRIu64 "\n", file->file_position);
+    1557             : 
+    1558             :     /* read header */
+    1559        2226 :     if (dlt_file_read_header(file, verbose) < DLT_RETURN_OK) {
+    1560             :         /* go back to last position in file */
+    1561          21 :         fseek(file->handle, file->file_position, SEEK_SET);
+    1562          21 :         return DLT_RETURN_ERROR;
+    1563             :     }
+    1564             : 
+    1565        2205 :     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        1575 :         if (fseek(file->handle,
+    1603        1575 :                   (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        1575 :         file->index[file->counter] = file->file_position;
+    1620        1575 :         file->counter++;
+    1621        1575 :         file->position = file->counter - 1;
+    1622             : 
+    1623             :         found = DLT_RETURN_TRUE;
+    1624             :     }
+    1625             : 
+    1626             :     /* increase total message counter */
+    1627        2205 :     file->counter_total++;
+    1628             : 
+    1629             :     /* store position to next message */
+    1630        2205 :     file->file_position = ftell(file->handle);
+    1631             : 
+    1632        2205 :     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        3261 : DltReturnValue dlt_file_message(DltFile *file, int index, int verbose)
+    1727             : {
+    1728        3261 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1729             : 
+    1730        3261 :     if (file == NULL)
+    1731             :         return DLT_RETURN_WRONG_PARAMETER;
+    1732             : 
+    1733             :     /* check if message is in range */
+    1734        3261 :     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        3261 :     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        3261 :     if (dlt_file_read_header(file, verbose) < DLT_RETURN_OK)
+    1748             :         return DLT_RETURN_ERROR;
+    1749             : 
+    1750        3261 :     if (dlt_file_read_header_extended(file, verbose) < DLT_RETURN_OK)
+    1751             :         return DLT_RETURN_ERROR;
+    1752             : 
+    1753        3261 :     if (dlt_file_read_data(file, verbose) < DLT_RETURN_OK)
+    1754             :         return DLT_RETURN_ERROR;
+    1755             : 
+    1756             :     /* set current position in file */
+    1757        3261 :     file->position = index;
+    1758             : 
+    1759        3261 :     return DLT_RETURN_OK;
+    1760             : }
+    1761             : 
+    1762          26 : DltReturnValue dlt_file_free(DltFile *file, int verbose)
+    1763             : {
+    1764          26 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1765             : 
+    1766          26 :     if (file == NULL)
+    1767             :         return DLT_RETURN_WRONG_PARAMETER;
+    1768             : 
+    1769             :     /* delete index lost if exists */
+    1770          26 :     if (file->index)
+    1771          19 :         free(file->index);
+    1772             : 
+    1773          26 :     file->index = NULL;
+    1774             : 
+    1775             :     /* close file */
+    1776          26 :     if (file->handle)
+    1777          24 :         fclose(file->handle);
+    1778             : 
+    1779          26 :     file->handle = NULL;
+    1780             : 
+    1781          26 :     return dlt_message_free(&(file->msg), verbose);
+    1782             : }
+    1783             : 
+    1784          12 : void dlt_log_set_level(int level)
+    1785             : {
+    1786          12 :     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          12 :         logging_level = level;
+    1794             :     }
+    1795          12 : }
+    1796             : 
+    1797          10 : void dlt_log_set_filename(const char *filename)
+    1798             : {
+    1799             :     /* check nullpointer */
+    1800          10 :     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           9 :     logging_filename[NAME_MAX] = 0;
+    1807             : }
+    1808             : 
+    1809             : #if defined DLT_DAEMON_USE_FIFO_IPC || defined DLT_LIB_USE_FIFO_IPC
+    1810        6689 : void dlt_log_set_fifo_basedir(const char *pipe_dir)
+    1811             : {
+    1812             :     strncpy(dltFifoBaseDir, pipe_dir, DLT_PATH_MAX);
+    1813        6689 :     dltFifoBaseDir[DLT_PATH_MAX - 1] = 0;
+    1814        6687 : }
+    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          19 : 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          19 :     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          19 :     logging_mode = mode;
+    1844             : 
+    1845          19 :     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           8 : void dlt_log_free(void)
+    1912             : {
+    1913           8 :     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           8 : }
+    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      818061 : 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      818061 :     if (s == NULL)
+    1973             :         return DLT_RETURN_WRONG_PARAMETER;
+    1974             : 
+    1975      818060 :     if (logging_level < prio)
+    1976             :         return DLT_RETURN_OK;
+    1977             : 
+    1978      817992 :     if ((prio < 0) || (prio > LOG_DEBUG))
+    1979             :         prio = LOG_DEBUG + 1;
+    1980             : 
+    1981      817992 :     clock_gettime(CLOCK_MONOTONIC, &sTimeSpec);
+    1982             : 
+    1983      817992 :     switch (logging_mode) {
+    1984          62 :     case DLT_LOG_TO_CONSOLE:
+    1985             :         /* log to stdout */
+    1986         124 :         fprintf(stdout, sFormatString,
+    1987          62 :                 (unsigned int)sTimeSpec.tv_sec,
+    1988          62 :                 (unsigned int)(sTimeSpec.tv_nsec / 1000),
+    1989             :                 getpid(),
+    1990          62 :                 asSeverity[prio],
+    1991             :                 s);
+    1992          62 :         fflush(stdout);
+    1993          62 :         break;
+    1994      817893 :     case DLT_LOG_TO_STDERR:
+    1995             :         /* log to stderr */
+    1996     1635786 :         fprintf(stderr, sFormatString,
+    1997      817893 :                 (unsigned int)sTimeSpec.tv_sec,
+    1998      817893 :                 (unsigned int)(sTimeSpec.tv_nsec / 1000),
+    1999             :                 getpid(),
+    2000      817893 :                 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      818423 : DltReturnValue dlt_vlog(int prio, const char *format, ...)
+    2040             : {
+    2041      818423 :     char outputString[2048] = { 0 }; /* TODO: what is a reasonable string length here? */
+    2042             : 
+    2043             :     va_list args;
+    2044             : 
+    2045      818423 :     if (format == NULL)
+    2046             :         return DLT_RETURN_WRONG_PARAMETER;
+    2047             : 
+    2048      818423 :     if (logging_level < prio)
+    2049             :         return DLT_RETURN_OK;
+    2050             : 
+    2051      811258 :     va_start(args, format);
+    2052             :     vsnprintf(outputString, 2047, format, args);
+    2053      811258 :     va_end(args);
+    2054             : 
+    2055      811258 :     dlt_log(prio, outputString);
+    2056             : 
+    2057      811258 :     return DLT_RETURN_OK;
+    2058             : }
+    2059             : 
+    2060        6687 : DltReturnValue dlt_vnlog(int prio, size_t size, const char *format, ...)
+    2061             : {
+    2062             :     char *outputString = NULL;
+    2063             : 
+    2064             :     va_list args;
+    2065             : 
+    2066        6687 :     if (format == NULL)
+    2067             :         return DLT_RETURN_WRONG_PARAMETER;
+    2068             : 
+    2069        6687 :     if ((logging_level < prio) || (size == 0))
+    2070             :         return DLT_RETURN_OK;
+    2071             : 
+    2072        6687 :     if ((outputString = (char *)calloc(size + 1, sizeof(char))) == NULL)
+    2073             :         return DLT_RETURN_ERROR;
+    2074             : 
+    2075        6687 :     va_start(args, format);
+    2076             :     vsnprintf(outputString, size, format, args);
+    2077        6687 :     va_end(args);
+    2078             : 
+    2079        6687 :     dlt_log(prio, outputString);
+    2080             : 
+    2081        6687 :     free(outputString);
+    2082             :     outputString = NULL;
+    2083             : 
+    2084        6687 :     return DLT_RETURN_OK;
+    2085             : }
+    2086             : 
+    2087        6702 : DltReturnValue dlt_receiver_init(DltReceiver *receiver, int fd, DltReceiverType type, int buffersize)
+    2088             : {
+    2089        6702 :     if (NULL == receiver)
+    2090             :         return DLT_RETURN_WRONG_PARAMETER;
+    2091             : 
+    2092        6702 :     receiver->fd = fd;
+    2093        6702 :     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        6702 :     if ((NULL != receiver->buffer) && ( buffersize != receiver->buffersize)) {
+    2099           0 :        free(receiver->buffer);
+    2100           0 :        receiver->buffer = NULL;
+    2101             :     }
+    2102             : 
+    2103        6702 :     if (NULL == receiver->buffer) {
+    2104        6702 :         receiver->lastBytesRcvd = 0;
+    2105        6702 :         receiver->bytesRcvd = 0;
+    2106        6702 :         receiver->totalBytesRcvd = 0;
+    2107        6702 :         receiver->buf = NULL;
+    2108        6702 :         receiver->backup_buf = NULL;
+    2109        6702 :         receiver->buffer = (char *)calloc(1, (size_t)buffersize);
+    2110        6702 :         receiver->buffersize = (uint32_t)buffersize;
+    2111             :     }
+    2112             : 
+    2113        6702 :     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        6702 :         receiver->buf = receiver->buffer;
+    2119             :     }
+    2120             : 
+    2121        6702 :     return DLT_RETURN_OK;
+    2122             : }
+    2123             : 
+    2124           2 : DltReturnValue dlt_receiver_init_global_buffer(DltReceiver *receiver, int fd, DltReceiverType type, char **buffer)
+    2125             : {
+    2126           2 :     if (receiver == NULL)
+    2127             :         return DLT_RETURN_WRONG_PARAMETER;
+    2128             : 
+    2129           2 :     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           2 :         *buffer = (char *)malloc(DLT_RECEIVE_BUFSIZE);
+    2134             : 
+    2135           2 :         if (*buffer == NULL)
+    2136             :             return DLT_RETURN_ERROR;
+    2137             :     }
+    2138             : 
+    2139           2 :     receiver->lastBytesRcvd = 0;
+    2140           2 :     receiver->bytesRcvd = 0;
+    2141           2 :     receiver->totalBytesRcvd = 0;
+    2142           2 :     receiver->buffersize = DLT_RECEIVE_BUFSIZE;
+    2143           2 :     receiver->fd = fd;
+    2144           2 :     receiver->type = type;
+    2145           2 :     receiver->buffer = *buffer;
+    2146           2 :     receiver->backup_buf = NULL;
+    2147           2 :     receiver->buf = receiver->buffer;
+    2148             : 
+    2149           2 :     return DLT_RETURN_OK;
+    2150             : }
+    2151             : 
+    2152        6702 : DltReturnValue dlt_receiver_free(DltReceiver *receiver)
+    2153             : {
+    2154             : 
+    2155        6702 :     if (receiver == NULL)
+    2156             :         return DLT_RETURN_WRONG_PARAMETER;
+    2157             : 
+    2158        6702 :     if (receiver->buffer)
+    2159        6700 :         free(receiver->buffer);
+    2160             : 
+    2161        6702 :     if (receiver->backup_buf)
+    2162           0 :         free(receiver->backup_buf);
+    2163             : 
+    2164        6702 :     receiver->buffer = NULL;
+    2165        6702 :     receiver->buf = NULL;
+    2166        6702 :     receiver->backup_buf = NULL;
+    2167             : 
+    2168        6702 :     return DLT_RETURN_OK;
+    2169             : }
+    2170             : 
+    2171           2 : DltReturnValue dlt_receiver_free_global_buffer(DltReceiver *receiver)
+    2172             : {
+    2173             : 
+    2174           2 :     if (receiver == NULL)
+    2175             :         return DLT_RETURN_WRONG_PARAMETER;
+    2176             : 
+    2177           2 :     if (receiver->backup_buf)
+    2178           0 :         free(receiver->backup_buf);
+    2179             : 
+    2180           2 :     receiver->buffer = NULL;
+    2181           2 :     receiver->buf = NULL;
+    2182           2 :     receiver->backup_buf = NULL;
+    2183             : 
+    2184           2 :     return DLT_RETURN_OK;
+    2185             : }
+    2186             : 
+    2187          12 : int dlt_receiver_receive(DltReceiver *receiver)
+    2188             : {
+    2189             :     socklen_t addrlen;
+    2190             : 
+    2191          12 :     if (receiver == NULL)
+    2192             :         return -1;
+    2193             : 
+    2194          12 :     if (receiver->buffer == NULL)
+    2195             :         return -1;
+    2196             : 
+    2197          11 :     receiver->buf = (char *)receiver->buffer;
+    2198          11 :     receiver->lastBytesRcvd = receiver->bytesRcvd;
+    2199             : 
+    2200          11 :     if ((receiver->lastBytesRcvd) && (receiver->backup_buf != NULL)) {
+    2201           2 :         memcpy(receiver->buf, receiver->backup_buf, (size_t)receiver->lastBytesRcvd);
+    2202           2 :         free(receiver->backup_buf);
+    2203           2 :         receiver->backup_buf = NULL;
+    2204             :     }
+    2205             : 
+    2206          11 :     if (receiver->type == DLT_RECEIVE_SOCKET)
+    2207             :         /* wait for data from socket */
+    2208          11 :         receiver->bytesRcvd = recv(receiver->fd,
+    2209          11 :                                    receiver->buf + receiver->lastBytesRcvd,
+    2210          11 :                                    receiver->buffersize - (uint32_t) receiver->lastBytesRcvd,
+    2211             :                                    0);
+    2212           0 :     else if (receiver->type == DLT_RECEIVE_FD)
+    2213             :         /* wait for data from fd */
+    2214           0 :         receiver->bytesRcvd = read(receiver->fd,
+    2215           0 :                                    receiver->buf + receiver->lastBytesRcvd,
+    2216           0 :                                    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          11 :     if (receiver->bytesRcvd <= 0) {
+    2230           0 :         receiver->bytesRcvd = 0;
+    2231           0 :         return receiver->bytesRcvd;
+    2232             :     } /* if */
+    2233             : 
+    2234          11 :     receiver->totalBytesRcvd += receiver->bytesRcvd;
+    2235          11 :     receiver->bytesRcvd += receiver->lastBytesRcvd;
+    2236             : 
+    2237          11 :     return receiver->bytesRcvd;
+    2238             : }
+    2239             : 
+    2240          21 : DltReturnValue dlt_receiver_remove(DltReceiver *receiver, int size)
+    2241             : {
+    2242          21 :     if (receiver == NULL)
+    2243             :         return DLT_RETURN_WRONG_PARAMETER;
+    2244             : 
+    2245          21 :     if (receiver->buf == NULL)
+    2246             :         return DLT_RETURN_ERROR;
+    2247             : 
+    2248          21 :     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          21 :     receiver->bytesRcvd = receiver->bytesRcvd - size;
+    2255           0 :     receiver->buf = receiver->buf + size;
+    2256             : 
+    2257          21 :     return DLT_RETURN_OK;
+    2258             : }
+    2259             : 
+    2260          11 : DltReturnValue dlt_receiver_move_to_begin(DltReceiver *receiver)
+    2261             : {
+    2262          11 :     if (receiver == NULL)
+    2263             :         return DLT_RETURN_WRONG_PARAMETER;
+    2264             : 
+    2265          11 :     if ((receiver->buffer == NULL) || (receiver->buf == NULL))
+    2266             :         return DLT_RETURN_ERROR;
+    2267             : 
+    2268          11 :     if ((receiver->buffer != receiver->buf) && (receiver->bytesRcvd != 0)) {
+    2269           2 :         receiver->backup_buf = calloc((size_t)(receiver->bytesRcvd + 1), sizeof(char));
+    2270             : 
+    2271           2 :         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           2 :             memcpy(receiver->backup_buf, receiver->buf, (size_t)receiver->bytesRcvd);
+    2277             :     }
+    2278             : 
+    2279             :     return DLT_RETURN_OK;
+    2280             : }
+    2281             : 
+    2282           0 : int dlt_receiver_check_and_get(DltReceiver *receiver,
+    2283             :                                void *dest,
+    2284             :                                unsigned int to_get,
+    2285             :                                unsigned int flags)
+    2286             : {
+    2287           0 :     size_t min_size = (size_t)to_get;
+    2288             :     uint8_t *src = NULL;
+    2289             : 
+    2290           0 :     if (flags & DLT_RCV_SKIP_HEADER)
+    2291           0 :         min_size += sizeof(DltUserHeader);
+    2292             : 
+    2293           0 :     if (!receiver ||
+    2294           0 :         (receiver->bytesRcvd < (int32_t) min_size) ||
+    2295           0 :         !receiver->buf ||
+    2296             :         !dest)
+    2297             :         return DLT_RETURN_WRONG_PARAMETER;
+    2298             : 
+    2299             :     src = (uint8_t *)receiver->buf;
+    2300             : 
+    2301           0 :     if (flags & DLT_RCV_SKIP_HEADER)
+    2302           0 :         src += sizeof(DltUserHeader);
+    2303             : 
+    2304             :     memcpy(dest, src, to_get);
+    2305             : 
+    2306           0 :     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           0 :     return to_get;
+    2314             : }
+    2315             : 
+    2316         234 : DltReturnValue dlt_set_storageheader(DltStorageHeader *storageheader, const char *ecu)
+    2317             : {
+    2318             : 
+    2319             : #if !defined(_MSC_VER)
+    2320             :     struct timeval tv;
+    2321             : #endif
+    2322             : 
+    2323         234 :     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         234 :     gettimeofday(&tv, NULL);
+    2331             : #endif
+    2332             : 
+    2333             :     /* prepare storage header */
+    2334         234 :     storageheader->pattern[0] = 'D';
+    2335         234 :     storageheader->pattern[1] = 'L';
+    2336         234 :     storageheader->pattern[2] = 'T';
+    2337         234 :     storageheader->pattern[3] = 0x01;
+    2338             : 
+    2339         234 :     dlt_set_id(storageheader->ecu, ecu);
+    2340             : 
+    2341             :     /* Set current time */
+    2342             : #if defined(_MSC_VER)
+    2343             :     storageheader->microseconds = 0;
+    2344             : #else
+    2345         234 :     storageheader->seconds = (uint32_t) tv.tv_sec; /* value is long */
+    2346         234 :     storageheader->microseconds = (int32_t) tv.tv_usec; /* value is long */
+    2347             : #endif
+    2348             : 
+    2349         234 :     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        5571 : DltReturnValue dlt_check_storageheader(DltStorageHeader *storageheader)
+    2364             : {
+    2365        5571 :     if (storageheader == NULL)
+    2366             :         return DLT_RETURN_WRONG_PARAMETER;
+    2367             : 
+    2368       11142 :     return ((storageheader->pattern[0] == 'D') &&
+    2369        5571 :             (storageheader->pattern[1] == 'L') &&
+    2370        5571 :             (storageheader->pattern[2] == 'T') &&
+    2371        5571 :             (storageheader->pattern[3] == 1))
+    2372       11142 :            ? 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        6811 : 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        6811 :     if (buf == NULL)
+    2435             :         return DLT_RETURN_WRONG_PARAMETER;
+    2436             : 
+    2437             :     /* catch 0 logical errors */
+    2438        6803 :     if ((min_size == 0) || (max_size == 0) || (step_size == 0))
+    2439             :         return DLT_RETURN_WRONG_PARAMETER;
+    2440             : 
+    2441        6796 :     if (min_size > max_size)
+    2442             :         return DLT_RETURN_WRONG_PARAMETER;
+    2443             : 
+    2444        6796 :     if (step_size > max_size)
+    2445             :         return DLT_RETURN_WRONG_PARAMETER;
+    2446             : 
+    2447             :     /* Init parameters */
+    2448        6796 :     buf->min_size = min_size;
+    2449        6796 :     buf->max_size = max_size;
+    2450        6796 :     buf->step_size = step_size;
+    2451             : 
+    2452             :     /* allocat memory */
+    2453        6796 :     buf->shm = malloc(buf->min_size);
+    2454             : 
+    2455        6796 :     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        6796 :     head->read = 0;
+    2465        6796 :     head->write = 0;
+    2466        6796 :     head->count = 0;
+    2467        6796 :     buf->mem = (unsigned char *)(buf->shm + sizeof(DltBufferHead));
+    2468             : 
+    2469        6796 :     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        6796 :     buf->size = (uint32_t) (buf->min_size - sizeof(DltBufferHead));
+    2477             : 
+    2478        6796 :     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        6796 :     memset(buf->mem, 0, (size_t)buf->size);
+    2484             : 
+    2485        6796 :     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        6785 : DltReturnValue dlt_buffer_free_dynamic(DltBuffer *buf)
+    2504             : {
+    2505             :     /* catch null pointer */
+    2506        6785 :     if (buf == NULL)
+    2507             :         return DLT_RETURN_WRONG_PARAMETER;
+    2508             : 
+    2509        6784 :     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        6784 :     free(buf->shm);
+    2516        6784 :     buf->shm = NULL;
+    2517        6784 :     buf->mem = NULL;
+    2518             : 
+    2519        6784 :     return DLT_RETURN_OK;
+    2520             : }
+    2521             : 
+    2522       24692 : void dlt_buffer_write_block(DltBuffer *buf, int *write, const unsigned char *data, unsigned int size)
+    2523             : {
+    2524             :     /* catch null pointer */
+    2525       24692 :     if ((buf != NULL) && (write != NULL) && (data != NULL)) {
+    2526       23673 :         if (size <= buf->size){
+    2527       23673 :             if (( (unsigned int) (*write ) + size) <= buf->size) {
+    2528             :                 /* write one block */
+    2529       23672 :                 memcpy(buf->mem + *write, data, size);
+    2530       23672 :                 *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       24692 : }
+    2552             : 
+    2553          45 : void dlt_buffer_read_block(DltBuffer *buf, int *read, unsigned char *data, unsigned int size)
+    2554             : {
+    2555             :     /* catch nullpointer */
+    2556          45 :     if ((buf != NULL) && (read != NULL) && (data != NULL)) {
+    2557          29 :         if (((unsigned int)(*read) + size) <= buf->size) {
+    2558             :             /* read one block */
+    2559          27 :             memcpy(data, buf->mem + *read, size);
+    2560          27 :             *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          45 : }
+    2578             : 
+    2579         852 : int dlt_buffer_check_size(DltBuffer *buf, int needed)
+    2580             : {
+    2581         852 :     if (buf == NULL)
+    2582             :         return DLT_RETURN_WRONG_PARAMETER;
+    2583             : 
+    2584         852 :     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           7 : int dlt_buffer_minimize_size(DltBuffer *buf)
+    2657             : {
+    2658             :     unsigned char *new_ptr;
+    2659             : 
+    2660             :     /* catch null pointer */
+    2661           7 :     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           6 :     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        9839 : 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        9839 :     if (buf == NULL)
+    2745             :         return DLT_RETURN_WRONG_PARAMETER;
+    2746             : 
+    2747        9771 :     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        9771 :     write = ((int *)(buf->shm))[0];
+    2755        9771 :     read = ((int *)(buf->shm))[1];
+    2756        9771 :     count = ((int *)(buf->shm))[2];
+    2757             : 
+    2758             :     /* check pointers */
+    2759        9771 :     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        9771 :     if (read > write)
+    2769           0 :         free_size = read - write;
+    2770        9771 :     else if (count && (write == read))
+    2771             :         free_size = 0;
+    2772             :     else
+    2773        9771 :         free_size = (int)buf->size - write + read;
+    2774             : 
+    2775             :     /* check size */
+    2776        9775 :     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        9771 :     head.status = 2;
+    2800        9771 :     head.size = (int)(size1 + size2 + size3);
+    2801             : 
+    2802             :     /* write data */
+    2803        9771 :     dlt_buffer_write_block(buf, &write, (unsigned char *)&head, sizeof(DltBufferBlockHead));
+    2804             : 
+    2805        9771 :     if (size1)
+    2806        9771 :         dlt_buffer_write_block(buf, &write, data1, size1);
+    2807             : 
+    2808        9771 :     if (size2)
+    2809        2257 :         dlt_buffer_write_block(buf, &write, data2, size2);
+    2810             : 
+    2811        9771 :     if (size3)
+    2812        1873 :         dlt_buffer_write_block(buf, &write, data3, size3);
+    2813             : 
+    2814             :     /* update global shm pointers */
+    2815        9771 :     ((int *)(buf->shm))[0] = write; /* set new write pointer */
+    2816        9771 :     ((int *)(buf->shm))[2] += 1; /* increase counter */
+    2817             : 
+    2818        9771 :     return DLT_RETURN_OK; /* OK */
+    2819             : 
+    2820             : }
+    2821             : 
+    2822          59 : 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          59 :     char head_compare[] = DLT_BUFFER_HEAD;
+    2827             :     DltBufferBlockHead head;
+    2828             : 
+    2829             :     /* catch null pointer */
+    2830          59 :     if (buf == NULL)
+    2831             :         return DLT_RETURN_WRONG_PARAMETER;
+    2832             : 
+    2833          42 :     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          42 :     write = ((int *)(buf->shm))[0];
+    2841          42 :     read = ((int *)(buf->shm))[1];
+    2842          42 :     count = ((int *)(buf->shm))[2];
+    2843             : 
+    2844             :     /* check pointers */
+    2845          42 :     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          39 :     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          17 :     if (write > read)
+    2867          16 :         used_size = write - read;
+    2868             :     else
+    2869           1 :         used_size = (int)buf->size - read + write;
+    2870             : 
+    2871             :     /* first check size */
+    2872          17 :     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          16 :     dlt_buffer_read_block(buf, &read, (unsigned char *)&head, sizeof(DltBufferBlockHead));
+    2882             : 
+    2883             :     /* check header */
+    2884          16 :     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          15 :     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          15 :     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          14 :     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          14 :     if ((data != NULL) && max_size) {
+    2914             :         /* read data */
+    2915          11 :         dlt_buffer_read_block(buf, &read, data, (unsigned int)head.size);
+    2916             : 
+    2917          11 :         if (delete)
+    2918             :             /* update buffer pointers */
+    2919           3 :             ((int *)(buf->shm))[1] = read; /* set new read pointer */
+    2920             : 
+    2921             :     }
+    2922           3 :     else if (delete)
+    2923             :     {
+    2924           3 :         if ((unsigned int)(read + head.size) <= buf->size)
+    2925           3 :             ((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          14 :     if (delete) {
+    2932           6 :         ((int *)(buf->shm))[2] -= 1; /* decrease counter */
+    2933             : 
+    2934           6 :         if (((int *)(buf->shm))[2] == 0)
+    2935             :             /* try to minimize size */
+    2936           4 :             dlt_buffer_minimize_size(buf);
+    2937             :     }
+    2938             : 
+    2939          14 :     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          10 : int dlt_buffer_copy(DltBuffer *buf, unsigned char *data, int max_size)
+    2948             : {
+    2949          10 :     return dlt_buffer_get(buf, data, max_size, 0);
+    2950             : }
+    2951             : 
+    2952           5 : int dlt_buffer_remove(DltBuffer *buf)
+    2953             : {
+    2954           5 :     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        2672 : int dlt_buffer_get_message_count(DltBuffer *buf)
+    3028             : {
+    3029             :     /* catch null pointer */
+    3030        2672 :     if (buf == NULL)
+    3031             :         return DLT_RETURN_WRONG_PARAMETER;
+    3032             : 
+    3033             :     /* check if buffer available */
+    3034        2672 :     if (buf->shm == NULL)
+    3035             :         return DLT_RETURN_OK;
+    3036             : 
+    3037        2672 :     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           6 : void dlt_get_version(char *buf, size_t size)
+    3283             : {
+    3284           6 :     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           2 : void dlt_get_major_version(char *buf, size_t size)
+    3308             : {
+    3309           2 :     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           2 : void dlt_get_minor_version(char *buf, size_t size)
+    3318             : {
+    3319           2 :     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         247 : 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         247 :     if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
+    3339         247 :         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         751 : 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         751 :     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         736 :     float32_t value32f = 0, value32f_tmp = 0;
+    3450         736 :     int32_t value32f_tmp_int32i = 0, value32f_tmp_int32i_swaped = 0;
+    3451         736 :     float64_t value64f = 0, value64f_tmp = 0;
+    3452         736 :     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         736 :     if ((type_info & DLT_TYPE_INFO_STRG) &&
+    3469         147 :         (((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         147 :         if (byteLength < 0) {
+    3472         147 :             DLT_MSG_READ_VALUE(value16u_tmp, *ptr, *datalength, uint16_t);
+    3473             : 
+    3474         147 :             if ((*datalength) < 0)
+    3475             :                 return DLT_RETURN_ERROR;
+    3476             : 
+    3477         147 :             length = (uint16_t) DLT_ENDIAN_GET_16(msg->standardheader->htyp, value16u_tmp);
+    3478             :         }
+    3479             :         else {
+    3480           0 :             length = (uint16_t)byteLength;
+    3481             :         }
+    3482             : 
+    3483         147 :         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         147 :         DLT_MSG_READ_STRING(value_text, *ptr, *datalength, textlength, length);
+    3508             : 
+    3509         147 :         if ((*datalength) < 0)
+    3510             :             return DLT_RETURN_ERROR;
+    3511             :     }
+    3512         589 :     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         477 :     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         477 :     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         477 :     else if ((type_info & DLT_TYPE_INFO_SINT) || (type_info & DLT_TYPE_INFO_UINT))
+    3635             :     {
+    3636             :         /* signed or unsigned argument received */
+    3637         350 :         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         350 :         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         350 :         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         301 :         case DLT_TYLE_32BIT:
+    3772             :         {
+    3773         301 :             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          14 :                 DLT_MSG_READ_VALUE(value32u_tmp, *ptr, *datalength, uint32_t);
+    3788             : 
+    3789          14 :                 if ((*datalength) < 0)
+    3790             :                     return DLT_RETURN_ERROR;
+    3791             : 
+    3792          14 :                 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         630 :     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         630 :     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        6687 : void dlt_check_envvar()
+    4073             : {
+    4074        6687 :     char *env_log_filename = getenv("DLT_LOG_FILENAME");
+    4075             : 
+    4076        6687 :     if (env_log_filename != NULL)
+    4077           0 :         dlt_log_set_filename(env_log_filename);
+    4078             : 
+    4079        6687 :     char *env_log_level_str = getenv("DLT_LOG_LEVEL");
+    4080             : 
+    4081        6687 :     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        6687 :     char *env_log_mode = getenv("DLT_LOG_MODE");
+    4089             : 
+    4090        6687 :     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        6687 :     char *env_pipe_dir = getenv("DLT_PIPE_DIR");
+    4099             : 
+    4100        6687 :     if (env_pipe_dir != NULL)
+    4101           0 :         dlt_log_set_fifo_basedir(env_pipe_dir);
+    4102             :     else
+    4103        6687 :         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        6687 : }
+    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..6922971ea --- /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:13817081.2 %
Date:2023-09-01 07:46:27Functions: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_sections8
dlt_config_file_get_section_name8
dlt_config_file_get_section_name_from_string8
dlt_config_file_init8
dlt_config_file_is_section_name8
dlt_config_file_read_file8
dlt_config_file_release8
dlt_config_file_set_section8
dlt_config_file_get_key_value56
dlt_config_file_set_section_data56
dlt_config_file_read_line64
dlt_config_file_trim_line64
dlt_config_file_get_value80
dlt_config_file_find_section84
+
+
+ + + +
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..a5ae417bf --- /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:13817081.2 %
Date:2023-09-01 07:46:27Functions:1515100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_config_file_check_section_name_exists4
dlt_config_file_find_section84
dlt_config_file_get_key_value56
dlt_config_file_get_num_sections8
dlt_config_file_get_section_name8
dlt_config_file_get_section_name_from_string8
dlt_config_file_get_value80
dlt_config_file_init8
dlt_config_file_is_section_name8
dlt_config_file_read_file8
dlt_config_file_read_line64
dlt_config_file_release8
dlt_config_file_set_section8
dlt_config_file_set_section_data56
dlt_config_file_trim_line64
+
+
+ + + +
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..b71aec138 --- /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:13817081.2 %
Date:2023-09-01 07:46:27Functions: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          64 : static void dlt_config_file_trim_line(char *line)
+      52             : {
+      53          64 :     if (line == NULL)
+      54             :         return;
+      55             : 
+      56             :     char *i = line;
+      57             :     char *j = line;
+      58             : 
+      59        1012 :     while (*j != '\0') {
+      60         948 :         *i = *j++;
+      61             : 
+      62         948 :         if (!isspace(*i))
+      63         884 :             i++;
+      64             :     }
+      65             : 
+      66          64 :     *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          64 :     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           8 : static int dlt_config_file_is_section_name(DltConfigFile *file, char *name)
+      96             : {
+      97             :     int i = 0;
+      98             : 
+      99           8 :     if ((file == NULL) || (name == NULL))
+     100             :         return -1;
+     101             : 
+     102           8 :     for (i = 0; i < file->num_sections; i++) {
+     103           0 :         DltConfigFileSection *s = &file->sections[i];
+     104             : 
+     105           0 :         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           8 : static int dlt_config_file_set_section(DltConfigFile *file, char *name)
+     122             : {
+     123           8 :     int section = file->num_sections;
+     124             : 
+     125             :     /* check if adding another section would exceed max number of sections */
+     126           8 :     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           8 :     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           8 :     DltConfigFileSection *s = &file->sections[section];
+     138             : 
+     139             :     /* alloc data for entries */
+     140           8 :     s->name = calloc(sizeof(char), DLT_CONFIG_FILE_ENTRY_MAX_LEN + 1);
+     141             : 
+     142           8 :     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           8 :     s->keys = calloc(sizeof(char), DLT_CONFIG_FILE_ENTRY_MAX_LEN * DLT_CONFIG_FILE_KEYS_MAX + 1);
+     148             : 
+     149           8 :     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           8 :     file->num_sections += 1;
+     158           8 :     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          56 : static int dlt_config_file_set_section_data(DltConfigFile *file, char *str1, char *str2)
+     172             : {
+     173             :     DltConfigKeyData **tmp = NULL;
+     174             : 
+     175          56 :     if ((file == NULL) || (str1 == NULL) || (str2 == NULL))
+     176             :         return -1;
+     177             : 
+     178          56 :     DltConfigFileSection *s = &file->sections[file->num_sections - 1];
+     179          56 :     int key_number = s->num_entries;
+     180             : 
+     181          56 :     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          56 :     strncpy(&s->keys[key_number * DLT_CONFIG_FILE_ENTRY_MAX_LEN], str1, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
+     188             : 
+     189          56 :     if (s->list == NULL) {
+     190             :         /* creating a list if it doesnt exists */
+     191           8 :         s->list = malloc(sizeof(DltConfigKeyData));
+     192             : 
+     193           8 :         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           8 :         tmp = &s->list;
+     199             :     }
+     200             :     else {
+     201          48 :         tmp = &s->list;
+     202             : 
+     203         220 :         while (*(tmp) != NULL)
+     204         172 :             tmp = &(*tmp)->next;
+     205             : 
+     206             :         /* Adding new entry to the list */
+     207          48 :         *tmp = malloc(sizeof(DltConfigKeyData));
+     208             : 
+     209          48 :         if (*tmp == NULL) {
+     210           0 :             dlt_log(LOG_WARNING, "Could not allocate memory to list \n");
+     211           0 :             return -1;
+     212             :         }
+     213             :     }
+     214             : 
+     215          56 :     (*tmp)->key = strdup(str1);
+     216          56 :     (*tmp)->data = strdup(str2);
+     217          56 :     (*tmp)->next = NULL;
+     218             : 
+     219          56 :     s->num_entries += 1;
+     220             : 
+     221          56 :     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          64 :     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           8 : 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           8 :     if ((line == NULL) || (name == NULL))
+     257             :         return -1;
+     258             : 
+     259          92 :     for (i = 0; i < DLT_CONFIG_FILE_ENTRY_MAX_LEN; i++) {
+     260          92 :         if ((line[i] == '[') || isspace(line[i]))
+     261           8 :             continue;
+     262          84 :         else if ((line[i] == ']') || (line[i] == '\n') || (line[i] == '\0'))
+     263             :             break;
+     264             :         else
+     265          76 :             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          56 : 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          56 :     if ((line == NULL) || (str1 == NULL) || (str2 == NULL))
+     288             :         return -1;
+     289             : 
+     290          56 :     ptr = strtok_r(line, delimiter, &save_ptr);
+     291             : 
+     292          56 :     if (ptr != NULL) { /* get key */
+     293             :         strncpy(str1, ptr, DLT_CONFIG_FILE_ENTRY_MAX_LEN - 1);
+     294          56 :         str1[DLT_CONFIG_FILE_ENTRY_MAX_LEN - 1] = '\0';
+     295             :     } else {
+     296             :         return -1;
+     297             :     }
+     298             : 
+     299          56 :     ptr = strtok_r(NULL, delimiter, &save_ptr);
+     300             : 
+     301          56 :     if (ptr != NULL) {
+     302             :         strncpy(str2, ptr, DLT_CONFIG_FILE_ENTRY_MAX_LEN - 1);
+     303          56 :         str2[DLT_CONFIG_FILE_ENTRY_MAX_LEN - 1] = '\0';
+     304             :     } else {
+     305             :         return -1;
+     306             :     }
+     307             : 
+     308          56 :     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          64 : static int dlt_config_file_read_line(char *line, char *str1, char *str2)
+     322             : {
+     323          64 :     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           8 :         if (dlt_config_file_get_section_name_from_string(line, str1) != 0)
+     334             :             return -1;
+     335             : 
+     336           8 :         return DLT_CONFIG_FILE_NEW_SECTION;
+     337             :     }
+     338             : 
+     339             :     /* copy strings as key value pair into str1, str2 */
+     340          56 :     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           8 : static void dlt_config_file_read_file(DltConfigFile *file, FILE *hdl)
+     355             : {
+     356             :     int ret = 0;
+     357           8 :     char line[DLT_CONFIG_FILE_LINE_MAX_LEN] = { '\0' };
+     358           8 :     char str1[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = { '\0' };
+     359           8 :     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          80 :     while (fgets(line, DLT_CONFIG_FILE_LINE_MAX_LEN, hdl) != NULL) {
+     365          64 :         line_number++;
+     366             : 
+     367             :         /* ignore empty and comment lines */
+     368           0 :         if (dlt_config_file_ignore_line(line) == 0)
+     369           0 :             continue;
+     370             : 
+     371             :         /* trim line end */
+     372          64 :         dlt_config_file_trim_line(line);
+     373             : 
+     374             :         /* parse content of line */
+     375          64 :         ret = dlt_config_file_read_line(line, str1, str2);
+     376             : 
+     377          64 :         switch (ret) {
+     378           8 :         case DLT_CONFIG_FILE_NEW_SECTION:     /* store str1 as new section */
+     379             :             is_section_valid = -1;
+     380             : 
+     381           8 :             if ((ret = dlt_config_file_set_section(file, str1)) == 0)
+     382             :                 is_section_valid = 0;
+     383             : 
+     384             :             break;
+     385          56 :         case DLT_CONFIG_FILE_NEW_DATA:     /* store str1 and str2 as new data for section */
+     386             : 
+     387          56 :             if (is_section_valid == 0)
+     388          56 :                 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           8 : }
+     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          84 : static int dlt_config_file_find_section(const DltConfigFile *file,
+     408             :                                         const char *section)
+     409             : {
+     410             :     int i = 0;
+     411             : 
+     412          84 :     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          88 :     for (i = 0; i < file->num_sections; i++) {
+     418          84 :         DltConfigFileSection *s = &file->sections[i];
+     419             : 
+     420          84 :         if (strncmp(s->name, section, DLT_CONFIG_FILE_ENTRY_MAX_LEN) == 0)
+     421          80 :             return i;
+     422             :     }
+     423             : 
+     424             :     return -1;
+     425             : }
+     426             : 
+     427             : /************************** interface implementation ***************************/
+     428           8 : DltConfigFile *dlt_config_file_init(char *file_name)
+     429             : {
+     430             :     DltConfigFile *file;
+     431             :     FILE *hdl = NULL;
+     432             : 
+     433           8 :     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           8 :     file = calloc(sizeof(DltConfigFile), 1);
+     439             : 
+     440           8 :     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           8 :     file->sections = calloc(sizeof(DltConfigFileSection), DLT_CONFIG_FILE_SECTIONS_MAX);
+     446             : 
+     447             :     /* open file */
+     448           8 :     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           8 :     dlt_config_file_read_file(file, hdl);
+     455             : 
+     456             :     /* all information stored internally */
+     457           8 :     fclose(hdl);
+     458             : 
+     459           8 :     return file;
+     460             : }
+     461             : 
+     462           8 : void dlt_config_file_release(DltConfigFile *file)
+     463             : {
+     464             :     int i = 0;
+     465             : 
+     466           8 :     if (file != NULL) {
+     467           8 :         int max = file->num_sections;
+     468             : 
+     469          16 :         for (i = 0; i < max; i++) {
+     470           8 :             DltConfigFileSection *s = &file->sections[i];
+     471           8 :             DltConfigKeyData *node = file->sections[i].list;
+     472           8 :             free(s->name);
+     473             : 
+     474           8 :             if (s->keys != NULL)
+     475           8 :                 free(s->keys);
+     476             : 
+     477          64 :             while (node) {
+     478             :                 DltConfigKeyData *tmp = node;
+     479          56 :                 node = node->next;
+     480          56 :                 free(tmp->key);
+     481          56 :                 free(tmp->data);
+     482          56 :                 free(tmp);
+     483             :             }
+     484             :         }
+     485             : 
+     486           8 :         free(file->sections);
+     487           8 :         free(file);
+     488             :     }
+     489           8 : }
+     490             : 
+     491           8 : int dlt_config_file_get_section_name(const DltConfigFile *file,
+     492             :                                      int num,
+     493             :                                      char *name)
+     494             : {
+     495           8 :     if ((file == NULL) || (name == NULL) || (num < 0) || (num >= file->num_sections))
+     496             :         return -1;
+     497             : 
+     498           8 :     strncpy(name, (file->sections + num)->name, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
+     499           8 :     name[DLT_CONFIG_FILE_ENTRY_MAX_LEN - 1] = '\0';
+     500             : 
+     501           8 :     return 0;
+     502             : }
+     503             : 
+     504           8 : int dlt_config_file_get_num_sections(const DltConfigFile *file, int *num)
+     505             : {
+     506           8 :     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           8 :     *num = file->num_sections;
+     514             : 
+     515           8 :     return 0;
+     516             : }
+     517             : 
+     518          80 : 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          80 :     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          80 :     num_section = dlt_config_file_find_section(file, section);
+     533             : 
+     534          80 :     if (num_section == -1)
+     535             :         return -1;
+     536             : 
+     537          80 :     s = (file->sections + num_section);
+     538             : 
+     539          80 :     tmp = &s->list;
+     540             : 
+     541         400 :     while (*(tmp) != NULL) {
+     542         372 :         if (strncmp((*tmp)->key, key, DLT_CONFIG_FILE_ENTRY_MAX_LEN) == 0) {
+     543          52 :             strncpy(value, (*tmp)->data, DLT_CONFIG_FILE_ENTRY_MAX_LEN);
+     544          52 :             return 0;
+     545             :         }
+     546             :         else { /* not found yet see list for more */
+     547         320 :             tmp = &(*tmp)->next;
+     548             :         }
+     549             :     }
+     550             : 
+     551          28 :     dlt_vlog(LOG_WARNING, "Entry does not exist in section: %s\n", key);
+     552          28 :     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..440edf7c4 --- /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-09-01 07:46:27Functions: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..c63d7cc57 --- /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-09-01 07:46:27Functions: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..70558224c --- /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-09-01 07:46:27Functions: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          24 :                     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..ec20560c2 --- /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-09-01 07:46:27Functions: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..8423ef896 --- /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-09-01 07:46:27Functions: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..3199cdac9 --- /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-09-01 07:46:27Functions: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..6ef72afc4 --- /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-09-01 07:46:27Functions: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..1e39de369 --- /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-09-01 07:46:27Functions: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..0f4594d2e --- /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-09-01 07:46:27Functions: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..d87418b53 --- /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:275450.0 %
Date:2023-09-01 07:46:27Functions:4666.7 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_user_check_userheader0
dlt_user_log_out3_with_timeout0
dlt_user_log_out2_with_timeout4
dlt_user_log_out2339
dlt_user_log_out3517
dlt_user_set_userheader858
+
+
+ + + +
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..159e99e63 --- /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:275450.0 %
Date:2023-09-01 07:46:27Functions:4666.7 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_user_check_userheader0
dlt_user_log_out2339
dlt_user_log_out2_with_timeout4
dlt_user_log_out3517
dlt_user_log_out3_with_timeout0
dlt_user_set_userheader858
+
+
+ + + +
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..7d25b12d3 --- /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:275450.0 %
Date:2023-09-01 07:46:27Functions:4666.7 %
+
+ + + + + + + + +

+
          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         858 : DltReturnValue dlt_user_set_userheader(DltUserHeader *userheader, uint32_t mtype)
+      80             : {
+      81         858 :     if (userheader == 0)
+      82             :         return DLT_RETURN_ERROR;
+      83             : 
+      84         858 :     if (mtype <= 0)
+      85             :         return DLT_RETURN_ERROR;
+      86             : 
+      87         858 :     userheader->pattern[0] = 'D';
+      88         858 :     userheader->pattern[1] = 'U';
+      89         858 :     userheader->pattern[2] = 'H';
+      90         858 :     userheader->pattern[3] = 1;
+      91         858 :     userheader->message = mtype;
+      92             : 
+      93         858 :     return DLT_RETURN_OK;
+      94             : }
+      95             : 
+      96           0 : int dlt_user_check_userheader(DltUserHeader *userheader)
+      97             : {
+      98           0 :     if (userheader == 0)
+      99             :         return -1;
+     100             : 
+     101           0 :     return (userheader->pattern[0] == 'D') &&
+     102           0 :            (userheader->pattern[1] == 'U') &&
+     103           0 :            (userheader->pattern[2] == 'H') &&
+     104           0 :            (userheader->pattern[3] == 1);
+     105             : }
+     106             : 
+     107         339 : 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         339 :     if (handle < 0)
+     113             :         /* Invalid handle */
+     114             :         return DLT_RETURN_ERROR;
+     115             : 
+     116           4 :     iov[0].iov_base = ptr1;
+     117           4 :     iov[0].iov_len = len1;
+     118           4 :     iov[1].iov_base = ptr2;
+     119           4 :     iov[1].iov_len = len2;
+     120             : 
+     121           4 :     bytes_written = (uint32_t) writev(handle, iov, 2);
+     122             : 
+     123           4 :     if (bytes_written != (len1 + len2))
+     124           0 :         return DLT_RETURN_ERROR;
+     125             : 
+     126             :     return DLT_RETURN_OK;
+     127             : }
+     128             : 
+     129           4 : DltReturnValue dlt_user_log_out2_with_timeout(int handle, void *ptr1, size_t len1, void *ptr2, size_t len2)
+     130             : {
+     131           4 :     if (handle < 0)
+     132             :         /* Invalid handle */
+     133             :         return DLT_RETURN_ERROR;
+     134             : 
+     135             :     fd_set fds;
+     136          68 :     FD_ZERO(&fds);
+     137           4 :     FD_SET(handle, &fds);
+     138             : 
+     139           4 :     struct timeval tv = { DLT_WRITEV_TIMEOUT_SEC, DLT_WRITEV_TIMEOUT_USEC };
+     140           4 :     if (select(handle+1, NULL, &fds, NULL, &tv) < 0) {
+     141             :         return DLT_RETURN_ERROR;
+     142             :     }
+     143             : 
+     144           4 :     if (FD_ISSET(handle, &fds)) {
+     145           4 :         return dlt_user_log_out2(handle, ptr1, len1, ptr2, len2);
+     146             :     } else {
+     147             :         return DLT_RETURN_ERROR;
+     148             :     }
+     149             : }
+     150             : 
+     151         517 : 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         517 :     if (handle < 0)
+     157             :         /* Invalid handle */
+     158             :         return DLT_RETURN_ERROR;
+     159             : 
+     160           0 :     iov[0].iov_base = ptr1;
+     161           0 :     iov[0].iov_len = len1;
+     162           0 :     iov[1].iov_base = ptr2;
+     163           0 :     iov[1].iov_len = len2;
+     164           0 :     iov[2].iov_base = ptr3;
+     165           0 :     iov[2].iov_len = len3;
+     166             : 
+     167           0 :     bytes_written = (uint32_t) writev(handle, iov, 3);
+     168             : 
+     169           0 :     if (bytes_written != (len1 + len2 + len3)) {
+     170           0 :         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..93e897751 --- /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:1403218264.3 %
Date:2023-09-01 07:46:27Functions:12714687.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 +
50.0%50.0%
+
50.0 %27 / 5466.7 %4 / 6
dlt_common.c +
62.7%62.7%
+
62.7 %1099 / 175285.5 %94 / 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 +
81.2%81.2%
+
81.2 %138 / 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..d1d30a3fa --- /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:1403218264.3 %
Date:2023-09-01 07:46:27Functions:12714687.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 +
50.0%50.0%
+
50.0 %27 / 5466.7 %4 / 6
dlt_common.c +
62.7%62.7%
+
62.7 %1099 / 175285.5 %94 / 110
dlt_multiple_files.c +
68.9%68.9%
+
68.9 %133 / 193100.0 %13 / 13
dlt_config_file_parser.c +
81.2%81.2%
+
81.2 %138 / 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..9559c311c --- /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:1403218264.3 %
Date:2023-09-01 07:46:27Functions:12714687.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_common.c +
62.7%62.7%
+
62.7 %1099 / 175285.5 %94 / 110
dlt_config_file_parser.c +
81.2%81.2%
+
81.2 %138 / 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 +
50.0%50.0%
+
50.0 %27 / 5466.7 %4 / 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