diff --git a/.gitmodules b/.gitmodules index 8cf8b5e3..e69de29b 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 00000000..2cab170d Binary files /dev/null and b/dlt_lcov_report/amber.png differ diff --git a/dlt_lcov_report/console/dlt-control-common.c.func-sort-c.html b/dlt_lcov_report/console/dlt-control-common.c.func-sort-c.html new file mode 100644 index 00000000..b5fe3f82 --- /dev/null +++ b/dlt_lcov_report/console/dlt-control-common.c.func-sort-c.html @@ -0,0 +1,148 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/dlt-control-common.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console - dlt-control-common.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:14721369.0 %
Date:2024-04-29 13:30:27Functions:181994.7 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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

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

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

Function Name Sort by function nameHit count Sort by hit count
empty_dir0
usage0
main35
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/dlt-convert.c.func.html b/dlt_lcov_report/console/dlt-convert.c.func.html new file mode 100644 index 00000000..8a799bdc --- /dev/null +++ b/dlt_lcov_report/console/dlt-convert.c.func.html @@ -0,0 +1,84 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/dlt-convert.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console - dlt-convert.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:3718420.1 %
Date:2024-04-29 13:30:27Functions:1333.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
empty_dir0
main35
usage0
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/dlt-convert.c.gcov.html b/dlt_lcov_report/console/dlt-convert.c.gcov.html new file mode 100644 index 00000000..2a9f30a0 --- /dev/null +++ b/dlt_lcov_report/console/dlt-convert.c.gcov.html @@ -0,0 +1,610 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/dlt-convert.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console - dlt-convert.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:3718420.1 %
Date:2024-04-29 13:30:27Functions:1333.3 %
+
+ + + + + + + + +

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

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

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

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

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt-convert.c +
20.1%20.1%
+
20.1 %37 / 18433.3 %1 / 3
dlt-receive.c +
35.6%35.6%
+
35.6 %84 / 23642.9 %3 / 7
dlt-control-common.c +
69.0%69.0%
+
69.0 %147 / 21394.7 %18 / 19
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/index-sort-l.html b/dlt_lcov_report/console/index-sort-l.html new file mode 100644 index 00000000..0a8beb6a --- /dev/null +++ b/dlt_lcov_report/console/index-sort-l.html @@ -0,0 +1,113 @@ + + + + + + + LCOV - dlt_final_coverage.info - console + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - consoleHitTotalCoverage
Test:dlt_final_coverage.infoLines:26863342.3 %
Date:2024-04-29 13:30:27Functions:222975.9 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt-convert.c +
20.1%20.1%
+
20.1 %37 / 18433.3 %1 / 3
dlt-receive.c +
35.6%35.6%
+
35.6 %84 / 23642.9 %3 / 7
dlt-control-common.c +
69.0%69.0%
+
69.0 %147 / 21394.7 %18 / 19
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/index.html b/dlt_lcov_report/console/index.html new file mode 100644 index 00000000..5bd6ae10 --- /dev/null +++ b/dlt_lcov_report/console/index.html @@ -0,0 +1,113 @@ + + + + + + + LCOV - dlt_final_coverage.info - console + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - consoleHitTotalCoverage
Test:dlt_final_coverage.infoLines:26863342.3 %
Date:2024-04-29 13:30:27Functions:222975.9 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt-control-common.c +
69.0%69.0%
+
69.0 %147 / 21394.7 %18 / 19
dlt-convert.c +
20.1%20.1%
+
20.1 %37 / 18433.3 %1 / 3
dlt-receive.c +
35.6%35.6%
+
35.6 %84 / 23642.9 %3 / 7
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/console/logstorage/dlt-logstorage-common.c.func-sort-c.html b/dlt_lcov_report/console/logstorage/dlt-logstorage-common.c.func-sort-c.html new file mode 100644 index 00000000..b034d6c4 --- /dev/null +++ b/dlt_lcov_report/console/logstorage/dlt-logstorage-common.c.func-sort-c.html @@ -0,0 +1,132 @@ + + + + + + + LCOV - dlt_final_coverage.info - console/logstorage/dlt-logstorage-common.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - console/logstorage - dlt-logstorage-common.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:328239.0 %
Date:2024-04-29 13:30:27Functions:71546.7 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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

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

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

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

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

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

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

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

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

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

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

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

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

Function Name Sort by function nameHit count Sort by hit count
create_timer_fd10
dlt_daemon_check_numeric_setting3
dlt_daemon_close_socket5
dlt_daemon_create_pipes_dir9
dlt_daemon_daemonize2
dlt_daemon_exit_trigger9
dlt_daemon_init_fifo9
dlt_daemon_init_serial9
dlt_daemon_initialize_control_socket9
dlt_daemon_local_cleanup9
dlt_daemon_local_connection_init9
dlt_daemon_local_ecu_version_init9
dlt_daemon_local_init_p19
dlt_daemon_local_init_p29
dlt_daemon_log_internal40
dlt_daemon_process_client_connect4
dlt_daemon_process_client_messages7
dlt_daemon_process_client_messages_serial0
dlt_daemon_process_control_connect2
dlt_daemon_process_control_messages4
dlt_daemon_process_user_message_log5809
dlt_daemon_process_user_message_log_mode0
dlt_daemon_process_user_message_marker0
dlt_daemon_process_user_message_not_sup0
dlt_daemon_process_user_message_overflow0
dlt_daemon_process_user_message_register_application7
dlt_daemon_process_user_message_register_context38
dlt_daemon_process_user_message_set_app_ll_ts0
dlt_daemon_process_user_message_unregister_application6
dlt_daemon_process_user_message_unregister_context37
dlt_daemon_process_user_messages1277
dlt_daemon_send_message_overflow0
dlt_daemon_send_ringbuffer_to_client2
dlt_daemon_signal_handler9
dlt_mkdir_recursive9
enforce_context_ll_and_ts_keep_message0
file_read_everything0
file_read_field0
main9
option_file_parser9
option_handling9
usage0
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt-daemon.c.gcov.html b/dlt_lcov_report/daemon/dlt-daemon.c.gcov.html new file mode 100644 index 00000000..f53f9ae3 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt-daemon.c.gcov.html @@ -0,0 +1,4053 @@ + + + + + + + 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:605114352.9 %
Date:2024-04-29 13:30:27Functions:314273.8 %
+
+ + + + + + + + +

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

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_control_callsw_cinjection0
dlt_daemon_control_message_buffer_overflow0
dlt_daemon_control_message_marker0
dlt_daemon_control_message_time0
dlt_daemon_control_message_timezone0
dlt_daemon_control_message_unregister_context0
dlt_daemon_control_passive_node_connect0
dlt_daemon_control_passive_node_connect_status0
dlt_daemon_control_set_all_log_level0
dlt_daemon_control_set_all_trace_status0
dlt_daemon_control_set_default_log_level0
dlt_daemon_control_set_default_trace_status0
dlt_daemon_control_set_timing_packets0
dlt_daemon_control_set_trace_status0
dlt_daemon_find_multiple_context_and_send_log_level0
dlt_daemon_find_multiple_context_and_send_trace_status0
dlt_daemon_process_sixty_s_timer0
dlt_daemon_process_systemd_timer0
dlt_daemon_send_log_level0
dlt_daemon_send_trace_status0
dlt_daemon_control_get_default_log_level1
dlt_daemon_control_set_log_level1
dlt_daemon_control_service_logstorage2
dlt_daemon_control_service_response3
dlt_daemon_control_get_log_info4
dlt_daemon_control_get_software_version4
dlt_daemon_control_message_connection_info9
dlt_daemon_process_one_s_timer11
dlt_daemon_client_process_control12
dlt_daemon_client_send_control_message21
dlt_daemon_client_send_all_multiple214
dlt_daemon_client_send_message_to_all_client5809
dlt_daemon_client_send5885
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_client.c.func.html b/dlt_lcov_report/daemon/dlt_daemon_client.c.func.html new file mode 100644 index 00000000..e3509f1f --- /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:26596627.4 %
Date:2024-04-29 13:30:27Functions:133339.4 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_client_process_control12
dlt_daemon_client_send5885
dlt_daemon_client_send_all_multiple214
dlt_daemon_client_send_control_message21
dlt_daemon_client_send_message_to_all_client5809
dlt_daemon_control_callsw_cinjection0
dlt_daemon_control_get_default_log_level1
dlt_daemon_control_get_log_info4
dlt_daemon_control_get_software_version4
dlt_daemon_control_message_buffer_overflow0
dlt_daemon_control_message_connection_info9
dlt_daemon_control_message_marker0
dlt_daemon_control_message_time0
dlt_daemon_control_message_timezone0
dlt_daemon_control_message_unregister_context0
dlt_daemon_control_passive_node_connect0
dlt_daemon_control_passive_node_connect_status0
dlt_daemon_control_service_logstorage2
dlt_daemon_control_service_response3
dlt_daemon_control_set_all_log_level0
dlt_daemon_control_set_all_trace_status0
dlt_daemon_control_set_default_log_level0
dlt_daemon_control_set_default_trace_status0
dlt_daemon_control_set_log_level1
dlt_daemon_control_set_timing_packets0
dlt_daemon_control_set_trace_status0
dlt_daemon_find_multiple_context_and_send_log_level0
dlt_daemon_find_multiple_context_and_send_trace_status0
dlt_daemon_process_one_s_timer11
dlt_daemon_process_sixty_s_timer0
dlt_daemon_process_systemd_timer0
dlt_daemon_send_log_level0
dlt_daemon_send_trace_status0
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_client.c.gcov.html b/dlt_lcov_report/daemon/dlt_daemon_client.c.gcov.html new file mode 100644 index 00000000..e4b9d695 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_client.c.gcov.html @@ -0,0 +1,2866 @@ + + + + + + + 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:26596627.4 %
Date:2024-04-29 13:30:27Functions:133339.4 %
+
+ + + + + + + + +

+
          Line data    Source code
+
+       1             : /*
+       2             :  * SPDX license identifier: MPL-2.0
+       3             :  *
+       4             :  * Copyright (C) 2011-2015, BMW AG
+       5             :  *
+       6             :  * This file is part of COVESA Project DLT - Diagnostic Log and Trace.
+       7             :  *
+       8             :  * This Source Code Form is subject to the terms of the
+       9             :  * Mozilla Public License (MPL), v. 2.0.
+      10             :  * If a copy of the MPL was not distributed with this file,
+      11             :  * You can obtain one at http://mozilla.org/MPL/2.0/.
+      12             :  *
+      13             :  * For further information see http://www.covesa.org/.
+      14             :  */
+      15             : 
+      16             : /*!
+      17             :  * \author
+      18             :  * Alexander Wenzel <alexander.aw.wenzel@bmw.de>
+      19             :  * Markus Klein <Markus.Klein@esk.fraunhofer.de>
+      20             :  * Mikko Rapeli <mikko.rapeli@bmw.de>
+      21             :  *
+      22             :  * \copyright Copyright © 2011-2015 BMW AG. \n
+      23             :  * License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
+      24             :  *
+      25             :  * \file dlt_daemon_client.c
+      26             :  */
+      27             : 
+      28             : #include <netdb.h>
+      29             : #include <ctype.h>
+      30             : #include <stdio.h>      /* for printf() and fprintf() */
+      31             : #include <sys/socket.h> /* for socket(), connect(), (), and recv() */
+      32             : #include <sys/stat.h>   /* for stat() */
+      33             : #include <arpa/inet.h>  /* for sockaddr_in and inet_addr() */
+      34             : #include <stdlib.h>     /* for atoi() and exit() */
+      35             : #include <string.h>     /* for memset() */
+      36             : #include <unistd.h>     /* for close() */
+      37             : #include <signal.h>
+      38             : #include <syslog.h>
+      39             : #include <errno.h>
+      40             : #include <pthread.h>
+      41             : 
+      42             : #ifdef linux
+      43             : #   include <sys/timerfd.h>
+      44             : #endif
+      45             : #include <sys/time.h>
+      46             : #if defined(linux) && defined(__NR_statx)
+      47             : #   include <linux/stat.h>
+      48             : #endif
+      49             : 
+      50             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+      51             : #   include <systemd/sd-daemon.h>
+      52             : #endif
+      53             : 
+      54             : #include "dlt_types.h"
+      55             : #include "dlt-daemon.h"
+      56             : #include "dlt-daemon_cfg.h"
+      57             : #include "dlt_daemon_common_cfg.h"
+      58             : 
+      59             : #include "dlt_daemon_socket.h"
+      60             : #include "dlt_daemon_serial.h"
+      61             : 
+      62             : #include "dlt_daemon_client.h"
+      63             : #include "dlt_daemon_connection.h"
+      64             : #include "dlt_daemon_event_handler.h"
+      65             : 
+      66             : #include "dlt_daemon_offline_logstorage.h"
+      67             : #include "dlt_gateway.h"
+      68             : 
+      69             : /** Inline function to calculate/set the requested log level or traces status
+      70             :  *  with default log level or trace status when "ForceContextLogLevelAndTraceStatus"
+      71             :  *  is enabled and set to 1 in dlt.conf file.
+      72             :  *
+      73             :  * @param request_log The requested log level (or) trace status
+      74             :  * @param context_log The default log level (or) trace status
+      75             :  *
+      76             :  * @return The log level if requested log level is lower or equal to ContextLogLevel
+      77             :  */
+      78             : static inline int8_t getStatus(uint8_t request_log, int context_log)
+      79             : {
+      80           0 :     return (request_log <= context_log) ? request_log : context_log;
+      81             : }
+      82             : 
+      83             : #ifdef UDP_CONNECTION_SUPPORT
+      84             : #   include "dlt_daemon_udp_socket.h"
+      85             : #endif
+      86             : 
+      87             : /** @brief Sends up to 2 messages to all the clients.
+      88             :  *
+      89             :  * Runs through the client list and sends the messages to them. If the message
+      90             :  * transfer fails and the connection is a socket connection, the socket is closed.
+      91             :  * Takes and release dlt_daemon_mutex.
+      92             :  *
+      93             :  * @param daemon Daemon structure needed for socket closure.
+      94             :  * @param daemon_local Daemon local structure
+      95             :  * @param data1 The first message to be sent.
+      96             :  * @param size1 The size of the first message.
+      97             :  * @param data2 The second message to be send.
+      98             :  * @param size2 The second message size.
+      99             :  * @param verbose Needed for socket closure.
+     100             :  *
+     101             :  * @return The amount of data transfered.
+     102             :  */
+     103         214 : static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon,
+     104             :                                                DltDaemonLocal *daemon_local,
+     105             :                                                void *data1,
+     106             :                                                int size1,
+     107             :                                                void *data2,
+     108             :                                                int size2,
+     109             :                                                int verbose)
+     110             : {
+     111             :     int sent = 0;
+     112             :     unsigned int i = 0;
+     113             :     int ret = 0;
+     114             :     DltConnection *temp = NULL;
+     115             :     int type_mask =
+     116             :         (DLT_CON_MASK_CLIENT_MSG_TCP | DLT_CON_MASK_CLIENT_MSG_SERIAL);
+     117             : 
+     118         214 :     PRINT_FUNCTION_VERBOSE(verbose);
+     119             : 
+     120         214 :     if ((daemon == NULL) || (daemon_local == NULL)) {
+     121           0 :         dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
+     122           0 :         return 0;
+     123             :     }
+     124             : 
+     125        1286 :     for (i = 0; i < daemon_local->pEvent.nfds; i++)
+     126             :     {
+     127        1072 :         temp = dlt_event_handler_find_connection(&(daemon_local->pEvent),
+     128        1072 :                                         daemon_local->pEvent.pfd[i].fd);
+     129             : 
+     130        1072 :         if ((temp == NULL) || (temp->receiver == NULL) ||
+     131        1072 :             !((1 << temp->type) & type_mask)) {
+     132         856 :             dlt_log(LOG_DEBUG, "The connection not found or the connection type not TCP/Serial.\n");
+     133         856 :             continue;
+     134             :         }
+     135             : 
+     136         216 :         ret = dlt_connection_send_multiple(temp,
+     137             :                                            data1,
+     138             :                                            size1,
+     139             :                                            data2,
+     140             :                                            size2,
+     141             :                                            daemon->sendserialheader);
+     142             : 
+     143         216 :         if ((ret != DLT_DAEMON_ERROR_OK) &&
+     144           0 :             (DLT_CONNECTION_CLIENT_MSG_TCP == temp->type)) {
+     145           0 :             dlt_daemon_close_socket(temp->receiver->fd,
+     146             :                                     daemon,
+     147             :                                     daemon_local,
+     148             :                                     verbose);
+     149             :         }
+     150             : 
+     151         216 :         if (ret != DLT_DAEMON_ERROR_OK)
+     152           0 :             dlt_vlog(LOG_WARNING, "%s: send dlt message failed\n", __func__);
+     153             :         else
+     154             :             /* If sent to at  least one client,
+     155             :              * then do not store in ring buffer
+     156             :              */
+     157             :             sent = 1;
+     158             :     } /* for */
+     159             : 
+     160             :     return sent;
+     161             : }
+     162             : 
+     163        5885 : 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        5885 :     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        5885 :     if ((sock != DLT_DAEMON_SEND_TO_ALL) && (sock != DLT_DAEMON_SEND_FORCE)) {
+     184             :         /* Send message to specific socket */
+     185          16 :         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          16 :             if ((ret =
+     194          16 :                      dlt_daemon_socket_send(sock, data1, size1, data2, size2,
+     195          16 :                                             daemon->sendserialheader))) {
+     196           1 :                 dlt_vlog(LOG_WARNING, "%s: socket send dlt message failed\n", __func__);
+     197           1 :                 return ret;
+     198             :             }
+     199             :         }
+     200             : 
+     201          15 :         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        5869 :     if ((sock != DLT_DAEMON_SEND_FORCE) && (daemon->state != DLT_DAEMON_STATE_SEND_BUFFER)) {
+     209        5865 :         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        5865 :         if (daemon_local->flags.offlineLogstorageMaxDevices > 0)
+     228        5839 :             ret_logstorage = dlt_daemon_logstorage_write(daemon,
+     229             :                                                          &daemon_local->flags,
+     230             :                                                          storage_header,
+     231             :                                                          storage_header_size,
+     232             :                                                          data1,
+     233             :                                                          size1,
+     234             :                                                          data2,
+     235             :                                                          size2);
+     236             :     }
+     237             : 
+     238             :     /* send messages to daemon socket */
+     239        5869 :     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        5869 :         if ((sock == DLT_DAEMON_SEND_FORCE) || (daemon->state == DLT_DAEMON_STATE_SEND_DIRECT)) {
+     255             :             /* Forward message to network client if network routing is not disabled */
+     256         415 :             if (ret_logstorage != 1) {
+     257         214 :                 sent = dlt_daemon_client_send_all_multiple(daemon,
+     258             :                                                            daemon_local,
+     259             :                                                            data1,
+     260             :                                                            size1,
+     261             :                                                            data2,
+     262             :                                                            size2,
+     263             :                                                            verbose);
+     264             : 
+     265         214 :                 if ((sock == DLT_DAEMON_SEND_FORCE) && !sent) {
+     266             :                     return DLT_DAEMON_ERROR_SEND_FAILED;
+     267             :                 }
+     268             :             }
+     269             :         }
+     270             :     }
+     271             : 
+     272             :     /* Message was not sent to client, so store it in client ringbuffer */
+     273        5869 :     if ((sock != DLT_DAEMON_SEND_FORCE) &&
+     274        5865 :         ((daemon->state == DLT_DAEMON_STATE_BUFFER) || (daemon->state == DLT_DAEMON_STATE_SEND_BUFFER) ||
+     275             :          (daemon->state == DLT_DAEMON_STATE_BUFFER_FULL))) {
+     276        5454 :         if (daemon->state != DLT_DAEMON_STATE_BUFFER_FULL) {
+     277             :             /* Store message in history buffer */
+     278        5454 :             ret = dlt_buffer_push3(&(daemon->client_ringbuffer), data1, size1, data2, size2, 0, 0);
+     279        5454 :             if (ret < DLT_RETURN_OK) {
+     280           0 :                 dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_BUFFER_FULL);
+     281             :             }
+     282             :         }
+     283        5454 :         if (daemon->state == DLT_DAEMON_STATE_BUFFER_FULL) {
+     284           0 :             daemon->overflow_counter += 1;
+     285           0 :             if (daemon->overflow_counter == 1)
+     286           0 :                 dlt_vlog(LOG_INFO, "%s: Buffer is full! Messages will be discarded.\n", __func__);
+     287             : 
+     288           0 :             return DLT_DAEMON_ERROR_BUFFER_FULL;
+     289             :         }
+     290             :     } else {
+     291         415 :         if ((daemon->overflow_counter > 0) &&
+     292           0 :             (daemon_local->client_connections > 0)) {
+     293           0 :             sent_message_overflow_cnt++;
+     294           0 :             if (sent_message_overflow_cnt >= 2) {
+     295           0 :                 sent_message_overflow_cnt--;
+     296             :             }
+     297             :             else {
+     298           0 :                 if (dlt_daemon_send_message_overflow(daemon, daemon_local,
+     299             :                                           verbose) == DLT_DAEMON_ERROR_OK) {
+     300           0 :                     dlt_vlog(LOG_WARNING,
+     301             :                              "%s: %u messages discarded! Now able to send messages to the client.\n",
+     302             :                              __func__,
+     303             :                              daemon->overflow_counter);
+     304           0 :                     daemon->overflow_counter = 0;
+     305           0 :                     sent_message_overflow_cnt--;
+     306             :                 }
+     307             :             }
+     308             :         }
+     309             :     }
+     310             : 
+     311             :     return DLT_DAEMON_ERROR_OK;
+     312             : 
+     313             : }
+     314             : 
+     315        5809 : int dlt_daemon_client_send_message_to_all_client(DltDaemon *daemon,
+     316             :                                        DltDaemonLocal *daemon_local,
+     317             :                                        int verbose)
+     318             : {
+     319             :     static char text[DLT_DAEMON_TEXTSIZE];
+     320             :     char * ecu_ptr = NULL;
+     321             : 
+     322        5809 :     PRINT_FUNCTION_VERBOSE(verbose);
+     323             : 
+     324        5809 :     if ((daemon == NULL) || (daemon_local == NULL)) {
+     325           0 :         dlt_vlog(LOG_ERR, "%s: invalid arguments\n", __func__);
+     326           0 :         return DLT_DAEMON_ERROR_UNKNOWN;
+     327             :     }
+     328             : 
+     329             :     /* set overwrite ecu id */
+     330        5809 :     if ((daemon_local->flags.evalue[0]) &&
+     331           0 :         (strncmp(daemon_local->msg.headerextra.ecu,
+     332             :                  DLT_DAEMON_ECU_ID, DLT_ID_SIZE) == 0)) {
+     333             :         /* Set header extra parameters */
+     334           0 :         dlt_set_id(daemon_local->msg.headerextra.ecu, daemon->ecuid);
+     335             : 
+     336             :         /*msg.headerextra.seid = 0; */
+     337           0 :         if (dlt_message_set_extraparameters(&(daemon_local->msg), 0)) {
+     338           0 :             dlt_vlog(LOG_WARNING,
+     339             :                      "%s: failed to set message extra parameters.\n", __func__);
+     340           0 :             return DLT_DAEMON_ERROR_UNKNOWN;
+     341             :         }
+     342             : 
+     343             :         /* Correct value of timestamp, this was changed by dlt_message_set_extraparameters() */
+     344           0 :         daemon_local->msg.headerextra.tmsp =
+     345           0 :                         DLT_BETOH_32(daemon_local->msg.headerextra.tmsp);
+     346             :     }
+     347             : 
+     348             :     /* prepare storage header */
+     349        5809 :     if (DLT_IS_HTYP_WEID(daemon_local->msg.standardheader->htyp)) {
+     350        5809 :         ecu_ptr = daemon_local->msg.headerextra.ecu;
+     351             :     } else {
+     352           0 :         ecu_ptr = daemon->ecuid;
+     353             :     }
+     354             : 
+     355        5809 :     if (dlt_set_storageheader(daemon_local->msg.storageheader, ecu_ptr)) {
+     356           0 :         dlt_vlog(LOG_WARNING,
+     357             :                  "%s: failed to set storage header with header type: 0x%x\n",
+     358           0 :                  __func__, daemon_local->msg.standardheader->htyp);
+     359           0 :         return DLT_DAEMON_ERROR_UNKNOWN;
+     360             :     }
+     361             : 
+     362             :     /* if no filter set or filter is matching display message */
+     363        5809 :     if (daemon_local->flags.xflag) {
+     364           0 :         if (DLT_RETURN_OK !=
+     365           0 :             dlt_message_print_hex(&(daemon_local->msg), text,
+     366             :                                   DLT_DAEMON_TEXTSIZE, verbose))
+     367           0 :             dlt_log(LOG_WARNING, "dlt_message_print_hex() failed!\n");
+     368        5809 :     } else if (daemon_local->flags.aflag) {
+     369           0 :         if (DLT_RETURN_OK !=
+     370           0 :             dlt_message_print_ascii(&(daemon_local->msg), text,
+     371             :                                     DLT_DAEMON_TEXTSIZE, verbose))
+     372           0 :             dlt_log(LOG_WARNING, "dlt_message_print_ascii() failed!\n");
+     373        5809 :     } else if (daemon_local->flags.sflag) {
+     374           0 :         if (DLT_RETURN_OK !=
+     375           0 :             dlt_message_print_header(&(daemon_local->msg), text,
+     376             :                                      DLT_DAEMON_TEXTSIZE, verbose))
+     377           0 :             dlt_log(LOG_WARNING, "dlt_message_print_header() failed!\n");
+     378             :     }
+     379             : 
+     380             :     /* send message to client or write to log file */
+     381        5809 :     return dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL, daemon, daemon_local,
+     382        5809 :                 daemon_local->msg.headerbuffer, sizeof(DltStorageHeader),
+     383             :                 daemon_local->msg.headerbuffer + sizeof(DltStorageHeader),
+     384        5809 :                 (int) (daemon_local->msg.headersize - sizeof(DltStorageHeader)),
+     385        5809 :                 daemon_local->msg.databuffer, (int) daemon_local->msg.datasize, verbose);
+     386             : 
+     387             : }
+     388             : 
+     389          21 : 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          21 :     PRINT_FUNCTION_VERBOSE(verbose);
+     401             : 
+     402          21 :     if ((daemon == 0) || (msg == 0) || (apid == 0) || (ctid == 0))
+     403             :         return DLT_DAEMON_ERROR_UNKNOWN;
+     404             : 
+     405             :     /* prepare storage header */
+     406          21 :     msg->storageheader = (DltStorageHeader *)msg->headerbuffer;
+     407             : 
+     408          21 :     if (dlt_set_storageheader(msg->storageheader, daemon->ecuid) == DLT_RETURN_ERROR)
+     409             :         return DLT_DAEMON_ERROR_UNKNOWN;
+     410             : 
+     411             :     /* prepare standard header */
+     412          21 :     msg->standardheader = (DltStandardHeader *)(msg->headerbuffer + sizeof(DltStorageHeader));
+     413          21 :     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          21 :     msg->standardheader->mcnt = 0;
+     420             : 
+     421             :     /* Set header extra parameters */
+     422          21 :     dlt_set_id(msg->headerextra.ecu, daemon->ecuid);
+     423             : 
+     424             :     /*msg->headerextra.seid = 0; */
+     425             : 
+     426          21 :     msg->headerextra.tmsp = dlt_uptime();
+     427             : 
+     428          21 :     dlt_message_set_extraparameters(msg, verbose);
+     429             : 
+     430             :     /* prepare extended header */
+     431          21 :     msg->extendedheader =
+     432          21 :         (DltExtendedHeader *)(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+     433          21 :                               DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp));
+     434          21 :     msg->extendedheader->msin = DLT_MSIN_CONTROL_RESPONSE;
+     435             : 
+     436          21 :     msg->extendedheader->noar = 1; /* number of arguments */
+     437             : 
+     438          21 :     if (strcmp(apid, "") == 0)
+     439          21 :         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          21 :     if (strcmp(ctid, "") == 0)
+     444          21 :         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          21 :     msg->headersize = (uint32_t) (sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) +
+     450          21 :         DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp));
+     451             : 
+     452          21 :     len = (int32_t) (msg->headersize - sizeof(DltStorageHeader) + msg->datasize);
+     453             : 
+     454          21 :     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          21 :     msg->standardheader->len = DLT_HTOBE_16(((uint16_t)len));
+     460             : 
+     461          21 :     if ((ret =
+     462          21 :              dlt_daemon_client_send(sock, daemon, daemon_local, msg->headerbuffer, sizeof(DltStorageHeader),
+     463             :                                     msg->headerbuffer + sizeof(DltStorageHeader),
+     464          21 :                                     (int) (msg->headersize - sizeof(DltStorageHeader)),
+     465          21 :                                     msg->databuffer, (int) msg->datasize, verbose))) {
+     466           1 :         dlt_log(LOG_DEBUG, "dlt_daemon_control_send_control_message: DLT message send to all failed!.\n");
+     467           1 :         return ret;
+     468             :     }
+     469             : 
+     470             :     return DLT_DAEMON_ERROR_OK;
+     471             : }
+     472             : 
+     473          12 : 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          12 :     PRINT_FUNCTION_VERBOSE(verbose);
+     483             : 
+     484          12 :     if ((daemon == NULL) || (daemon_local == NULL) || (msg == NULL))
+     485             :         return -1;
+     486             : 
+     487          12 :     if (msg->datasize < (int32_t)sizeof(uint32_t))
+     488             :         return -1;
+     489             : 
+     490          12 :     extra = msg->headerextra;
+     491             : 
+     492             :     /* check if the message needs to be forwarded */
+     493          12 :     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          12 :     id_tmp = *((uint32_t *)(msg->databuffer));
+     503          12 :     id = DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp);
+     504             : 
+     505          12 :     if ((id > DLT_SERVICE_ID) && (id < DLT_SERVICE_ID_CALLSW_CINJECTION)) {
+     506             :         /* Control message handling */
+     507          12 :         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           4 :         case DLT_SERVICE_ID_GET_SOFTWARE_VERSION:
+     673             :         {
+     674           4 :             dlt_daemon_control_get_software_version(sock, daemon, daemon_local, verbose);
+     675           4 :             break;
+     676             :         }
+     677           0 :         case DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW:
+     678             :         {
+     679           0 :             dlt_daemon_control_message_buffer_overflow(sock, daemon, daemon_local, daemon->overflow_counter, "",
+     680             :                                                        verbose);
+     681           0 :             break;
+     682             :         }
+     683           2 :         case DLT_SERVICE_ID_OFFLINE_LOGSTORAGE:
+     684             :         {
+     685           2 :             dlt_daemon_control_service_logstorage(sock, daemon, daemon_local, msg, verbose);
+     686           2 :             break;
+     687             :         }
+     688           0 :         case DLT_SERVICE_ID_PASSIVE_NODE_CONNECT:
+     689             :         {
+     690           0 :             dlt_daemon_control_passive_node_connect(sock,
+     691             :                                                     daemon,
+     692             :                                                     daemon_local,
+     693             :                                                     msg,
+     694             :                                                     verbose);
+     695           0 :             break;
+     696             :         }
+     697           0 :         case DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS:
+     698             :         {
+     699           0 :             dlt_daemon_control_passive_node_connect_status(sock,
+     700             :                                                            daemon,
+     701             :                                                            daemon_local,
+     702             :                                                            verbose);
+     703           0 :             break;
+     704             :         }
+     705           0 :         case DLT_SERVICE_ID_SET_ALL_LOG_LEVEL:
+     706             :         {
+     707           0 :             dlt_daemon_control_set_all_log_level(sock, daemon, daemon_local, msg, verbose);
+     708           0 :             break;
+     709             :         }
+     710           0 :         case DLT_SERVICE_ID_SET_ALL_TRACE_STATUS:
+     711             :         {
+     712           0 :             dlt_daemon_control_set_all_trace_status(sock, daemon, daemon_local, msg, verbose);
+     713           0 :             break;
+     714             :         }
+     715           0 :         default:
+     716             :         {
+     717           0 :             dlt_daemon_control_service_response(sock,
+     718             :                                                 daemon,
+     719             :                                                 daemon_local,
+     720             :                                                 id,
+     721             :                                                 DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+     722             :                                                 verbose);
+     723           0 :             break;
+     724             :         }
+     725             :         }
+     726             :     }
+     727             :     else {
+     728             :         /* Injection handling */
+     729           0 :         dlt_daemon_control_callsw_cinjection(sock, daemon, daemon_local, msg, verbose);
+     730             :     }
+     731             : 
+     732             :     return 0;
+     733             : }
+     734             : 
+     735           4 : 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           4 :     PRINT_FUNCTION_VERBOSE(verbose);
+     742             : 
+     743           4 :     if (daemon == 0)
+     744           0 :         return;
+     745             : 
+     746             :     /* initialise new message */
+     747           4 :     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           4 :     len = (uint32_t) strlen(daemon->ECUVersionString);
+     759             : 
+     760             :     /* msg.datasize = sizeof(serviceID) + sizeof(status) + sizeof(length) + len */
+     761           4 :     msg.datasize = (uint32_t) (sizeof(uint32_t) + sizeof(uint8_t) + sizeof(uint32_t) + len);
+     762             : 
+     763           4 :     if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
+     764           0 :         free(msg.databuffer);
+     765           0 :         msg.databuffer = 0;
+     766             :     }
+     767             : 
+     768           4 :     if (msg.databuffer == 0) {
+     769           4 :         msg.databuffer = (uint8_t *)malloc(msg.datasize);
+     770           4 :         msg.databuffersize = msg.datasize;
+     771             :     }
+     772             : 
+     773           4 :     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           4 :     resp->service_id = DLT_SERVICE_ID_GET_SOFTWARE_VERSION;
+     785           4 :     resp->status = DLT_SERVICE_RESPONSE_OK;
+     786           4 :     resp->length = len;
+     787           4 :     memcpy(msg.databuffer + msg.datasize - len, daemon->ECUVersionString, len);
+     788             : 
+     789             :     /* send message */
+     790           4 :     dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose);
+     791             : 
+     792             :     /* free message */
+     793           4 :     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           3 : 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           3 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1291             : 
+    1292           3 :     if (daemon == 0)
+    1293           0 :         return;
+    1294             : 
+    1295             :     /* initialise new message */
+    1296           3 :     if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+    1297             :         return;
+    1298             : 
+    1299             :     /* prepare payload of data */
+    1300           3 :     msg.datasize = sizeof(DltServiceResponse);
+    1301             : 
+    1302           3 :     if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
+    1303           0 :         free(msg.databuffer);
+    1304           0 :         msg.databuffer = 0;
+    1305             :     }
+    1306             : 
+    1307           3 :     if (msg.databuffer == 0) {
+    1308           3 :         msg.databuffer = (uint8_t *)malloc(msg.datasize);
+    1309           3 :         msg.databuffersize = msg.datasize;
+    1310             :     }
+    1311             : 
+    1312           3 :     if (msg.databuffer == 0)
+    1313             :         return;
+    1314             : 
+    1315             :     resp = (DltServiceResponse *)msg.databuffer;
+    1316           3 :     resp->service_id = service_id;
+    1317           3 :     resp->status = (uint8_t) status;
+    1318             : 
+    1319             :     /* send message */
+    1320           3 :     dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose);
+    1321             : 
+    1322             :     /* free message */
+    1323           3 :     dlt_message_free(&msg, 0);
+    1324             : }
+    1325             : 
+    1326           0 : int dlt_daemon_control_message_unregister_context(int sock,
+    1327             :                                                   DltDaemon *daemon,
+    1328             :                                                   DltDaemonLocal *daemon_local,
+    1329             :                                                   char *apid,
+    1330             :                                                   char *ctid,
+    1331             :                                                   char *comid,
+    1332             :                                                   int verbose)
+    1333             : {
+    1334             :     DltMessage msg;
+    1335             :     DltServiceUnregisterContext *resp;
+    1336             : 
+    1337           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1338             : 
+    1339           0 :     if (daemon == 0)
+    1340             :         return -1;
+    1341             : 
+    1342             :     /* initialise new message */
+    1343           0 :     if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+    1344             :         return -1;
+    1345             : 
+    1346             :     /* prepare payload of data */
+    1347           0 :     msg.datasize = sizeof(DltServiceUnregisterContext);
+    1348             : 
+    1349           0 :     if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
+    1350           0 :         free(msg.databuffer);
+    1351           0 :         msg.databuffer = 0;
+    1352             :     }
+    1353             : 
+    1354           0 :     if (msg.databuffer == 0) {
+    1355           0 :         msg.databuffer = (uint8_t *)malloc(msg.datasize);
+    1356           0 :         msg.databuffersize = msg.datasize;
+    1357             :     }
+    1358             : 
+    1359           0 :     if (msg.databuffer == 0)
+    1360             :         return -1;
+    1361             : 
+    1362             :     resp = (DltServiceUnregisterContext *)msg.databuffer;
+    1363           0 :     resp->service_id = DLT_SERVICE_ID_UNREGISTER_CONTEXT;
+    1364           0 :     resp->status = DLT_SERVICE_RESPONSE_OK;
+    1365           0 :     dlt_set_id(resp->apid, apid);
+    1366           0 :     dlt_set_id(resp->ctid, ctid);
+    1367           0 :     dlt_set_id(resp->comid, comid);
+    1368             : 
+    1369             :     /* send message */
+    1370           0 :     if (dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose)) {
+    1371           0 :         dlt_message_free(&msg, 0);
+    1372           0 :         return -1;
+    1373             :     }
+    1374             : 
+    1375             :     /* free message */
+    1376           0 :     dlt_message_free(&msg, 0);
+    1377             : 
+    1378           0 :     return 0;
+    1379             : }
+    1380             : 
+    1381           9 : int dlt_daemon_control_message_connection_info(int sock,
+    1382             :                                                DltDaemon *daemon,
+    1383             :                                                DltDaemonLocal *daemon_local,
+    1384             :                                                uint8_t state,
+    1385             :                                                char *comid,
+    1386             :                                                int verbose)
+    1387             : {
+    1388             :     DltMessage msg;
+    1389             :     DltServiceConnectionInfo *resp;
+    1390             : 
+    1391           9 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1392             : 
+    1393           9 :     if (daemon == 0)
+    1394             :         return -1;
+    1395             : 
+    1396             :     /* initialise new message */
+    1397           9 :     if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+    1398             :         return -1;
+    1399             : 
+    1400             :     /* prepare payload of data */
+    1401           9 :     msg.datasize = sizeof(DltServiceConnectionInfo);
+    1402             : 
+    1403           9 :     if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
+    1404           0 :         free(msg.databuffer);
+    1405           0 :         msg.databuffer = 0;
+    1406             :     }
+    1407             : 
+    1408           9 :     if (msg.databuffer == 0) {
+    1409           9 :         msg.databuffer = (uint8_t *)malloc(msg.datasize);
+    1410           9 :         msg.databuffersize = msg.datasize;
+    1411             :     }
+    1412             : 
+    1413           9 :     if (msg.databuffer == 0)
+    1414             :         return -1;
+    1415             : 
+    1416             :     resp = (DltServiceConnectionInfo *)msg.databuffer;
+    1417           9 :     resp->service_id = DLT_SERVICE_ID_CONNECTION_INFO;
+    1418           9 :     resp->status = DLT_SERVICE_RESPONSE_OK;
+    1419           9 :     resp->state = state;
+    1420           9 :     dlt_set_id(resp->comid, comid);
+    1421             : 
+    1422             :     /* send message */
+    1423           9 :     if (dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose)) {
+    1424           0 :         dlt_message_free(&msg, 0);
+    1425           0 :         return -1;
+    1426             :     }
+    1427             : 
+    1428             :     /* free message */
+    1429           9 :     dlt_message_free(&msg, 0);
+    1430             : 
+    1431           9 :     return 0;
+    1432             : }
+    1433             : 
+    1434           0 : int dlt_daemon_control_message_timezone(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
+    1435             : {
+    1436             :     DltMessage msg;
+    1437             :     DltServiceTimezone *resp;
+    1438             : 
+    1439           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1440             : 
+    1441           0 :     if (daemon == 0)
+    1442             :         return -1;
+    1443             : 
+    1444             :     /* initialise new message */
+    1445           0 :     if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+    1446             :         return -1;
+    1447             : 
+    1448             :     /* prepare payload of data */
+    1449           0 :     msg.datasize = sizeof(DltServiceTimezone);
+    1450             : 
+    1451           0 :     if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
+    1452           0 :         free(msg.databuffer);
+    1453           0 :         msg.databuffer = 0;
+    1454             :     }
+    1455             : 
+    1456           0 :     if (msg.databuffer == 0) {
+    1457           0 :         msg.databuffer = (uint8_t *)malloc(msg.datasize);
+    1458           0 :         msg.databuffersize = msg.datasize;
+    1459             :     }
+    1460             : 
+    1461           0 :     if (msg.databuffer == 0)
+    1462             :         return -1;
+    1463             : 
+    1464             :     resp = (DltServiceTimezone *)msg.databuffer;
+    1465           0 :     resp->service_id = DLT_SERVICE_ID_TIMEZONE;
+    1466           0 :     resp->status = DLT_SERVICE_RESPONSE_OK;
+    1467             : 
+    1468           0 :     time_t t = time(NULL);
+    1469             :     struct tm lt;
+    1470           0 :     tzset();
+    1471           0 :     localtime_r(&t, &lt);
+    1472             : #if !defined(__CYGWIN__)
+    1473           0 :     resp->timezone = (int32_t)lt.tm_gmtoff;
+    1474             : #endif
+    1475           0 :     resp->isdst = (uint8_t)lt.tm_isdst;
+    1476             : 
+    1477             :     /* send message */
+    1478           0 :     if (dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose)) {
+    1479           0 :         dlt_message_free(&msg, 0);
+    1480           0 :         return -1;
+    1481             :     }
+    1482             : 
+    1483             :     /* free message */
+    1484           0 :     dlt_message_free(&msg, 0);
+    1485             : 
+    1486           0 :     return 0;
+    1487             : }
+    1488             : 
+    1489           0 : int dlt_daemon_control_message_marker(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
+    1490             : {
+    1491             :     DltMessage msg;
+    1492             :     DltServiceMarker *resp;
+    1493             : 
+    1494           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1495             : 
+    1496           0 :     if (daemon == 0)
+    1497             :         return -1;
+    1498             : 
+    1499             :     /* initialise new message */
+    1500           0 :     if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+    1501             :         return -1;
+    1502             : 
+    1503             :     /* prepare payload of data */
+    1504           0 :     msg.datasize = sizeof(DltServiceMarker);
+    1505             : 
+    1506           0 :     if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
+    1507           0 :         free(msg.databuffer);
+    1508           0 :         msg.databuffer = 0;
+    1509             :     }
+    1510             : 
+    1511           0 :     if (msg.databuffer == 0) {
+    1512           0 :         msg.databuffer = (uint8_t *)malloc(msg.datasize);
+    1513           0 :         msg.databuffersize = msg.datasize;
+    1514             :     }
+    1515             : 
+    1516           0 :     if (msg.databuffer == 0)
+    1517             :         return -1;
+    1518             : 
+    1519             :     resp = (DltServiceMarker *)msg.databuffer;
+    1520           0 :     resp->service_id = DLT_SERVICE_ID_MARKER;
+    1521           0 :     resp->status = DLT_SERVICE_RESPONSE_OK;
+    1522             : 
+    1523             :     /* send message */
+    1524           0 :     if (dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose)) {
+    1525           0 :         dlt_message_free(&msg, 0);
+    1526           0 :         return -1;
+    1527             :     }
+    1528             : 
+    1529             :     /* free message */
+    1530           0 :     dlt_message_free(&msg, 0);
+    1531             : 
+    1532           0 :     return 0;
+    1533             : }
+    1534             : 
+    1535           0 : void dlt_daemon_control_callsw_cinjection(int sock,
+    1536             :                                           DltDaemon *daemon,
+    1537             :                                           DltDaemonLocal *daemon_local,
+    1538             :                                           DltMessage *msg,
+    1539             :                                           int verbose)
+    1540             : {
+    1541             :     char apid[DLT_ID_SIZE], ctid[DLT_ID_SIZE];
+    1542             :     uint32_t id = 0, id_tmp = 0;
+    1543             :     uint8_t *ptr;
+    1544             :     DltDaemonContext *context;
+    1545             :     uint32_t data_length_inject = 0;
+    1546             :     uint32_t data_length_inject_tmp = 0;
+    1547             : 
+    1548             :     int32_t datalength;
+    1549             : 
+    1550             :     DltUserHeader userheader;
+    1551             :     DltUserControlMsgInjection usercontext;
+    1552             :     uint8_t *userbuffer;
+    1553             : 
+    1554           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1555             : 
+    1556           0 :     if ((daemon == NULL) || (daemon_local == NULL) || (msg == NULL) || (msg->databuffer == NULL))
+    1557           0 :         return;
+    1558             : 
+    1559           0 :     datalength = (int32_t) msg->datasize;
+    1560             :     ptr = msg->databuffer;
+    1561             : 
+    1562           0 :     DLT_MSG_READ_VALUE(id_tmp, ptr, datalength, uint32_t); /* Get service id */
+    1563           0 :     id = DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp);
+    1564             : 
+    1565             :     /* injectionMode is disabled */
+    1566           0 :     if (daemon_local->flags.injectionMode == 0) {
+    1567           0 :         dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_PERM_DENIED, verbose);
+    1568           0 :         return;
+    1569             :     }
+    1570             : 
+    1571             :     /* id is always less than DLT_DAEMON_INJECTION_MAX since its type is uinit32_t */
+    1572           0 :     if (id >= DLT_DAEMON_INJECTION_MIN) {
+    1573             :         /* This a a real SW-C injection call */
+    1574             :         data_length_inject = 0;
+    1575             :         data_length_inject_tmp = 0;
+    1576             : 
+    1577           0 :         DLT_MSG_READ_VALUE(data_length_inject_tmp, ptr, datalength, uint32_t); /* Get data length */
+    1578           0 :         data_length_inject = DLT_ENDIAN_GET_32(msg->standardheader->htyp, data_length_inject_tmp);
+    1579             : 
+    1580             :         /* Get context handle for apid, ctid (and seid) */
+    1581             :         /* Warning: seid is ignored in this implementation! */
+    1582           0 :         if (DLT_IS_HTYP_UEH(msg->standardheader->htyp)) {
+    1583           0 :             dlt_set_id(apid, msg->extendedheader->apid);
+    1584           0 :             dlt_set_id(ctid, msg->extendedheader->ctid);
+    1585             :         }
+    1586             :         else {
+    1587             :             /* No extended header, and therefore no apid and ctid available */
+    1588           0 :             dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+    1589           0 :             return;
+    1590             :         }
+    1591             : 
+    1592             :         /* At this point, apid and ctid is available */
+    1593           0 :         context = dlt_daemon_context_find(daemon,
+    1594             :                                           apid,
+    1595             :                                           ctid,
+    1596           0 :                                           daemon->ecuid,
+    1597             :                                           verbose);
+    1598             : 
+    1599           0 :         if (context == 0) {
+    1600             :             /* dlt_log(LOG_INFO,"No context found!\n"); */
+    1601           0 :             dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+    1602           0 :             return;
+    1603             :         }
+    1604             : 
+    1605             :         /* Send user message to handle, specified in context */
+    1606           0 :         if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_INJECTION) < DLT_RETURN_OK) {
+    1607           0 :             dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+    1608           0 :             return;
+    1609             :         }
+    1610             : 
+    1611           0 :         usercontext.log_level_pos = context->log_level_pos;
+    1612             : 
+    1613           0 :         if (data_length_inject > (uint32_t) msg->databuffersize) {
+    1614           0 :             dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+    1615           0 :             return;
+    1616             :         }
+    1617             : 
+    1618           0 :         userbuffer = malloc(data_length_inject);
+    1619             : 
+    1620           0 :         if (userbuffer == 0) {
+    1621           0 :             dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+    1622           0 :             return;
+    1623             :         }
+    1624             : 
+    1625           0 :         usercontext.data_length_inject = (uint32_t) data_length_inject;
+    1626           0 :         usercontext.service_id = id;
+    1627             : 
+    1628             :         memcpy(userbuffer, ptr, (size_t) data_length_inject);  /* Copy received injection to send buffer */
+    1629             : 
+    1630             :         /* write to FIFO */
+    1631             :         DltReturnValue ret =
+    1632           0 :             dlt_user_log_out3_with_timeout(context->user_handle, &(userheader), sizeof(DltUserHeader),
+    1633             :                               &(usercontext), sizeof(DltUserControlMsgInjection),
+    1634             :                               userbuffer, (size_t) data_length_inject);
+    1635             : 
+    1636           0 :         if (ret < DLT_RETURN_OK) {
+    1637           0 :             if (ret == DLT_RETURN_PIPE_ERROR) {
+    1638             :                 /* Close connection */
+    1639           0 :                 close(context->user_handle);
+    1640           0 :                 context->user_handle = DLT_FD_INIT;
+    1641             :             }
+    1642             : 
+    1643           0 :             dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+    1644             :         }
+    1645             :         else {
+    1646           0 :             dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+    1647             :         }
+    1648             : 
+    1649           0 :         free(userbuffer);
+    1650             :         userbuffer = 0;
+    1651             : 
+    1652             :     }
+    1653             :     else {
+    1654             :         /* Invalid ID */
+    1655           0 :         dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+    1656             :                                             verbose);
+    1657             :     }
+    1658             : }
+    1659             : 
+    1660           0 : void dlt_daemon_send_log_level(int sock,
+    1661             :                                DltDaemon *daemon,
+    1662             :                                DltDaemonLocal *daemon_local,
+    1663             :                                DltDaemonContext *context,
+    1664             :                                int8_t loglevel,
+    1665             :                                int verbose)
+    1666             : {
+    1667           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1668             : 
+    1669             :     int32_t id = DLT_SERVICE_ID_SET_LOG_LEVEL;
+    1670             :     int8_t old_log_level = 0;
+    1671             : 
+    1672           0 :     old_log_level = context->log_level;
+    1673           0 :     context->log_level = loglevel; /* No endianess conversion necessary*/
+    1674             : 
+    1675           0 :     if ((context->user_handle >= DLT_FD_MINIMUM) &&
+    1676           0 :         (dlt_daemon_user_send_log_level(daemon, context, verbose) == 0)) {
+    1677           0 :         dlt_daemon_control_service_response(sock, daemon, daemon_local, (uint32_t) id, DLT_SERVICE_RESPONSE_OK, verbose);
+    1678             :     }
+    1679             :     else {
+    1680           0 :         dlt_log(LOG_ERR, "Log level could not be sent!\n");
+    1681           0 :         context->log_level = old_log_level;
+    1682           0 :         dlt_daemon_control_service_response(sock, daemon, daemon_local, (uint32_t) id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+    1683             :     }
+    1684           0 : }
+    1685             : 
+    1686           0 : void dlt_daemon_find_multiple_context_and_send_log_level(int sock,
+    1687             :                                                          DltDaemon *daemon,
+    1688             :                                                          DltDaemonLocal *daemon_local,
+    1689             :                                                          int8_t app_flag,
+    1690             :                                                          char *str,
+    1691             :                                                          int8_t len,
+    1692             :                                                          int8_t loglevel,
+    1693             :                                                          int verbose)
+    1694             : {
+    1695           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1696             : 
+    1697             :     int count = 0;
+    1698             :     DltDaemonContext *context = NULL;
+    1699           0 :     char src_str[DLT_ID_SIZE + 1] = { 0 };
+    1700             :     int ret = 0;
+    1701             :     DltDaemonRegisteredUsers *user_list = NULL;
+    1702             : 
+    1703           0 :     if (daemon == 0) {
+    1704           0 :         dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
+    1705           0 :         return;
+    1706             :     }
+    1707             : 
+    1708           0 :     user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+    1709             : 
+    1710           0 :     if (user_list == NULL)
+    1711             :         return;
+    1712             : 
+    1713           0 :     for (count = 0; count < user_list->num_contexts; count++) {
+    1714           0 :         context = &(user_list->contexts[count]);
+    1715             : 
+    1716           0 :         if (context) {
+    1717           0 :             if (app_flag == 1)
+    1718           0 :                 strncpy(src_str, context->apid, DLT_ID_SIZE);
+    1719             :             else
+    1720           0 :                 strncpy(src_str, context->ctid, DLT_ID_SIZE);
+    1721             : 
+    1722           0 :             ret = strncmp(src_str, str, len);
+    1723             : 
+    1724           0 :             if (ret == 0)
+    1725           0 :                 dlt_daemon_send_log_level(sock, daemon, daemon_local, context, loglevel, verbose);
+    1726           0 :             else if ((ret > 0) && (app_flag == 1))
+    1727             :                 break;
+    1728             :             else
+    1729           0 :                 continue;
+    1730             :         }
+    1731             :     }
+    1732             : }
+    1733             : 
+    1734           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          11 : int dlt_daemon_process_one_s_timer(DltDaemon *daemon,
+    2265             :                                    DltDaemonLocal *daemon_local,
+    2266             :                                    DltReceiver *receiver,
+    2267             :                                    int verbose)
+    2268             : {
+    2269          11 :     uint64_t expir = 0;
+    2270             :     ssize_t res = 0;
+    2271             : 
+    2272          11 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2273             : 
+    2274          11 :     if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
+    2275           0 :         dlt_vlog(LOG_ERR, "%s: invalid parameters", __func__);
+    2276           0 :         return -1;
+    2277             :     }
+    2278             : 
+    2279          11 :     res = read(receiver->fd, &expir, sizeof(expir));
+    2280             : 
+    2281          11 :     if (res < 0) {
+    2282           0 :         dlt_vlog(LOG_WARNING, "%s: Fail to read timer (%s)\n", __func__,
+    2283           0 :                  strerror(errno));
+    2284             :         /* Activity received on timer_wd, but unable to read the fd:
+    2285             :          * let's go on sending notification */
+    2286             :     }
+    2287             : 
+    2288          11 :     if ((daemon->state == DLT_DAEMON_STATE_SEND_BUFFER) ||
+    2289             :         (daemon->state == DLT_DAEMON_STATE_BUFFER_FULL)) {
+    2290           0 :         if (dlt_daemon_send_ringbuffer_to_client(daemon,
+    2291             :                                                  daemon_local,
+    2292             :                                                  daemon_local->flags.vflag))
+    2293           0 :             dlt_log(LOG_DEBUG,
+    2294             :                     "Can't send contents of ring buffer to clients\n");
+    2295             :     }
+    2296             : 
+    2297          11 :     if ((daemon->timingpackets) &&
+    2298           0 :         (daemon->state == DLT_DAEMON_STATE_SEND_DIRECT))
+    2299           0 :         dlt_daemon_control_message_time(DLT_DAEMON_SEND_TO_ALL,
+    2300             :                                         daemon,
+    2301             :                                         daemon_local,
+    2302             :                                         daemon_local->flags.vflag);
+    2303             : 
+    2304          11 :     dlt_log(LOG_DEBUG, "Timer timingpacket\n");
+    2305             : 
+    2306          11 :     return 0;
+    2307             : }
+    2308             : 
+    2309           0 : int dlt_daemon_process_sixty_s_timer(DltDaemon *daemon,
+    2310             :                                      DltDaemonLocal *daemon_local,
+    2311             :                                      DltReceiver *receiver,
+    2312             :                                      int verbose)
+    2313             : {
+    2314           0 :     uint64_t expir = 0;
+    2315             :     ssize_t res = 0;
+    2316             : 
+    2317           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2318             : 
+    2319           0 :     if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
+    2320           0 :         dlt_vlog(LOG_ERR, "%s: invalid parameters", __func__);
+    2321           0 :         return -1;
+    2322             :     }
+    2323             : 
+    2324           0 :     res = read(receiver->fd, &expir, sizeof(expir));
+    2325             : 
+    2326           0 :     if (res < 0) {
+    2327           0 :         dlt_vlog(LOG_WARNING, "%s: Fail to read timer (%s)\n", __func__,
+    2328           0 :                  strerror(errno));
+    2329             :         /* Activity received on timer_wd, but unable to read the fd:
+    2330             :          * let's go on sending notification */
+    2331             :     }
+    2332             : 
+    2333           0 :     if (daemon_local->flags.sendECUSoftwareVersion > 0)
+    2334           0 :         dlt_daemon_control_get_software_version(DLT_DAEMON_SEND_TO_ALL,
+    2335             :                                                 daemon,
+    2336             :                                                 daemon_local,
+    2337             :                                                 daemon_local->flags.vflag);
+    2338             : 
+    2339           0 :     if (daemon_local->flags.sendTimezone > 0) {
+    2340             :         /* send timezone information */
+    2341           0 :         time_t t = time(NULL);
+    2342             :         struct tm lt;
+    2343             : 
+    2344             :         /*Added memset to avoid compiler warning for near initialization */
+    2345             :         memset((void *)&lt, 0, sizeof(lt));
+    2346           0 :         tzset();
+    2347           0 :         localtime_r(&t, &lt);
+    2348             : 
+    2349           0 :         dlt_daemon_control_message_timezone(DLT_DAEMON_SEND_TO_ALL,
+    2350             :                                             daemon,
+    2351             :                                             daemon_local,
+    2352             :                                             daemon_local->flags.vflag);
+    2353             :     }
+    2354             : 
+    2355           0 :     dlt_log(LOG_DEBUG, "Timer ecuversion\n");
+    2356             : 
+    2357           0 :     return 0;
+    2358             : }
+    2359             : 
+    2360             : #ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+    2361             : int dlt_daemon_process_systemd_timer(DltDaemon *daemon,
+    2362             :                                      DltDaemonLocal *daemon_local,
+    2363             :                                      DltReceiver *receiver,
+    2364             :                                      int verbose)
+    2365             : {
+    2366             :     uint64_t expir = 0;
+    2367             :     ssize_t res = -1;
+    2368             : 
+    2369             :     PRINT_FUNCTION_VERBOSE(verbose);
+    2370             : 
+    2371             :     if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
+    2372             :         dlt_vlog(LOG_ERR, "%s: invalid parameters", __func__);
+    2373             :         return res;
+    2374             :     }
+    2375             : 
+    2376             :     res = read(receiver->fd, &expir, sizeof(expir));
+    2377             : 
+    2378             :     if (res < 0) {
+    2379             :         dlt_vlog(LOG_WARNING, "Failed to read timer_wd; %s\n", strerror(errno));
+    2380             :         /* Activity received on timer_wd, but unable to read the fd:
+    2381             :          * let's go on sending notification */
+    2382             :     }
+    2383             : 
+    2384             : #ifdef DLT_SYSTEMD_WATCHDOG_ENFORCE_MSG_RX_ENABLE
+    2385             :     if (!daemon->received_message_since_last_watchdog_interval) {
+    2386             :       dlt_log(LOG_WARNING, "No new messages received since last watchdog timer run\n");
+    2387             :       return 0;
+    2388             :     }
+    2389             :     daemon->received_message_since_last_watchdog_interval = 0;
+    2390             : #endif
+    2391             : 
+    2392             :     if (sd_notify(0, "WATCHDOG=1") < 0)
+    2393             :         dlt_log(LOG_CRIT, "Could not reset systemd watchdog\n");
+    2394             : 
+    2395             :     dlt_log(LOG_DEBUG, "Timer watchdog\n");
+    2396             : 
+    2397             :     return 0;
+    2398             : }
+    2399             : #else
+    2400           0 : int dlt_daemon_process_systemd_timer(DltDaemon *daemon,
+    2401             :                                      DltDaemonLocal *daemon_local,
+    2402             :                                      DltReceiver *receiver,
+    2403             :                                      int verbose)
+    2404             : {
+    2405             :     (void)daemon;
+    2406             :     (void)daemon_local;
+    2407             :     (void)receiver;
+    2408             :     (void)verbose;
+    2409             : 
+    2410           0 :     dlt_log(LOG_DEBUG, "Timer watchdog not enabled\n");
+    2411             : 
+    2412           0 :     return -1;
+    2413             : }
+    2414             : #endif
+    2415             : 
+    2416           2 : void dlt_daemon_control_service_logstorage(int sock,
+    2417             :                                            DltDaemon *daemon,
+    2418             :                                            DltDaemonLocal *daemon_local,
+    2419             :                                            DltMessage *msg,
+    2420             :                                            int verbose)
+    2421             : {
+    2422             :     DltServiceOfflineLogstorage *req = NULL;
+    2423             :     int ret = 0;
+    2424             :     unsigned int connection_type = 0;
+    2425             :     DltLogStorage *device = NULL;
+    2426             :     int device_index = -1;
+    2427             :     uint32_t i = 0;
+    2428             : 
+    2429             :     int tmp_errno = 0;
+    2430             : 
+    2431           2 :     struct stat daemon_mpoint_st = {0};
+    2432             :     int daemon_st_status = 0;
+    2433             : 
+    2434           2 :     struct stat req_mpoint_st = {0};
+    2435             :     int req_st_status = 0;
+    2436             : 
+    2437           2 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2438             : 
+    2439           2 :     if ((daemon == NULL) || (msg == NULL) || (daemon_local == NULL)) {
+    2440           0 :         dlt_vlog(LOG_ERR,
+    2441             :                  "%s: Invalid function parameters\n",
+    2442             :                  __func__);
+    2443           0 :         return;
+    2444             :     }
+    2445             : 
+    2446           2 :     if ((daemon_local->flags.offlineLogstorageMaxDevices <= 0) || (msg->databuffer == NULL)) {
+    2447           0 :         dlt_daemon_control_service_response(sock,
+    2448             :                                             daemon,
+    2449             :                                             daemon_local,
+    2450             :                                             DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2451             :                                             DLT_SERVICE_RESPONSE_ERROR,
+    2452             :                                             verbose);
+    2453             : 
+    2454           0 :         dlt_log(LOG_INFO,
+    2455             :                 "Logstorage functionality not enabled or MAX device set is 0\n");
+    2456           0 :         return;
+    2457             :     }
+    2458             : 
+    2459           2 :     if (dlt_check_rcv_data_size(msg->datasize, sizeof(DltServiceOfflineLogstorage)) < 0)
+    2460             :         return;
+    2461             : 
+    2462           2 :     req = (DltServiceOfflineLogstorage *)(msg->databuffer);
+    2463             : 
+    2464           2 :     if(req->connection_type != DLT_OFFLINE_LOGSTORAGE_SYNC_CACHES) {
+    2465           0 :         req_st_status = stat(req->mount_point, &req_mpoint_st);
+    2466           0 :         tmp_errno = errno;
+    2467           0 :         if (req_st_status < 0) {
+    2468           0 :             dlt_daemon_control_service_response(sock,
+    2469             :                                                 daemon,
+    2470             :                                                 daemon_local,
+    2471             :                                                 DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2472             :                                                 DLT_SERVICE_RESPONSE_ERROR,
+    2473             :                                                 verbose);
+    2474             : 
+    2475           0 :             dlt_vlog(LOG_WARNING,
+    2476             :                      "%s: Failed to stat requested mount point [%s] with error [%s]\n",
+    2477             :                      __func__, req->mount_point, strerror(tmp_errno));
+    2478           0 :             return;
+    2479             :         }
+    2480             :     }
+    2481             : 
+    2482           4 :     for (i = 0; i < (uint32_t) daemon_local->flags.offlineLogstorageMaxDevices; i++) {
+    2483           2 :         connection_type = daemon->storage_handle[i].connection_type;
+    2484             : 
+    2485             :         memset(&daemon_mpoint_st, 0, sizeof(struct stat));
+    2486           2 :         if (strlen(daemon->storage_handle[i].device_mount_point) > 1) {
+    2487           0 :             daemon_st_status = stat(daemon->storage_handle[i].device_mount_point,
+    2488             :                     &daemon_mpoint_st);
+    2489           0 :             tmp_errno = errno;
+    2490             : 
+    2491           0 :             if (daemon_st_status < 0) {
+    2492           0 :                 dlt_daemon_control_service_response(sock,
+    2493             :                                                     daemon,
+    2494             :                                                     daemon_local,
+    2495             :                                                     DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2496             :                                                     DLT_SERVICE_RESPONSE_ERROR,
+    2497             :                                                     verbose);
+    2498           0 :                 dlt_vlog(LOG_WARNING,
+    2499             :                         "%s: Failed to stat daemon mount point [%s] with error [%s]\n",
+    2500           0 :                         __func__, daemon->storage_handle[i].device_mount_point,
+    2501             :                         strerror(tmp_errno));
+    2502           0 :                 return;
+    2503             :             }
+    2504             : 
+    2505             :             /* Check if the requested device path is already used as log storage device */
+    2506           0 :             if (req_mpoint_st.st_dev == daemon_mpoint_st.st_dev &&
+    2507           0 :                     req_mpoint_st.st_ino == daemon_mpoint_st.st_ino) {
+    2508           0 :                 device_index = (int) i;
+    2509           0 :                 break;
+    2510             :             }
+    2511             :         }
+    2512             : 
+    2513             :         /* Get first available device index here */
+    2514           2 :         if ((connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) &&
+    2515           2 :             (device_index == -1))
+    2516           0 :             device_index = (int) i;
+    2517             :     }
+    2518             : 
+    2519             :     /* It might be possible to sync all caches of all devices */
+    2520           2 :     if ((req->connection_type == DLT_OFFLINE_LOGSTORAGE_SYNC_CACHES) &&
+    2521           2 :         (strlen(req->mount_point) == 0)) {
+    2522             :         /* It is expected to receive an empty mount point to sync all Logstorage
+    2523             :          * devices in this case. */
+    2524             :     }
+    2525           0 :     else if (device_index == -1) {
+    2526           0 :         dlt_daemon_control_service_response(sock,
+    2527             :                                             daemon,
+    2528             :                                             daemon_local,
+    2529             :                                             DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2530             :                                             DLT_SERVICE_RESPONSE_ERROR,
+    2531             :                                             verbose);
+    2532           0 :         dlt_log(LOG_WARNING, "MAX devices already in use  \n");
+    2533           0 :         return;
+    2534             :     }
+    2535             : 
+    2536             :     /* Check for device connection request from log storage ctrl app  */
+    2537           2 :     device = &daemon->storage_handle[device_index];
+    2538             : 
+    2539           2 :     if (req->connection_type == DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) {
+    2540           0 :         ret = dlt_logstorage_device_connected(device, req->mount_point);
+    2541             : 
+    2542           0 :         if (ret == 1) {
+    2543           0 :             dlt_daemon_control_service_response(sock,
+    2544             :                                                 daemon,
+    2545             :                                                 daemon_local,
+    2546             :                                                 DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2547             :                                                 DLT_SERVICE_RESPONSE_WARNING,
+    2548             :                                                 verbose);
+    2549           0 :             return;
+    2550             :         }
+    2551           0 :         else if (ret != 0)
+    2552             :         {
+    2553           0 :             dlt_daemon_control_service_response(sock,
+    2554             :                                                 daemon,
+    2555             :                                                 daemon_local,
+    2556             :                                                 DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2557             :                                                 DLT_SERVICE_RESPONSE_ERROR,
+    2558             :                                                 verbose);
+    2559           0 :             return;
+    2560             :         }
+    2561             : 
+    2562           0 :         dlt_daemon_control_service_response(sock,
+    2563             :                                             daemon,
+    2564             :                                             daemon_local,
+    2565             :                                             DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2566             :                                             DLT_SERVICE_RESPONSE_OK,
+    2567             :                                             verbose);
+    2568             : 
+    2569             :         /* Update maintain logstorage loglevel if necessary */
+    2570           0 :         if (daemon->storage_handle[device_index].maintain_logstorage_loglevel != DLT_MAINTAIN_LOGSTORAGE_LOGLEVEL_UNDEF)
+    2571             :         {
+    2572           0 :             daemon->maintain_logstorage_loglevel = daemon->storage_handle[device_index].maintain_logstorage_loglevel;
+    2573             :         }
+    2574             : 
+    2575             :         /* Check if log level of running application needs an update */
+    2576           0 :         dlt_daemon_logstorage_update_application_loglevel(daemon,
+    2577             :                                                           daemon_local,
+    2578             :                                                           device_index,
+    2579             :                                                           verbose);
+    2580             : 
+    2581             :     }
+    2582             :     /* Check for device disconnection request from log storage ctrl app  */
+    2583           2 :     else if (req->connection_type == DLT_OFFLINE_LOGSTORAGE_DEVICE_DISCONNECTED)
+    2584             :     {
+    2585             :         /* Check if log level of running application needs to be reset */
+    2586           0 :         dlt_daemon_logstorage_reset_application_loglevel(
+    2587             :             daemon,
+    2588             :             daemon_local,
+    2589             :             device_index,
+    2590             :             (int) daemon_local->flags.offlineLogstorageMaxDevices,
+    2591             :             verbose);
+    2592             : 
+    2593           0 :         dlt_logstorage_device_disconnected(&(daemon->storage_handle[device_index]),
+    2594             :                                            DLT_LOGSTORAGE_SYNC_ON_DEVICE_DISCONNECT);
+    2595             : 
+    2596           0 :         dlt_daemon_control_service_response(sock,
+    2597             :                                             daemon,
+    2598             :                                             daemon_local,
+    2599             :                                             DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2600             :                                             DLT_SERVICE_RESPONSE_OK,
+    2601             :                                             verbose);
+    2602             : 
+    2603             :     }
+    2604             :     /* Check for cache synchronization request from log storage ctrl app */
+    2605           2 :     else if (req->connection_type == DLT_OFFLINE_LOGSTORAGE_SYNC_CACHES)
+    2606             :     {
+    2607             :         ret = 0;
+    2608             : 
+    2609           2 :         if (device_index == -1) { /* sync all Logstorage devices */
+    2610             : 
+    2611           4 :             for (i = 0; i < (uint32_t) daemon_local->flags.offlineLogstorageMaxDevices; i++)
+    2612           2 :                 if (daemon->storage_handle[i].connection_type ==
+    2613             :                     DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED)
+    2614           2 :                     ret = dlt_daemon_logstorage_sync_cache(
+    2615             :                         daemon,
+    2616             :                         daemon_local,
+    2617           2 :                         daemon->storage_handle[i].device_mount_point,
+    2618             :                         verbose);
+    2619             :         }
+    2620             :         else {
+    2621             :             /* trigger logstorage to sync caches */
+    2622           0 :             ret = dlt_daemon_logstorage_sync_cache(daemon,
+    2623             :                                                    daemon_local,
+    2624           0 :                                                    req->mount_point,
+    2625             :                                                    verbose);
+    2626             :         }
+    2627             : 
+    2628           2 :         if (ret == 0)
+    2629           2 :             dlt_daemon_control_service_response(sock,
+    2630             :                                                 daemon,
+    2631             :                                                 daemon_local,
+    2632             :                                                 DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2633             :                                                 DLT_SERVICE_RESPONSE_OK,
+    2634             :                                                 verbose);
+    2635             :         else
+    2636           0 :             dlt_daemon_control_service_response(sock,
+    2637             :                                                 daemon,
+    2638             :                                                 daemon_local,
+    2639             :                                                 DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2640             :                                                 DLT_SERVICE_RESPONSE_ERROR,
+    2641             :                                                 verbose);
+    2642             :     }
+    2643             :     else {
+    2644           0 :         dlt_daemon_control_service_response(sock,
+    2645             :                                             daemon,
+    2646             :                                             daemon_local,
+    2647             :                                             DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+    2648             :                                             DLT_SERVICE_RESPONSE_ERROR,
+    2649             :                                             verbose);
+    2650             :     }
+    2651             : }
+    2652             : 
+    2653           0 : void dlt_daemon_control_passive_node_connect(int sock,
+    2654             :                                              DltDaemon *daemon,
+    2655             :                                              DltDaemonLocal *daemon_local,
+    2656             :                                              DltMessage *msg,
+    2657             :                                              int verbose)
+    2658             : {
+    2659           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2660             : 
+    2661             :     DltServicePassiveNodeConnect *req;
+    2662             :     uint32_t id = DLT_SERVICE_ID_PASSIVE_NODE_CONNECT;
+    2663             : 
+    2664           0 :     if ((daemon == NULL) || (daemon_local == NULL) || (msg == NULL) ||
+    2665           0 :         (msg->databuffer == NULL))
+    2666             :         return;
+    2667             : 
+    2668             :     /* return error, if gateway mode not enabled*/
+    2669           0 :     if (daemon_local->flags.gatewayMode == 0) {
+    2670           0 :         dlt_log(LOG_WARNING,
+    2671             :                 "Received passive node connection status request, "
+    2672             :                 "but GatewayMode is disabled\n");
+    2673             : 
+    2674           0 :         dlt_daemon_control_service_response(
+    2675             :             sock,
+    2676             :             daemon,
+    2677             :             daemon_local,
+    2678             :             DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS,
+    2679             :             DLT_SERVICE_RESPONSE_ERROR,
+    2680             :             verbose);
+    2681             : 
+    2682           0 :         return;
+    2683             :     }
+    2684             : 
+    2685           0 :     if (dlt_check_rcv_data_size(msg->datasize, sizeof(DltServicePassiveNodeConnect)) < 0)
+    2686             :         return;
+    2687             : 
+    2688           0 :     req = (DltServicePassiveNodeConnect *)msg->databuffer;
+    2689             : 
+    2690           0 :     if (dlt_gateway_process_on_demand_request(&daemon_local->pGateway,
+    2691             :                                               daemon_local,
+    2692           0 :                                               req->node_id,
+    2693           0 :                                               (int) req->connection_status,
+    2694             :                                               verbose) < 0)
+    2695           0 :         dlt_daemon_control_service_response(sock,
+    2696             :                                             daemon,
+    2697             :                                             daemon_local,
+    2698             :                                             id,
+    2699             :                                             DLT_SERVICE_RESPONSE_ERROR,
+    2700             :                                             verbose);
+    2701             :     else
+    2702           0 :         dlt_daemon_control_service_response(sock,
+    2703             :                                             daemon,
+    2704             :                                             daemon_local,
+    2705             :                                             id,
+    2706             :                                             DLT_SERVICE_RESPONSE_OK,
+    2707             :                                             verbose);
+    2708             : }
+    2709             : 
+    2710           0 : void dlt_daemon_control_passive_node_connect_status(int sock,
+    2711             :                                                     DltDaemon *daemon,
+    2712             :                                                     DltDaemonLocal *daemon_local,
+    2713             :                                                     int verbose)
+    2714             : {
+    2715             :     DltMessage msg;
+    2716             :     DltServicePassiveNodeConnectionInfo *resp;
+    2717             :     DltGatewayConnection *con = NULL;
+    2718             :     unsigned int i = 0;
+    2719             : 
+    2720           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    2721             : 
+    2722           0 :     if ((daemon == NULL) || (daemon_local == NULL))
+    2723           0 :         return;
+    2724             : 
+    2725           0 :     if (dlt_message_init(&msg, verbose) == -1)
+    2726             :         return;
+    2727             : 
+    2728             :     /* return error, if gateway mode not enabled*/
+    2729           0 :     if (daemon_local->flags.gatewayMode == 0) {
+    2730           0 :         dlt_log(LOG_WARNING,
+    2731             :                 "Received passive node connection status request, "
+    2732             :                 "but GatewayMode is disabled\n");
+    2733             : 
+    2734           0 :         dlt_daemon_control_service_response(
+    2735             :             sock,
+    2736             :             daemon,
+    2737             :             daemon_local,
+    2738             :             DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS,
+    2739             :             DLT_SERVICE_RESPONSE_ERROR,
+    2740             :             verbose);
+    2741             : 
+    2742           0 :         return;
+    2743             :     }
+    2744             : 
+    2745             :     /* prepare payload of data */
+    2746           0 :     msg.datasize = sizeof(DltServicePassiveNodeConnectionInfo);
+    2747             : 
+    2748           0 :     if (msg.databuffer && (msg.databuffersize < msg.datasize))
+    2749           0 :         msg.databuffer = NULL;
+    2750             : 
+    2751           0 :     if (msg.databuffer == NULL) {
+    2752           0 :         msg.databuffer = (uint8_t *)malloc(msg.datasize);
+    2753             : 
+    2754           0 :         if (msg.databuffer == NULL) {
+    2755           0 :             dlt_log(LOG_CRIT, "Cannot allocate memory for message response\n");
+    2756           0 :             return;
+    2757             :         }
+    2758             : 
+    2759           0 :         msg.databuffersize = msg.datasize;
+    2760             :     }
+    2761             : 
+    2762           0 :     resp = (DltServicePassiveNodeConnectionInfo *)msg.databuffer;
+    2763             :     memset(resp, 0, msg.datasize);
+    2764           0 :     resp->service_id = DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS;
+    2765             :     resp->status = DLT_SERVICE_RESPONSE_OK;
+    2766           0 :     resp->num_connections = (uint32_t) daemon_local->pGateway.num_connections;
+    2767             : 
+    2768           0 :     for (i = 0; i < resp->num_connections; i++) {
+    2769           0 :         if ((i * DLT_ID_SIZE) > DLT_ENTRY_MAX) {
+    2770           0 :             dlt_log(LOG_ERR,
+    2771             :                     "Maximal message size reached. Skip further information\n");
+    2772           0 :             break;
+    2773             :         }
+    2774             : 
+    2775           0 :         con = &daemon_local->pGateway.connections[i];
+    2776             : 
+    2777           0 :         resp->connection_status[i] = con->status;
+    2778           0 :         memcpy(&resp->node_id[i * DLT_ID_SIZE], con->ecuid, DLT_ID_SIZE);
+    2779             :     }
+    2780             : 
+    2781           0 :     dlt_daemon_client_send_control_message(sock,
+    2782             :                                            daemon,
+    2783             :                                            daemon_local,
+    2784             :                                            &msg,
+    2785             :                                            "",
+    2786             :                                            "",
+    2787             :                                            verbose);
+    2788             :     /* free message */
+    2789           0 :     dlt_message_free(&msg, verbose);
+    2790             : }
+
+
+
+ + + + +
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 00000000..e4efcc67 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_common.c.func-sort-c.html @@ -0,0 +1,200 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_common.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_common.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:35162356.3 %
Date:2024-04-29 13:30:27Functions:233271.9 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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

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

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

Function Name Sort by function nameHit count Sort by hit count
dlt_connection_get_next2
dlt_connection_create47
dlt_connection_destroy48
dlt_connection_get_receiver48
dlt_connection_destroy_receiver49
dlt_connection_send_multiple219
dlt_connection_send436
dlt_connection_get_callback1308
+
+
+ + + +
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 00000000..ef6bfe13 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_connection.c.func.html @@ -0,0 +1,104 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_connection.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_connection.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:10211588.7 %
Date:2024-04-29 13:30:27Functions:88100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_add_connection6
dlt_event_handler_disable_fd7
dlt_event_handler_unregister_connection7
dlt_event_handler_cleanup_connections10
dlt_daemon_prepare_event_handling16
dlt_daemon_remove_connection47
dlt_event_handler_enable_fd49
dlt_event_handler_register_connection49
dlt_connection_check_activate57
dlt_event_handler_find_connection1122
dlt_daemon_handle_event1316
+
+
+ + + +
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 00000000..f040c5db --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_event_handler.c.func.html @@ -0,0 +1,116 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_event_handler.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_event_handler.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:12515083.3 %
Date:2024-04-29 13:30:27Functions:1111100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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

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

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_socket_close0
dlt_daemon_socket_get_send_qeue_max_size9
dlt_daemon_socket_open9
dlt_daemon_socket_send16
dlt_daemon_socket_sendreliable466
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_socket.c.func.html b/dlt_lcov_report/daemon/dlt_daemon_socket.c.func.html new file mode 100644 index 00000000..c1370d9f --- /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:345957.6 %
Date:2024-04-29 13:30:27Functions:4580.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_socket_close0
dlt_daemon_socket_get_send_qeue_max_size9
dlt_daemon_socket_open9
dlt_daemon_socket_send16
dlt_daemon_socket_sendreliable466
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_socket.c.gcov.html b/dlt_lcov_report/daemon/dlt_daemon_socket.c.gcov.html new file mode 100644 index 00000000..6fe6d342 --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_socket.c.gcov.html @@ -0,0 +1,322 @@ + + + + + + + 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:345957.6 %
Date:2024-04-29 13:30:27Functions:4580.0 %
+
+ + + + + + + + +

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

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

Function Name Sort by function nameHit count Sort by hit count
dlt_daemon_unix_socket_close0
dlt_daemon_unix_socket_open9
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/dlt_daemon_unix_socket.c.gcov.html b/dlt_lcov_report/daemon/dlt_daemon_unix_socket.c.gcov.html new file mode 100644 index 00000000..25beb9ca --- /dev/null +++ b/dlt_lcov_report/daemon/dlt_daemon_unix_socket.c.gcov.html @@ -0,0 +1,264 @@ + + + + + + + LCOV - dlt_final_coverage.info - daemon/dlt_daemon_unix_socket.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - daemon - dlt_daemon_unix_socket.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:122744.4 %
Date:2024-04-29 13:30: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           9 : int dlt_daemon_unix_socket_open(int *sock, char *sock_path, int type, int mask)
+      88             : {
+      89             :     struct sockaddr_un addr;
+      90             :     int old_mask;
+      91             : 
+      92           9 :     if ((sock == NULL) || (sock_path == NULL)) {
+      93           0 :         dlt_log(LOG_ERR, "dlt_daemon_unix_socket_open: arguments invalid");
+      94           0 :         return -1;
+      95             :     }
+      96             : 
+      97             : #ifdef DLT_SYSTEM_SOCKET_ACTIVATION_ENABLE
+      98             : 
+      99             :     char **names = NULL;
+     100             :     const int num_fds = sd_listen_fds_with_names(0, &names);
+     101             :     bool sd_socket_open = false;
+     102             :     int i;
+     103             : 
+     104             :     if (num_fds <= 0) {
+     105             :         dlt_vlog(LOG_WARNING, "unix socket: no sockets configured via systemd, error: %s\n", strerror(errno));
+     106             :     } else {
+     107             :         for (i = 0; i < num_fds; ++i) {
+     108             :             if (strcmp(sock_path, names[i]) != 0) {
+     109             :                 continue;
+     110             :             }
+     111             : 
+     112             :             if (sd_is_socket_unix(i + SD_LISTEN_FDS_START, type, 1, names[i], strlen(names[i])) < 0) {
+     113             :                 dlt_vlog(LOG_WARNING,
+     114             :                         "unix socket: socket with matching name is not of correct type or not in listen mode, error: %s\n",
+     115             :                         strerror(errno));
+     116             :                 continue;
+     117             :             }
+     118             : 
+     119             :             *sock = i + SD_LISTEN_FDS_START;
+     120             :             sd_socket_open = true;
+     121             :             dlt_vlog(LOG_INFO, "unix socket: sock_path %s found systemd socket %s\n", sock_path, names[i]);
+     122             :             break;
+     123             :         }
+     124             : 
+     125             :         /*
+     126             :          * The caller [of sd_listen_fds_with_names] needs to free the array
+     127             :          * itself and each of its elements with libc's free() call after use.
+     128             :          * */
+     129             :         for (i = 0; i < num_fds; ++i) {
+     130             :             free(names[i]);
+     131             :         }
+     132             :         free(names);
+     133             :     }
+     134             : 
+     135             :     if (!sd_socket_open) {
+     136             :         dlt_vlog(LOG_INFO, "unix socket: sock_path %s no systemd socket found\n", sock_path);
+     137             : #endif
+     138             : 
+     139           9 :     if ((*sock = socket(AF_UNIX, type, 0)) == -1) {
+     140           0 :         dlt_log(LOG_WARNING, "unix socket: socket() error");
+     141           0 :         return -1;
+     142             :     }
+     143             : 
+     144             :     memset(&addr, 0, sizeof(addr));
+     145           9 :     addr.sun_family = AF_UNIX;
+     146             :     memcpy(addr.sun_path, sock_path, sizeof(addr.sun_path));
+     147             : 
+     148           9 :     if (unlink(sock_path) != 0) {
+     149           8 :         dlt_vlog(LOG_WARNING, "%s: unlink() failed: %s\n",
+     150           8 :                 __func__, strerror(errno));
+     151             :     }
+     152             : 
+     153             :     /* set appropriate access permissions */
+     154           9 :     old_mask = umask(mask);
+     155             : 
+     156           9 :     if (bind(*sock, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
+     157           0 :         dlt_vlog(LOG_WARNING, "%s: bind() error (%s)\n", __func__,
+     158           0 :                  strerror(errno));
+     159           0 :         return -1;
+     160             :     }
+     161             : 
+     162           9 :     if (listen(*sock, 1) == -1) {
+     163           0 :         dlt_vlog(LOG_WARNING, "%s: listen error (%s)\n", __func__,
+     164           0 :                  strerror(errno));
+     165           0 :         return -1;
+     166             :     }
+     167             : 
+     168             :     /* restore permissions */
+     169           9 :     umask(old_mask);
+     170             : 
+     171             : #ifdef DLT_SYSTEM_SOCKET_ACTIVATION_ENABLE
+     172             :     } // end of: if (!sd_socket_open) {
+     173             : #endif
+     174             : 
+     175             : 
+     176           9 :     return 0;
+     177             : }
+     178             : 
+     179           0 : int dlt_daemon_unix_socket_close(int sock)
+     180             : {
+     181           0 :     int ret = close(sock);
+     182             : 
+     183           0 :     if (ret != 0) {
+     184           0 :         dlt_vlog(LOG_WARNING, "unix socket close failed: %s", strerror(errno));
+     185             :     }
+     186             : 
+     187           0 :     return ret;
+     188             : }
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/index-sort-f.html b/dlt_lcov_report/daemon/index-sort-f.html new file mode 100644 index 00000000..a0e266ec --- /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:1699342349.6 %
Date:2024-04-29 13:30:27Functions:11015770.1 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_daemon_serial.c +
0.0%
+
0.0 %0 / 80.0 %0 / 1
dlt_daemon_client.c +
27.4%27.4%
+
27.4 %265 / 96639.4 %13 / 33
dlt_daemon_unix_socket.c +
44.4%44.4%
+
44.4 %12 / 2750.0 %1 / 2
dlt_daemon_common.c +
56.3%56.3%
+
56.3 %351 / 62371.9 %23 / 32
dlt-daemon.c +
52.9%52.9%
+
52.9 %605 / 114373.8 %31 / 42
dlt_daemon_socket.c +
57.6%57.6%
+
57.6 %34 / 5980.0 %4 / 5
dlt_daemon_offline_logstorage.c +
61.7%61.7%
+
61.7 %205 / 33282.6 %19 / 23
dlt_daemon_connection.c +
88.7%88.7%
+
88.7 %102 / 115100.0 %8 / 8
dlt_daemon_event_handler.c +
83.3%83.3%
+
83.3 %125 / 150100.0 %11 / 11
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/index-sort-l.html b/dlt_lcov_report/daemon/index-sort-l.html new file mode 100644 index 00000000..10acd626 --- /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:1699342349.6 %
Date:2024-04-29 13:30:27Functions:11015770.1 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_daemon_serial.c +
0.0%
+
0.0 %0 / 80.0 %0 / 1
dlt_daemon_client.c +
27.4%27.4%
+
27.4 %265 / 96639.4 %13 / 33
dlt_daemon_unix_socket.c +
44.4%44.4%
+
44.4 %12 / 2750.0 %1 / 2
dlt-daemon.c +
52.9%52.9%
+
52.9 %605 / 114373.8 %31 / 42
dlt_daemon_common.c +
56.3%56.3%
+
56.3 %351 / 62371.9 %23 / 32
dlt_daemon_socket.c +
57.6%57.6%
+
57.6 %34 / 5980.0 %4 / 5
dlt_daemon_offline_logstorage.c +
61.7%61.7%
+
61.7 %205 / 33282.6 %19 / 23
dlt_daemon_event_handler.c +
83.3%83.3%
+
83.3 %125 / 150100.0 %11 / 11
dlt_daemon_connection.c +
88.7%88.7%
+
88.7 %102 / 115100.0 %8 / 8
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/daemon/index.html b/dlt_lcov_report/daemon/index.html new file mode 100644 index 00000000..6b7cc56c --- /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:1699342349.6 %
Date:2024-04-29 13:30:27Functions:11015770.1 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt-daemon.c +
52.9%52.9%
+
52.9 %605 / 114373.8 %31 / 42
dlt_daemon_client.c +
27.4%27.4%
+
27.4 %265 / 96639.4 %13 / 33
dlt_daemon_common.c +
56.3%56.3%
+
56.3 %351 / 62371.9 %23 / 32
dlt_daemon_connection.c +
88.7%88.7%
+
88.7 %102 / 115100.0 %8 / 8
dlt_daemon_event_handler.c +
83.3%83.3%
+
83.3 %125 / 150100.0 %11 / 11
dlt_daemon_offline_logstorage.c +
61.7%61.7%
+
61.7 %205 / 33282.6 %19 / 23
dlt_daemon_serial.c +
0.0%
+
0.0 %0 / 80.0 %0 / 1
dlt_daemon_socket.c +
57.6%57.6%
+
57.6 %34 / 5980.0 %4 / 5
dlt_daemon_unix_socket.c +
44.4%44.4%
+
44.4 %12 / 2750.0 %1 / 2
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/dlt_final_coverage.info b/dlt_lcov_report/dlt_final_coverage.info new file mode 100644 index 00000000..9fdb62bc --- /dev/null +++ b/dlt_lcov_report/dlt_final_coverage.info @@ -0,0 +1,12670 @@ +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/console/dlt-control-common.c +FN:102,get_verbosity +FN:107,set_verbosity +FN:112,get_ecuid +FN:117,set_ecuid +FN:144,set_conf +FN:156,get_timeout +FN:161,set_timeout +FN:172,set_send_serial_header +FN:177,set_resync_serial_header +FN:182,dlt_parse_config_param +FN:263,prepare_extra_headers +FN:310,prepare_headers +FN:366,dlt_control_prepare_message +FN:433,dlt_control_init_connection +FN:475,dlt_control_listen_to_daemon +FN:499,dlt_control_callback +FN:549,dlt_control_send_message +FN:618,dlt_control_init +FN:655,dlt_control_deinit +FNDA:2,dlt_control_deinit +FNDA:18,get_verbosity +FNDA:4,get_ecuid +FNDA:0,set_verbosity +FNDA:2,set_ecuid +FNDA:2,dlt_parse_config_param +FNDA:2,set_resync_serial_header +FNDA:2,dlt_control_send_message +FNDA:2,set_timeout +FNDA:2,get_timeout +FNDA:2,set_conf +FNDA:2,dlt_control_callback +FNDA:2,prepare_extra_headers +FNDA:2,dlt_control_listen_to_daemon +FNDA:2,prepare_headers +FNDA:2,set_send_serial_header +FNDA:2,dlt_control_init +FNDA:2,dlt_control_prepare_message +FNDA:2,dlt_control_init_connection +FNF:19 +FNH:18 +DA:102,18 +DA:104,46 +DA:107,0 +DA:109,2 +DA:110,0 +DA:112,4 +DA:114,4 +DA:117,2 +DA:119,2 +DA:121,2 +DA:123,0 +DA:124,0 +DA:126,0 +DA:127,0 +DA:129,0 +DA:132,0 +DA:139,0 +DA:142,2 +DA:144,2 +DA:146,2 +DA:149,2 +DA:152,0 +DA:154,2 +DA:156,2 +DA:158,2 +DA:161,2 +DA:163,2 +DA:165,2 +DA:166,2 +DA:168,0 +DA:170,2 +DA:172,2 +DA:174,2 +DA:175,2 +DA:177,2 +DA:179,2 +DA:180,2 +DA:182,2 +DA:186,2 +DA:187,2 +DA:188,2 +DA:192,2 +DA:193,0 +DA:196,2 +DA:201,2 +DA:203,2 +DA:206,14 +DA:207,12 +DA:208,2 +DA:209,2 +DA:210,2 +DA:212,4 +DA:213,4 +DA:215,2 +DA:219,2 +DA:220,2 +DA:223,2 +DA:226,2 +DA:227,2 +DA:228,2 +DA:229,2 +DA:242,2 +DA:245,0 +DA:248,2 +DA:249,0 +DA:263,2 +DA:267,2 +DA:269,2 +DA:272,2 +DA:274,2 +DA:277,2 +DA:279,2 +DA:282,2 +DA:283,0 +DA:284,0 +DA:288,2 +DA:290,2 +DA:292,2 +DA:295,2 +DA:296,2 +DA:298,2 +DA:310,2 +DA:314,2 +DA:316,2 +DA:319,2 +DA:321,2 +DA:322,0 +DA:323,0 +DA:327,2 +DA:328,2 +DA:330,2 +DA:337,2 +DA:340,2 +DA:345,2 +DA:347,2 +DA:348,0 +DA:349,0 +DA:352,2 +DA:354,2 +DA:366,2 +DA:370,2 +DA:372,2 +DA:373,0 +DA:374,0 +DA:377,2 +DA:379,2 +DA:380,0 +DA:381,0 +DA:384,2 +DA:385,0 +DA:386,0 +DA:387,0 +DA:391,2 +DA:394,2 +DA:396,2 +DA:397,0 +DA:398,0 +DA:399,0 +DA:403,2 +DA:406,2 +DA:407,0 +DA:408,0 +DA:409,0 +DA:413,2 +DA:414,0 +DA:415,0 +DA:416,0 +DA:433,2 +DA:435,2 +DA:437,2 +DA:438,0 +DA:439,0 +DA:442,2 +DA:444,2 +DA:445,0 +DA:446,0 +DA:449,2 +DA:451,2 +DA:453,2 +DA:455,0 +DA:456,0 +DA:457,0 +DA:461,2 +DA:463,2 +DA:475,2 +DA:477,2 +DA:478,2 +DA:479,2 +DA:499,2 +DA:501,2 +DA:504,2 +DA:505,0 +DA:506,0 +DA:510,2 +DA:511,2 +DA:513,0 +DA:515,2 +DA:518,2 +DA:526,2 +DA:527,4 +DA:528,2 +DA:529,2 +DA:530,2 +DA:531,2 +DA:533,2 +DA:549,2 +DA:554,2 +DA:555,0 +DA:556,0 +DA:559,2 +DA:560,0 +DA:561,0 +DA:564,2 +DA:567,2 +DA:569,2 +DA:570,0 +DA:571,0 +DA:574,2 +DA:577,2 +DA:579,2 +DA:581,0 +DA:582,0 +DA:583,0 +DA:586,0 +DA:587,0 +DA:594,2 +DA:595,2 +DA:598,2 +DA:599,2 +DA:604,2 +DA:618,2 +DA:622,2 +DA:623,0 +DA:624,0 +DA:627,2 +DA:628,2 +DA:631,2 +DA:632,0 +DA:633,0 +DA:634,0 +DA:638,2 +DA:642,0 +DA:643,0 +DA:655,2 +DA:661,2 +DA:662,2 +DA:663,2 +DA:664,2 +DA:668,2 +DA:669,0 +DA:672,2 +DA:673,0 +DA:678,2 +LF:213 +LH:147 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/console/dlt-convert.c +FN:100,usage +FN:129,empty_dir +FN:182,main +FNDA:0,usage +FNDA:0,empty_dir +FNDA:35,main +FNF:3 +FNH:1 +DA:100,0 +DA:104,0 +DA:127,0 +DA:129,0 +DA:131,0 +DA:134,0 +DA:137,0 +DA:138,0 +DA:139,0 +DA:142,0 +DA:143,0 +DA:144,0 +DA:147,0 +DA:148,0 +DA:149,0 +DA:150,0 +DA:153,0 +DA:155,0 +DA:157,0 +DA:158,0 +DA:159,0 +DA:161,0 +DA:162,0 +DA:163,0 +DA:164,0 +DA:165,0 +DA:167,0 +DA:173,0 +DA:176,0 +DA:182,35 +DA:207,35 +DA:210,35 +DA:213,35 +DA:221,35 +DA:223,70 +DA:224,35 +DA:231,0 +DA:234,0 +DA:236,35 +DA:239,35 +DA:241,0 +DA:244,0 +DA:246,0 +DA:249,0 +DA:251,0 +DA:254,0 +DA:256,0 +DA:259,0 +DA:261,0 +DA:264,0 +DA:266,0 +DA:268,0 +DA:269,0 +DA:271,0 +DA:273,0 +DA:274,0 +DA:276,0 +DA:278,0 +DA:279,0 +DA:281,0 +DA:283,0 +DA:284,0 +DA:286,0 +DA:288,0 +DA:289,0 +DA:291,0 +DA:293,0 +DA:294,0 +DA:295,0 +DA:296,0 +DA:298,0 +DA:301,0 +DA:302,0 +DA:312,35 +DA:315,35 +DA:316,0 +DA:317,0 +DA:318,0 +DA:321,0 +DA:324,35 +DA:327,0 +DA:328,0 +DA:329,0 +DA:330,0 +DA:334,35 +DA:336,0 +DA:337,0 +DA:338,0 +DA:339,0 +DA:340,0 +DA:342,0 +DA:346,0 +DA:347,0 +DA:349,0 +DA:352,0 +DA:356,0 +DA:357,0 +DA:358,0 +DA:359,0 +DA:360,0 +DA:363,0 +DA:364,0 +DA:365,0 +DA:366,0 +DA:371,0 +DA:372,0 +DA:373,0 +DA:374,0 +DA:375,0 +DA:377,0 +DA:381,0 +DA:384,70 +DA:385,35 +DA:388,0 +DA:390,0 +DA:394,35 +DA:395,739 +DA:399,35 +DA:400,35 +DA:405,35 +DA:408,35 +DA:410,35 +DA:411,0 +DA:412,0 +DA:413,0 +DA:415,0 +DA:418,35 +DA:419,0 +DA:420,0 +DA:421,0 +DA:423,0 +DA:426,739 +DA:427,704 +DA:428,0 +DA:430,704 +DA:432,0 +DA:433,0 +DA:435,704 +DA:438,704 +DA:439,0 +DA:443,704 +DA:444,0 +DA:448,0 +DA:450,0 +DA:451,0 +DA:453,0 +DA:456,0 +DA:457,0 +DA:463,704 +DA:464,0 +DA:465,0 +DA:466,0 +DA:467,0 +DA:469,0 +DA:471,0 +DA:473,0 +DA:474,0 +DA:475,0 +DA:480,704 +DA:482,0 +DA:485,0 +DA:488,0 +DA:489,0 +DA:490,0 +DA:502,35 +DA:503,0 +DA:505,0 +DA:506,0 +DA:510,35 +DA:511,0 +DA:513,35 +DA:514,0 +DA:515,0 +DA:516,0 +DA:517,0 +DA:518,0 +DA:520,0 +DA:522,0 +DA:524,35 +DA:526,0 +DA:527,0 +DA:528,0 +DA:531,35 +DA:533,35 +LF:184 +LH:37 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/console/dlt-receive.c +FN:94,signal_handler +FN:144,usage +FN:179,convert_arg_to_byte_size +FN:233,dlt_receive_open_output_file +FN:307,dlt_receive_close_output_file +FN:319,main +FN:640,dlt_receive_message_callback +FNDA:0,usage +FNDA:206,dlt_receive_message_callback +FNDA:1,signal_handler +FNDA:0,convert_arg_to_byte_size +FNDA:0,dlt_receive_close_output_file +FNDA:0,dlt_receive_open_output_file +FNDA:1,main +FNF:7 +FNH:3 +DA:94,1 +DA:96,1 +DA:97,1 +DA:102,1 +DA:103,1 +DA:109,1 +DA:144,0 +DA:148,0 +DA:176,0 +DA:179,0 +DA:186,0 +DA:187,0 +DA:193,0 +DA:199,0 +DA:205,0 +DA:209,0 +DA:218,0 +DA:219,0 +DA:233,0 +DA:238,0 +DA:243,0 +DA:244,0 +DA:246,0 +DA:248,0 +DA:249,0 +DA:259,0 +DA:267,0 +DA:271,0 +DA:273,0 +DA:274,0 +DA:278,0 +DA:280,0 +DA:285,0 +DA:287,0 +DA:290,0 +DA:291,0 +DA:292,0 +DA:293,0 +DA:294,0 +DA:296,0 +DA:300,0 +DA:302,0 +DA:303,0 +DA:307,0 +DA:309,0 +DA:310,0 +DA:311,0 +DA:313,0 +DA:319,1 +DA:327,1 +DA:328,1 +DA:329,1 +DA:330,1 +DA:337,1 +DA:338,1 +DA:339,1 +DA:340,1 +DA:341,1 +DA:342,1 +DA:345,1 +DA:347,2 +DA:348,1 +DA:349,0 +DA:351,0 +DA:352,0 +DA:354,0 +DA:356,0 +DA:357,0 +DA:359,0 +DA:361,0 +DA:362,0 +DA:364,0 +DA:366,0 +DA:367,0 +DA:369,0 +DA:371,0 +DA:372,0 +DA:374,0 +DA:376,0 +DA:377,0 +DA:379,0 +DA:381,0 +DA:382,0 +DA:384,0 +DA:386,0 +DA:387,0 +DA:389,0 +DA:391,0 +DA:392,0 +DA:394,0 +DA:396,0 +DA:397,0 +DA:399,0 +DA:401,0 +DA:402,0 +DA:404,0 +DA:406,0 +DA:407,0 +DA:409,0 +DA:415,0 +DA:417,0 +DA:420,1 +DA:422,1 +DA:423,1 +DA:425,1 +DA:428,1 +DA:430,1 +DA:431,0 +DA:432,0 +DA:435,1 +DA:436,1 +DA:439,0 +DA:441,0 +DA:442,0 +DA:444,0 +DA:446,0 +DA:447,0 +DA:449,0 +DA:451,0 +DA:452,0 +DA:455,0 +DA:457,0 +DA:459,0 +DA:460,0 +DA:462,0 +DA:463,0 +DA:468,0 +DA:470,0 +DA:471,0 +DA:472,0 +DA:473,0 +DA:475,0 +DA:478,0 +DA:479,0 +DA:481,0 +DA:483,0 +DA:489,1 +DA:492,1 +DA:495,1 +DA:496,0 +DA:499,1 +DA:502,1 +DA:503,1 +DA:506,2 +DA:507,1 +DA:508,1 +DA:509,0 +DA:512,1 +DA:513,1 +DA:514,1 +DA:516,1 +DA:518,0 +DA:521,1 +DA:522,1 +DA:524,1 +DA:525,0 +DA:526,0 +DA:530,1 +DA:532,0 +DA:533,0 +DA:534,0 +DA:535,0 +DA:538,1 +DA:539,0 +DA:540,0 +DA:541,0 +DA:546,0 +DA:547,0 +DA:548,0 +DA:549,0 +DA:552,0 +DA:554,0 +DA:555,0 +DA:556,0 +DA:559,0 +DA:563,1 +DA:564,1 +DA:567,1 +DA:570,1 +DA:572,1 +DA:573,0 +DA:574,0 +DA:575,0 +DA:578,0 +DA:595,1 +DA:596,1 +DA:597,0 +DA:599,0 +DA:602,1 +DA:605,1 +DA:606,0 +DA:607,0 +DA:608,0 +DA:612,1 +DA:613,0 +DA:615,1 +DA:618,1 +DA:621,1 +DA:624,1 +DA:628,1 +DA:629,1 +DA:631,1 +DA:633,1 +DA:635,1 +DA:637,1 +DA:640,206 +DA:648,206 +DA:654,206 +DA:655,206 +DA:657,0 +DA:659,206 +DA:660,0 +DA:662,206 +DA:663,0 +DA:665,206 +DA:668,0 +DA:672,0 +DA:676,206 +DA:678,0 +DA:680,206 +DA:683,0 +DA:689,206 +DA:690,206 +DA:691,206 +DA:692,206 +DA:693,206 +DA:695,206 +DA:696,0 +DA:698,0 +DA:701,0 +DA:704,0 +DA:707,0 +DA:711,206 +DA:713,206 +DA:715,206 +DA:717,0 +LF:236 +LH:84 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/console/logstorage/dlt-logstorage-common.c +FN:87,get_handler_type +FN:92,set_handler_type +FN:100,get_default_event_type +FN:105,set_default_event_type +FN:110,get_default_path +FN:115,set_default_path +FN:126,get_logstorage_control +FN:131,dlt_logstorage_get_handler_cb +FN:136,dlt_logstorage_get_handler_fd +FN:145,dlt_logstorage_init_handler +FN:164,dlt_logstorage_deinit_handler +FN:188,dlt_logstorage_check_config_file +FN:233,dlt_logstorage_check_directory_permission +FN:254,prepare_message_body +FN:306,dlt_logstorage_send_event +FNDA:2,set_default_path +FNDA:0,set_handler_type +FNDA:2,prepare_message_body +FNDA:0,dlt_logstorage_check_config_file +FNDA:2,get_default_path +FNDA:4,get_handler_type +FNDA:0,dlt_logstorage_get_handler_fd +FNDA:2,dlt_logstorage_send_event +FNDA:0,get_logstorage_control +FNDA:0,dlt_logstorage_get_handler_cb +FNDA:0,dlt_logstorage_init_handler +FNDA:6,get_default_event_type +FNDA:0,dlt_logstorage_deinit_handler +FNDA:0,dlt_logstorage_check_directory_permission +FNDA:2,set_default_event_type +FNF:15 +FNH:7 +DA:87,4 +DA:89,4 +DA:92,0 +DA:94,0 +DA:98,0 +DA:100,6 +DA:102,6 +DA:105,2 +DA:107,2 +DA:108,2 +DA:110,2 +DA:112,2 +DA:115,2 +DA:119,2 +DA:121,2 +DA:126,0 +DA:128,0 +DA:131,0 +DA:133,0 +DA:136,0 +DA:138,0 +DA:145,0 +DA:147,0 +DA:150,0 +DA:155,0 +DA:164,0 +DA:166,0 +DA:169,0 +DA:174,0 +DA:188,0 +DA:195,0 +DA:196,0 +DA:197,0 +DA:200,0 +DA:202,0 +DA:204,0 +DA:205,0 +DA:206,0 +DA:210,0 +DA:212,0 +DA:214,0 +DA:218,0 +DA:220,0 +DA:221,0 +DA:223,0 +DA:224,0 +DA:233,0 +DA:235,0 +DA:236,0 +DA:237,0 +DA:240,0 +DA:241,0 +DA:254,2 +DA:260,2 +DA:261,0 +DA:262,0 +DA:265,2 +DA:267,2 +DA:269,2 +DA:270,0 +DA:271,0 +DA:274,2 +DA:276,2 +DA:277,0 +DA:278,0 +DA:279,0 +DA:280,0 +DA:283,2 +DA:287,2 +DA:288,2 +DA:292,2 +DA:294,2 +DA:296,2 +DA:306,2 +DA:309,2 +DA:312,2 +DA:313,0 +DA:314,0 +DA:317,2 +DA:319,2 +DA:320,2 +DA:322,2 +LF:82 +LH:32 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/console/logstorage/dlt-logstorage-ctrl.c +FN:90,dlt_logstorage_exit +FN:99,dlt_logstorage_must_exit +FN:110,catch_signal +FN:123,install_signal_handler +FN:153,analyze_response +FN:212,dlt_logstorage_ctrl_add_event +FN:236,dlt_logstorage_ctrl_execute_event_loop +FN:293,dlt_logstorage_ctrl_setup_event_loop +FN:349,dlt_logstorage_ctrl_single_request +FN:391,usage +FN:439,parse_args +FN:540,sd_notify +FN:558,main +FNDA:2,analyze_response +FNDA:0,usage +FNDA:2,dlt_logstorage_ctrl_single_request +FNDA:0,dlt_logstorage_ctrl_add_event +FNDA:2,parse_args +FNDA:0,dlt_logstorage_exit +FNDA:0,dlt_logstorage_ctrl_execute_event_loop +FNDA:0,install_signal_handler +FNDA:2,main +FNDA:0,dlt_logstorage_must_exit +FNDA:0,sd_notify +FNDA:0,catch_signal +FNDA:0,dlt_logstorage_ctrl_setup_event_loop +FNF:13 +FNH:4 +DA:90,0 +DA:92,0 +DA:93,0 +DA:99,0 +DA:101,0 +DA:110,0 +DA:112,0 +DA:113,0 +DA:116,0 +DA:123,0 +DA:125,0 +DA:129,0 +DA:132,0 +DA:134,0 +DA:136,0 +DA:137,0 +DA:140,0 +DA:153,2 +DA:156,2 +DA:157,2 +DA:158,2 +DA:160,2 +DA:182,2 +DA:185,2 +DA:186,0 +DA:190,2 +DA:191,0 +DA:195,2 +DA:196,2 +DA:212,0 +DA:216,0 +DA:217,0 +DA:218,0 +DA:221,0 +DA:223,0 +DA:224,0 +DA:226,0 +DA:236,0 +DA:239,0 +DA:241,0 +DA:243,0 +DA:244,0 +DA:247,0 +DA:248,0 +DA:250,0 +DA:253,0 +DA:256,0 +DA:257,0 +DA:261,0 +DA:262,0 +DA:263,0 +DA:265,0 +DA:268,0 +DA:269,0 +DA:271,0 +DA:274,0 +DA:276,0 +DA:277,0 +DA:279,0 +DA:293,0 +DA:296,0 +DA:303,0 +DA:305,0 +DA:308,0 +DA:310,0 +DA:311,0 +DA:312,0 +DA:315,0 +DA:316,0 +DA:317,0 +DA:320,0 +DA:322,0 +DA:323,0 +DA:324,0 +DA:325,0 +DA:328,0 +DA:331,0 +DA:335,0 +DA:336,0 +DA:339,0 +DA:340,0 +DA:342,0 +DA:349,2 +DA:354,2 +DA:356,0 +DA:357,0 +DA:360,0 +DA:363,0 +DA:364,0 +DA:365,0 +DA:370,2 +DA:372,0 +DA:373,0 +DA:374,0 +DA:377,2 +DA:381,2 +DA:384,2 +DA:386,2 +DA:391,0 +DA:411,0 +DA:414,0 +DA:439,2 +DA:442,2 +DA:444,6 +DA:448,6 +DA:449,4 +DA:450,2 +DA:451,2 +DA:453,2 +DA:454,0 +DA:455,0 +DA:458,2 +DA:459,2 +DA:460,0 +DA:461,0 +DA:462,0 +DA:464,0 +DA:466,0 +DA:467,0 +DA:469,0 +DA:471,0 +DA:472,0 +DA:474,0 +DA:475,0 +DA:476,0 +DA:477,0 +DA:478,0 +DA:479,0 +DA:480,0 +DA:481,0 +DA:482,0 +DA:483,0 +DA:485,0 +DA:487,0 +DA:488,0 +DA:489,0 +DA:492,0 +DA:493,0 +DA:494,0 +DA:495,0 +DA:496,0 +DA:498,0 +DA:499,0 +DA:500,0 +DA:502,2 +DA:503,2 +DA:504,2 +DA:506,0 +DA:507,0 +DA:508,0 +DA:509,0 +DA:510,0 +DA:512,0 +DA:513,0 +DA:515,0 +DA:517,0 +DA:518,0 +DA:519,0 +DA:520,0 +DA:521,0 +DA:526,4 +DA:527,2 +DA:528,0 +DA:529,0 +DA:533,2 +DA:534,0 +DA:540,0 +DA:545,0 +DA:558,2 +DA:562,2 +DA:563,2 +DA:564,2 +DA:567,2 +DA:572,2 +DA:573,2 +DA:575,2 +DA:577,2 +DA:578,0 +DA:581,0 +DA:585,0 +DA:590,0 +DA:591,0 +DA:592,0 +DA:596,0 +DA:597,0 +DA:600,2 +LF:186 +LH:43 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/console/logstorage/dlt-logstorage-list.c +FN:79,print_list +FN:103,logstorage_find_dev_info +FN:135,logstorage_store_dev_info +FN:200,logstorage_delete_dev_info +FNDA:0,logstorage_delete_dev_info +FNDA:0,logstorage_store_dev_info +FNDA:0,logstorage_find_dev_info +FNDA:0,print_list +FNF:4 +FNH:0 +DA:79,0 +DA:81,0 +DA:82,0 +DA:84,0 +DA:85,0 +DA:86,0 +DA:89,0 +DA:91,0 +DA:103,0 +DA:105,0 +DA:107,0 +DA:110,0 +DA:112,0 +DA:113,0 +DA:114,0 +DA:118,0 +DA:135,0 +DA:140,0 +DA:141,0 +DA:142,0 +DA:145,0 +DA:146,0 +DA:147,0 +DA:148,0 +DA:151,0 +DA:153,0 +DA:154,0 +DA:155,0 +DA:158,0 +DA:159,0 +DA:164,0 +DA:166,0 +DA:167,0 +DA:168,0 +DA:170,0 +DA:173,0 +DA:174,0 +DA:177,0 +DA:179,0 +DA:180,0 +DA:182,0 +DA:184,0 +DA:185,0 +DA:187,0 +DA:200,0 +DA:205,0 +DA:207,0 +DA:208,0 +DA:209,0 +DA:210,0 +DA:214,0 +DA:216,0 +DA:217,0 +DA:219,0 +DA:220,0 +DA:222,0 +DA:223,0 +DA:225,0 +DA:226,0 +DA:228,0 +DA:229,0 +DA:231,0 +LF:62 +LH:0 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/daemon/dlt-daemon.c +FN:173,usage +FN:214,option_handling +FN:343,option_file_parser +FN:1029,dlt_mkdir_recursive +FN:1078,dlt_daemon_create_pipes_dir +FN:1121,main +FN:1355,dlt_daemon_local_init_p1 +FN:1416,dlt_daemon_local_init_p2 +FN:1518,dlt_daemon_init_serial +FN:1576,dlt_daemon_init_fifo +FN:1750,dlt_daemon_initialize_control_socket +FN:1797,dlt_daemon_local_connection_init +FN:1913,file_read_everything +FN:1967,file_read_field +FN:2023,dlt_daemon_local_ecu_version_init +FN:2052,dlt_daemon_local_cleanup +FN:2112,dlt_daemon_exit_trigger +FN:2136,dlt_daemon_signal_handler +FN:2185,dlt_daemon_daemonize +FN:2255,dlt_daemon_log_internal +FN:2332,dlt_daemon_check_numeric_setting +FN:2348,dlt_daemon_process_client_connect +FN:2458,dlt_daemon_process_client_messages +FN:2535,dlt_daemon_process_client_messages_serial +FN:2604,dlt_daemon_process_control_connect +FN:2700,dlt_daemon_process_control_messages +FN:2768,dlt_daemon_process_user_message_not_sup +FN:2809,dlt_daemon_process_user_messages +FN:2894,dlt_daemon_process_user_message_overflow +FN:2932,dlt_daemon_send_message_overflow +FN:2952,dlt_daemon_process_user_message_register_application +FN:3070,dlt_daemon_process_user_message_register_context +FN:3278,dlt_daemon_process_user_message_unregister_application +FN:3376,dlt_daemon_process_user_message_unregister_context +FN:3454,dlt_daemon_process_user_message_log +FN:3585,enforce_context_ll_and_ts_keep_message +FN:3610,dlt_daemon_process_user_message_set_app_ll_ts +FN:3686,dlt_daemon_process_user_message_log_mode +FN:3719,dlt_daemon_process_user_message_marker +FN:3749,dlt_daemon_send_ringbuffer_to_client +FN:3838,create_timer_fd +FN:3930,dlt_daemon_close_socket +FNDA:0,file_read_field +FNDA:6,dlt_daemon_process_user_message_unregister_application +FNDA:9,dlt_daemon_local_ecu_version_init +FNDA:0,enforce_context_ll_and_ts_keep_message +FNDA:9,dlt_daemon_exit_trigger +FNDA:0,dlt_daemon_process_user_message_not_sup +FNDA:5,dlt_daemon_close_socket +FNDA:1277,dlt_daemon_process_user_messages +FNDA:9,dlt_daemon_initialize_control_socket +FNDA:5809,dlt_daemon_process_user_message_log +FNDA:0,dlt_daemon_process_user_message_overflow +FNDA:9,main +FNDA:4,dlt_daemon_process_control_messages +FNDA:10,create_timer_fd +FNDA:40,dlt_daemon_log_internal +FNDA:4,dlt_daemon_process_client_connect +FNDA:3,dlt_daemon_check_numeric_setting +FNDA:7,dlt_daemon_process_user_message_register_application +FNDA:0,dlt_daemon_process_client_messages_serial +FNDA:37,dlt_daemon_process_user_message_unregister_context +FNDA:9,dlt_daemon_local_init_p2 +FNDA:2,dlt_daemon_send_ringbuffer_to_client +FNDA:0,file_read_everything +FNDA:0,dlt_daemon_process_user_message_marker +FNDA:38,dlt_daemon_process_user_message_register_context +FNDA:2,dlt_daemon_process_control_connect +FNDA:9,dlt_daemon_init_serial +FNDA:0,dlt_daemon_send_message_overflow +FNDA:0,dlt_daemon_process_user_message_log_mode +FNDA:9,dlt_daemon_local_connection_init +FNDA:0,usage +FNDA:9,dlt_daemon_local_init_p1 +FNDA:9,option_handling +FNDA:7,dlt_daemon_process_client_messages +FNDA:9,dlt_daemon_create_pipes_dir +FNDA:9,dlt_daemon_init_fifo +FNDA:9,dlt_mkdir_recursive +FNDA:9,option_file_parser +FNDA:9,dlt_daemon_signal_handler +FNDA:2,dlt_daemon_daemonize +FNDA:9,dlt_daemon_local_cleanup +FNDA:0,dlt_daemon_process_user_message_set_app_ll_ts +FNF:42 +FNH:31 +DA:173,0 +DA:176,0 +DA:209,0 +DA:214,9 +DA:222,9 +DA:223,0 +DA:224,0 +DA:231,9 +DA:234,9 +DA:241,9 +DA:249,20 +DA:250,11 +DA:251,2 +DA:253,2 +DA:254,2 +DA:256,8 +DA:258,8 +DA:269,0 +DA:271,0 +DA:272,0 +DA:283,1 +DA:285,1 +DA:287,1 +DA:288,0 +DA:289,0 +DA:294,0 +DA:296,0 +DA:297,0 +DA:299,0 +DA:301,0 +DA:306,0 +DA:307,0 +DA:308,0 +DA:310,0 +DA:313,0 +DA:314,0 +DA:316,0 +DA:318,0 +DA:319,0 +DA:326,9 +DA:328,9 +DA:336,9 +DA:343,9 +DA:344,9 +DA:346,9 +DA:347,9 +DA:348,9 +DA:354,9 +DA:355,9 +DA:356,9 +DA:357,9 +DA:358,9 +DA:359,9 +DA:360,9 +DA:361,9 +DA:368,9 +DA:373,9 +DA:374,0 +DA:377,9 +DA:378,9 +DA:379,9 +DA:381,9 +DA:382,9 +DA:383,9 +DA:384,9 +DA:385,9 +DA:386,9 +DA:387,9 +DA:388,9 +DA:389,9 +DA:390,9 +DA:391,9 +DA:392,9 +DA:393,9 +DA:394,9 +DA:395,9 +DA:396,9 +DA:397,9 +DA:398,9 +DA:400,9 +DA:411,9 +DA:413,9 +DA:414,9 +DA:417,9 +DA:418,9 +DA:419,9 +DA:420,9 +DA:426,9 +DA:427,9 +DA:430,9 +DA:431,8 +DA:436,9 +DA:438,9 +DA:441,112 +DA:442,49 +DA:443,49 +DA:444,49 +DA:446,92 +DA:447,86 +DA:450,86 +DA:451,43 +DA:452,43 +DA:455,43 +DA:456,43 +DA:457,43 +DA:460,43 +DA:463,49 +DA:465,43 +DA:466,0 +DA:469,43 +DA:471,0 +DA:474,43 +DA:476,0 +DA:479,43 +DA:481,0 +DA:484,43 +DA:486,0 +DA:489,43 +DA:491,1 +DA:494,42 +DA:496,0 +DA:499,42 +DA:501,0 +DA:504,42 +DA:506,0 +DA:509,42 +DA:511,0 +DA:514,42 +DA:516,0 +DA:517,0 +DA:520,42 +DA:522,0 +DA:523,0 +DA:526,42 +DA:528,1 +DA:529,1 +DA:532,41 +DA:534,0 +DA:535,0 +DA:538,41 +DA:540,1 +DA:543,40 +DA:545,1 +DA:548,39 +DA:553,1 +DA:556,38 +DA:558,0 +DA:560,38 +DA:562,0 +DA:564,38 +DA:566,0 +DA:568,38 +DA:570,1 +DA:573,37 +DA:575,1 +DA:579,36 +DA:581,1 +DA:585,35 +DA:587,1 +DA:591,34 +DA:593,1 +DA:596,33 +DA:598,0 +DA:601,0 +DA:604,33 +DA:606,0 +DA:609,33 +DA:611,0 +DA:614,33 +DA:616,0 +DA:619,33 +DA:621,0 +DA:624,33 +DA:629,0 +DA:632,33 +DA:636,0 +DA:639,33 +DA:641,0 +DA:644,33 +DA:646,6 +DA:648,27 +DA:650,6 +DA:654,21 +DA:657,6 +DA:658,6 +DA:660,15 +DA:663,0 +DA:664,0 +DA:666,15 +DA:668,0 +DA:669,0 +DA:670,15 +DA:671,6 +DA:673,9 +DA:675,0 +DA:676,0 +DA:677,0 +DA:680,9 +DA:691,2 +DA:693,1 +DA:696,1 +DA:707,0 +DA:711,0 +DA:712,0 +DA:716,0 +DA:723,0 +DA:727,0 +DA:728,0 +DA:732,0 +DA:739,0 +DA:743,0 +DA:744,0 +DA:748,0 +DA:755,0 +DA:757,0 +DA:764,0 +DA:767,0 +DA:797,0 +DA:802,0 +DA:804,0 +DA:805,0 +DA:807,0 +DA:808,0 +DA:809,0 +DA:810,0 +DA:813,0 +DA:816,0 +DA:819,0 +DA:821,0 +DA:822,0 +DA:824,0 +DA:825,0 +DA:826,0 +DA:827,0 +DA:830,0 +DA:833,0 +DA:835,0 +DA:840,0 +DA:843,0 +DA:844,0 +DA:847,0 +DA:856,7 +DA:859,2 +DA:1029,9 +DA:1038,9 +DA:1040,9 +DA:1041,0 +DA:1043,9 +DA:1045,36 +DA:1046,27 +DA:1047,0 +DA:1049,0 +DA:1050,0 +DA:1058,0 +DA:1063,9 +DA:1064,9 +DA:1071,9 +DA:1074,9 +DA:1078,9 +DA:1082,9 +DA:1083,0 +DA:1084,0 +DA:1088,9 +DA:1091,9 +DA:1092,0 +DA:1097,0 +DA:1101,9 +DA:1105,9 +DA:1106,0 +DA:1109,0 +DA:1111,0 +DA:1121,9 +DA:1133,9 +DA:1134,0 +DA:1135,0 +DA:1137,0 +DA:1141,9 +DA:1142,0 +DA:1143,0 +DA:1145,0 +DA:1149,9 +DA:1150,9 +DA:1152,9 +DA:1153,9 +DA:1157,9 +DA:1158,0 +DA:1175,9 +DA:1177,9 +DA:1179,9 +DA:1184,9 +DA:1185,0 +DA:1186,0 +DA:1198,9 +DA:1199,0 +DA:1200,0 +DA:1205,9 +DA:1207,0 +DA:1208,0 +DA:1212,9 +DA:1213,0 +DA:1214,0 +DA:1219,9 +DA:1220,0 +DA:1221,0 +DA:1228,9 +DA:1231,9 +DA:1232,0 +DA:1233,0 +DA:1247,9 +DA:1248,6 +DA:1253,0 +DA:1276,9 +DA:1279,9 +DA:1280,9 +DA:1281,0 +DA:1284,9 +DA:1285,1 +DA:1286,0 +DA:1287,0 +DA:1291,1 +DA:1300,9 +DA:1301,0 +DA:1303,9 +DA:1305,9 +DA:1314,9 +DA:1315,0 +DA:1316,0 +DA:1318,0 +DA:1320,9 +DA:1326,1323 +DA:1327,1314 +DA:1331,9 +DA:1333,9 +DA:1335,9 +DA:1337,9 +DA:1343,9 +DA:1345,9 +DA:1347,9 +DA:1349,9 +DA:1351,9 +DA:1355,9 +DA:1357,9 +DA:1360,9 +DA:1361,0 +DA:1362,0 +DA:1384,9 +DA:1390,9 +DA:1391,2 +DA:1394,9 +DA:1396,9 +DA:1397,0 +DA:1399,0 +DA:1400,0 +DA:1403,9 +DA:1405,9 +DA:1406,9 +DA:1407,9 +DA:1408,9 +DA:1413,9 +DA:1416,9 +DA:1418,9 +DA:1420,9 +DA:1421,0 +DA:1422,0 +DA:1426,9 +DA:1427,9 +DA:1431,0 +DA:1432,0 +DA:1436,9 +DA:1437,0 +DA:1438,0 +DA:1439,0 +DA:1442,0 +DA:1446,0 +DA:1447,0 +DA:1452,9 +DA:1453,6 +DA:1455,6 +DA:1456,0 +DA:1457,0 +DA:1464,9 +DA:1465,1 +DA:1467,8 +DA:1470,9 +DA:1491,9 +DA:1492,0 +DA:1493,0 +DA:1497,9 +DA:1498,0 +DA:1501,9 +DA:1502,9 +DA:1504,9 +DA:1505,0 +DA:1506,0 +DA:1509,9 +DA:1513,9 +DA:1515,9 +DA:1518,9 +DA:1524,9 +DA:1527,0 +DA:1529,0 +DA:1530,0 +DA:1533,0 +DA:1534,0 +DA:1537,0 +DA:1540,0 +DA:1541,0 +DA:1543,0 +DA:1545,0 +DA:1546,0 +DA:1547,0 +DA:1549,0 +DA:1550,0 +DA:1552,0 +DA:1555,0 +DA:1556,0 +DA:1559,0 +DA:1560,0 +DA:1563,0 +DA:1564,0 +DA:1565,0 +DA:1568,0 +DA:1576,9 +DA:1583,9 +DA:1586,9 +DA:1587,9 +DA:1589,9 +DA:1591,9 +DA:1592,0 +DA:1593,0 +DA:1594,0 +DA:1598,9 +DA:1599,0 +DA:1600,0 +DA:1602,0 +DA:1603,0 +DA:1605,0 +DA:1606,0 +DA:1610,0 +DA:1612,0 +DA:1617,0 +DA:1625,9 +DA:1626,0 +DA:1627,0 +DA:1628,0 +DA:1635,9 +DA:1637,0 +DA:1638,0 +DA:1642,9 +DA:1643,0 +DA:1645,9 +DA:1652,9 +DA:1750,9 +DA:1755,9 +DA:1757,9 +DA:1758,0 +DA:1759,0 +DA:1778,9 +DA:1779,9 +DA:1783,9 +DA:1784,9 +DA:1789,0 +DA:1797,9 +DA:1801,9 +DA:1803,9 +DA:1805,9 +DA:1806,0 +DA:1807,0 +DA:1810,9 +DA:1821,9 +DA:1822,0 +DA:1823,0 +DA:1836,9 +DA:1838,9 +DA:1840,9 +DA:1841,9 +DA:1846,0 +DA:1847,0 +DA:1851,0 +DA:1852,0 +DA:1857,0 +DA:1859,0 +DA:1860,0 +DA:1865,0 +DA:1871,0 +DA:1874,0 +DA:1877,0 +DA:1878,0 +DA:1879,0 +DA:1899,9 +DA:1900,0 +DA:1901,0 +DA:1905,9 +DA:1906,0 +DA:1907,0 +DA:1913,0 +DA:1915,0 +DA:1920,0 +DA:1921,0 +DA:1922,0 +DA:1923,0 +DA:1924,0 +DA:1925,0 +DA:1929,0 +DA:1930,0 +DA:1931,0 +DA:1932,0 +DA:1933,0 +DA:1936,0 +DA:1937,0 +DA:1938,0 +DA:1939,0 +DA:1940,0 +DA:1944,0 +DA:1945,0 +DA:1947,0 +DA:1948,0 +DA:1949,0 +DA:1950,0 +DA:1951,0 +DA:1954,0 +DA:1955,0 +DA:1956,0 +DA:1957,0 +DA:1958,0 +DA:1962,0 +DA:1964,0 +DA:1967,0 +DA:1969,0 +DA:1974,0 +DA:1978,0 +DA:1979,0 +DA:1983,0 +DA:1991,0 +DA:1992,0 +DA:1993,0 +DA:1997,0 +DA:1998,0 +DA:1999,0 +DA:2005,0 +DA:2008,0 +DA:2009,0 +DA:2013,0 +DA:2014,0 +DA:2018,0 +DA:2020,0 +DA:2023,9 +DA:2027,9 +DA:2030,9 +DA:2033,9 +DA:2035,9 +DA:2037,9 +DA:2038,9 +DA:2041,0 +DA:2042,0 +DA:2044,0 +DA:2047,0 +DA:2049,0 +DA:2052,9 +DA:2054,9 +DA:2056,9 +DA:2057,0 +DA:2058,0 +DA:2062,9 +DA:2064,9 +DA:2067,9 +DA:2068,0 +DA:2071,9 +DA:2075,9 +DA:2091,9 +DA:2093,6 +DA:2097,6 +DA:2100,9 +DA:2101,9 +DA:2103,9 +DA:2104,1 +DA:2105,1 +DA:2109,9 +DA:2112,9 +DA:2115,9 +DA:2118,9 +DA:2121,9 +DA:2122,9 +DA:2123,0 +DA:2127,9 +DA:2134,9 +DA:2136,9 +DA:2138,9 +DA:2140,9 +DA:2141,9 +DA:2147,9 +DA:2149,9 +DA:2150,9 +DA:2159,9 +DA:2185,2 +DA:2190,2 +DA:2192,2 +DA:2195,2 +DA:2197,4 +DA:2198,0 +DA:2199,0 +DA:2202,4 +DA:2203,2 +DA:2210,2 +DA:2211,0 +DA:2212,0 +DA:2218,2 +DA:2220,2 +DA:2221,0 +DA:2224,2 +DA:2225,0 +DA:2227,2 +DA:2230,0 +DA:2231,0 +DA:2235,2 +DA:2238,2 +DA:2239,0 +DA:2242,2 +DA:2243,2 +DA:2244,2 +DA:2245,2 +DA:2247,2 +DA:2255,40 +DA:2257,40 +DA:2264,40 +DA:2267,40 +DA:2268,40 +DA:2271,40 +DA:2272,40 +DA:2274,40 +DA:2278,40 +DA:2283,40 +DA:2284,40 +DA:2285,40 +DA:2288,40 +DA:2289,40 +DA:2290,40 +DA:2291,40 +DA:2293,40 +DA:2294,40 +DA:2295,40 +DA:2298,40 +DA:2299,40 +DA:2300,40 +DA:2302,40 +DA:2303,40 +DA:2305,40 +DA:2306,0 +DA:2307,0 +DA:2312,40 +DA:2313,40 +DA:2314,40 +DA:2315,40 +DA:2316,40 +DA:2319,40 +DA:2321,40 +DA:2324,40 +DA:2325,40 +DA:2327,40 +DA:2329,40 +DA:2332,3 +DA:2335,3 +DA:2336,3 +DA:2337,3 +DA:2338,3 +DA:2339,3 +DA:2340,0 +DA:2343,0 +DA:2348,4 +DA:2357,4 +DA:2359,4 +DA:2361,4 +DA:2362,0 +DA:2365,0 +DA:2369,4 +DA:2371,4 +DA:2372,0 +DA:2374,0 +DA:2375,0 +DA:2381,4 +DA:2382,4 +DA:2386,4 +DA:2387,4 +DA:2389,4 +DA:2394,0 +DA:2396,4 +DA:2401,0 +DA:2402,0 +DA:2403,0 +DA:2407,4 +DA:2415,4 +DA:2417,0 +DA:2422,0 +DA:2423,0 +DA:2429,4 +DA:2433,4 +DA:2435,4 +DA:2437,4 +DA:2438,2 +DA:2439,0 +DA:2441,2 +DA:2443,2 +DA:2444,0 +DA:2445,0 +DA:2447,0 +DA:2451,2 +DA:2452,2 +DA:2458,7 +DA:2466,7 +DA:2468,7 +DA:2469,0 +DA:2472,0 +DA:2475,7 +DA:2477,7 +DA:2478,0 +DA:2482,0 +DA:2486,17 +DA:2487,17 +DA:2488,17 +DA:2490,17 +DA:2492,10 +DA:2493,10 +DA:2494,10 +DA:2500,10 +DA:2501,10 +DA:2504,10 +DA:2507,10 +DA:2508,0 +DA:2510,10 +DA:2511,0 +DA:2513,0 +DA:2517,7 +DA:2518,0 +DA:2520,0 +DA:2523,7 +DA:2527,2 +DA:2535,0 +DA:2542,0 +DA:2544,0 +DA:2545,0 +DA:2548,0 +DA:2551,0 +DA:2552,0 +DA:2555,0 +DA:2559,0 +DA:2560,0 +DA:2561,0 +DA:2563,0 +DA:2565,0 +DA:2566,0 +DA:2572,0 +DA:2573,0 +DA:2577,0 +DA:2578,0 +DA:2581,0 +DA:2584,0 +DA:2585,0 +DA:2587,0 +DA:2588,0 +DA:2590,0 +DA:2594,0 +DA:2595,0 +DA:2598,0 +DA:2604,2 +DA:2614,2 +DA:2616,2 +DA:2617,0 +DA:2620,0 +DA:2624,2 +DA:2626,2 +DA:2627,0 +DA:2628,0 +DA:2634,2 +DA:2635,2 +DA:2637,2 +DA:2642,0 +DA:2644,0 +DA:2647,2 +DA:2648,0 +DA:2700,4 +DA:2708,4 +DA:2710,4 +DA:2711,0 +DA:2714,0 +DA:2717,4 +DA:2718,2 +DA:2725,2 +DA:2729,4 +DA:2731,4 +DA:2732,4 +DA:2734,4 +DA:2736,2 +DA:2737,2 +DA:2738,2 +DA:2743,2 +DA:2744,2 +DA:2747,2 +DA:2750,2 +DA:2751,0 +DA:2753,2 +DA:2754,0 +DA:2756,0 +DA:2760,2 +DA:2761,0 +DA:2762,0 +DA:2768,0 +DA:2773,0 +DA:2777,0 +DA:2779,0 +DA:2783,0 +DA:2784,0 +DA:2787,0 +DA:2809,1277 +DA:2820,1277 +DA:2822,1277 +DA:2823,0 +DA:2826,0 +DA:2829,1277 +DA:2831,1277 +DA:2832,0 +DA:2836,0 +DA:2838,1277 +DA:2839,0 +DA:2841,0 +DA:2845,7174 +DA:2849,5897 +DA:2851,5897 +DA:2852,0 +DA:2854,0 +DA:2855,0 +DA:2859,5897 +DA:2863,5897 +DA:2864,0 +DA:2865,0 +DA:2867,0 +DA:2871,5897 +DA:2874,5897 +DA:2876,5897 +DA:2884,1277 +DA:2885,0 +DA:2888,0 +DA:2894,0 +DA:2902,0 +DA:2904,0 +DA:2905,0 +DA:2907,0 +DA:2910,0 +DA:2919,0 +DA:2927,0 +DA:2932,0 +DA:2935,0 +DA:2937,0 +DA:2938,0 +DA:2939,0 +DA:2943,0 +DA:2944,0 +DA:2947,0 +DA:2952,7 +DA:2962,7 +DA:2967,7 +DA:2969,7 +DA:2970,0 +DA:2972,0 +DA:2976,7 +DA:2982,7 +DA:2987,7 +DA:2991,7 +DA:2994,7 +DA:2996,7 +DA:2998,0 +DA:3002,7 +DA:3004,7 +DA:3005,0 +DA:3016,7 +DA:3018,7 +DA:3021,7 +DA:3022,0 +DA:3023,0 +DA:3026,7 +DA:3028,7 +DA:3029,0 +DA:3031,7 +DA:3032,0 +DA:3034,7 +DA:3043,7 +DA:3045,7 +DA:3046,0 +DA:3048,0 +DA:3050,7 +DA:3052,7 +DA:3054,7 +DA:3057,7 +DA:3060,7 +DA:3064,7 +DA:3070,38 +DA:3078,38 +DA:3086,38 +DA:3088,38 +DA:3089,0 +DA:3091,0 +DA:3095,38 +DA:3100,38 +DA:3105,38 +DA:3109,38 +DA:3112,38 +DA:3114,38 +DA:3115,0 +DA:3120,38 +DA:3122,38 +DA:3123,0 +DA:3134,38 +DA:3136,38 +DA:3139,38 +DA:3140,0 +DA:3141,0 +DA:3144,38 +DA:3146,38 +DA:3149,38 +DA:3150,0 +DA:3156,0 +DA:3160,38 +DA:3161,38 +DA:3164,0 +DA:3171,38 +DA:3172,38 +DA:3175,0 +DA:3181,38 +DA:3184,38 +DA:3185,38 +DA:3192,38 +DA:3193,0 +DA:3196,0 +DA:3199,38 +DA:3201,38 +DA:3204,38 +DA:3205,38 +DA:3208,38 +DA:3209,0 +DA:3211,38 +DA:3214,38 +DA:3216,33 +DA:3217,33 +DA:3218,33 +DA:3222,5 +DA:3225,38 +DA:3227,0 +DA:3228,0 +DA:3229,0 +DA:3232,0 +DA:3234,0 +DA:3235,0 +DA:3236,0 +DA:3239,0 +DA:3240,0 +DA:3241,0 +DA:3244,0 +DA:3245,0 +DA:3246,0 +DA:3251,0 +DA:3252,0 +DA:3253,0 +DA:3254,0 +DA:3255,0 +DA:3257,0 +DA:3259,0 +DA:3262,38 +DA:3263,38 +DA:3265,38 +DA:3266,0 +DA:3270,0 +DA:3278,6 +DA:3290,6 +DA:3292,6 +DA:3293,0 +DA:3296,0 +DA:3299,6 +DA:3306,6 +DA:3308,6 +DA:3311,6 +DA:3315,6 +DA:3320,6 +DA:3324,6 +DA:3325,0 +DA:3327,6 +DA:3328,0 +DA:3330,0 +DA:3332,0 +DA:3336,0 +DA:3338,0 +DA:3339,0 +DA:3341,0 +DA:3347,6 +DA:3351,0 +DA:3353,0 +DA:3355,0 +DA:3358,6 +DA:3364,6 +DA:3368,6 +DA:3376,37 +DA:3385,37 +DA:3387,37 +DA:3388,0 +DA:3392,0 +DA:3395,37 +DA:3402,37 +DA:3405,37 +DA:3412,37 +DA:3414,37 +DA:3415,0 +DA:3420,0 +DA:3423,37 +DA:3431,37 +DA:3432,0 +DA:3437,37 +DA:3442,37 +DA:3443,0 +DA:3454,5809 +DA:3462,5809 +DA:3464,5809 +DA:3465,0 +DA:3466,0 +DA:3520,5809 +DA:3521,5809 +DA:3522,5809 +DA:3526,5809 +DA:3527,0 +DA:3535,0 +DA:3537,0 +DA:3545,0 +DA:3548,0 +DA:3557,0 +DA:3564,0 +DA:3565,5809 +DA:3568,5809 +DA:3569,5809 +DA:3572,5809 +DA:3575,5809 +DA:3576,0 +DA:3577,0 +DA:3585,0 +DA:3591,5809 +DA:3592,0 +DA:3596,0 +DA:3607,0 +DA:3610,0 +DA:3623,0 +DA:3625,0 +DA:3626,0 +DA:3629,0 +DA:3632,0 +DA:3634,0 +DA:3639,0 +DA:3646,0 +DA:3648,0 +DA:3653,0 +DA:3657,0 +DA:3658,0 +DA:3660,0 +DA:3661,0 +DA:3663,0 +DA:3664,0 +DA:3665,0 +DA:3667,0 +DA:3668,0 +DA:3671,0 +DA:3672,0 +DA:3675,0 +DA:3676,0 +DA:3686,0 +DA:3694,0 +DA:3696,0 +DA:3697,0 +DA:3698,0 +DA:3703,0 +DA:3711,0 +DA:3714,0 +DA:3716,0 +DA:3719,0 +DA:3726,0 +DA:3728,0 +DA:3729,0 +DA:3731,0 +DA:3736,0 +DA:3744,0 +DA:3746,0 +DA:3749,2 +DA:3758,2 +DA:3760,2 +DA:3761,0 +DA:3762,0 +DA:3765,2 +DA:3766,0 +DA:3767,0 +DA:3770,4 +DA:3775,4 +DA:3776,4 +DA:3778,0 +DA:3780,4 +DA:3782,4 +DA:3783,0 +DA:3785,4 +DA:3786,2 +DA:3787,2 +DA:3838,10 +DA:3846,10 +DA:3847,0 +DA:3848,0 +DA:3851,10 +DA:3853,10 +DA:3854,0 +DA:3855,0 +DA:3858,10 +DA:3860,0 +DA:3866,10 +DA:3868,10 +DA:3869,0 +DA:3870,0 +DA:3872,10 +DA:3873,10 +DA:3874,10 +DA:3875,10 +DA:3877,10 +DA:3878,0 +DA:3879,0 +DA:3922,10 +DA:3926,10 +DA:3930,5 +DA:3932,5 +DA:3934,5 +DA:3936,5 +DA:3937,0 +DA:3938,0 +DA:3942,5 +DA:3946,5 +DA:3948,3 +DA:3949,3 +DA:3954,3 +DA:3955,3 +DA:3958,5 +DA:3965,5 +DA:3969,5 +DA:3970,5 +DA:3972,5 +LF:1143 +LH:605 +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:5809,dlt_daemon_client_send_message_to_all_client +FNDA:0,dlt_daemon_control_set_default_trace_status +FNDA:0,dlt_daemon_control_message_buffer_overflow +FNDA:0,dlt_daemon_send_log_level +FNDA:5885,dlt_daemon_client_send +FNDA:0,dlt_daemon_control_message_marker +FNDA:0,dlt_daemon_control_set_all_log_level +FNDA:0,dlt_daemon_control_set_default_log_level +FNDA:0,dlt_daemon_control_message_time +FNDA:0,dlt_daemon_process_sixty_s_timer +FNDA:4,dlt_daemon_control_get_log_info +FNDA:214,dlt_daemon_client_send_all_multiple +FNDA:1,dlt_daemon_control_set_log_level +FNDA:11,dlt_daemon_process_one_s_timer +FNDA:12,dlt_daemon_client_process_control +FNDA:1,dlt_daemon_control_get_default_log_level +FNDA:0,dlt_daemon_find_multiple_context_and_send_log_level +FNDA:0,dlt_daemon_control_message_timezone +FNDA:0,dlt_daemon_control_passive_node_connect_status +FNDA:21,dlt_daemon_client_send_control_message +FNDA:0,dlt_daemon_control_set_timing_packets +FNDA:0,dlt_daemon_control_callsw_cinjection +FNDA:0,dlt_daemon_send_trace_status +FNDA:0,dlt_daemon_process_systemd_timer +FNDA:0,dlt_daemon_control_passive_node_connect +FNDA:2,dlt_daemon_control_service_logstorage +FNDA:0,dlt_daemon_control_set_all_trace_status +FNDA:4,dlt_daemon_control_get_software_version +FNDA:9,dlt_daemon_control_message_connection_info +FNDA:0,dlt_daemon_find_multiple_context_and_send_trace_status +FNDA:0,dlt_daemon_control_message_unregister_context +FNDA:3,dlt_daemon_control_service_response +FNDA:0,dlt_daemon_control_set_trace_status +FNF:33 +FNH:13 +DA:80,0 +DA:103,214 +DA:118,214 +DA:120,214 +DA:121,0 +DA:122,0 +DA:125,1286 +DA:127,1072 +DA:128,1072 +DA:130,1072 +DA:131,1072 +DA:132,856 +DA:133,856 +DA:136,216 +DA:143,216 +DA:144,0 +DA:145,0 +DA:151,216 +DA:152,0 +DA:163,5885 +DA:178,5885 +DA:179,0 +DA:180,0 +DA:183,5885 +DA:185,16 +DA:186,0 +DA:187,0 +DA:188,0 +DA:189,0 +DA:190,0 +DA:193,16 +DA:194,16 +DA:195,16 +DA:196,1 +DA:197,1 +DA:201,15 +DA:208,5869 +DA:209,5865 +DA:210,0 +DA:211,0 +DA:215,0 +DA:216,0 +DA:217,0 +DA:227,5865 +DA:228,5839 +DA:239,5869 +DA:254,5869 +DA:256,415 +DA:257,214 +DA:265,214 +DA:273,5869 +DA:274,5865 +DA:276,5454 +DA:278,5454 +DA:279,5454 +DA:280,0 +DA:283,5454 +DA:284,0 +DA:285,0 +DA:286,0 +DA:288,0 +DA:291,415 +DA:292,0 +DA:293,0 +DA:294,0 +DA:295,0 +DA:298,0 +DA:300,0 +DA:304,0 +DA:305,0 +DA:315,5809 +DA:322,5809 +DA:324,5809 +DA:325,0 +DA:326,0 +DA:330,5809 +DA:331,0 +DA:334,0 +DA:337,0 +DA:338,0 +DA:340,0 +DA:344,0 +DA:345,0 +DA:349,5809 +DA:350,5809 +DA:352,0 +DA:355,5809 +DA:356,0 +DA:358,0 +DA:359,0 +DA:363,5809 +DA:364,0 +DA:365,0 +DA:367,0 +DA:368,5809 +DA:369,0 +DA:370,0 +DA:372,0 +DA:373,5809 +DA:374,0 +DA:375,0 +DA:377,0 +DA:381,5809 +DA:382,5809 +DA:384,5809 +DA:385,5809 +DA:389,21 +DA:400,21 +DA:402,21 +DA:406,21 +DA:408,21 +DA:412,21 +DA:413,21 +DA:419,21 +DA:422,21 +DA:426,21 +DA:428,21 +DA:431,21 +DA:432,21 +DA:433,21 +DA:434,21 +DA:436,21 +DA:438,21 +DA:439,21 +DA:441,0 +DA:443,21 +DA:444,21 +DA:446,0 +DA:449,21 +DA:450,21 +DA:452,21 +DA:454,21 +DA:455,0 +DA:456,0 +DA:459,21 +DA:461,21 +DA:462,21 +DA:464,21 +DA:465,21 +DA:466,1 +DA:467,1 +DA:473,12 +DA:482,12 +DA:484,12 +DA:487,12 +DA:490,12 +DA:493,12 +DA:494,0 +DA:495,0 +DA:502,12 +DA:503,12 +DA:505,12 +DA:507,12 +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,4 +DA:674,4 +DA:675,4 +DA:677,0 +DA:679,0 +DA:681,0 +DA:683,2 +DA:685,2 +DA:686,2 +DA:688,0 +DA:690,0 +DA:695,0 +DA:697,0 +DA:699,0 +DA:703,0 +DA:705,0 +DA:707,0 +DA:708,0 +DA:710,0 +DA:712,0 +DA:713,0 +DA:715,0 +DA:717,0 +DA:723,0 +DA:729,0 +DA:735,4 +DA:741,4 +DA:743,4 +DA:744,0 +DA:747,4 +DA:748,0 +DA:754,0 +DA:758,4 +DA:761,4 +DA:763,4 +DA:764,0 +DA:765,0 +DA:768,4 +DA:769,4 +DA:770,4 +DA:773,4 +DA:774,0 +DA:780,0 +DA:784,4 +DA:785,4 +DA:786,4 +DA:787,4 +DA:790,4 +DA:793,4 +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,3 +DA:1290,3 +DA:1292,3 +DA:1293,0 +DA:1296,3 +DA:1300,3 +DA:1302,3 +DA:1303,0 +DA:1304,0 +DA:1307,3 +DA:1308,3 +DA:1309,3 +DA:1312,3 +DA:1316,3 +DA:1317,3 +DA:1320,3 +DA:1323,3 +DA:1326,0 +DA:1337,0 +DA:1339,0 +DA:1343,0 +DA:1347,0 +DA:1349,0 +DA:1350,0 +DA:1351,0 +DA:1354,0 +DA:1355,0 +DA:1356,0 +DA:1359,0 +DA:1363,0 +DA:1364,0 +DA:1365,0 +DA:1366,0 +DA:1367,0 +DA:1370,0 +DA:1371,0 +DA:1372,0 +DA:1376,0 +DA:1378,0 +DA:1381,9 +DA:1391,9 +DA:1393,9 +DA:1397,9 +DA:1401,9 +DA:1403,9 +DA:1404,0 +DA:1405,0 +DA:1408,9 +DA:1409,9 +DA:1410,9 +DA:1413,9 +DA:1417,9 +DA:1418,9 +DA:1419,9 +DA:1420,9 +DA:1423,9 +DA:1424,0 +DA:1425,0 +DA:1429,9 +DA:1431,9 +DA:1434,0 +DA:1439,0 +DA:1441,0 +DA:1445,0 +DA:1449,0 +DA:1451,0 +DA:1452,0 +DA:1453,0 +DA:1456,0 +DA:1457,0 +DA:1458,0 +DA:1461,0 +DA:1465,0 +DA:1466,0 +DA:1468,0 +DA:1470,0 +DA:1471,0 +DA:1473,0 +DA:1475,0 +DA:1478,0 +DA:1479,0 +DA:1480,0 +DA:1484,0 +DA:1486,0 +DA:1489,0 +DA:1494,0 +DA:1496,0 +DA:1500,0 +DA:1504,0 +DA:1506,0 +DA:1507,0 +DA:1508,0 +DA:1511,0 +DA:1512,0 +DA:1513,0 +DA:1516,0 +DA:1520,0 +DA:1521,0 +DA:1524,0 +DA:1525,0 +DA:1526,0 +DA:1530,0 +DA:1532,0 +DA:1535,0 +DA:1554,0 +DA:1556,0 +DA:1557,0 +DA:1559,0 +DA:1562,0 +DA:1563,0 +DA:1566,0 +DA:1567,0 +DA:1568,0 +DA:1572,0 +DA:1577,0 +DA:1578,0 +DA:1582,0 +DA:1583,0 +DA:1584,0 +DA:1588,0 +DA:1589,0 +DA:1593,0 +DA:1596,0 +DA:1599,0 +DA:1601,0 +DA:1602,0 +DA:1606,0 +DA:1607,0 +DA:1608,0 +DA:1611,0 +DA:1613,0 +DA:1614,0 +DA:1615,0 +DA:1618,0 +DA:1620,0 +DA:1621,0 +DA:1622,0 +DA:1625,0 +DA:1626,0 +DA:1632,0 +DA:1636,0 +DA:1637,0 +DA:1639,0 +DA:1640,0 +DA:1643,0 +DA:1646,0 +DA:1649,0 +DA:1655,0 +DA:1660,0 +DA:1667,0 +DA:1672,0 +DA:1673,0 +DA:1675,0 +DA:1676,0 +DA:1677,0 +DA:1680,0 +DA:1681,0 +DA:1682,0 +DA:1684,0 +DA:1686,0 +DA:1695,0 +DA:1699,0 +DA:1703,0 +DA:1704,0 +DA:1705,0 +DA:1708,0 +DA:1710,0 +DA:1713,0 +DA:1714,0 +DA:1716,0 +DA:1717,0 +DA:1718,0 +DA:1720,0 +DA:1722,0 +DA:1724,0 +DA:1725,0 +DA:1726,0 +DA:1729,0 +DA:1734,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,11 +DA:2269,11 +DA:2272,11 +DA:2274,11 +DA:2275,0 +DA:2276,0 +DA:2279,11 +DA:2281,11 +DA:2282,0 +DA:2283,0 +DA:2288,11 +DA:2290,0 +DA:2293,0 +DA:2297,11 +DA:2298,0 +DA:2299,0 +DA:2304,11 +DA:2306,11 +DA:2309,0 +DA:2314,0 +DA:2317,0 +DA:2319,0 +DA:2320,0 +DA:2321,0 +DA:2324,0 +DA:2326,0 +DA:2327,0 +DA:2328,0 +DA:2333,0 +DA:2334,0 +DA:2339,0 +DA:2341,0 +DA:2346,0 +DA:2347,0 +DA:2349,0 +DA:2355,0 +DA:2357,0 +DA:2400,0 +DA:2410,0 +DA:2412,0 +DA:2416,2 +DA:2431,2 +DA:2434,2 +DA:2437,2 +DA:2439,2 +DA:2440,0 +DA:2443,0 +DA:2446,2 +DA:2447,0 +DA:2454,0 +DA:2456,0 +DA:2459,2 +DA:2462,2 +DA:2464,2 +DA:2465,0 +DA:2466,0 +DA:2467,0 +DA:2468,0 +DA:2475,0 +DA:2478,0 +DA:2482,4 +DA:2483,2 +DA:2486,2 +DA:2487,0 +DA:2489,0 +DA:2491,0 +DA:2492,0 +DA:2498,0 +DA:2500,0 +DA:2502,0 +DA:2506,0 +DA:2507,0 +DA:2508,0 +DA:2509,0 +DA:2514,2 +DA:2515,2 +DA:2516,0 +DA:2520,2 +DA:2521,2 +DA:2525,0 +DA:2526,0 +DA:2532,0 +DA:2533,0 +DA:2537,2 +DA:2539,2 +DA:2540,0 +DA:2542,0 +DA:2543,0 +DA:2549,0 +DA:2551,0 +DA:2553,0 +DA:2559,0 +DA:2562,0 +DA:2570,0 +DA:2572,0 +DA:2576,0 +DA:2583,2 +DA:2586,0 +DA:2593,0 +DA:2596,0 +DA:2605,2 +DA:2609,2 +DA:2611,4 +DA:2612,2 +DA:2614,2 +DA:2617,2 +DA:2622,0 +DA:2624,0 +DA:2628,2 +DA:2629,2 +DA:2636,0 +DA:2644,0 +DA:2653,0 +DA:2659,0 +DA:2664,0 +DA:2665,0 +DA:2669,0 +DA:2670,0 +DA:2674,0 +DA:2682,0 +DA:2685,0 +DA:2688,0 +DA:2690,0 +DA:2692,0 +DA:2693,0 +DA:2695,0 +DA:2702,0 +DA:2710,0 +DA:2720,0 +DA:2722,0 +DA:2723,0 +DA:2725,0 +DA:2729,0 +DA:2730,0 +DA:2734,0 +DA:2742,0 +DA:2746,0 +DA:2748,0 +DA:2749,0 +DA:2751,0 +DA:2752,0 +DA:2754,0 +DA:2755,0 +DA:2756,0 +DA:2759,0 +DA:2762,0 +DA:2764,0 +DA:2766,0 +DA:2768,0 +DA:2769,0 +DA:2770,0 +DA:2772,0 +DA:2775,0 +DA:2777,0 +DA:2778,0 +DA:2781,0 +DA:2789,0 +LF:966 +LH:265 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/daemon/dlt_daemon_common.c +FN:95,dlt_daemon_cmp_apid +FN:106,dlt_daemon_cmp_apid_ctid +FN:127,dlt_daemon_find_users_list +FN:233,dlt_daemon_init_runtime_configuration +FN:290,dlt_daemon_init +FN:342,dlt_daemon_free +FN:380,dlt_daemon_init_user_information +FN:426,dlt_daemon_applications_invalidate_fd +FN:452,dlt_daemon_applications_clear +FN:488,dlt_daemon_application_reset_user_handle +FN:515,dlt_daemon_application_add +FN:683,dlt_daemon_application_del +FN:728,dlt_daemon_application_find +FN:762,dlt_daemon_applications_load +FN:854,dlt_daemon_applications_save +FN:903,dlt_daemon_context_add +FN:1122,dlt_daemon_context_del +FN:1175,dlt_daemon_context_find +FN:1212,dlt_daemon_contexts_invalidate_fd +FN:1238,dlt_daemon_contexts_clear +FN:1272,dlt_daemon_contexts_load +FN:1382,dlt_daemon_contexts_save +FN:1436,dlt_daemon_configuration_save +FN:1457,dlt_daemon_configuration_load +FN:1524,dlt_daemon_user_send_log_level +FN:1585,dlt_daemon_user_send_log_state +FN:1614,dlt_daemon_control_reset_to_factory_default +FN:1670,dlt_daemon_user_send_default_update +FN:1704,dlt_daemon_user_send_all_log_level_update +FN:1760,dlt_daemon_user_send_all_trace_status_update +FN:1796,dlt_daemon_user_send_all_log_state +FN:1825,dlt_daemon_change_state +FNDA:0,dlt_daemon_contexts_save +FNDA:0,dlt_daemon_cmp_apid +FNDA:9,dlt_daemon_free +FNDA:0,dlt_daemon_user_send_all_trace_status_update +FNDA:41,dlt_daemon_context_add +FNDA:9,dlt_daemon_configuration_load +FNDA:0,dlt_daemon_configuration_save +FNDA:149,dlt_daemon_application_find +FNDA:18,dlt_daemon_init_user_information +FNDA:10,dlt_daemon_applications_clear +FNDA:15,dlt_daemon_application_reset_user_handle +FNDA:5,dlt_daemon_user_send_all_log_state +FNDA:17,dlt_daemon_init +FNDA:41,dlt_daemon_user_send_log_level +FNDA:15,dlt_daemon_applications_invalidate_fd +FNDA:0,dlt_daemon_control_reset_to_factory_default +FNDA:0,dlt_daemon_contexts_load +FNDA:9,dlt_daemon_applications_load +FNDA:471,dlt_daemon_cmp_apid_ctid +FNDA:0,dlt_daemon_user_send_all_log_level_update +FNDA:9,dlt_daemon_init_runtime_configuration +FNDA:9,dlt_daemon_user_send_log_state +FNDA:6,dlt_daemon_application_del +FNDA:10,dlt_daemon_contexts_clear +FNDA:157,dlt_daemon_context_find +FNDA:474,dlt_daemon_find_users_list +FNDA:0,dlt_daemon_applications_save +FNDA:37,dlt_daemon_context_del +FNDA:16,dlt_daemon_change_state +FNDA:15,dlt_daemon_contexts_invalidate_fd +FNDA:10,dlt_daemon_application_add +FNDA:0,dlt_daemon_user_send_default_update +FNF:32 +FNH:23 +DA:95,0 +DA:97,132 +DA:103,132 +DA:106,471 +DA:108,471 +DA:115,471 +DA:117,471 +DA:119,471 +DA:120,471 +DA:127,474 +DA:131,474 +DA:135,474 +DA:136,0 +DA:137,0 +DA:140,476 +DA:141,444 +DA:142,442 +DA:144,32 +DA:145,32 +DA:233,9 +DA:235,9 +DA:238,9 +DA:242,9 +DA:244,9 +DA:250,9 +DA:251,0 +DA:252,0 +DA:255,9 +DA:256,9 +DA:259,9 +DA:263,9 +DA:264,0 +DA:265,0 +DA:268,9 +DA:269,9 +DA:272,9 +DA:276,9 +DA:277,0 +DA:278,0 +DA:281,9 +DA:282,9 +DA:285,9 +DA:287,9 +DA:290,17 +DA:300,17 +DA:302,17 +DA:305,17 +DA:306,17 +DA:308,17 +DA:309,17 +DA:310,17 +DA:312,17 +DA:314,17 +DA:316,17 +DA:318,17 +DA:320,17 +DA:321,17 +DA:323,17 +DA:326,17 +DA:329,17 +DA:335,17 +DA:339,17 +DA:342,9 +DA:347,9 +DA:349,9 +DA:353,19 +DA:354,10 +DA:356,10 +DA:358,10 +DA:359,10 +DA:363,9 +DA:371,9 +DA:372,9 +DA:375,9 +DA:377,9 +DA:380,18 +DA:388,18 +DA:390,18 +DA:393,18 +DA:395,17 +DA:397,17 +DA:398,0 +DA:399,0 +DA:402,17 +DA:403,17 +DA:406,1 +DA:409,1 +DA:411,1 +DA:412,0 +DA:413,0 +DA:416,1 +DA:417,1 +DA:419,2 +DA:420,1 +DA:426,15 +DA:434,15 +DA:436,15 +DA:439,15 +DA:441,15 +DA:442,26 +DA:443,11 +DA:444,0 +DA:452,10 +DA:457,10 +DA:459,10 +DA:462,10 +DA:464,10 +DA:467,11 +DA:468,1 +DA:475,1 +DA:476,1 +DA:479,10 +DA:480,7 +DA:482,10 +DA:483,10 +DA:485,10 +DA:488,15 +DA:496,15 +DA:499,6 +DA:500,6 +DA:501,6 +DA:502,0 +DA:503,0 +DA:504,0 +DA:508,6 +DA:509,6 +DA:511,6 +DA:512,6 +DA:515,10 +DA:534,10 +DA:537,10 +DA:539,10 +DA:542,10 +DA:543,10 +DA:544,10 +DA:546,10 +DA:553,10 +DA:555,10 +DA:556,10 +DA:558,10 +DA:559,10 +DA:561,0 +DA:562,0 +DA:563,0 +DA:564,0 +DA:567,0 +DA:568,0 +DA:569,0 +DA:570,0 +DA:573,0 +DA:575,0 +DA:576,0 +DA:580,10 +DA:582,10 +DA:583,10 +DA:584,10 +DA:585,10 +DA:586,10 +DA:587,10 +DA:592,0 +DA:595,0 +DA:603,10 +DA:604,0 +DA:605,0 +DA:608,10 +DA:609,10 +DA:611,10 +DA:612,10 +DA:614,0 +DA:615,0 +DA:616,0 +DA:620,10 +DA:621,9 +DA:622,9 +DA:626,10 +DA:646,9 +DA:647,0 +DA:648,0 +DA:656,9 +DA:657,9 +DA:659,9 +DA:660,9 +DA:661,9 +DA:665,10 +DA:666,10 +DA:667,10 +DA:672,10 +DA:683,6 +DA:691,6 +DA:693,6 +DA:696,6 +DA:698,6 +DA:701,6 +DA:702,6 +DA:705,6 +DA:706,6 +DA:707,6 +DA:710,6 +DA:713,6 +DA:714,6 +DA:715,6 +DA:718,6 +DA:722,6 +DA:728,149 +DA:736,149 +DA:738,149 +DA:739,149 +DA:742,149 +DA:744,149 +DA:748,132 +DA:749,132 +DA:750,132 +DA:754,132 +DA:755,132 +DA:756,132 +DA:757,132 +DA:762,9 +DA:770,9 +DA:772,9 +DA:775,9 +DA:777,9 +DA:778,9 +DA:782,9 +DA:784,9 +DA:787,0 +DA:794,0 +DA:797,0 +DA:798,0 +DA:801,0 +DA:802,0 +DA:803,0 +DA:805,0 +DA:807,0 +DA:808,0 +DA:811,0 +DA:814,0 +DA:815,0 +DA:819,0 +DA:821,0 +DA:823,0 +DA:824,0 +DA:825,0 +DA:827,0 +DA:830,0 +DA:835,0 +DA:837,0 +DA:841,0 +DA:842,0 +DA:849,0 +DA:851,0 +DA:854,0 +DA:862,0 +DA:864,0 +DA:869,0 +DA:871,0 +DA:874,0 +DA:875,0 +DA:877,0 +DA:878,0 +DA:879,0 +DA:881,0 +DA:882,0 +DA:891,0 +DA:894,0 +DA:903,41 +DA:920,41 +DA:922,41 +DA:923,41 +DA:926,41 +DA:929,41 +DA:932,41 +DA:934,41 +DA:937,41 +DA:938,10 +DA:940,10 +DA:945,41 +DA:947,41 +DA:951,41 +DA:953,41 +DA:954,41 +DA:956,41 +DA:957,41 +DA:959,0 +DA:960,0 +DA:961,0 +DA:962,0 +DA:965,0 +DA:966,0 +DA:967,0 +DA:968,0 +DA:971,0 +DA:973,0 +DA:974,0 +DA:978,41 +DA:981,41 +DA:982,41 +DA:984,41 +DA:989,41 +DA:990,0 +DA:991,0 +DA:994,41 +DA:995,41 +DA:997,41 +DA:998,41 +DA:1032,41 +DA:1036,0 +DA:1040,0 +DA:1043,0 +DA:1054,41 +DA:1055,0 +DA:1056,41 +DA:1057,41 +DA:1060,41 +DA:1061,41 +DA:1066,41 +DA:1067,0 +DA:1069,41 +DA:1072,41 +DA:1073,41 +DA:1074,41 +DA:1079,41 +DA:1122,37 +DA:1131,37 +DA:1133,37 +DA:1136,37 +DA:1138,37 +DA:1141,37 +DA:1142,37 +DA:1148,37 +DA:1149,37 +DA:1150,37 +DA:1153,37 +DA:1156,37 +DA:1157,37 +DA:1158,37 +DA:1161,37 +DA:1165,37 +DA:1168,37 +DA:1169,37 +DA:1175,157 +DA:1184,157 +DA:1186,157 +DA:1187,157 +DA:1190,157 +DA:1192,157 +DA:1196,112 +DA:1197,112 +DA:1198,112 +DA:1202,112 +DA:1203,112 +DA:1205,112 +DA:1206,112 +DA:1207,112 +DA:1212,15 +DA:1220,15 +DA:1222,15 +DA:1225,15 +DA:1227,15 +DA:1228,39 +DA:1229,24 +DA:1230,0 +DA:1238,10 +DA:1243,10 +DA:1245,10 +DA:1248,10 +DA:1250,10 +DA:1253,11 +DA:1254,1 +DA:1255,1 +DA:1256,1 +DA:1259,10 +DA:1260,7 +DA:1261,7 +DA:1264,11 +DA:1265,1 +DA:1267,10 +DA:1269,10 +DA:1272,0 +DA:1281,0 +DA:1283,0 +DA:1286,0 +DA:1288,0 +DA:1289,0 +DA:1292,0 +DA:1294,0 +DA:1297,0 +DA:1304,0 +DA:1307,0 +DA:1308,0 +DA:1311,0 +DA:1312,0 +DA:1313,0 +DA:1315,0 +DA:1317,0 +DA:1318,0 +DA:1321,0 +DA:1324,0 +DA:1325,0 +DA:1329,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:1346,0 +DA:1347,0 +DA:1349,0 +DA:1353,0 +DA:1356,0 +DA:1357,0 +DA:1361,0 +DA:1363,0 +DA:1366,0 +DA:1367,0 +DA:1377,0 +DA:1379,0 +DA:1382,0 +DA:1390,0 +DA:1392,0 +DA:1395,0 +DA:1397,0 +DA:1403,0 +DA:1404,0 +DA:1406,0 +DA:1407,0 +DA:1408,0 +DA:1409,0 +DA:1411,0 +DA:1412,0 +DA:1413,0 +DA:1414,0 +DA:1415,0 +DA:1418,0 +DA:1419,0 +DA:1420,0 +DA:1423,0 +DA:1426,0 +DA:1436,0 +DA:1440,0 +DA:1442,0 +DA:1445,0 +DA:1447,0 +DA:1449,0 +DA:1451,0 +DA:1457,9 +DA:1459,9 +DA:1468,9 +DA:1470,9 +DA:1472,9 +DA:1475,18 +DA:1476,9 +DA:1477,9 +DA:1478,9 +DA:1480,18 +DA:1481,9 +DA:1484,9 +DA:1486,9 +DA:1490,0 +DA:1491,0 +DA:1494,9 +DA:1497,9 +DA:1499,0 +DA:1500,0 +DA:1501,0 +DA:1505,0 +DA:1515,9 +DA:1518,0 +DA:1524,41 +DA:1531,41 +DA:1533,41 +DA:1534,0 +DA:1535,0 +DA:1538,41 +DA:1539,0 +DA:1540,0 +DA:1543,41 +DA:1544,34 +DA:1545,32 +DA:1548,9 +DA:1549,9 +DA:1551,41 +DA:1552,41 +DA:1554,41 +DA:1556,41 +DA:1557,41 +DA:1558,41 +DA:1559,41 +DA:1560,41 +DA:1565,41 +DA:1566,41 +DA:1570,41 +DA:1571,0 +DA:1573,0 +DA:1575,0 +DA:1576,0 +DA:1577,0 +DA:1578,0 +DA:1582,41 +DA:1585,9 +DA:1591,9 +DA:1593,9 +DA:1596,9 +DA:1599,9 +DA:1602,9 +DA:1606,9 +DA:1607,0 +DA:1608,0 +DA:1611,9 +DA:1614,0 +DA:1624,0 +DA:1626,0 +DA:1627,0 +DA:1628,0 +DA:1631,0 +DA:1632,0 +DA:1633,0 +DA:1637,0 +DA:1639,0 +DA:1641,0 +DA:1642,0 +DA:1643,0 +DA:1644,0 +DA:1648,0 +DA:1650,0 +DA:1652,0 +DA:1653,0 +DA:1654,0 +DA:1655,0 +DA:1659,0 +DA:1660,0 +DA:1661,0 +DA:1667,0 +DA:1670,0 +DA:1676,0 +DA:1678,0 +DA:1679,0 +DA:1680,0 +DA:1683,0 +DA:1685,0 +DA:1688,0 +DA:1689,0 +DA:1691,0 +DA:1692,0 +DA:1693,0 +DA:1694,0 +DA:1695,0 +DA:1698,0 +DA:1704,0 +DA:1714,0 +DA:1716,0 +DA:1719,0 +DA:1721,0 +DA:1724,0 +DA:1725,0 +DA:1727,0 +DA:1728,0 +DA:1729,0 +DA:1731,0 +DA:1742,0 +DA:1743,0 +DA:1747,0 +DA:1750,0 +DA:1752,0 +DA:1753,0 +DA:1754,0 +DA:1760,0 +DA:1766,0 +DA:1768,0 +DA:1771,0 +DA:1773,0 +DA:1776,0 +DA:1778,0 +DA:1779,0 +DA:1781,0 +DA:1782,0 +DA:1783,0 +DA:1785,0 +DA:1786,0 +DA:1788,0 +DA:1789,0 +DA:1790,0 +DA:1796,5 +DA:1802,5 +DA:1804,5 +DA:1805,0 +DA:1806,0 +DA:1809,5 +DA:1811,5 +DA:1814,7 +DA:1815,2 +DA:1817,2 +DA:1818,2 +DA:1819,2 +DA:1820,0 +DA:1825,16 +DA:1827,16 +DA:1828,0 +DA:1829,0 +DA:1830,0 +DA:1831,0 +DA:1832,12 +DA:1833,12 +DA:1834,12 +DA:1835,12 +DA:1836,0 +DA:1837,0 +DA:1838,0 +DA:1839,0 +DA:1840,2 +DA:1841,2 +DA:1842,2 +DA:1843,2 +DA:1844,2 +DA:1845,2 +DA:1846,2 +DA:1847,2 +DA:1849,16 +LF:623 +LH:351 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/daemon/dlt_daemon_connection.c +FN:68,dlt_connection_send +FN:110,dlt_connection_send_multiple +FN:148,dlt_connection_get_next +FN:156,dlt_connection_destroy_receiver +FN:192,dlt_connection_get_receiver +FN:279,dlt_connection_get_callback +FN:344,dlt_connection_destroy +FN:367,dlt_connection_create +FNDA:1308,dlt_connection_get_callback +FNDA:436,dlt_connection_send +FNDA:48,dlt_connection_destroy +FNDA:48,dlt_connection_get_receiver +FNDA:47,dlt_connection_create +FNDA:49,dlt_connection_destroy_receiver +FNDA:219,dlt_connection_send_multiple +FNDA:2,dlt_connection_get_next +FNF:8 +FNH:8 +DA:68,436 +DA:75,436 +DA:76,436 +DA:78,436 +DA:79,1 +DA:81,1 +DA:82,1 +DA:86,434 +DA:87,434 +DA:90,434 +DA:110,219 +DA:119,219 +DA:122,218 +DA:123,1 +DA:127,218 +DA:128,218 +DA:130,218 +DA:131,214 +DA:148,2 +DA:150,3 +DA:151,1 +DA:153,2 +DA:156,49 +DA:158,49 +DA:161,49 +DA:165,9 +DA:166,9 +DA:167,9 +DA:168,9 +DA:169,9 +DA:170,36 +DA:171,36 +DA:172,36 +DA:173,36 +DA:174,36 +DA:192,48 +DA:200,48 +DA:201,25 +DA:208,25 +DA:210,25 +DA:211,25 +DA:214,1 +DA:215,1 +DA:217,1 +DA:218,1 +DA:221,9 +DA:222,9 +DA:226,9 +DA:227,9 +DA:230,0 +DA:234,9 +DA:235,9 +DA:242,10 +DA:251,10 +DA:253,10 +DA:254,10 +DA:257,3 +DA:259,3 +DA:260,3 +DA:265,48 +DA:279,1308 +DA:284,1308 +DA:285,1308 +DA:287,1308 +DA:291,7 +DA:293,7 +DA:294,0 +DA:296,0 +DA:302,1277 +DA:304,1277 +DA:305,11 +DA:307,11 +DA:308,0 +DA:310,0 +DA:316,2 +DA:318,2 +DA:319,4 +DA:321,4 +DA:322,3 +DA:324,3 +DA:325,0 +DA:327,0 +DA:328,0 +DA:332,1308 +DA:344,48 +DA:346,48 +DA:347,48 +DA:348,48 +DA:349,48 +DA:350,48 +DA:367,47 +DA:375,47 +DA:379,47 +DA:387,47 +DA:389,47 +DA:390,0 +DA:391,0 +DA:396,47 +DA:398,47 +DA:399,0 +DA:401,0 +DA:402,0 +DA:406,47 +DA:407,47 +DA:416,47 +DA:417,20 +DA:420,20 +DA:421,1 +DA:422,1 +DA:427,46 +DA:429,46 +DA:431,10 +DA:433,46 +DA:434,46 +DA:439,46 +LF:115 +LH:102 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/daemon/dlt_daemon_event_handler.c +FN:78,dlt_daemon_prepare_event_handling +FN:110,dlt_event_handler_enable_fd +FN:143,dlt_event_handler_disable_fd +FN:183,dlt_daemon_handle_event +FN:288,dlt_event_handler_find_connection +FN:311,dlt_daemon_remove_connection +FN:351,dlt_event_handler_cleanup_connections +FN:376,dlt_daemon_add_connection +FN:401,dlt_connection_check_activate +FN:462,dlt_event_handler_register_connection +FN:503,dlt_event_handler_unregister_connection +FNDA:16,dlt_daemon_prepare_event_handling +FNDA:1316,dlt_daemon_handle_event +FNDA:7,dlt_event_handler_unregister_connection +FNDA:10,dlt_event_handler_cleanup_connections +FNDA:1122,dlt_event_handler_find_connection +FNDA:49,dlt_event_handler_enable_fd +FNDA:6,dlt_daemon_add_connection +FNDA:49,dlt_event_handler_register_connection +FNDA:7,dlt_event_handler_disable_fd +FNDA:47,dlt_daemon_remove_connection +FNDA:57,dlt_connection_check_activate +FNF:11 +FNH:11 +DA:65,293 +DA:66,293 +DA:67,293 +DA:68,7 +DA:78,16 +DA:82,16 +DA:85,15 +DA:87,15 +DA:88,0 +DA:89,0 +DA:92,255 +DA:93,240 +DA:95,15 +DA:96,15 +DA:98,15 +DA:110,49 +DA:112,49 +DA:113,2 +DA:114,2 +DA:115,2 +DA:117,2 +DA:118,0 +DA:120,0 +DA:123,2 +DA:124,2 +DA:126,2 +DA:127,0 +DA:130,49 +DA:131,49 +DA:132,49 +DA:143,7 +DA:147,7 +DA:149,36 +DA:150,29 +DA:152,7 +DA:153,7 +DA:156,29 +DA:157,22 +DA:160,7 +DA:161,0 +DA:162,0 +DA:163,0 +DA:169,7 +DA:183,1316 +DA:191,1316 +DA:194,1315 +DA:196,1315 +DA:200,10 +DA:203,1 +DA:204,0 +DA:206,10 +DA:213,6762 +DA:218,5457 +DA:219,4148 +DA:221,1309 +DA:223,1309 +DA:224,1309 +DA:225,1309 +DA:228,0 +DA:229,0 +DA:233,1309 +DA:236,1 +DA:241,1 +DA:243,0 +DA:247,1 +DA:251,1308 +DA:253,1308 +DA:254,0 +DA:257,0 +DA:261,1308 +DA:265,0 +DA:267,0 +DA:288,1122 +DA:290,2436 +DA:292,4805 +DA:293,4757 +DA:294,1074 +DA:295,2369 +DA:311,47 +DA:314,47 +DA:317,47 +DA:321,70 +DA:323,23 +DA:326,47 +DA:328,0 +DA:329,0 +DA:331,47 +DA:333,41 +DA:336,6 +DA:340,47 +DA:342,47 +DA:351,10 +DA:355,10 +DA:359,50 +DA:361,40 +DA:363,49 +DA:364,39 +DA:366,10 +DA:376,6 +DA:380,50 +DA:382,143 +DA:383,93 +DA:385,50 +DA:386,6 +DA:401,57 +DA:405,57 +DA:406,1 +DA:407,1 +DA:410,56 +DA:411,7 +DA:413,7 +DA:414,7 +DA:416,7 +DA:418,7 +DA:419,0 +DA:421,7 +DA:425,49 +DA:427,49 +DA:428,49 +DA:430,49 +DA:431,49 +DA:434,49 +DA:438,0 +DA:439,0 +DA:440,0 +DA:462,49 +DA:467,49 +DA:468,1 +DA:469,1 +DA:472,4 +DA:474,48 +DA:476,4 +DA:479,48 +DA:481,48 +DA:482,48 +DA:484,48 +DA:503,7 +DA:507,7 +DA:513,2 +DA:515,7 +DA:516,1 +DA:517,1 +DA:520,6 +DA:522,3 +DA:524,3 +DA:525,0 +DA:526,0 +DA:530,6 +DA:533,0 +DA:536,6 +LF:150 +LH:125 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/daemon/dlt_daemon_offline_logstorage.c +FN:43,dlt_logstorage_split_ecuid +FN:71,dlt_logstorage_split_ctid +FN:96,dlt_logstorage_split_apid +FN:121,dlt_logstorage_split_apid_ctid +FN:161,dlt_logstorage_split_ecuid_apid +FN:205,dlt_logstorage_split_multi +FN:263,dlt_logstorage_split_key +FN:309,dlt_daemon_logstorage_update_passive_node_context +FN:371,dlt_daemon_logstorage_send_log_level +FN:433,dlt_daemon_logstorage_reset_log_level +FN:485,dlt_daemon_logstorage_force_reset_level +FN:547,dlt_logstorage_update_all_contexts +FN:618,dlt_logstorage_update_context +FN:691,dlt_logstorage_update_context_loglevel +FN:786,dlt_daemon_logstorage_reset_application_loglevel +FN:873,dlt_daemon_logstorage_update_application_loglevel +FN:946,dlt_daemon_logstorage_get_loglevel +FN:1014,dlt_daemon_logstorage_write +FN:1093,dlt_daemon_logstorage_setup_internal_storage +FN:1133,dlt_daemon_logstorage_set_logstorage_cache_size +FN:1139,dlt_daemon_logstorage_cleanup +FN:1174,dlt_daemon_logstorage_sync_cache +FN:1236,dlt_daemon_logstorage_get_device +FNDA:8,dlt_daemon_logstorage_setup_internal_storage +FNDA:1,dlt_logstorage_split_ecuid_apid +FNDA:34,dlt_logstorage_split_multi +FNDA:37,dlt_logstorage_update_context_loglevel +FNDA:38,dlt_logstorage_update_context +FNDA:0,dlt_daemon_logstorage_update_passive_node_context +FNDA:10,dlt_daemon_logstorage_set_logstorage_cache_size +FNDA:4,dlt_logstorage_update_all_contexts +FNDA:5,dlt_daemon_logstorage_get_device +FNDA:10,dlt_daemon_logstorage_update_application_loglevel +FNDA:2,dlt_daemon_logstorage_send_log_level +FNDA:0,dlt_logstorage_split_ctid +FNDA:35,dlt_daemon_logstorage_get_loglevel +FNDA:5841,dlt_daemon_logstorage_write +FNDA:1,dlt_logstorage_split_apid +FNDA:42,dlt_logstorage_split_key +FNDA:0,dlt_daemon_logstorage_force_reset_level +FNDA:1,dlt_daemon_logstorage_reset_log_level +FNDA:4,dlt_daemon_logstorage_sync_cache +FNDA:8,dlt_daemon_logstorage_cleanup +FNDA:2,dlt_daemon_logstorage_reset_application_loglevel +FNDA:1,dlt_logstorage_split_apid_ctid +FNDA:0,dlt_logstorage_split_ecuid +FNF:23 +FNH:19 +DA:43,0 +DA:49,0 +DA:52,0 +DA:56,0 +DA:71,0 +DA:76,0 +DA:79,0 +DA:82,0 +DA:96,1 +DA:101,1 +DA:104,1 +DA:107,1 +DA:121,1 +DA:128,1 +DA:132,1 +DA:134,1 +DA:139,1 +DA:141,1 +DA:146,1 +DA:161,1 +DA:169,1 +DA:173,1 +DA:175,1 +DA:180,1 +DA:182,1 +DA:189,1 +DA:205,34 +DA:213,34 +DA:216,34 +DA:218,34 +DA:221,34 +DA:223,34 +DA:226,0 +DA:228,0 +DA:235,34 +DA:237,34 +DA:240,34 +DA:242,34 +DA:263,42 +DA:269,42 +DA:272,37 +DA:274,37 +DA:276,37 +DA:280,37 +DA:281,0 +DA:283,37 +DA:284,0 +DA:286,37 +DA:287,1 +DA:289,36 +DA:290,1 +DA:292,35 +DA:293,1 +DA:296,34 +DA:309,0 +DA:317,0 +DA:318,0 +DA:321,0 +DA:323,0 +DA:324,0 +DA:325,0 +DA:326,0 +DA:329,0 +DA:331,0 +DA:332,0 +DA:335,0 +DA:338,0 +DA:339,0 +DA:341,0 +DA:342,0 +DA:344,0 +DA:346,0 +DA:347,0 +DA:351,0 +DA:371,2 +DA:381,2 +DA:382,2 +DA:383,0 +DA:384,0 +DA:387,2 +DA:388,2 +DA:390,2 +DA:393,2 +DA:394,2 +DA:395,0 +DA:396,0 +DA:402,0 +DA:404,0 +DA:406,0 +DA:407,0 +DA:408,0 +DA:409,0 +DA:433,1 +DA:440,1 +DA:441,1 +DA:442,0 +DA:443,0 +DA:447,1 +DA:449,1 +DA:450,1 +DA:451,1 +DA:454,0 +DA:455,0 +DA:459,0 +DA:460,0 +DA:461,0 +DA:485,0 +DA:496,0 +DA:498,0 +DA:499,0 +DA:500,0 +DA:501,0 +DA:504,0 +DA:505,0 +DA:507,0 +DA:511,0 +DA:512,0 +DA:515,0 +DA:518,0 +DA:519,0 +DA:521,0 +DA:523,0 +DA:547,4 +DA:557,4 +DA:559,4 +DA:560,3 +DA:562,1 +DA:563,1 +DA:566,3 +DA:568,3 +DA:571,3 +DA:572,0 +DA:573,0 +DA:574,0 +DA:575,0 +DA:578,0 +DA:580,0 +DA:581,0 +DA:582,0 +DA:584,0 +DA:589,0 +DA:591,0 +DA:618,38 +DA:628,38 +DA:629,37 +DA:630,1 +DA:631,1 +DA:634,37 +DA:636,37 +DA:637,3 +DA:638,2 +DA:645,1 +DA:653,34 +DA:656,0 +DA:665,34 +DA:671,34 +DA:691,37 +DA:698,37 +DA:699,37 +DA:700,37 +DA:702,37 +DA:704,37 +DA:707,36 +DA:708,0 +DA:710,0 +DA:713,36 +DA:714,2 +DA:717,36 +DA:720,0 +DA:727,0 +DA:729,36 +DA:732,1 +DA:739,0 +DA:742,35 +DA:746,0 +DA:753,0 +DA:757,35 +DA:765,34 +DA:786,2 +DA:795,2 +DA:799,2 +DA:801,2 +DA:802,1 +DA:803,2 +DA:806,2 +DA:809,0 +DA:811,0 +DA:812,0 +DA:817,0 +DA:818,0 +DA:820,0 +DA:824,0 +DA:825,0 +DA:833,0 +DA:840,0 +DA:844,0 +DA:845,0 +DA:847,0 +DA:848,0 +DA:850,0 +DA:851,0 +DA:873,10 +DA:880,10 +DA:884,10 +DA:886,10 +DA:888,1 +DA:891,1 +DA:894,9 +DA:896,9 +DA:897,9 +DA:902,9 +DA:903,44 +DA:905,70 +DA:909,35 +DA:910,35 +DA:914,35 +DA:915,35 +DA:917,0 +DA:918,0 +DA:922,35 +DA:928,35 +DA:946,35 +DA:951,35 +DA:958,35 +DA:961,68 +DA:962,34 +DA:964,34 +DA:968,34 +DA:970,34 +DA:971,1 +DA:972,1 +DA:975,66 +DA:977,33 +DA:978,0 +DA:982,33 +DA:983,0 +DA:984,0 +DA:987,33 +DA:988,33 +DA:994,34 +DA:1014,5841 +DA:1027,5841 +DA:1028,5840 +DA:1029,5840 +DA:1030,1 +DA:1033,1 +DA:1038,5840 +DA:1039,5840 +DA:1040,5840 +DA:1041,5840 +DA:1042,5840 +DA:1043,5840 +DA:1045,11680 +DA:1046,5840 +DA:1048,5840 +DA:1049,5840 +DA:1058,0 +DA:1063,0 +DA:1064,0 +DA:1067,5840 +DA:1068,5840 +DA:1072,0 +DA:1093,8 +DA:1100,8 +DA:1102,8 +DA:1107,7 +DA:1109,7 +DA:1110,0 +DA:1111,0 +DA:1115,7 +DA:1120,7 +DA:1122,0 +DA:1125,0 +DA:1133,10 +DA:1136,10 +DA:1137,10 +DA:1139,8 +DA:1145,8 +DA:1147,8 +DA:1150,14 +DA:1152,7 +DA:1155,6 +DA:1156,6 +DA:1157,6 +DA:1158,6 +DA:1159,6 +DA:1160,6 +DA:1161,6 +DA:1162,6 +DA:1163,6 +DA:1164,6 +DA:1166,6 +DA:1174,4 +DA:1182,4 +DA:1184,4 +DA:1187,3 +DA:1188,3 +DA:1193,3 +DA:1197,3 +DA:1198,3 +DA:1199,3 +DA:1200,3 +DA:1201,3 +DA:1202,3 +DA:1203,3 +DA:1204,3 +DA:1205,3 +DA:1206,3 +DA:1208,3 +DA:1209,0 +DA:1214,0 +DA:1215,0 +DA:1217,0 +DA:1218,0 +DA:1219,0 +DA:1220,0 +DA:1221,0 +DA:1222,0 +DA:1223,0 +DA:1224,0 +DA:1225,0 +DA:1226,0 +DA:1228,0 +DA:1236,5 +DA:1246,5 +DA:1248,5 +DA:1251,4 +DA:1253,4 +DA:1254,4 +DA:1259,4 +DA:1261,4 +DA:1262,4 +LF:332 +LH:205 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/daemon/dlt_daemon_serial.c +FN:69,dlt_daemon_serial_send +FNDA:0,dlt_daemon_serial_send +FNF:1 +FNH:0 +DA:69,0 +DA:77,0 +DA:78,0 +DA:85,0 +DA:86,0 +DA:91,0 +DA:92,0 +DA:93,0 +LF:8 +LH:0 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/daemon/dlt_daemon_socket.c +FN:62,dlt_daemon_socket_open +FN:162,dlt_daemon_socket_close +FN:169,dlt_daemon_socket_send +FN:205,dlt_daemon_socket_get_send_qeue_max_size +FN:218,dlt_daemon_socket_sendreliable +FNDA:9,dlt_daemon_socket_open +FNDA:0,dlt_daemon_socket_close +FNDA:16,dlt_daemon_socket_send +FNDA:9,dlt_daemon_socket_get_send_qeue_max_size +FNDA:466,dlt_daemon_socket_sendreliable +FNF:5 +FNH:4 +DA:62,9 +DA:64,9 +DA:71,9 +DA:72,0 +DA:73,0 +DA:75,0 +DA:89,9 +DA:92,9 +DA:93,0 +DA:94,0 +DA:99,0 +DA:106,9 +DA:107,9 +DA:109,9 +DA:110,9 +DA:112,0 +DA:124,0 +DA:125,0 +DA:126,0 +DA:132,0 +DA:135,9 +DA:136,0 +DA:137,0 +DA:138,0 +DA:140,0 +DA:144,9 +DA:147,9 +DA:150,9 +DA:151,0 +DA:152,0 +DA:156,0 +DA:162,0 +DA:164,0 +DA:166,0 +DA:169,16 +DA:179,16 +DA:180,0 +DA:184,0 +DA:190,16 +DA:191,16 +DA:193,16 +DA:198,16 +DA:199,16 +DA:205,9 +DA:207,9 +DA:208,9 +DA:209,9 +DA:210,0 +DA:212,0 +DA:215,9 +DA:218,466 +DA:222,931 +DA:223,466 +DA:225,466 +DA:228,466 +DA:229,1 +DA:230,1 +DA:239,1 +DA:241,465 +LF:59 +LH:34 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/daemon/dlt_daemon_unix_socket.c +FN:87,dlt_daemon_unix_socket_open +FN:179,dlt_daemon_unix_socket_close +FNDA:9,dlt_daemon_unix_socket_open +FNDA:0,dlt_daemon_unix_socket_close +FNF:2 +FNH:1 +DA:87,9 +DA:92,9 +DA:93,0 +DA:94,0 +DA:139,9 +DA:140,0 +DA:141,0 +DA:145,9 +DA:148,9 +DA:149,8 +DA:150,8 +DA:154,9 +DA:156,9 +DA:157,0 +DA:158,0 +DA:159,0 +DA:162,9 +DA:163,0 +DA:164,0 +DA:165,0 +DA:169,9 +DA:176,9 +DA:179,0 +DA:181,0 +DA:183,0 +DA:184,0 +DA:187,0 +LF:27 +LH:12 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/gateway/dlt_gateway.c +FN:57,dlt_gateway_check_ip +FN:98,dlt_gateway_check_port +FN:136,dlt_gateway_check_ecu +FN:159,dlt_gateway_check_connect_trigger +FN:190,dlt_gateway_check_timeout +FN:214,dlt_gateway_check_interval +FN:237,dlt_gateway_check_send_serial +FN:256,dlt_gateway_allocate_control_messages +FN:294,dlt_gateway_check_control_messages +FN:361,dlt_gateway_check_periodic_control_messages +FN:541,dlt_gateway_check_general_param +FN:565,dlt_gateway_check_param +FN:589,dlt_gateway_store_connection +FN:657,dlt_gateway_configure +FN:831,dlt_gateway_init +FN:865,dlt_gateway_deinit +FN:904,dlt_gateway_add_to_event_loop +FN:961,dlt_gateway_establish_connections +FN:1051,dlt_gateway_get_connection_receiver +FN:1080,dlt_gateway_parse_get_log_info +FN:1206,dlt_gateway_parse_get_default_log_level +FN:1255,dlt_gateway_control_service_logstorage +FN:1282,dlt_gateway_process_passive_node_messages +FN:1495,dlt_gateway_process_gateway_timer +FN:1532,dlt_gateway_forward_control_message +FN:1610,dlt_gateway_process_on_demand_request +FN:1678,dlt_gateway_send_control_message +FN:1757,dlt_gateway_get_connection +FNDA:10,dlt_gateway_deinit +FNDA:17,dlt_gateway_allocate_control_messages +FNDA:1,dlt_gateway_control_service_logstorage +FNDA:0,dlt_gateway_check_general_param +FNDA:0,dlt_gateway_forward_control_message +FNDA:6,dlt_gateway_check_control_messages +FNDA:3,dlt_gateway_process_on_demand_request +FNDA:7,dlt_gateway_check_timeout +FNDA:6,dlt_gateway_get_connection_receiver +FNDA:6,dlt_gateway_establish_connections +FNDA:2,dlt_gateway_process_gateway_timer +FNDA:32,dlt_gateway_check_param +FNDA:9,dlt_gateway_check_port +FNDA:6,dlt_gateway_check_send_serial +FNDA:6,dlt_gateway_check_ecu +FNDA:7,dlt_gateway_store_connection +FNDA:3,dlt_gateway_add_to_event_loop +FNDA:0,dlt_gateway_check_interval +FNDA:0,dlt_gateway_get_connection +FNDA:7,dlt_gateway_check_ip +FNDA:7,dlt_gateway_check_connect_trigger +FNDA:0,dlt_gateway_parse_get_default_log_level +FNDA:2,dlt_gateway_check_periodic_control_messages +FNDA:4,dlt_gateway_init +FNDA:12,dlt_gateway_send_control_message +FNDA:5,dlt_gateway_configure +FNDA:3,dlt_gateway_parse_get_log_info +FNDA:5,dlt_gateway_process_passive_node_messages +FNF:28 +FNH:23 +DA:57,7 +DA:59,7 +DA:60,1 +DA:61,1 +DA:67,6 +DA:74,6 +DA:75,6 +DA:77,6 +DA:78,0 +DA:79,0 +DA:85,0 +DA:88,0 +DA:98,9 +DA:103,9 +DA:104,1 +DA:105,1 +DA:108,8 +DA:109,8 +DA:110,8 +DA:111,8 +DA:112,0 +DA:113,0 +DA:117,8 +DA:119,6 +DA:120,6 +DA:123,2 +DA:126,2 +DA:136,6 +DA:139,6 +DA:140,1 +DA:141,1 +DA:144,5 +DA:146,5 +DA:147,0 +DA:159,7 +DA:162,7 +DA:163,1 +DA:164,1 +DA:167,6 +DA:168,5 +DA:170,1 +DA:172,0 +DA:175,1 +DA:176,1 +DA:177,1 +DA:190,7 +DA:193,7 +DA:194,1 +DA:195,1 +DA:198,6 +DA:201,6 +DA:202,5 +DA:214,0 +DA:217,0 +DA:218,0 +DA:219,0 +DA:222,0 +DA:224,0 +DA:225,0 +DA:237,6 +DA:240,6 +DA:241,1 +DA:242,1 +DA:245,5 +DA:247,5 +DA:256,17 +DA:258,17 +DA:259,1 +DA:260,1 +DA:263,16 +DA:264,7 +DA:266,7 +DA:267,0 +DA:269,0 +DA:273,9 +DA:275,9 +DA:276,0 +DA:278,0 +DA:281,9 +DA:294,6 +DA:299,6 +DA:302,6 +DA:303,1 +DA:304,1 +DA:307,5 +DA:311,5 +DA:313,18 +DA:314,13 +DA:315,0 +DA:317,0 +DA:320,13 +DA:321,13 +DA:322,13 +DA:323,13 +DA:324,13 +DA:326,13 +DA:329,13 +DA:330,0 +DA:333,0 +DA:335,13 +DA:338,0 +DA:341,0 +DA:344,13 +DA:348,5 +DA:349,5 +DA:351,5 +DA:361,2 +DA:366,2 +DA:369,2 +DA:370,1 +DA:371,1 +DA:374,1 +DA:378,1 +DA:381,1 +DA:383,3 +DA:385,2 +DA:388,2 +DA:390,2 +DA:391,2 +DA:394,2 +DA:397,3 +DA:398,1 +DA:399,0 +DA:400,0 +DA:402,0 +DA:403,0 +DA:411,1 +DA:415,2 +DA:417,2 +DA:420,2 +DA:421,1 +DA:424,0 +DA:427,2 +DA:428,0 +DA:430,0 +DA:433,2 +DA:434,2 +DA:435,2 +DA:436,2 +DA:437,2 +DA:439,2 +DA:440,0 +DA:445,2 +DA:446,1 +DA:450,2 +DA:451,0 +DA:454,0 +DA:456,2 +DA:459,0 +DA:462,0 +DA:465,2 +DA:469,1 +DA:470,1 +DA:472,1 +DA:541,0 +DA:545,0 +DA:546,0 +DA:547,0 +DA:550,0 +DA:551,0 +DA:565,32 +DA:570,32 +DA:571,1 +DA:572,1 +DA:575,31 +DA:576,31 +DA:589,7 +DA:595,7 +DA:597,7 +DA:598,2 +DA:599,2 +DA:603,5 +DA:604,5 +DA:607,0 +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:623,5 +DA:625,5 +DA:628,0 +DA:629,0 +DA:630,0 +DA:631,0 +DA:632,0 +DA:633,0 +DA:634,0 +DA:635,0 +DA:639,5 +DA:640,5 +DA:641,0 +DA:643,0 +DA:657,5 +DA:662,5 +DA:664,5 +DA:666,5 +DA:667,1 +DA:668,1 +DA:672,4 +DA:673,4 +DA:678,4 +DA:679,4 +DA:680,0 +DA:681,0 +DA:682,0 +DA:685,4 +DA:686,4 +DA:691,4 +DA:692,4 +DA:701,0 +DA:704,4 +DA:707,4 +DA:708,0 +DA:709,0 +DA:710,0 +DA:713,8 +DA:718,4 +DA:719,4 +DA:724,4 +DA:725,4 +DA:727,4 +DA:728,4 +DA:729,0 +DA:730,0 +DA:733,4 +DA:735,0 +DA:736,0 +DA:738,0 +DA:741,0 +DA:743,0 +DA:746,0 +DA:748,0 +DA:750,0 +DA:753,0 +DA:757,0 +DA:759,0 +DA:760,0 +DA:766,36 +DA:767,32 +DA:769,32 +DA:772,32 +DA:774,4 +DA:777,4 +DA:779,28 +DA:781,0 +DA:785,0 +DA:789,28 +DA:791,28 +DA:792,0 +DA:798,4 +DA:802,4 +DA:803,0 +DA:809,4 +DA:811,4 +DA:812,0 +DA:817,4 +DA:818,4 +DA:819,4 +DA:821,4 +DA:822,4 +DA:827,4 +DA:828,4 +DA:831,4 +DA:833,4 +DA:835,4 +DA:836,1 +DA:837,1 +DA:840,3 +DA:844,3 +DA:845,3 +DA:847,3 +DA:848,3 +DA:850,0 +DA:851,0 +DA:860,3 +DA:862,3 +DA:865,10 +DA:870,10 +DA:871,0 +DA:872,0 +DA:875,10 +DA:877,12 +DA:878,2 +DA:879,2 +DA:880,2 +DA:881,2 +DA:882,2 +DA:883,2 +DA:885,6 +DA:886,4 +DA:887,4 +DA:888,4 +DA:892,10 +DA:893,10 +DA:904,3 +DA:911,3 +DA:912,0 +DA:913,0 +DA:917,3 +DA:918,3 +DA:919,3 +DA:920,3 +DA:923,3 +DA:928,0 +DA:929,0 +DA:933,3 +DA:935,9 +DA:936,6 +DA:938,6 +DA:942,6 +DA:946,6 +DA:947,0 +DA:948,0 +DA:949,0 +DA:951,6 +DA:955,3 +DA:956,3 +DA:958,3 +DA:961,6 +DA:968,6 +DA:970,6 +DA:971,1 +DA:972,1 +DA:975,10 +DA:976,5 +DA:979,5 +DA:980,5 +DA:982,5 +DA:984,5 +DA:986,3 +DA:987,0 +DA:988,0 +DA:992,2 +DA:995,2 +DA:997,2 +DA:998,0 +DA:999,0 +DA:1000,0 +DA:1005,2 +DA:1006,2 +DA:1010,0 +DA:1011,0 +DA:1014,0 +DA:1019,0 +DA:1020,0 +DA:1024,0 +DA:1026,0 +DA:1027,0 +DA:1029,0 +DA:1033,0 +DA:1036,0 +DA:1040,0 +DA:1041,0 +DA:1043,0 +DA:1044,0 +DA:1051,6 +DA:1055,6 +DA:1056,1 +DA:1057,1 +DA:1060,6 +DA:1061,5 +DA:1063,5 +DA:1064,4 +DA:1080,3 +DA:1086,3 +DA:1093,3 +DA:1095,3 +DA:1096,1 +DA:1097,1 +DA:1100,2 +DA:1104,1 +DA:1106,0 +DA:1107,0 +DA:1108,0 +DA:1112,0 +DA:1113,0 +DA:1114,0 +DA:1119,1 +DA:1123,0 +DA:1124,0 +DA:1128,1 +DA:1130,1 +DA:1131,0 +DA:1133,0 +DA:1136,1 +DA:1137,0 +DA:1138,0 +DA:1139,0 +DA:1142,1 +DA:1143,0 +DA:1144,0 +DA:1145,0 +DA:1148,2 +DA:1149,1 +DA:1152,1 +DA:1159,0 +DA:1162,0 +DA:1163,0 +DA:1166,2 +DA:1167,1 +DA:1170,1 +DA:1173,1 +DA:1174,1 +DA:1180,0 +DA:1184,0 +DA:1185,0 +DA:1191,1 +DA:1193,1 +DA:1206,0 +DA:1215,0 +DA:1217,0 +DA:1218,0 +DA:1219,0 +DA:1222,0 +DA:1224,0 +DA:1225,0 +DA:1229,0 +DA:1231,0 +DA:1235,0 +DA:1236,0 +DA:1239,0 +DA:1242,0 +DA:1244,0 +DA:1255,1 +DA:1262,1 +DA:1263,1 +DA:1265,1 +DA:1268,0 +DA:1269,0 +DA:1271,0 +DA:1273,0 +DA:1282,5 +DA:1290,5 +DA:1293,5 +DA:1294,1 +DA:1295,1 +DA:1298,4 +DA:1307,4 +DA:1308,4 +DA:1313,4 +DA:1314,0 +DA:1315,0 +DA:1319,4 +DA:1320,0 +DA:1322,0 +DA:1326,4 +DA:1328,1 +DA:1329,0 +DA:1330,0 +DA:1333,1 +DA:1335,1 +DA:1336,1 +DA:1337,1 +DA:1338,1 +DA:1341,0 +DA:1343,0 +DA:1346,0 +DA:1349,1 +DA:1352,14 +DA:1353,14 +DA:1354,14 +DA:1356,14 +DA:1363,11 +DA:1366,11 +DA:1368,11 +DA:1376,11 +DA:1377,11 +DA:1380,11 +DA:1381,1 +DA:1382,1 +DA:1383,1 +DA:1386,1 +DA:1388,1 +DA:1391,1 +DA:1396,1 +DA:1397,1 +DA:1400,0 +DA:1403,10 +DA:1405,0 +DA:1411,0 +DA:1416,11 +DA:1418,0 +DA:1419,0 +DA:1422,11 +DA:1428,11 +DA:1429,11 +DA:1433,0 +DA:1441,0 +DA:1442,0 +DA:1444,0 +DA:1448,0 +DA:1450,0 +DA:1459,11 +DA:1460,0 +DA:1461,0 +DA:1462,0 +DA:1463,0 +DA:1466,0 +DA:1467,0 +DA:1470,11 +DA:1471,11 +DA:1472,11 +DA:1475,0 +DA:1476,0 +DA:1480,3 +DA:1481,0 +DA:1483,3 +DA:1485,0 +DA:1486,0 +DA:1489,3 +DA:1490,0 +DA:1495,2 +DA:1500,2 +DA:1503,2 +DA:1505,2 +DA:1506,1 +DA:1509,1 +DA:1512,1 +DA:1514,1 +DA:1515,1 +DA:1518,1 +DA:1523,1 +DA:1527,1 +DA:1529,1 +DA:1532,0 +DA:1544,0 +DA:1546,0 +DA:1547,0 +DA:1548,0 +DA:1551,0 +DA:1552,0 +DA:1561,0 +DA:1562,0 +DA:1563,0 +DA:1566,0 +DA:1567,0 +DA:1568,0 +DA:1571,0 +DA:1572,0 +DA:1577,0 +DA:1578,0 +DA:1579,0 +DA:1583,0 +DA:1585,0 +DA:1588,0 +DA:1589,0 +DA:1590,0 +DA:1593,0 +DA:1595,0 +DA:1596,0 +DA:1597,0 +DA:1601,0 +DA:1602,0 +DA:1604,0 +DA:1607,0 +DA:1610,3 +DA:1619,3 +DA:1621,3 +DA:1622,1 +DA:1623,1 +DA:1627,2 +DA:1628,2 +DA:1634,2 +DA:1635,0 +DA:1636,0 +DA:1639,2 +DA:1641,2 +DA:1642,1 +DA:1644,0 +DA:1645,0 +DA:1646,0 +DA:1650,1 +DA:1651,1 +DA:1655,1 +DA:1658,0 +DA:1661,0 +DA:1662,0 +DA:1664,0 +DA:1667,0 +DA:1671,0 +DA:1672,0 +DA:1678,12 +DA:1685,12 +DA:1687,12 +DA:1688,1 +DA:1691,1 +DA:1695,11 +DA:1700,11 +DA:1701,0 +DA:1704,0 +DA:1706,0 +DA:1711,11 +DA:1712,0 +DA:1717,0 +DA:1718,0 +DA:1719,0 +DA:1723,11 +DA:1724,4 +DA:1725,4 +DA:1727,1 +DA:1728,1 +DA:1730,4 +DA:1731,4 +DA:1733,2 +DA:1735,2 +DA:1736,1 +DA:1739,1 +DA:1743,1 +DA:1744,1 +DA:1745,1 +DA:1746,1 +DA:1748,0 +DA:1749,0 +DA:1754,0 +DA:1757,0 +DA:1764,0 +DA:1766,0 +DA:1767,0 +DA:1768,0 +DA:1771,0 +DA:1772,0 +DA:1774,0 +DA:1775,0 +DA:1778,0 +DA:1780,0 +LF:633 +LH:385 +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:1373,dlt_client_cleanup_get_log_info +FNDA:4,dlt_client_get_log_info +FNDA:3,dlt_client_main_loop +FNDA:2,dlt_client_send_message_to_socket +FNDA:1,dlt_client_send_log_level +FNDA:0,dlt_client_set_host_if_address +FNDA:2,dlt_client_parse_get_log_info_resp_text +FNDA:3,dlt_client_register_message_callback +FNDA:6,dlt_client_set_server_ip +FNDA:0,dlt_client_send_trace_status +FNDA:0,dlt_client_register_fetch_next_message_callback +FNDA:5,dlt_client_cleanup +FNDA:0,dlt_client_send_default_log_level +FNDA:0,dlt_client_set_mode +FNDA:0,dlt_client_send_timing_pakets +FNDA:0,dlt_client_setbaudrate +FNDA:0,dlt_client_send_all_log_level +FNDA:0,dlt_client_send_all_trace_status +FNDA:0,dlt_client_send_store_config +FNDA:2,dlt_client_cleanup_get_log_info +FNDA:0,dlt_client_free_calloc_failed_get_log_info +FNDA:0,dlt_client_set_serial_device +FNDA:9,dlt_client_connect +FNDA:0,dlt_client_send_inject_msg +FNDA:3,dlt_client_init +FNDA:10,dlt_client_send_ctrl_msg +FNDA:8,dlt_client_init_port +FNDA:0,dlt_client_send_reset_to_factory_default +FNDA:0,dlt_client_send_default_trace_status +FNDA:1,dlt_client_get_default_log_level +FNDA:0,dlt_client_set_socket_path +FNDA:4,dlt_client_get_software_version +FNF:31 +FNH:15 +DA:103,3 +DA:105,3 +DA:106,3 +DA:108,0 +DA:110,0 +DA:111,0 +DA:113,8 +DA:115,8 +DA:116,0 +DA:121,8 +DA:124,8 +DA:125,8 +DA:126,8 +DA:127,8 +DA:128,8 +DA:129,8 +DA:130,8 +DA:131,8 +DA:132,8 +DA:133,8 +DA:134,8 +DA:136,8 +DA:139,3 +DA:147,3 +DA:149,3 +DA:152,0 +DA:153,0 +DA:157,0 +DA:160,0 +DA:164,3 +DA:165,0 +DA:169,3 +DA:172,9 +DA:174,9 +DA:175,9 +DA:185,9 +DA:189,9 +DA:191,9 +DA:194,9 +DA:195,7 +DA:196,7 +DA:198,7 +DA:199,0 +DA:203,3 +DA:206,11 +DA:207,8 +DA:208,0 +DA:211,0 +DA:212,0 +DA:216,8 +DA:218,0 +DA:220,0 +DA:221,0 +DA:222,0 +DA:225,8 +DA:226,8 +DA:227,8 +DA:228,8 +DA:230,8 +DA:231,0 +DA:233,0 +DA:234,0 +DA:236,16 +DA:237,8 +DA:239,8 +DA:240,4 +DA:241,4 +DA:242,4 +DA:243,0 +DA:246,0 +DA:247,0 +DA:252,4 +DA:253,4 +DA:257,0 +DA:258,0 +DA:259,0 +DA:264,0 +DA:265,0 +DA:272,7 +DA:274,7 +DA:275,3 +DA:279,3 +DA:282,4 +DA:283,1 +DA:291,6 +DA:292,0 +DA:294,0 +DA:296,0 +DA:297,0 +DA:301,0 +DA:304,0 +DA:307,0 +DA:308,0 +DA:312,0 +DA:313,0 +DA:321,0 +DA:322,0 +DA:326,0 +DA:328,0 +DA:331,0 +DA:332,0 +DA:340,2 +DA:342,2 +DA:343,0 +DA:346,0 +DA:348,0 +DA:352,2 +DA:353,2 +DA:355,2 +DA:358,0 +DA:361,0 +DA:363,0 +DA:366,2 +DA:367,0 +DA:372,0 +DA:378,0 +DA:380,0 +DA:382,0 +DA:385,0 +DA:387,0 +DA:391,0 +DA:393,0 +DA:396,0 +DA:398,0 +DA:401,0 +DA:402,0 +DA:404,0 +DA:407,0 +DA:409,0 +DA:412,0 +DA:414,0 +DA:417,0 +DA:418,0 +DA:420,0 +DA:422,0 +DA:424,0 +DA:428,0 +DA:431,0 +DA:432,0 +DA:434,0 +DA:435,0 +DA:436,0 +DA:438,0 +DA:443,0 +DA:446,0 +DA:448,0 +DA:451,0 +DA:453,0 +DA:455,0 +DA:460,0 +DA:461,0 +DA:466,0 +DA:469,6 +DA:470,0 +DA:471,0 +DA:477,5 +DA:481,5 +DA:482,0 +DA:484,5 +DA:487,5 +DA:488,5 +DA:490,5 +DA:491,0 +DA:495,5 +DA:496,0 +DA:497,0 +DA:500,5 +DA:501,3 +DA:502,3 +DA:505,5 +DA:506,2 +DA:507,2 +DA:510,5 +DA:511,0 +DA:512,0 +DA:517,3 +DA:522,3 +DA:525,3 +DA:529,408 +DA:531,408 +DA:533,408 +DA:535,3 +DA:538,3 +DA:541,613 +DA:542,613 +DA:544,613 +DA:547,208 +DA:548,208 +DA:550,208 +DA:551,0 +DA:552,0 +DA:556,0 +DA:557,0 +DA:560,208 +DA:561,208 +DA:564,0 +DA:565,0 +DA:569,405 +DA:571,0 +DA:572,0 +DA:574,405 +DA:575,0 +DA:578,0 +DA:579,0 +DA:584,2 +DA:588,2 +DA:589,2 +DA:591,0 +DA:592,0 +DA:595,2 +DA:597,0 +DA:599,0 +DA:601,0 +DA:602,0 +DA:603,0 +DA:607,4 +DA:609,2 +DA:610,2 +DA:612,0 +DA:613,0 +DA:616,2 +DA:617,2 +DA:619,0 +DA:620,0 +DA:626,10 +DA:635,10 +DA:639,10 +DA:643,10 +DA:645,10 +DA:646,0 +DA:647,0 +DA:650,10 +DA:651,10 +DA:652,10 +DA:655,10 +DA:656,0 +DA:657,0 +DA:661,10 +DA:664,10 +DA:666,10 +DA:667,0 +DA:668,0 +DA:672,10 +DA:673,10 +DA:679,10 +DA:682,10 +DA:684,10 +DA:687,10 +DA:688,0 +DA:689,0 +DA:693,10 +DA:695,10 +DA:696,10 +DA:698,10 +DA:700,10 +DA:702,19 +DA:703,19 +DA:706,10 +DA:709,10 +DA:711,10 +DA:713,10 +DA:714,0 +DA:718,0 +DA:720,0 +DA:723,10 +DA:726,10 +DA:728,10 +DA:730,0 +DA:731,0 +DA:733,0 +DA:734,0 +DA:735,0 +DA:738,10 +DA:739,10 +DA:741,10 +DA:742,0 +DA:743,0 +DA:744,0 +DA:747,10 +DA:749,10 +DA:750,0 +DA:751,0 +DA:752,0 +DA:755,10 +DA:756,10 +DA:758,10 +DA:765,0 +DA:767,0 +DA:768,0 +DA:769,0 +DA:774,10 +DA:775,0 +DA:780,0 +DA:790,0 +DA:792,0 +DA:798,0 +DA:800,0 +DA:803,0 +DA:805,0 +DA:806,0 +DA:809,0 +DA:811,0 +DA:815,1 +DA:820,1 +DA:823,1 +DA:825,1 +DA:828,1 +DA:829,1 +DA:830,1 +DA:831,1 +DA:832,1 +DA:835,1 +DA:842,1 +DA:844,1 +DA:847,4 +DA:852,4 +DA:855,4 +DA:857,4 +DA:860,4 +DA:861,4 +DA:862,4 +DA:863,4 +DA:864,4 +DA:867,4 +DA:873,4 +DA:875,4 +DA:878,1 +DA:883,1 +DA:887,1 +DA:889,1 +DA:892,1 +DA:895,1 +DA:901,1 +DA:903,1 +DA:906,4 +DA:911,4 +DA:914,4 +DA:916,4 +DA:919,4 +DA:925,4 +DA:927,4 +DA:930,0 +DA:934,0 +DA:936,0 +DA:939,0 +DA:940,0 +DA:941,0 +DA:942,0 +DA:943,0 +DA:946,0 +DA:948,0 +DA:949,0 +DA:952,0 +DA:954,0 +DA:957,0 +DA:961,0 +DA:963,0 +DA:966,0 +DA:967,0 +DA:968,0 +DA:971,0 +DA:973,0 +DA:974,0 +DA:977,0 +DA:979,0 +DA:982,0 +DA:986,0 +DA:988,0 +DA:991,0 +DA:992,0 +DA:993,0 +DA:996,0 +DA:998,0 +DA:999,0 +DA:1002,0 +DA:1004,0 +DA:1007,0 +DA:1011,0 +DA:1013,0 +DA:1016,0 +DA:1017,0 +DA:1018,0 +DA:1021,0 +DA:1023,0 +DA:1024,0 +DA:1027,0 +DA:1029,0 +DA:1032,0 +DA:1036,0 +DA:1037,0 +DA:1038,0 +DA:1041,0 +DA:1043,0 +DA:1044,0 +DA:1045,0 +DA:1048,0 +DA:1049,0 +DA:1050,0 +DA:1053,0 +DA:1055,0 +DA:1056,0 +DA:1059,0 +DA:1061,0 +DA:1064,0 +DA:1068,0 +DA:1070,0 +DA:1073,0 +DA:1074,0 +DA:1077,0 +DA:1079,0 +DA:1080,0 +DA:1083,0 +DA:1085,0 +DA:1088,0 +DA:1092,0 +DA:1095,0 +DA:1096,0 +DA:1101,0 +DA:1105,0 +DA:1108,0 +DA:1109,0 +DA:1114,0 +DA:1116,0 +DA:1119,0 +DA:1121,0 +DA:1124,0 +DA:1126,0 +DA:1129,0 +DA:1130,0 +DA:1134,6 +DA:1136,6 +DA:1138,6 +DA:1139,0 +DA:1140,0 +DA:1146,0 +DA:1148,0 +DA:1150,0 +DA:1151,0 +DA:1152,0 +DA:1158,0 +DA:1160,0 +DA:1162,0 +DA:1163,0 +DA:1164,0 +DA:1170,0 +DA:1172,0 +DA:1174,0 +DA:1175,0 +DA:1176,0 +DA:1187,0 +DA:1195,0 +DA:1196,0 +DA:1198,0 +DA:1199,0 +DA:1201,0 +DA:1202,0 +DA:1205,0 +DA:1206,0 +DA:1208,0 +DA:1209,0 +DA:1212,0 +DA:1213,0 +DA:1214,0 +DA:1216,0 +DA:1219,2 +DA:1227,2 +DA:1229,2 +DA:1253,2 +DA:1257,2 +DA:1259,0 +DA:1260,0 +DA:1264,0 +DA:1265,0 +DA:1270,0 +DA:1275,0 +DA:1279,2 +DA:1280,2 +DA:1281,2 +DA:1283,2 +DA:1284,2 +DA:1286,2 +DA:1287,0 +DA:1288,0 +DA:1289,0 +DA:1292,5 +DA:1293,3 +DA:1295,3 +DA:1298,3 +DA:1299,3 +DA:1300,3 +DA:1302,3 +DA:1303,3 +DA:1305,3 +DA:1306,0 +DA:1308,0 +DA:1309,0 +DA:1312,9 +DA:1313,6 +DA:1315,6 +DA:1317,6 +DA:1321,6 +DA:1322,6 +DA:1326,6 +DA:1327,6 +DA:1331,6 +DA:1332,6 +DA:1334,6 +DA:1335,6 +DA:1337,6 +DA:1338,0 +DA:1339,0 +DA:1340,0 +DA:1343,6 +DA:1351,3 +DA:1352,3 +DA:1354,3 +DA:1355,3 +DA:1357,3 +DA:1358,0 +DA:1359,0 +DA:1360,0 +DA:1363,3 +DA:1373,2 +DA:1379,2 +DA:1382,5 +DA:1383,3 +DA:1385,9 +DA:1386,6 +DA:1387,6 +DA:1390,3 +DA:1392,3 +DA:1396,2 +DA:1399,2 +DA:1402,2 +LF:534 +LH:240 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/lib/dlt_env_ll.c +FN:58,dlt_env_extract_id +FN:90,dlt_env_helper_to_lower +FN:126,dlt_env_extract_symbolic_ll +FN:198,dlt_env_extract_ll +FN:239,dlt_env_extract_ll_item +FN:284,dlt_env_init_ll_set +FN:307,dlt_env_free_ll_set +FN:329,dlt_env_increase_ll_set +FN:364,dlt_env_extract_ll_set +FN:403,dlt_env_ids_match +FN:436,dlt_env_ll_item_get_matching_prio +FN:471,dlt_env_adjust_ll_from_env +FNDA:0,dlt_env_init_ll_set +FNDA:0,dlt_env_extract_id +FNDA:0,dlt_env_extract_symbolic_ll +FNDA:0,dlt_env_extract_ll +FNDA:0,dlt_env_ids_match +FNDA:205,dlt_env_adjust_ll_from_env +FNDA:0,dlt_env_extract_ll_set +FNDA:0,dlt_env_increase_ll_set +FNDA:0,dlt_env_helper_to_lower +FNDA:0,dlt_env_extract_ll_item +FNDA:0,dlt_env_ll_item_get_matching_prio +FNDA:5439,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,5439 +DA:309,5439 +DA:313,5439 +DA:314,0 +DA:315,0 +DA:318,5439 +DA:319,5439 +DA:329,0 +DA:334,0 +DA:338,0 +DA:339,0 +DA:341,0 +DA:342,0 +DA:344,0 +DA:346,0 +DA:347,0 +DA:349,0 +DA:350,0 +DA:351,0 +DA:364,0 +DA:366,0 +DA:370,0 +DA:374,0 +DA:379,0 +DA:380,0 +DA:385,0 +DA:389,0 +DA:390,0 +DA:392,0 +DA:403,0 +DA:405,0 +DA:409,0 +DA:413,0 +DA:417,0 +DA:418,0 +DA:436,0 +DA:440,0 +DA:444,0 +DA:445,0 +DA:447,0 +DA:448,0 +DA:450,0 +DA:451,0 +DA:453,0 +DA:454,0 +DA:471,205 +DA:476,205 +DA:484,205 +DA:485,0 +DA:487,0 +DA:489,0 +DA:491,0 +DA:492,0 +LF:132 +LH:8 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/lib/dlt_filetransfer.c +FN:84,getFilesize +FN:103,stringHash +FN:129,getFileSerialNumber +FN:155,getFileCreationDate +FN:175,getFileCreationDate2 +FN:196,isFile +FN:206,doTimeout +FN:218,checkUserBufferForFreeSpace +FN:236,doRemoveFile +FN:241,dlt_user_log_file_errorMessage +FN:306,dlt_user_log_file_infoAbout +FN:369,dlt_user_log_file_complete +FN:404,dlt_user_log_file_packagesCount +FN:454,dlt_user_log_file_header_alias +FN:516,dlt_user_log_file_header +FN:576,dlt_user_log_file_data +FN:594,dlt_user_log_file_data_cancelable +FN:745,dlt_user_log_file_end +FNDA:0,doRemoveFile +FNDA:0,doTimeout +FNDA:0,dlt_user_log_file_header_alias +FNDA:0,checkUserBufferForFreeSpace +FNDA:0,getFilesize +FNDA:0,stringHash +FNDA:0,dlt_user_log_file_end +FNDA:0,dlt_user_log_file_data_cancelable +FNDA:0,getFileSerialNumber +FNDA:0,getFileCreationDate +FNDA:0,dlt_user_log_file_packagesCount +FNDA:0,dlt_user_log_file_complete +FNDA:0,isFile +FNDA:0,getFileCreationDate2 +FNDA:0,dlt_user_log_file_data +FNDA:0,dlt_user_log_file_errorMessage +FNDA:0,dlt_user_log_file_header +FNDA:0,dlt_user_log_file_infoAbout +FNF:18 +FNH:0 +DA:84,0 +DA:88,0 +DA:90,0 +DA:91,0 +DA:94,0 +DA:95,0 +DA:103,0 +DA:105,0 +DA:109,0 +DA:113,0 +DA:117,0 +DA:118,0 +DA:129,0 +DA:134,0 +DA:135,0 +DA:136,0 +DA:138,0 +DA:139,0 +DA:140,0 +DA:141,0 +DA:142,0 +DA:143,0 +DA:146,0 +DA:155,0 +DA:159,0 +DA:160,0 +DA:161,0 +DA:164,0 +DA:165,0 +DA:175,0 +DA:180,0 +DA:181,0 +DA:183,0 +DA:186,0 +DA:187,0 +DA:188,0 +DA:189,0 +DA:196,0 +DA:199,0 +DA:206,0 +DA:209,0 +DA:210,0 +DA:211,0 +DA:212,0 +DA:218,0 +DA:222,0 +DA:224,0 +DA:225,0 +DA:236,0 +DA:238,0 +DA:241,0 +DA:244,0 +DA:245,0 +DA:246,0 +DA:248,0 +DA:249,0 +DA:254,0 +DA:256,0 +DA:257,0 +DA:263,0 +DA:264,0 +DA:266,0 +DA:267,0 +DA:273,0 +DA:275,0 +DA:288,0 +DA:296,0 +DA:306,0 +DA:309,0 +DA:312,0 +DA:314,0 +DA:315,0 +DA:321,0 +DA:323,0 +DA:324,0 +DA:330,0 +DA:331,0 +DA:333,0 +DA:334,0 +DA:340,0 +DA:352,0 +DA:353,0 +DA:369,0 +DA:374,0 +DA:375,0 +DA:376,0 +DA:379,0 +DA:383,0 +DA:388,0 +DA:389,0 +DA:404,0 +DA:409,0 +DA:412,0 +DA:414,0 +DA:415,0 +DA:420,0 +DA:423,0 +DA:426,0 +DA:428,0 +DA:431,0 +DA:435,0 +DA:440,0 +DA:454,0 +DA:457,0 +DA:460,0 +DA:462,0 +DA:463,0 +DA:467,0 +DA:470,0 +DA:472,0 +DA:473,0 +DA:479,0 +DA:480,0 +DA:482,0 +DA:483,0 +DA:489,0 +DA:500,0 +DA:502,0 +DA:503,0 +DA:516,0 +DA:519,0 +DA:522,0 +DA:524,0 +DA:525,0 +DA:531,0 +DA:533,0 +DA:534,0 +DA:540,0 +DA:541,0 +DA:543,0 +DA:544,0 +DA:550,0 +DA:563,0 +DA:564,0 +DA:576,0 +DA:581,0 +DA:582,0 +DA:594,0 +DA:604,0 +DA:606,0 +DA:608,0 +DA:609,0 +DA:610,0 +DA:613,0 +DA:615,0 +DA:616,0 +DA:617,0 +DA:626,0 +DA:627,0 +DA:632,0 +DA:637,0 +DA:638,0 +DA:645,0 +DA:646,0 +DA:652,0 +DA:654,0 +DA:655,0 +DA:658,0 +DA:659,0 +DA:662,0 +DA:670,0 +DA:671,0 +DA:675,0 +DA:677,0 +DA:681,0 +DA:684,0 +DA:685,0 +DA:686,0 +DA:688,0 +DA:696,0 +DA:698,0 +DA:699,0 +DA:702,0 +DA:703,0 +DA:706,0 +DA:713,0 +DA:714,0 +DA:718,0 +DA:721,0 +DA:722,0 +DA:724,0 +DA:728,0 +DA:730,0 +DA:732,0 +DA:733,0 +DA:745,0 +DA:748,0 +DA:751,0 +DA:753,0 +DA:754,0 +DA:757,0 +DA:760,0 +DA:766,0 +DA:767,0 +DA:768,0 +DA:771,0 +DA:775,0 +DA:777,0 +DA:778,0 +LF:199 +LH:0 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/lib/dlt_user.c +FN:164,dlt_lock_mutex +FN:174,dlt_unlock_mutex +FN:230,dlt_user_check_library_version +FN:391,dlt_initialize_fifo_connection +FN:459,dlt_init +FN:563,dlt_get_appid +FN:574,dlt_init_file +FN:613,dlt_set_filesize_max +FN:635,dlt_init_message_queue +FN:707,dlt_init_common +FN:913,dlt_user_atexit_handler +FN:941,dlt_user_atexit_blow_out_user_buffer +FN:1004,dlt_free +FN:1200,dlt_check_library_version +FN:1205,dlt_register_app +FN:1282,dlt_register_context +FN:1309,dlt_register_context_ll_ts_llccb +FN:1512,dlt_register_context_ll_ts +FN:1527,dlt_register_context_llccb +FN:1558,dlt_unregister_app_util +FN:1596,dlt_unregister_app +FN:1601,dlt_unregister_app_flush_buffered_logs +FN:1623,dlt_unregister_context +FN:1685,dlt_set_application_ll_ts_limit +FN:1735,dlt_get_log_state +FN:1740,dlt_set_log_mode +FN:1763,dlt_set_resend_timeout_atexit +FN:1779,dlt_user_log_write_start_init +FN:1805,dlt_user_log_write_start +FN:1810,dlt_user_log_write_start_id +FN:1818,dlt_user_log_write_start_internal +FN:1881,dlt_user_log_write_start_w_given_buffer +FN:1916,dlt_user_log_write_finish +FN:1930,dlt_user_log_write_finish_w_given_buffer +FN:1942,dlt_user_log_write_raw_internal +FN:2022,dlt_user_log_write_raw +FN:2027,dlt_user_log_write_raw_formatted +FN:2032,dlt_user_log_write_raw_attr +FN:2037,dlt_user_log_write_raw_formatted_attr +FN:2043,dlt_user_log_write_generic_attr +FN:2116,dlt_user_log_write_generic_formatted +FN:2160,dlt_user_log_write_float32 +FN:2169,dlt_user_log_write_float64 +FN:2178,dlt_user_log_write_float32_attr +FN:2188,dlt_user_log_write_float64_attr +FN:2198,dlt_user_log_write_uint +FN:2239,dlt_user_log_write_uint8 +FN:2245,dlt_user_log_write_uint16 +FN:2251,dlt_user_log_write_uint32 +FN:2257,dlt_user_log_write_uint64 +FN:2263,dlt_user_log_write_uint_attr +FN:2304,dlt_user_log_write_uint8_attr +FN:2311,dlt_user_log_write_uint16_attr +FN:2318,dlt_user_log_write_uint32_attr +FN:2325,dlt_user_log_write_uint64_attr +FN:2332,dlt_user_log_write_uint8_formatted +FN:2338,dlt_user_log_write_uint16_formatted +FN:2344,dlt_user_log_write_uint32_formatted +FN:2350,dlt_user_log_write_uint64_formatted +FN:2356,dlt_user_log_write_ptr +FN:2384,dlt_user_log_write_int +FN:2425,dlt_user_log_write_int8 +FN:2431,dlt_user_log_write_int16 +FN:2437,dlt_user_log_write_int32 +FN:2443,dlt_user_log_write_int64 +FN:2449,dlt_user_log_write_int_attr +FN:2490,dlt_user_log_write_int8_attr +FN:2497,dlt_user_log_write_int16_attr +FN:2504,dlt_user_log_write_int32_attr +FN:2511,dlt_user_log_write_int64_attr +FN:2518,dlt_user_log_write_bool +FN:2524,dlt_user_log_write_bool_attr +FN:2531,dlt_user_log_write_string +FN:2536,dlt_user_log_write_string_attr +FN:2541,dlt_user_log_write_sized_string +FN:2546,dlt_user_log_write_sized_string_attr +FN:2551,dlt_user_log_write_constant_string +FN:2557,dlt_user_log_write_constant_string_attr +FN:2563,dlt_user_log_write_sized_constant_string +FN:2569,dlt_user_log_write_sized_constant_string_attr +FN:2575,dlt_user_log_write_utf8_string +FN:2580,dlt_user_log_write_utf8_string_attr +FN:2585,dlt_user_log_write_sized_utf8_string +FN:2590,dlt_user_log_write_sized_utf8_string_attr +FN:2595,dlt_user_log_write_constant_utf8_string +FN:2601,dlt_user_log_write_constant_utf8_string_attr +FN:2607,dlt_user_log_write_sized_constant_utf8_string +FN:2613,dlt_user_log_write_sized_constant_utf8_string_attr +FN:2619,dlt_user_log_write_sized_string_utils_attr +FN:2774,dlt_user_log_write_string_utils_attr +FN:2783,dlt_register_injection_callback_with_id +FN:2874,dlt_register_injection_callback +FN:2885,dlt_register_log_level_changed_callback +FN:2925,check_buffer +FN:2937,dlt_user_trace_network_segmented_start +FN:3034,dlt_user_trace_network_segmented_segment +FN:3117,dlt_user_trace_network_segmented_end +FN:3173,dlt_user_trace_network_segmented_thread +FN:3240,dlt_user_trace_network_segmented_thread_segmenter +FN:3277,dlt_user_trace_network_segmented +FN:3365,dlt_user_trace_network +FN:3375,dlt_user_trace_network_truncated +FN:3527,dlt_log_string +FN:3548,dlt_log_string_int +FN:3570,dlt_log_string_uint +FN:3592,dlt_log_int +FN:3612,dlt_log_uint +FN:3632,dlt_log_raw +FN:3656,dlt_log_marker +FN:3668,dlt_verbose_mode +FN:3683,dlt_nonverbose_mode +FN:3698,dlt_use_extended_header_for_non_verbose +FN:3713,dlt_with_session_id +FN:3728,dlt_with_timestamp +FN:3743,dlt_with_ecu_id +FN:3758,dlt_enable_local_print +FN:3772,dlt_disable_local_print +FN:3787,dlt_user_cleanup_handler +FN:3800,dlt_user_housekeeperthread_function +FN:3877,dlt_user_log_init +FN:3900,dlt_user_log_send_log +FN:4187,dlt_user_log_send_register_application +FN:4230,dlt_user_log_send_unregister_application +FN:4266,dlt_user_log_send_register_context +FN:4325,dlt_user_log_send_unregister_context +FN:4370,dlt_send_app_ll_ts_limit +FN:4417,dlt_user_log_send_log_mode +FN:4454,dlt_user_log_send_marker +FN:4482,dlt_user_print_msg +FN:4519,dlt_user_log_check_user_message +FN:4793,dlt_user_log_resend_buffer +FN:4887,dlt_user_log_reattach_to_daemon +FN:4967,dlt_user_log_send_overflow +FN:4988,dlt_user_check_buffer +FN:5020,dlt_start_threads +FN:5101,dlt_stop_threads +FN:5173,dlt_fork_child_fork_handler +FN:5180,dlt_user_log_out_error_handling +FNDA:0,dlt_with_ecu_id +FNDA:203,dlt_register_context +FNDA:7,dlt_user_check_library_version +FNDA:7,dlt_user_log_write_float32_attr +FNDA:8,dlt_user_log_write_sized_utf8_string +FNDA:10878,dlt_user_housekeeperthread_function +FNDA:14,dlt_user_trace_network +FNDA:10878,dlt_user_cleanup_handler +FNDA:28,dlt_user_log_write_uint32_formatted +FNDA:25,dlt_log_string_uint +FNDA:5455,dlt_user_log_check_user_message +FNDA:6,dlt_user_log_write_sized_string_attr +FNDA:0,dlt_with_session_id +FNDA:10,dlt_nonverbose_mode +FNDA:5834,dlt_user_log_resend_buffer +FNDA:0,dlt_init_message_queue +FNDA:0,dlt_register_injection_callback +FNDA:28,dlt_user_log_write_uint64_formatted +FNDA:1,dlt_log_marker +FNDA:3,dlt_user_log_write_sized_constant_string_attr +FNDA:5926,dlt_user_log_write_start +FNDA:5,dlt_user_log_write_sized_constant_utf8_string +FNDA:0,dlt_set_filesize_max +FNDA:3,dlt_user_log_write_bool_attr +FNDA:5,dlt_user_log_write_constant_string_attr +FNDA:7,dlt_check_library_version +FNDA:0,dlt_register_injection_callback_with_id +FNDA:13,dlt_user_log_write_raw +FNDA:0,dlt_fork_child_fork_handler +FNDA:5,dlt_user_log_write_constant_utf8_string +FNDA:4559601,dlt_init +FNDA:37,dlt_user_log_write_int +FNDA:1,dlt_get_log_state +FNDA:3,dlt_user_log_write_bool +FNDA:18,dlt_user_log_write_uint32_attr +FNDA:0,dlt_user_log_send_overflow +FNDA:6008,dlt_user_log_send_log +FNDA:7,dlt_user_log_write_uint_attr +FNDA:7,dlt_user_log_write_utf8_string_attr +FNDA:216,dlt_register_context_ll_ts +FNDA:5439,dlt_initialize_fifo_connection +FNDA:0,dlt_set_resend_timeout_atexit +FNDA:6008,dlt_user_log_write_finish +FNDA:2,dlt_user_log_write_sized_string +FNDA:6,dlt_user_log_write_int8 +FNDA:0,dlt_user_trace_network_segmented_start +FNDA:14,dlt_user_log_write_int32_attr +FNDA:6411,dlt_user_log_init +FNDA:19,dlt_user_log_write_raw_formatted +FNDA:205,dlt_user_log_send_register_context +FNDA:181,dlt_user_log_send_unregister_application +FNDA:25,dlt_log_string_int +FNDA:167,dlt_unregister_app +FNDA:7,dlt_user_log_write_int64_attr +FNDA:7,dlt_user_log_write_constant_string +FNDA:0,dlt_user_trace_network_segmented_end +FNDA:7,dlt_user_log_write_string_attr +FNDA:11729,dlt_user_log_write_sized_string_utils_attr +FNDA:23947,dlt_free +FNDA:42,dlt_user_log_write_int32 +FNDA:859,dlt_user_log_out_error_handling +FNDA:0,dlt_user_trace_network_segmented_thread_segmenter +FNDA:7,dlt_user_log_write_sized_utf8_string_attr +FNDA:0,dlt_enable_local_print +FNDA:22,dlt_log_uint +FNDA:7,dlt_user_log_write_float64 +FNDA:7,dlt_user_log_write_float32 +FNDA:16317,dlt_unlock_mutex +FNDA:10878,dlt_lock_mutex +FNDA:7,dlt_user_log_write_int8_attr +FNDA:6001,dlt_user_log_write_start_init +FNDA:6,dlt_user_log_write_int64 +FNDA:1,dlt_user_log_write_sized_constant_string +FNDA:4,dlt_user_log_write_sized_constant_utf8_string_attr +FNDA:216,dlt_register_context_ll_ts_llccb +FNDA:121,dlt_user_log_reattach_to_daemon +FNDA:5440,dlt_init_common +FNDA:204,dlt_unregister_context +FNDA:4,dlt_user_log_write_uint8 +FNDA:21,dlt_user_log_write_utf8_string +FNDA:0,dlt_user_trace_network_segmented_segment +FNDA:7,dlt_user_log_write_int16_attr +FNDA:5439,dlt_start_threads +FNDA:18,dlt_log_string +FNDA:204,dlt_user_log_send_unregister_context +FNDA:7,dlt_user_log_write_int_attr +FNDA:171,dlt_user_log_send_register_application +FNDA:0,dlt_user_log_write_start_w_given_buffer +FNDA:3,dlt_user_log_write_raw_formatted_attr +FNDA:0,dlt_send_app_ll_ts_limit +FNDA:7,dlt_user_log_write_uint64_attr +FNDA:11760,dlt_user_log_write_generic_attr +FNDA:11721,dlt_user_log_write_string_utils_attr +FNDA:1,dlt_user_log_send_marker +FNDA:11,dlt_log_raw +FNDA:7,dlt_user_atexit_blow_out_user_buffer +FNDA:4,dlt_set_log_mode +FNDA:10,dlt_verbose_mode +FNDA:38,dlt_user_log_write_raw_internal +FNDA:7,dlt_unregister_app_flush_buffered_logs +FNDA:0,dlt_user_log_write_ptr +FNDA:176,dlt_register_app +FNDA:6,dlt_user_log_write_int16 +FNDA:0,dlt_user_print_msg +FNDA:21,dlt_user_trace_network_truncated +FNDA:7,dlt_user_log_write_uint16_attr +FNDA:7,dlt_user_log_write_uint8_attr +FNDA:0,dlt_get_appid +FNDA:28,dlt_user_log_write_uint8_formatted +FNDA:4,dlt_user_log_send_log_mode +FNDA:0,dlt_user_log_write_finish_w_given_buffer +FNDA:7,dlt_user_trace_network_segmented +FNDA:22,dlt_log_int +FNDA:0,dlt_set_application_ll_ts_limit +FNDA:6059,dlt_user_log_write_start_internal +FNDA:35,dlt_user_log_write_uint +FNDA:4,dlt_user_log_write_uint16 +FNDA:23,dlt_user_log_write_start_id +FNDA:11686,dlt_user_log_write_string +FNDA:8,dlt_user_atexit_handler +FNDA:2,dlt_use_extended_header_for_non_verbose +FNDA:3,dlt_user_log_write_raw_attr +FNDA:7,dlt_user_log_write_float64_attr +FNDA:181,dlt_unregister_app_util +FNDA:28,dlt_user_log_write_uint16_formatted +FNDA:0,dlt_with_timestamp +FNDA:11580,dlt_user_log_write_uint32 +FNDA:10878,dlt_user_trace_network_segmented_thread +FNDA:112,dlt_user_log_write_generic_formatted +FNDA:5439,dlt_stop_threads +FNDA:4,dlt_user_log_write_uint64 +FNDA:0,check_buffer +FNDA:0,dlt_register_context_llccb +FNDA:4,dlt_user_log_write_constant_utf8_string_attr +FNDA:0,dlt_user_check_buffer +FNDA:1,dlt_register_log_level_changed_callback +FNDA:0,dlt_disable_local_print +FNDA:0,dlt_init_file +FNF:138 +FNH:111 +DA:164,10878 +DA:166,10878 +DA:168,10878 +DA:169,0 +DA:172,10878 +DA:174,16317 +DA:176,16317 +DA:177,16317 +DA:230,7 +DA:235,7 +DA:236,7 +DA:238,7 +DA:239,0 +DA:247,0 +DA:391,5439 +DA:398,5439 +DA:400,5439 +DA:401,0 +DA:402,0 +DA:406,5439 +DA:408,1 +DA:412,1 +DA:413,0 +DA:414,0 +DA:419,5439 +DA:422,5439 +DA:424,5439 +DA:426,5439 +DA:427,0 +DA:430,5439 +DA:432,5439 +DA:433,0 +DA:434,0 +DA:437,5439 +DA:439,5439 +DA:440,0 +DA:441,0 +DA:442,0 +DA:446,5439 +DA:448,5439 +DA:452,5432 +DA:459,4559601 +DA:462,4559601 +DA:463,1905326 +DA:465,1905326 +DA:477,2654275 +DA:482,5439 +DA:485,5439 +DA:486,0 +DA:490,5439 +DA:491,0 +DA:492,0 +DA:495,5439 +DA:496,5439 +DA:497,5439 +DA:499,5439 +DA:500,5439 +DA:526,5439 +DA:529,5439 +DA:533,0 +DA:534,0 +DA:541,5439 +DA:542,5439 +DA:544,5439 +DA:547,5439 +DA:548,0 +DA:549,0 +DA:553,5439 +DA:556,5439 +DA:557,0 +DA:563,0 +DA:565,0 +DA:567,0 +DA:569,0 +DA:570,0 +DA:574,0 +DA:577,0 +DA:589,0 +DA:593,0 +DA:598,0 +DA:601,0 +DA:604,0 +DA:605,0 +DA:606,0 +DA:607,0 +DA:613,0 +DA:615,0 +DA:617,0 +DA:619,0 +DA:622,0 +DA:623,0 +DA:626,0 +DA:628,0 +DA:631,0 +DA:635,0 +DA:637,0 +DA:639,0 +DA:640,0 +DA:642,0 +DA:643,0 +DA:648,0 +DA:652,0 +DA:653,0 +DA:654,0 +DA:655,0 +DA:661,0 +DA:665,0 +DA:666,0 +DA:667,0 +DA:669,0 +DA:670,0 +DA:673,0 +DA:679,0 +DA:680,0 +DA:681,0 +DA:682,0 +DA:686,0 +DA:688,0 +DA:690,0 +DA:691,0 +DA:692,0 +DA:695,0 +DA:696,0 +DA:697,0 +DA:704,11776 +DA:707,5440 +DA:723,10880 +DA:724,10880 +DA:725,5440 +DA:726,0 +DA:727,0 +DA:731,5440 +DA:733,5440 +DA:734,5440 +DA:736,5440 +DA:737,5440 +DA:739,5440 +DA:742,5440 +DA:751,5440 +DA:756,5440 +DA:758,5440 +DA:759,0 +DA:760,0 +DA:764,5440 +DA:769,5440 +DA:772,5440 +DA:775,5440 +DA:778,5440 +DA:780,5440 +DA:782,5440 +DA:784,5440 +DA:786,5440 +DA:787,0 +DA:788,0 +DA:789,0 +DA:790,0 +DA:791,0 +DA:792,0 +DA:795,5440 +DA:797,5440 +DA:798,0 +DA:799,0 +DA:805,5440 +DA:806,5440 +DA:807,5440 +DA:808,5440 +DA:811,5440 +DA:812,5440 +DA:813,5440 +DA:815,5440 +DA:816,0 +DA:818,0 +DA:819,0 +DA:826,5440 +DA:827,0 +DA:829,0 +DA:830,0 +DA:837,5440 +DA:838,0 +DA:840,0 +DA:841,0 +DA:849,5440 +DA:850,5440 +DA:852,5440 +DA:853,7 +DA:855,7 +DA:856,0 +DA:857,0 +DA:861,7 +DA:862,7 +DA:868,5440 +DA:869,5439 +DA:870,5439 +DA:872,5439 +DA:873,0 +DA:874,0 +DA:875,0 +DA:876,0 +DA:880,5440 +DA:881,5440 +DA:882,0 +DA:883,0 +DA:886,5440 +DA:890,0 +DA:891,0 +DA:892,0 +DA:895,5440 +DA:897,5440 +DA:899,5440 +DA:900,8 +DA:901,8 +DA:913,8 +DA:916,8 +DA:919,8 +DA:920,1 +DA:922,1 +DA:923,1 +DA:927,7 +DA:929,7 +DA:930,1 +DA:934,7 +DA:938,7 +DA:941,7 +DA:947,7 +DA:950,7 +DA:951,7 +DA:952,7 +DA:954,7 +DA:955,101 +DA:956,100 +DA:958,100 +DA:960,100 +DA:961,0 +DA:962,0 +DA:966,0 +DA:971,100 +DA:972,0 +DA:974,0 +DA:975,0 +DA:976,0 +DA:977,0 +DA:979,0 +DA:983,100 +DA:984,100 +DA:985,100 +DA:988,1 +DA:989,1 +DA:990,1 +DA:998,11449 +DA:999,2 +DA:1000,11438 +DA:1004,23947 +DA:1014,23947 +DA:1019,23947 +DA:1020,18508 +DA:1021,18508 +DA:1024,5439 +DA:1026,5439 +DA:1030,5439 +DA:1031,5438 +DA:1032,5438 +DA:1033,5438 +DA:1034,5438 +DA:1044,5439 +DA:1108,6 +DA:1110,6 +DA:1111,0 +DA:1113,6 +DA:1117,5439 +DA:1118,5439 +DA:1119,5439 +DA:1122,5439 +DA:1125,5439 +DA:1128,5439 +DA:1129,0 +DA:1130,5439 +DA:1132,5439 +DA:1133,10020 +DA:1134,10000 +DA:1135,1 +DA:1136,1 +DA:1139,10000 +DA:1140,1 +DA:1141,1 +DA:1144,10000 +DA:1145,1 +DA:1146,1 +DA:1149,10000 +DA:1150,0 +DA:1151,0 +DA:1154,10000 +DA:1155,10000 +DA:1158,20 +DA:1159,20 +DA:1160,20 +DA:1161,20 +DA:1164,5439 +DA:1165,5439 +DA:1169,5439 +DA:1175,5439 +DA:1176,0 +DA:1178,5439 +DA:1179,0 +DA:1181,5439 +DA:1182,5439 +DA:1183,0 +DA:1185,5439 +DA:1186,5439 +DA:1188,5439 +DA:1190,5439 +DA:1195,5439 +DA:1197,5439 +DA:1200,7 +DA:1202,7 +DA:1205,176 +DA:1210,176 +DA:1213,176 +DA:1214,8 +DA:1215,0 +DA:1216,0 +DA:1220,176 +DA:1225,172 +DA:1226,2 +DA:1229,170 +DA:1231,2 +DA:1232,0 +DA:1235,168 +DA:1237,2 +DA:1238,0 +DA:1239,0 +DA:1242,166 +DA:1243,1 +DA:1244,1 +DA:1245,1 +DA:1250,171 +DA:1253,171 +DA:1255,171 +DA:1256,0 +DA:1258,171 +DA:1260,171 +DA:1261,171 +DA:1262,171 +DA:1264,171 +DA:1267,0 +DA:1268,0 +DA:1272,171 +DA:1274,171 +DA:1276,171 +DA:1277,7 +DA:1282,203 +DA:1285,203 +DA:1289,197 +DA:1292,197 +DA:1293,0 +DA:1294,0 +DA:1295,0 +DA:1299,197 +DA:1302,189 +DA:1309,216 +DA:1323,216 +DA:1327,209 +DA:1330,209 +DA:1331,2 +DA:1332,2 +DA:1335,207 +DA:1336,2 +DA:1337,2 +DA:1340,205 +DA:1344,205 +DA:1349,205 +DA:1355,205 +DA:1356,21 +DA:1358,21 +DA:1359,0 +DA:1360,0 +DA:1363,21 +DA:1366,10521 +DA:1367,10500 +DA:1371,10500 +DA:1372,10500 +DA:1374,10500 +DA:1375,10500 +DA:1377,10500 +DA:1379,10500 +DA:1380,10500 +DA:1381,10500 +DA:1384,184 +DA:1391,0 +DA:1393,0 +DA:1394,0 +DA:1395,0 +DA:1396,0 +DA:1397,0 +DA:1399,0 +DA:1400,0 +DA:1401,0 +DA:1402,0 +DA:1403,0 +DA:1406,0 +DA:1407,0 +DA:1410,0 +DA:1411,0 +DA:1415,0 +DA:1416,0 +DA:1418,0 +DA:1419,0 +DA:1421,0 +DA:1423,0 +DA:1424,0 +DA:1425,0 +DA:1431,205 +DA:1434,205 +DA:1436,205 +DA:1437,0 +DA:1439,205 +DA:1441,205 +DA:1442,205 +DA:1443,205 +DA:1445,205 +DA:1446,0 +DA:1447,0 +DA:1453,205 +DA:1454,205 +DA:1456,205 +DA:1457,0 +DA:1458,0 +DA:1462,205 +DA:1463,205 +DA:1465,205 +DA:1466,0 +DA:1467,0 +DA:1472,205 +DA:1477,205 +DA:1478,0 +DA:1481,205 +DA:1483,16 +DA:1486,205 +DA:1487,15 +DA:1490,205 +DA:1491,205 +DA:1493,205 +DA:1494,205 +DA:1496,205 +DA:1498,205 +DA:1499,205 +DA:1500,205 +DA:1502,205 +DA:1503,205 +DA:1505,205 +DA:1507,205 +DA:1509,205 +DA:1512,216 +DA:1518,216 +DA:1527,0 +DA:1534,0 +DA:1538,0 +DA:1541,0 +DA:1542,0 +DA:1543,0 +DA:1544,0 +DA:1548,0 +DA:1558,181 +DA:1563,181 +DA:1567,181 +DA:1568,0 +DA:1569,0 +DA:1573,181 +DA:1575,181 +DA:1577,181 +DA:1579,181 +DA:1580,7 +DA:1582,180 +DA:1584,180 +DA:1585,171 +DA:1588,180 +DA:1591,181 +DA:1593,181 +DA:1596,167 +DA:1598,167 +DA:1601,7 +DA:1606,7 +DA:1609,7 +DA:1610,0 +DA:1611,0 +DA:1614,7 +DA:1616,6 +DA:1617,6 +DA:1620,7 +DA:1623,204 +DA:1629,204 +DA:1633,204 +DA:1634,204 +DA:1636,204 +DA:1640,204 +DA:1642,204 +DA:1643,204 +DA:1645,204 +DA:1647,204 +DA:1649,204 +DA:1650,204 +DA:1652,204 +DA:1653,204 +DA:1656,204 +DA:1657,204 +DA:1658,204 +DA:1661,204 +DA:1662,204 +DA:1663,204 +DA:1666,204 +DA:1668,204 +DA:1669,0 +DA:1670,0 +DA:1673,204 +DA:1674,204 +DA:1677,204 +DA:1680,204 +DA:1682,204 +DA:1685,0 +DA:1690,0 +DA:1693,0 +DA:1694,0 +DA:1695,0 +DA:1698,0 +DA:1699,0 +DA:1700,0 +DA:1703,0 +DA:1704,0 +DA:1705,0 +DA:1706,0 +DA:1710,0 +DA:1712,0 +DA:1713,0 +DA:1714,0 +DA:1718,0 +DA:1719,0 +DA:1720,0 +DA:1722,0 +DA:1723,0 +DA:1725,0 +DA:1726,0 +DA:1729,0 +DA:1732,0 +DA:1735,1 +DA:1737,1 +DA:1740,4 +DA:1745,4 +DA:1748,4 +DA:1749,0 +DA:1750,0 +DA:1753,4 +DA:1754,0 +DA:1755,0 +DA:1756,0 +DA:1760,4 +DA:1763,0 +DA:1766,0 +DA:1769,0 +DA:1770,0 +DA:1773,0 +DA:1774,0 +DA:1779,6001 +DA:1787,6001 +DA:1790,6001 +DA:1791,6001 +DA:1792,6001 +DA:1793,6001 +DA:1794,6001 +DA:1796,6001 +DA:1805,5926 +DA:1807,6036 +DA:1810,23 +DA:1815,23 +DA:1818,6059 +DA:1827,6059 +DA:1831,6053 +DA:1839,6040 +DA:1840,39 +DA:1841,39 +DA:1844,6001 +DA:1845,6001 +DA:1847,6001 +DA:1849,0 +DA:1850,0 +DA:1854,6001 +DA:1857,6001 +DA:1858,0 +DA:1859,0 +DA:1864,6011 +DA:1865,3 +DA:1870,3 +DA:1881,0 +DA:1891,0 +DA:1895,0 +DA:1899,0 +DA:1903,0 +DA:1906,0 +DA:1907,0 +DA:1908,0 +DA:1909,0 +DA:1910,0 +DA:1916,6008 +DA:1920,6008 +DA:1923,6008 +DA:1930,0 +DA:1934,0 +DA:1937,0 +DA:1939,0 +DA:1942,38 +DA:1945,38 +DA:1949,31 +DA:1950,0 +DA:1951,0 +DA:1954,31 +DA:1955,0 +DA:1956,0 +DA:1959,31 +DA:1961,31 +DA:1962,31 +DA:1965,29 +DA:1966,29 +DA:1968,29 +DA:1969,29 +DA:1970,6 +DA:1971,6 +DA:1973,6 +DA:1975,29 +DA:1976,0 +DA:1980,29 +DA:1981,8 +DA:1982,8 +DA:1984,21 +DA:1986,4 +DA:1987,4 +DA:1990,29 +DA:1991,29 +DA:1994,29 +DA:1995,29 +DA:1997,29 +DA:1998,29 +DA:2002,6 +DA:2003,6 +DA:2007,6 +DA:2008,4 +DA:2009,4 +DA:2014,29 +DA:2015,29 +DA:2017,29 +DA:2019,29 +DA:2022,13 +DA:2024,13 +DA:2027,19 +DA:2029,19 +DA:2032,3 +DA:2034,3 +DA:2037,3 +DA:2039,3 +DA:2043,11760 +DA:2045,11760 +DA:2048,11749 +DA:2049,0 +DA:2050,0 +DA:2054,11749 +DA:2057,11751 +DA:2063,11745 +DA:2064,11745 +DA:2065,89 +DA:2066,89 +DA:2068,89 +DA:2069,89 +DA:2070,89 +DA:2071,86 +DA:2072,86 +DA:2075,89 +DA:2077,11745 +DA:2078,0 +DA:2080,11745 +DA:2081,11745 +DA:2083,11745 +DA:2087,89 +DA:2088,89 +DA:2089,89 +DA:2090,86 +DA:2091,86 +DA:2096,89 +DA:2097,64 +DA:2098,64 +DA:2100,89 +DA:2101,62 +DA:2102,62 +DA:2107,11747 +DA:2108,11747 +DA:2110,11747 +DA:2112,11747 +DA:2116,112 +DA:2118,112 +DA:2122,84 +DA:2123,0 +DA:2124,0 +DA:2127,84 +DA:2128,0 +DA:2129,0 +DA:2133,84 +DA:2136,84 +DA:2137,84 +DA:2138,84 +DA:2142,84 +DA:2143,48 +DA:2145,36 +DA:2146,24 +DA:2148,84 +DA:2149,84 +DA:2152,84 +DA:2153,84 +DA:2155,84 +DA:2157,84 +DA:2160,7 +DA:2166,7 +DA:2169,7 +DA:2175,7 +DA:2178,7 +DA:2184,7 +DA:2185,7 +DA:2188,7 +DA:2194,7 +DA:2195,7 +DA:2198,35 +DA:2200,35 +DA:2203,34 +DA:2204,0 +DA:2205,0 +DA:2219,34 +DA:2221,34 +DA:2239,4 +DA:2242,4 +DA:2245,4 +DA:2248,4 +DA:2251,11580 +DA:2254,11580 +DA:2257,4 +DA:2260,4 +DA:2263,7 +DA:2265,7 +DA:2268,7 +DA:2269,0 +DA:2270,0 +DA:2284,7 +DA:2286,7 +DA:2304,7 +DA:2307,7 +DA:2308,7 +DA:2311,7 +DA:2314,7 +DA:2315,7 +DA:2318,18 +DA:2321,18 +DA:2322,18 +DA:2325,7 +DA:2328,7 +DA:2329,7 +DA:2332,28 +DA:2335,28 +DA:2338,28 +DA:2341,28 +DA:2344,28 +DA:2347,28 +DA:2350,28 +DA:2353,28 +DA:2356,0 +DA:2358,0 +DA:2361,0 +DA:2362,0 +DA:2363,0 +DA:2372,0 +DA:2373,0 +DA:2384,37 +DA:2386,37 +DA:2389,36 +DA:2390,0 +DA:2391,0 +DA:2405,36 +DA:2407,36 +DA:2425,6 +DA:2428,6 +DA:2431,6 +DA:2434,6 +DA:2437,42 +DA:2440,42 +DA:2443,6 +DA:2446,6 +DA:2449,7 +DA:2451,7 +DA:2454,7 +DA:2455,0 +DA:2456,0 +DA:2470,7 +DA:2472,7 +DA:2490,7 +DA:2493,7 +DA:2494,7 +DA:2497,7 +DA:2500,7 +DA:2501,7 +DA:2504,14 +DA:2507,14 +DA:2508,14 +DA:2511,7 +DA:2514,7 +DA:2515,7 +DA:2518,3 +DA:2521,3 +DA:2524,3 +DA:2527,3 +DA:2528,3 +DA:2531,11686 +DA:2533,11686 +DA:2536,7 +DA:2538,7 +DA:2541,2 +DA:2543,2 +DA:2546,6 +DA:2548,6 +DA:2551,7 +DA:2554,8 +DA:2557,5 +DA:2560,7 +DA:2563,1 +DA:2566,1 +DA:2569,3 +DA:2572,3 +DA:2575,21 +DA:2577,21 +DA:2580,7 +DA:2582,7 +DA:2585,8 +DA:2587,8 +DA:2590,7 +DA:2592,7 +DA:2595,5 +DA:2598,6 +DA:2601,4 +DA:2604,4 +DA:2607,5 +DA:2610,6 +DA:2613,4 +DA:2616,4 +DA:2619,11729 +DA:2621,11729 +DA:2624,11720 +DA:2625,0 +DA:2626,0 +DA:2629,11720 +DA:2631,11720 +DA:2633,11720 +DA:2635,11720 +DA:2637,11727 +DA:2638,11720 +DA:2639,11720 +DA:2640,21 +DA:2641,21 +DA:2643,21 +DA:2652,11720 +DA:2656,21 +DA:2658,21 +DA:2660,21 +DA:2661,21 +DA:2662,21 +DA:2663,21 +DA:2664,0 +DA:2665,0 +DA:2670,21 +DA:2671,1 +DA:2672,1 +DA:2676,20 +DA:2678,20 +DA:2684,12 +DA:2687,12 +DA:2689,9 +DA:2692,6 +DA:2695,3 +DA:2699,12 +DA:2700,12 +DA:2704,11719 +DA:2705,11719 +DA:2706,11694 +DA:2707,11694 +DA:2708,11694 +DA:2709,25 +DA:2710,25 +DA:2711,25 +DA:2717,11719 +DA:2718,11719 +DA:2721,11719 +DA:2722,11719 +DA:2724,11726 +DA:2725,11719 +DA:2729,21 +DA:2730,21 +DA:2734,21 +DA:2735,15 +DA:2736,15 +DA:2741,11719 +DA:2742,11699 +DA:2745,11699 +DA:2747,11699 +DA:2748,11699 +DA:2749,11699 +DA:2751,20 +DA:2754,20 +DA:2755,20 +DA:2758,20 +DA:2759,20 +DA:2760,20 +DA:2769,11719 +DA:2771,11719 +DA:2774,11721 +DA:2776,11721 +DA:2779,11706 +DA:2780,11706 +DA:2783,0 +DA:2792,0 +DA:2795,0 +DA:2800,0 +DA:2803,0 +DA:2805,0 +DA:2806,0 +DA:2807,0 +DA:2811,0 +DA:2814,0 +DA:2815,0 +DA:2816,0 +DA:2821,0 +DA:2828,0 +DA:2829,0 +DA:2830,0 +DA:2832,0 +DA:2833,0 +DA:2834,0 +DA:2839,0 +DA:2840,0 +DA:2842,0 +DA:2843,0 +DA:2844,0 +DA:2845,0 +DA:2848,0 +DA:2849,0 +DA:2852,0 +DA:2856,0 +DA:2858,0 +DA:2859,0 +DA:2860,0 +DA:2861,0 +DA:2864,0 +DA:2865,0 +DA:2866,0 +DA:2869,0 +DA:2871,0 +DA:2874,0 +DA:2879,0 +DA:2885,1 +DA:2894,1 +DA:2899,1 +DA:2902,1 +DA:2904,1 +DA:2905,0 +DA:2906,0 +DA:2910,1 +DA:2913,1 +DA:2915,1 +DA:2917,1 +DA:2925,0 +DA:2928,0 +DA:2930,0 +DA:2937,0 +DA:2944,0 +DA:2949,0 +DA:2952,0 +DA:2953,0 +DA:2954,0 +DA:2957,0 +DA:2960,0 +DA:2962,0 +DA:2965,0 +DA:2966,0 +DA:2968,0 +DA:2969,0 +DA:2970,0 +DA:2974,0 +DA:2975,0 +DA:2976,0 +DA:2978,0 +DA:2979,0 +DA:2982,0 +DA:2984,0 +DA:2988,0 +DA:2990,0 +DA:2994,0 +DA:2996,0 +DA:3000,0 +DA:3002,0 +DA:3006,0 +DA:3009,0 +DA:3012,0 +DA:3014,0 +DA:3018,0 +DA:3020,0 +DA:3024,0 +DA:3028,0 +DA:3034,0 +DA:3044,0 +DA:3045,0 +DA:3046,0 +DA:3049,0 +DA:3051,0 +DA:3052,0 +DA:3053,0 +DA:3054,0 +DA:3057,0 +DA:3060,0 +DA:3061,0 +DA:3063,0 +DA:3067,0 +DA:3068,0 +DA:3070,0 +DA:3071,0 +DA:3072,0 +DA:3076,0 +DA:3077,0 +DA:3078,0 +DA:3081,0 +DA:3083,0 +DA:3087,0 +DA:3089,0 +DA:3093,0 +DA:3095,0 +DA:3099,0 +DA:3101,0 +DA:3104,0 +DA:3109,0 +DA:3113,0 +DA:3114,0 +DA:3117,0 +DA:3119,0 +DA:3122,0 +DA:3123,0 +DA:3124,0 +DA:3127,0 +DA:3130,0 +DA:3132,0 +DA:3136,0 +DA:3137,0 +DA:3139,0 +DA:3140,0 +DA:3141,0 +DA:3145,0 +DA:3146,0 +DA:3147,0 +DA:3150,0 +DA:3152,0 +DA:3156,0 +DA:3158,0 +DA:3161,0 +DA:3166,0 +DA:3173,5439 +DA:3178,5439 +DA:3179,0 +DA:3184,10878 +DA:3190,5439 +DA:3192,5791 +DA:3194,5791 +DA:3197,0 +DA:3199,0 +DA:3202,0 +DA:3203,0 +DA:3206,0 +DA:3207,0 +DA:3208,0 +DA:3209,0 +DA:3212,0 +DA:3215,0 +DA:3219,0 +DA:3220,0 +DA:3223,0 +DA:3226,0 +DA:3228,0 +DA:3229,0 +DA:3232,0 +DA:3233,0 +DA:3234,0 +DA:3240,0 +DA:3250,0 +DA:3251,0 +DA:3256,0 +DA:3259,0 +DA:3260,0 +DA:3263,0 +DA:3267,0 +DA:3268,0 +DA:3269,0 +DA:3272,0 +DA:3273,0 +DA:3274,0 +DA:3277,7 +DA:3285,7 +DA:3289,7 +DA:3290,7 +DA:3293,0 +DA:3295,0 +DA:3298,0 +DA:3300,0 +DA:3301,0 +DA:3302,0 +DA:3305,0 +DA:3307,0 +DA:3308,0 +DA:3309,0 +DA:3310,0 +DA:3314,0 +DA:3315,0 +DA:3316,0 +DA:3318,0 +DA:3322,0 +DA:3329,0 +DA:3330,0 +DA:3331,0 +DA:3332,0 +DA:3333,0 +DA:3334,0 +DA:3338,0 +DA:3339,0 +DA:3340,0 +DA:3341,0 +DA:3342,0 +DA:3344,0 +DA:3348,0 +DA:3350,0 +DA:3351,0 +DA:3353,0 +DA:3354,0 +DA:3355,0 +DA:3356,0 +DA:3357,0 +DA:3365,14 +DA:3372,14 +DA:3375,21 +DA:3384,21 +DA:3386,21 +DA:3389,15 +DA:3390,0 +DA:3391,0 +DA:3394,15 +DA:3397,15 +DA:3398,0 +DA:3402,0 +DA:3403,0 +DA:3405,0 +DA:3406,0 +DA:3407,0 +DA:3411,0 +DA:3412,0 +DA:3413,0 +DA:3415,0 +DA:3419,0 +DA:3421,0 +DA:3423,0 +DA:3427,0 +DA:3429,0 +DA:3433,0 +DA:3435,0 +DA:3442,0 +DA:3445,0 +DA:3447,0 +DA:3453,0 +DA:3455,0 +DA:3458,0 +DA:3462,0 +DA:3464,0 +DA:3468,0 +DA:3473,0 +DA:3527,18 +DA:3529,18 +DA:3532,18 +DA:3538,15 +DA:3539,11 +DA:3541,11 +DA:3548,25 +DA:3550,25 +DA:3553,25 +DA:3559,22 +DA:3560,16 +DA:3561,16 +DA:3563,16 +DA:3570,25 +DA:3572,25 +DA:3575,25 +DA:3581,22 +DA:3582,16 +DA:3583,16 +DA:3585,16 +DA:3592,22 +DA:3594,22 +DA:3597,22 +DA:3602,21 +DA:3603,15 +DA:3605,15 +DA:3606,0 +DA:3612,22 +DA:3614,22 +DA:3617,22 +DA:3622,21 +DA:3623,15 +DA:3625,15 +DA:3626,0 +DA:3632,11 +DA:3634,11 +DA:3637,11 +DA:3643,9 +DA:3644,7 +DA:3646,2 +DA:3649,5 +DA:3650,0 +DA:3656,1 +DA:3658,1 +DA:3659,0 +DA:3660,0 +DA:3661,0 +DA:3665,1 +DA:3668,10 +DA:3670,10 +DA:3671,0 +DA:3672,0 +DA:3673,0 +DA:3678,10 +DA:3680,10 +DA:3683,10 +DA:3685,10 +DA:3686,0 +DA:3687,0 +DA:3688,0 +DA:3693,10 +DA:3695,10 +DA:3698,2 +DA:3700,2 +DA:3701,0 +DA:3702,0 +DA:3703,0 +DA:3708,2 +DA:3710,2 +DA:3713,0 +DA:3715,0 +DA:3716,0 +DA:3717,0 +DA:3718,0 +DA:3723,0 +DA:3725,0 +DA:3728,0 +DA:3730,0 +DA:3731,0 +DA:3732,0 +DA:3733,0 +DA:3738,0 +DA:3740,0 +DA:3743,0 +DA:3745,0 +DA:3746,0 +DA:3747,0 +DA:3748,0 +DA:3753,0 +DA:3755,0 +DA:3758,0 +DA:3760,0 +DA:3761,0 +DA:3762,0 +DA:3763,0 +DA:3767,0 +DA:3769,0 +DA:3772,0 +DA:3774,0 +DA:3775,0 +DA:3776,0 +DA:3777,0 +DA:3781,0 +DA:3783,0 +DA:3787,10878 +DA:3793,10878 +DA:3797,10878 +DA:3798,10878 +DA:3800,5439 +DA:3824,5439 +DA:3825,0 +DA:3831,10878 +DA:3834,5439 +DA:3835,5439 +DA:3836,5439 +DA:3837,0 +DA:3842,5455 +DA:3843,5455 +DA:3845,0 +DA:3848,21 +DA:3851,21 +DA:3852,10 +DA:3867,21 +DA:3868,21 +DA:3869,21 +DA:3877,6411 +DA:3881,6411 +DA:3884,6411 +DA:3885,0 +DA:3887,0 +DA:3888,0 +DA:3889,0 +DA:3891,0 +DA:3895,6411 +DA:3896,6411 +DA:3897,6411 +DA:3900,6008 +DA:3908,6008 +DA:3909,0 +DA:3910,0 +DA:3913,6008 +DA:3914,6008 +DA:3915,5999 +DA:3916,5999 +DA:3921,5999 +DA:3924,5999 +DA:3927,5999 +DA:3929,5999 +DA:3932,5999 +DA:3933,5999 +DA:3936,5999 +DA:3937,5999 +DA:3940,5999 +DA:3941,5999 +DA:3944,5999 +DA:3945,5999 +DA:3946,5999 +DA:3949,6009 +DA:3951,5996 +DA:3954,3 +DA:3955,2 +DA:3961,5999 +DA:3964,5999 +DA:3967,5999 +DA:3968,5998 +DA:3971,1 +DA:3974,5999 +DA:3978,5999 +DA:3980,5998 +DA:3981,5998 +DA:3982,5998 +DA:3984,5998 +DA:3985,5998 +DA:3987,5998 +DA:3988,5998 +DA:3989,5998 +DA:3991,0 +DA:3993,0 +DA:3994,0 +DA:3995,0 +DA:4006,6007 +DA:4007,5996 +DA:4009,5998 +DA:4010,5998 +DA:4011,5998 +DA:4013,5998 +DA:4014,5998 +DA:4018,1 +DA:4022,5999 +DA:4024,5999 +DA:4025,0 +DA:4026,0 +DA:4029,5999 +DA:4032,5999 +DA:4034,5999 +DA:4035,0 +DA:4039,5999 +DA:4040,0 +DA:4046,0 +DA:4047,0 +DA:4048,0 +DA:4049,0 +DA:4052,0 +DA:4056,0 +DA:4057,0 +DA:4058,0 +DA:4059,0 +DA:4060,0 +DA:4063,0 +DA:4067,0 +DA:4069,0 +DA:4070,0 +DA:4074,5999 +DA:4075,0 +DA:4076,0 +DA:4077,0 +DA:4084,5999 +DA:4085,5811 +DA:4087,5999 +DA:4115,5998 +DA:4118,5998 +DA:4119,5998 +DA:4125,5999 +DA:4126,190 +DA:4129,190 +DA:4130,190 +DA:4131,190 +DA:4133,190 +DA:4134,5999 +DA:4135,0 +DA:4137,0 +DA:4138,0 +DA:4142,0 +DA:4148,0 +DA:4151,0 +DA:4152,0 +DA:4162,0 +DA:4163,0 +DA:4165,0 +DA:4167,0 +DA:4170,0 +DA:4172,0 +DA:4174,0 +DA:4176,0 +DA:4179,0 +DA:4187,171 +DA:4194,171 +DA:4198,171 +DA:4202,171 +DA:4203,171 +DA:4205,171 +DA:4206,171 +DA:4208,0 +DA:4210,171 +DA:4213,171 +DA:4216,171 +DA:4219,171 +DA:4220,164 +DA:4224,164 +DA:4225,164 +DA:4230,181 +DA:4236,181 +DA:4240,172 +DA:4244,172 +DA:4245,172 +DA:4247,172 +DA:4250,172 +DA:4255,172 +DA:4256,166 +DA:4266,205 +DA:4272,205 +DA:4275,205 +DA:4278,205 +DA:4282,205 +DA:4286,205 +DA:4287,205 +DA:4288,205 +DA:4289,205 +DA:4291,205 +DA:4292,205 +DA:4294,205 +DA:4295,205 +DA:4297,0 +DA:4299,205 +DA:4302,205 +DA:4304,205 +DA:4310,205 +DA:4313,205 +DA:4314,167 +DA:4318,167 +DA:4319,167 +DA:4325,204 +DA:4331,204 +DA:4334,204 +DA:4337,204 +DA:4341,204 +DA:4345,204 +DA:4346,204 +DA:4347,204 +DA:4349,204 +DA:4352,204 +DA:4359,204 +DA:4360,167 +DA:4370,0 +DA:4376,0 +DA:4377,0 +DA:4378,0 +DA:4381,0 +DA:4382,0 +DA:4383,0 +DA:4386,0 +DA:4390,0 +DA:4394,0 +DA:4395,0 +DA:4396,0 +DA:4398,0 +DA:4401,0 +DA:4406,0 +DA:4407,0 +DA:4417,4 +DA:4423,4 +DA:4424,0 +DA:4425,0 +DA:4429,4 +DA:4433,4 +DA:4435,4 +DA:4438,4 +DA:4443,4 +DA:4444,4 +DA:4454,1 +DA:4460,1 +DA:4463,1 +DA:4467,1 +DA:4471,1 +DA:4472,1 +DA:4482,0 +DA:4489,0 +DA:4493,0 +DA:4494,0 +DA:4495,0 +DA:4498,0 +DA:4499,0 +DA:4501,0 +DA:4502,0 +DA:4503,0 +DA:4506,0 +DA:4510,0 +DA:4511,0 +DA:4512,0 +DA:4514,0 +DA:4516,0 +DA:4519,5455 +DA:4547,5455 +DA:4553,5455 +DA:4555,5455 +DA:4556,5455 +DA:4558,5455 +DA:4560,21 +DA:4561,9 +DA:4562,0 +DA:4563,0 +DA:4566,9 +DA:4572,21 +DA:4579,12 +DA:4582,12 +DA:4585,0 +DA:4587,0 +DA:4590,24 +DA:4591,12 +DA:4595,12 +DA:4596,0 +DA:4597,0 +DA:4600,12 +DA:4601,5 +DA:4603,5 +DA:4608,5 +DA:4612,5 +DA:4614,5 +DA:4615,5 +DA:4616,5 +DA:4617,5 +DA:4618,5 +DA:4619,5 +DA:4621,5 +DA:4622,0 +DA:4625,5 +DA:4626,0 +DA:4627,0 +DA:4629,5 +DA:4630,5 +DA:4633,5 +DA:4634,5 +DA:4638,5 +DA:4642,5 +DA:4643,0 +DA:4645,0 +DA:4646,0 +DA:4649,5 +DA:4655,0 +DA:4658,0 +DA:4663,0 +DA:4664,0 +DA:4669,0 +DA:4670,0 +DA:4671,0 +DA:4676,0 +DA:4678,0 +DA:4680,0 +DA:4681,0 +DA:4682,0 +DA:4683,0 +DA:4685,0 +DA:4691,0 +DA:4698,0 +DA:4703,0 +DA:4705,0 +DA:4709,0 +DA:4710,0 +DA:4711,0 +DA:4717,0 +DA:4720,0 +DA:4722,0 +DA:4725,0 +DA:4727,0 +DA:4730,0 +DA:4737,0 +DA:4741,0 +DA:4743,0 +DA:4744,0 +DA:4749,7 +DA:4752,7 +DA:4757,7 +DA:4758,7 +DA:4761,7 +DA:4767,0 +DA:4769,0 +DA:4771,0 +DA:4772,0 +DA:4784,9 +DA:4785,0 +DA:4793,5834 +DA:4799,5834 +DA:4801,5834 +DA:4802,3 +DA:4803,3 +DA:4807,5831 +DA:4808,5831 +DA:4810,5831 +DA:4812,1 +DA:4813,1 +DA:4815,1 +DA:4816,1 +DA:4819,1 +DA:4820,1 +DA:4821,0 +DA:4824,0 +DA:4826,0 +DA:4827,0 +DA:4831,1 +DA:4834,1 +DA:4838,1 +DA:4839,0 +DA:4861,1 +DA:4865,1 +DA:4866,0 +DA:4869,1 +DA:4871,1 +DA:4872,1 +DA:4876,1 +DA:4877,1 +DA:4881,0 +DA:4887,121 +DA:4893,121 +DA:4894,111 +DA:4914,111 +DA:4915,111 +DA:4917,0 +DA:4920,0 +DA:4932,0 +DA:4935,0 +DA:4938,0 +DA:4941,0 +DA:4943,0 +DA:4945,0 +DA:4946,0 +DA:4947,0 +DA:4951,0 +DA:4953,0 +DA:4954,0 +DA:4956,0 +DA:4961,0 +DA:4963,0 +DA:4967,0 +DA:4973,0 +DA:4976,0 +DA:4980,0 +DA:4981,0 +DA:4983,0 +DA:4988,0 +DA:4990,0 +DA:4993,0 +DA:4999,0 +DA:5000,0 +DA:5003,0 +DA:5004,0 +DA:5020,5439 +DA:5025,5439 +DA:5032,5439 +DA:5033,5439 +DA:5034,5439 +DA:5036,5439 +DA:5040,0 +DA:5041,0 +DA:5044,5439 +DA:5046,5439 +DA:5058,5439 +DA:5059,733084 +DA:5066,730618 +DA:5067,730618 +DA:5068,730618 +DA:5071,730618 +DA:5072,730618 +DA:5076,730618 +DA:5079,730618 +DA:5084,5439 +DA:5085,0 +DA:5086,0 +DA:5087,0 +DA:5092,5439 +DA:5094,0 +DA:5095,0 +DA:5101,5439 +DA:5106,5439 +DA:5109,5439 +DA:5120,5439 +DA:5121,0 +DA:5134,5439 +DA:5135,5439 +DA:5136,5439 +DA:5137,5439 +DA:5139,5439 +DA:5141,5439 +DA:5142,0 +DA:5148,5439 +DA:5149,5439 +DA:5151,5439 +DA:5152,0 +DA:5156,5439 +DA:5160,5439 +DA:5161,5439 +DA:5163,5439 +DA:5164,0 +DA:5168,5439 +DA:5171,5439 +DA:5173,0 +DA:5175,0 +DA:5176,0 +DA:5177,0 +DA:5178,0 +DA:5180,859 +DA:5184,859 +DA:5186,859 +DA:5187,859 +DA:5188,859 +DA:5190,859 +DA:5192,859 +DA:5196,0 +DA:5197,0 +DA:5202,859 +DA:5204,859 +LF:1748 +LH:1010 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/offlinelogstorage/dlt_offline_logstorage.c +FN:43,dlt_logstorage_filter_config_free +FN:122,dlt_logstorage_list_destroy +FN:159,dlt_logstorage_list_add_config +FN:200,dlt_logstorage_list_add +FN:263,dlt_logstorage_list_find +FN:290,dlt_logstorage_count_ids +FN:320,dlt_logstorage_free +FN:347,dlt_logstorage_read_list_of_names +FN:410,dlt_logstorage_set_number +FN:435,dlt_logstorage_read_number +FN:471,dlt_logstorage_get_keys_list +FN:519,dlt_logstorage_check_excluded_ids +FN:569,dlt_logstorage_create_keys_only_ctid +FN:604,dlt_logstorage_create_keys_only_apid +FN:641,dlt_logstorage_create_keys_multi +FN:681,dlt_logstorage_create_keys_only_ecu +FN:719,dlt_logstorage_create_keys +FN:817,dlt_logstorage_prepare_table +FN:908,dlt_logstorage_validate_filter_name +FN:958,dlt_logstorage_filter_set_strategy +FN:978,dlt_logstorage_check_apids +FN:989,dlt_logstorage_check_ctids +FN:998,dlt_logstorage_store_config_excluded_apids +FN:1009,dlt_logstorage_store_config_excluded_ctids +FN:1020,dlt_logstorage_set_loglevel +FN:1032,dlt_logstorage_check_loglevel +FN:1071,dlt_logstorage_check_reset_loglevel +FN:1118,dlt_logstorage_check_filename +FN:1162,dlt_logstorage_check_filesize +FN:1171,dlt_logstorage_check_nofiles +FN:1180,dlt_logstorage_check_specificsize +FN:1189,dlt_logstorage_set_sync_strategy +FN:1217,dlt_logstorage_check_sync_strategy +FN:1267,dlt_logstorage_check_overwrite_strategy +FN:1299,dlt_logstorage_check_disable_network +FN:1331,dlt_logstorage_check_gzip_compression +FN:1364,dlt_logstorage_check_ecuid +FN:1634,dlt_logstorage_check_param +FN:1647,dlt_logstorage_get_filter_section_value +FN:1682,dlt_logstorage_get_filter_value +FN:1725,dlt_logstorage_setup_table +FN:1748,dlt_daemon_offline_setup_filter_properties +FN:1851,dlt_logstorage_check_maintain_logstorage_loglevel +FN:1895,dlt_logstorage_check_general_param +FN:1912,dlt_daemon_setup_general_properties +FN:1970,dlt_logstorage_store_filters +FN:2057,dlt_logstorage_load_config +FN:2112,dlt_logstorage_device_connected +FN:2155,dlt_logstorage_device_disconnected +FN:2201,dlt_logstorage_get_loglevel_by_key +FN:2262,dlt_logstorage_get_config +FN:2407,dlt_logstorage_filter +FN:2508,dlt_logstorage_write +FN:2782,dlt_logstorage_sync_caches +FNDA:8,dlt_logstorage_device_disconnected +FNDA:12,dlt_logstorage_set_number +FNDA:4,dlt_logstorage_sync_caches +FNDA:26,dlt_logstorage_check_param +FNDA:38,dlt_logstorage_check_loglevel +FNDA:5849,dlt_logstorage_filter +FNDA:27,dlt_logstorage_check_sync_strategy +FNDA:78,dlt_logstorage_read_list_of_names +FNDA:11,dlt_logstorage_store_filters +FNDA:9,dlt_logstorage_device_connected +FNDA:38,dlt_logstorage_check_nofiles +FNDA:5884,dlt_logstorage_get_config +FNDA:39,dlt_logstorage_check_filesize +FNDA:4,dlt_logstorage_check_specificsize +FNDA:0,dlt_logstorage_check_reset_loglevel +FNDA:36,dlt_logstorage_setup_table +FNDA:7,dlt_logstorage_free +FNDA:38,dlt_logstorage_validate_filter_name +FNDA:40315,dlt_logstorage_list_find +FNDA:0,dlt_logstorage_create_keys_only_ctid +FNDA:34,dlt_logstorage_check_ecuid +FNDA:5,dlt_logstorage_set_loglevel +FNDA:19,dlt_logstorage_count_ids +FNDA:5842,dlt_logstorage_write +FNDA:13,dlt_logstorage_filter_set_strategy +FNDA:0,dlt_logstorage_create_keys_only_ecu +FNDA:34,dlt_logstorage_create_keys_multi +FNDA:76,dlt_logstorage_list_add +FNDA:76,dlt_logstorage_get_keys_list +FNDA:2,dlt_logstorage_store_config_excluded_apids +FNDA:38,dlt_logstorage_prepare_table +FNDA:2,dlt_logstorage_store_config_excluded_ctids +FNDA:37,dlt_logstorage_get_loglevel_by_key +FNDA:0,dlt_logstorage_check_general_param +FNDA:24,dlt_logstorage_check_excluded_ids +FNDA:30,dlt_logstorage_check_overwrite_strategy +FNDA:38,dlt_logstorage_create_keys +FNDA:0,dlt_logstorage_set_sync_strategy +FNDA:39,dlt_logstorage_check_filename +FNDA:0,dlt_daemon_setup_general_properties +FNDA:36,dlt_daemon_offline_setup_filter_properties +FNDA:38,dlt_logstorage_check_ctids +FNDA:540,dlt_logstorage_get_filter_value +FNDA:1,dlt_logstorage_check_disable_network +FNDA:0,dlt_logstorage_check_maintain_logstorage_loglevel +FNDA:13,dlt_logstorage_list_destroy +FNDA:4,dlt_logstorage_create_keys_only_apid +FNDA:10,dlt_logstorage_load_config +FNDA:38,dlt_logstorage_check_apids +FNDA:540,dlt_logstorage_get_filter_section_value +FNDA:81,dlt_logstorage_read_number +FNDA:0,dlt_logstorage_check_gzip_compression +FNDA:77,dlt_logstorage_list_add_config +FNDA:75,dlt_logstorage_filter_config_free +FNF:54 +FNH:46 +DA:43,75 +DA:48,75 +DA:49,72 +DA:50,72 +DA:53,75 +DA:54,72 +DA:55,72 +DA:58,75 +DA:59,0 +DA:60,0 +DA:63,75 +DA:64,0 +DA:65,0 +DA:68,75 +DA:69,70 +DA:70,70 +DA:73,75 +DA:74,27 +DA:75,27 +DA:78,75 +DA:79,64 +DA:80,64 +DA:83,75 +DA:84,17 +DA:91,75 +DA:92,23 +DA:93,23 +DA:96,75 +DA:98,113 +DA:100,38 +DA:101,38 +DA:102,38 +DA:106,38 +DA:109,75 +DA:122,13 +DA:129,52 +DA:131,39 +DA:132,39 +DA:134,39 +DA:135,39 +DA:138,39 +DA:141,39 +DA:146,39 +DA:148,39 +DA:152,39 +DA:156,13 +DA:159,77 +DA:162,77 +DA:168,77 +DA:169,72 +DA:171,77 +DA:172,72 +DA:174,77 +DA:175,12 +DA:177,77 +DA:178,12 +DA:180,77 +DA:181,70 +DA:183,77 +DA:184,66 +DA:200,76 +DA:207,245 +DA:208,169 +DA:211,76 +DA:213,76 +DA:216,76 +DA:217,76 +DA:218,76 +DA:220,0 +DA:222,0 +DA:226,76 +DA:227,76 +DA:228,76 +DA:230,76 +DA:231,0 +DA:233,0 +DA:235,0 +DA:238,76 +DA:239,0 +DA:241,0 +DA:243,0 +DA:245,0 +DA:248,76 +DA:250,76 +DA:263,40315 +DA:270,460056 +DA:271,833774 +DA:273,419741 +DA:274,419741 +DA:277,5708 +DA:278,5708 +DA:279,5708 +DA:282,419741 +DA:285,40315 +DA:290,19 +DA:293,19 +DA:301,400 +DA:302,322 +DA:303,18 +DA:305,322 +DA:320,7 +DA:322,7 +DA:323,0 +DA:324,0 +DA:327,7 +DA:328,7 +DA:347,78 +DA:355,78 +DA:356,1 +DA:357,1 +DA:361,77 +DA:362,5 +DA:363,5 +DA:366,77 +DA:368,77 +DA:369,0 +DA:371,0 +DA:375,13 +DA:378,77 +DA:380,77 +DA:381,0 +DA:382,0 +DA:385,77 +DA:386,77 +DA:390,169 +DA:391,92 +DA:392,92 +DA:394,92 +DA:396,92 +DA:397,15 +DA:399,92 +DA:401,92 +DA:402,92 +DA:410,12 +DA:412,12 +DA:413,0 +DA:414,0 +DA:417,80 +DA:419,80 +DA:435,81 +DA:441,81 +DA:444,80 +DA:445,80 +DA:448,308 +DA:449,228 +DA:450,0 +DA:451,0 +DA:454,80 +DA:456,80 +DA:471,76 +DA:475,76 +DA:478,76 +DA:481,76 +DA:483,76 +DA:486,76 +DA:488,76 +DA:489,0 +DA:490,0 +DA:493,76 +DA:496,76 +DA:497,0 +DA:498,0 +DA:501,152 +DA:503,76 +DA:504,0 +DA:505,0 +DA:508,76 +DA:510,76 +DA:511,76 +DA:514,76 +DA:516,76 +DA:519,24 +DA:522,24 +DA:525,24 +DA:526,1 +DA:527,1 +DA:530,23 +DA:532,23 +DA:533,0 +DA:534,0 +DA:537,23 +DA:539,23 +DA:540,0 +DA:541,0 +DA:542,0 +DA:545,39 +DA:546,29 +DA:547,13 +DA:548,13 +DA:551,16 +DA:554,10 +DA:555,10 +DA:569,0 +DA:572,0 +DA:576,0 +DA:584,0 +DA:585,0 +DA:586,0 +DA:589,0 +DA:590,0 +DA:591,0 +DA:604,4 +DA:607,4 +DA:611,4 +DA:619,4 +DA:620,4 +DA:621,4 +DA:625,4 +DA:626,4 +DA:627,4 +DA:641,34 +DA:644,34 +DA:648,34 +DA:656,34 +DA:657,34 +DA:658,34 +DA:663,34 +DA:664,34 +DA:665,34 +DA:668,34 +DA:669,34 +DA:670,34 +DA:681,0 +DA:683,0 +DA:688,0 +DA:689,0 +DA:719,38 +DA:726,38 +DA:727,38 +DA:728,38 +DA:729,38 +DA:732,38 +DA:736,38 +DA:737,38 +DA:738,0 +DA:739,0 +DA:740,0 +DA:741,0 +DA:744,0 +DA:747,0 +DA:748,0 +DA:751,38 +DA:752,0 +DA:753,0 +DA:757,38 +DA:758,0 +DA:759,0 +DA:763,38 +DA:764,0 +DA:765,0 +DA:766,0 +DA:769,38 +DA:772,38 +DA:775,38 +DA:776,0 +DA:777,0 +DA:778,0 +DA:782,76 +DA:783,38 +DA:785,76 +DA:786,38 +DA:788,38 +DA:789,0 +DA:790,38 +DA:791,4 +DA:793,34 +DA:795,38 +DA:797,38 +DA:802,38 +DA:803,38 +DA:805,38 +DA:817,38 +DA:821,38 +DA:823,38 +DA:828,38 +DA:829,1 +DA:830,1 +DA:833,37 +DA:839,37 +DA:840,0 +DA:841,0 +DA:845,37 +DA:850,0 +DA:851,0 +DA:852,0 +DA:854,0 +DA:857,37 +DA:858,36 +DA:860,165 +DA:861,139 +DA:867,139 +DA:872,26 +DA:873,36 +DA:874,36 +DA:876,0 +DA:879,0 +DA:881,0 +DA:883,36 +DA:884,36 +DA:885,36 +DA:887,36 +DA:888,10 +DA:890,26 +DA:894,37 +DA:896,37 +DA:908,38 +DA:916,38 +DA:919,37 +DA:922,37 +DA:925,45 +DA:926,8 +DA:932,0 +DA:936,0 +DA:937,0 +DA:943,0 +DA:947,0 +DA:948,0 +DA:958,13 +DA:961,13 +DA:965,13 +DA:967,20 +DA:968,20 +DA:969,20 +DA:972,25 +DA:973,25 +DA:974,25 +DA:978,38 +DA:981,38 +DA:982,1 +DA:983,1 +DA:986,37 +DA:989,38 +DA:992,38 +DA:995,37 +DA:998,2 +DA:1001,2 +DA:1002,1 +DA:1003,1 +DA:1006,1 +DA:1009,2 +DA:1012,2 +DA:1013,1 +DA:1014,1 +DA:1017,1 +DA:1020,5 +DA:1023,37 +DA:1024,37 +DA:1025,0 +DA:1026,0 +DA:1027,0 +DA:1032,38 +DA:1037,38 +DA:1038,1 +DA:1039,0 +DA:1040,1 +DA:1041,1 +DA:1044,37 +DA:1047,36 +DA:1051,32 +DA:1055,32 +DA:1059,0 +DA:1063,0 +DA:1068,5 +DA:1071,0 +DA:1074,0 +DA:1077,0 +DA:1078,0 +DA:1079,0 +DA:1082,0 +DA:1083,0 +DA:1085,0 +DA:1087,0 +DA:1089,0 +DA:1091,0 +DA:1093,0 +DA:1095,0 +DA:1097,0 +DA:1099,0 +DA:1101,0 +DA:1103,0 +DA:1105,0 +DA:1107,0 +DA:1110,0 +DA:1111,0 +DA:1112,0 +DA:1118,39 +DA:1123,39 +DA:1124,1 +DA:1125,1 +DA:1128,38 +DA:1129,2 +DA:1130,2 +DA:1133,38 +DA:1135,38 +DA:1136,0 +DA:1138,0 +DA:1142,38 +DA:1143,37 +DA:1145,37 +DA:1146,0 +DA:1148,0 +DA:1151,37 +DA:1154,1 +DA:1156,1 +DA:1159,37 +DA:1162,39 +DA:1165,39 +DA:1168,38 +DA:1171,38 +DA:1174,38 +DA:1177,37 +DA:1180,4 +DA:1183,4 +DA:1186,4 +DA:1189,0 +DA:1192,0 +DA:1194,0 +DA:1196,0 +DA:1198,0 +DA:1199,0 +DA:1217,27 +DA:1220,27 +DA:1223,26 +DA:1224,1 +DA:1225,1 +DA:1229,25 +DA:1230,8 +DA:1232,25 +DA:1233,4 +DA:1235,25 +DA:1236,0 +DA:1238,25 +DA:1239,4 +DA:1241,25 +DA:1242,12 +DA:1244,25 +DA:1245,1 +DA:1247,1 +DA:1248,1 +DA:1267,30 +DA:1270,30 +DA:1273,30 +DA:1274,12 +DA:1275,18 +DA:1276,18 +DA:1278,0 +DA:1280,0 +DA:1281,0 +DA:1299,1 +DA:1302,1 +DA:1305,1 +DA:1306,1 +DA:1307,0 +DA:1308,0 +DA:1310,0 +DA:1312,0 +DA:1313,0 +DA:1331,0 +DA:1349,0 +DA:1350,0 +DA:1352,0 +DA:1364,34 +DA:1369,34 +DA:1372,33 +DA:1373,1 +DA:1374,1 +DA:1377,33 +DA:1378,33 +DA:1380,33 +DA:1383,33 +DA:1385,33 +DA:1634,26 +DA:1638,26 +DA:1641,25 +DA:1642,25 +DA:1647,540 +DA:1654,540 +DA:1657,540 +DA:1658,504 +DA:1662,504 +DA:1663,0 +DA:1666,0 +DA:1669,504 +DA:1670,197 +DA:1672,197 +DA:1682,540 +DA:1692,540 +DA:1696,540 +DA:1699,540 +DA:1703,0 +DA:1706,0 +DA:1710,0 +DA:1713,0 +DA:1718,0 +DA:1725,36 +DA:1732,36 +DA:1734,36 +DA:1736,36 +DA:1737,0 +DA:1741,36 +DA:1748,36 +DA:1753,36 +DA:1757,36 +DA:1761,36 +DA:1763,36 +DA:1765,576 +DA:1766,540 +DA:1768,540 +DA:1771,540 +DA:1772,233 +DA:1775,307 +DA:1777,307 +DA:1778,0 +DA:1779,0 +DA:1780,0 +DA:1783,0 +DA:1784,0 +DA:1785,0 +DA:1788,0 +DA:1789,0 +DA:1790,0 +DA:1793,0 +DA:1794,0 +DA:1795,0 +DA:1798,0 +DA:1799,0 +DA:1800,0 +DA:1803,0 +DA:1804,0 +DA:1805,0 +DA:1808,0 +DA:1809,0 +DA:1813,0 +DA:1817,36 +DA:1818,0 +DA:1819,0 +DA:1823,36 +DA:1825,36 +DA:1826,0 +DA:1830,36 +DA:1834,36 +DA:1836,36 +DA:1851,0 +DA:1854,0 +DA:1859,0 +DA:1861,0 +DA:1863,0 +DA:1865,0 +DA:1869,0 +DA:1871,0 +DA:1872,0 +DA:1895,0 +DA:1899,0 +DA:1904,0 +DA:1906,0 +DA:1912,0 +DA:1917,0 +DA:1919,0 +DA:1924,0 +DA:1926,0 +DA:1928,0 +DA:1931,0 +DA:1933,0 +DA:1940,0 +DA:1942,0 +DA:1948,0 +DA:1951,0 +DA:1970,11 +DA:1975,11 +DA:1981,11 +DA:1982,1 +DA:1983,1 +DA:1986,10 +DA:1988,10 +DA:1989,0 +DA:1990,0 +DA:1993,10 +DA:1994,10 +DA:1996,46 +DA:1999,36 +DA:2000,0 +DA:2001,0 +DA:2002,0 +DA:2005,36 +DA:2006,0 +DA:2008,0 +DA:2009,0 +DA:2012,36 +DA:2014,36 +DA:2016,36 +DA:2019,36 +DA:2022,0 +DA:2026,0 +DA:2030,36 +DA:2034,0 +DA:2038,10 +DA:2040,10 +DA:2057,10 +DA:2059,10 +DA:2063,10 +DA:2064,9 +DA:2068,9 +DA:2069,0 +DA:2072,0 +DA:2075,9 +DA:2078,9 +DA:2080,0 +DA:2082,0 +DA:2084,9 +DA:2085,9 +DA:2087,9 +DA:2088,0 +DA:2089,0 +DA:2091,9 +DA:2093,0 +DA:2095,0 +DA:2098,9 +DA:2100,9 +DA:2112,9 +DA:2114,9 +DA:2115,1 +DA:2116,1 +DA:2119,8 +DA:2120,0 +DA:2123,0 +DA:2128,8 +DA:2129,8 +DA:2130,8 +DA:2131,8 +DA:2132,8 +DA:2133,8 +DA:2134,8 +DA:2136,8 +DA:2137,8 +DA:2139,8 +DA:2155,8 +DA:2158,8 +DA:2162,7 +DA:2163,6 +DA:2166,7 +DA:2167,7 +DA:2168,7 +DA:2169,7 +DA:2170,7 +DA:2172,39 +DA:2174,32 +DA:2175,32 +DA:2176,32 +DA:2177,32 +DA:2179,32 +DA:2180,23 +DA:2183,32 +DA:2201,37 +DA:2203,37 +DA:2209,37 +DA:2210,37 +DA:2211,36 +DA:2212,36 +DA:2215,36 +DA:2217,36 +DA:2219,0 +DA:2220,0 +DA:2222,36 +DA:2224,36 +DA:2226,36 +DA:2235,0 +DA:2238,0 +DA:2240,0 +DA:2262,5884 +DA:2269,5884 +DA:2279,5884 +DA:2280,5883 +DA:2281,5883 +DA:2295,5883 +DA:2300,5883 +DA:2302,0 +DA:2306,0 +DA:2308,0 +DA:2311,5883 +DA:2312,5883 +DA:2318,5883 +DA:2319,5883 +DA:2327,5883 +DA:2328,5883 +DA:2334,5883 +DA:2335,5883 +DA:2339,5883 +DA:2340,5883 +DA:2342,5883 +DA:2343,5883 +DA:2346,5883 +DA:2348,5883 +DA:2349,5883 +DA:2351,5883 +DA:2352,5883 +DA:2357,5883 +DA:2358,5883 +DA:2365,5883 +DA:2366,5883 +DA:2374,45860 +DA:2376,40278 +DA:2377,40278 +DA:2379,40278 +DA:2381,40278 +DA:2407,5849 +DA:2417,5849 +DA:2421,5848 +DA:2423,5848 +DA:2424,231 +DA:2427,231 +DA:2430,11252 +DA:2432,5635 +DA:2434,0 +DA:2437,0 +DA:2441,5635 +DA:2442,6 +DA:2445,6 +DA:2446,6 +DA:2450,5629 +DA:2451,5629 +DA:2453,0 +DA:2456,0 +DA:2457,0 +DA:2461,5629 +DA:2463,6 +DA:2464,3 +DA:2465,3 +DA:2466,3 +DA:2467,3 +DA:2470,5623 +DA:2472,5617 +DA:2473,3 +DA:2474,3 +DA:2475,3 +DA:2478,6 +DA:2480,6 +DA:2481,3 +DA:2482,3 +DA:2483,3 +DA:2508,5842 +DA:2518,5842 +DA:2536,5842 +DA:2537,5841 +DA:2538,5841 +DA:2539,5841 +DA:2545,5841 +DA:2548,5841 +DA:2549,5 +DA:2551,5841 +DA:2552,2 +DA:2557,5841 +DA:2558,5841 +DA:2561,5841 +DA:2562,0 +DA:2563,0 +DA:2566,5841 +DA:2567,5841 +DA:2569,5841 +DA:2573,5841 +DA:2574,5841 +DA:2576,5841 +DA:2577,231 +DA:2580,231 +DA:2584,0 +DA:2587,0 +DA:2588,0 +DA:2589,0 +DA:2596,0 +DA:2597,0 +DA:2599,0 +DA:2600,0 +DA:2601,0 +DA:2606,11224 +DA:2608,5614 +DA:2610,6 +DA:2613,6 +DA:2618,5608 +DA:2620,0 +DA:2623,0 +DA:2627,5608 +DA:2628,201 +DA:2629,201 +DA:2630,0 +DA:2633,201 +DA:2637,5608 +DA:2639,1811 +DA:2642,1811 +DA:2645,3797 +DA:2646,23940 +DA:2647,23940 +DA:2652,20143 +DA:2655,3797 +DA:2656,0 +DA:2658,0 +DA:2662,3797 +DA:2663,0 +DA:2666,3797 +DA:2669,3797 +DA:2670,3797 +DA:2672,3797 +DA:2673,3797 +DA:2677,3797 +DA:2678,4 +DA:2681,3793 +DA:2682,3780 +DA:2685,691 +DA:2686,0 +DA:2688,0 +DA:2694,691 +DA:2695,684 +DA:2696,684 +DA:2698,691 +DA:2699,691 +DA:2703,3793 +DA:2704,3780 +DA:2706,3780 +DA:2714,3780 +DA:2722,3780 +DA:2724,3089 +DA:2725,1690 +DA:2726,1674 +DA:2727,1674 +DA:2729,1690 +DA:2730,1690 +DA:2735,3780 +DA:2740,3780 +DA:2741,0 +DA:2745,0 +DA:2747,0 +DA:2751,0 +DA:2756,13 +DA:2758,13 +DA:2760,2 +DA:2761,2 +DA:2765,11 +DA:2782,4 +DA:2786,4 +DA:2789,4 +DA:2791,30 +DA:2792,26 +DA:2793,26 +DA:2795,26 +DA:2797,0 +DA:2802,26 +LF:844 +LH:598 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/offlinelogstorage/dlt_offline_logstorage_behavior.c +FN:47,dlt_logstorage_concat_logfile_name +FN:85,dlt_logstorage_log_file_name +FN:168,dlt_logstorage_sort_file_name +FN:212,dlt_logstorage_rearrange_file_name +FN:262,dlt_logstorage_get_idx_of_log_file +FN:302,dlt_logstorage_storage_dir_info +FN:490,dlt_logstorage_open_log_output_file +FN:526,dlt_logstorage_open_log_file +FN:782,dlt_logstorage_find_dlt_header +FN:808,dlt_logstorage_find_last_dlt_header +FN:834,dlt_logstorage_write_to_log +FN:856,dlt_logstorage_check_write_ret +FN:907,dlt_logstorage_close_file +FN:935,dlt_logstorage_sync_to_file +FN:1052,dlt_logstorage_prepare_on_msg +FN:1172,dlt_logstorage_write_on_msg +FN:1226,dlt_logstorage_sync_on_msg +FN:1266,dlt_logstorage_prepare_msg_cache +FN:1384,dlt_logstorage_write_msg_cache +FN:1519,dlt_logstorage_sync_msg_cache +FNDA:2,dlt_logstorage_close_file +FNDA:3299,dlt_logstorage_sync_msg_cache +FNDA:324,dlt_logstorage_open_log_file +FNDA:200,dlt_logstorage_check_write_ret +FNDA:3098,dlt_logstorage_prepare_msg_cache +FNDA:457,dlt_logstorage_get_idx_of_log_file +FNDA:321,dlt_logstorage_sort_file_name +FNDA:708,dlt_logstorage_prepare_on_msg +FNDA:86,dlt_logstorage_find_last_dlt_header +FNDA:3093,dlt_logstorage_write_msg_cache +FNDA:714,dlt_logstorage_sync_on_msg +FNDA:325,dlt_logstorage_storage_dir_info +FNDA:198,dlt_logstorage_open_log_output_file +FNDA:270,dlt_logstorage_find_dlt_header +FNDA:3,dlt_logstorage_rearrange_file_name +FNDA:693,dlt_logstorage_write_on_msg +FNDA:297,dlt_logstorage_concat_logfile_name +FNDA:187,dlt_logstorage_sync_to_file +FNDA:5,dlt_logstorage_write_to_log +FNDA:147,dlt_logstorage_log_file_name +FNF:20 +FNH:20 +DA:47,297 +DA:49,297 +DA:50,297 +DA:52,297 +DA:53,297 +DA:56,0 +DA:59,297 +DA:60,0 +DA:62,297 +DA:85,147 +DA:92,147 +DA:95,146 +DA:96,146 +DA:98,146 +DA:105,146 +DA:109,146 +DA:110,146 +DA:114,146 +DA:115,97 +DA:116,97 +DA:117,0 +DA:119,97 +DA:120,0 +DA:130,146 +DA:131,5 +DA:132,5 +DA:135,5 +DA:136,5 +DA:137,5 +DA:141,5 +DA:142,5 +DA:147,5 +DA:148,0 +DA:151,5 +DA:154,146 +DA:155,146 +DA:156,0 +DA:168,321 +DA:173,321 +DA:176,362 +DA:179,187 +DA:180,187 +DA:184,390 +DA:185,203 +DA:186,203 +DA:188,13 +DA:189,13 +DA:190,13 +DA:195,203 +DA:197,203 +DA:212,3 +DA:220,3 +DA:223,2 +DA:229,4 +DA:233,3 +DA:234,1 +DA:245,1 +DA:246,1 +DA:247,1 +DA:248,1 +DA:262,457 +DA:266,457 +DA:279,456 +DA:280,456 +DA:281,456 +DA:282,456 +DA:284,456 +DA:285,0 +DA:288,456 +DA:302,325 +DA:311,325 +DA:315,325 +DA:316,325 +DA:319,325 +DA:320,325 +DA:321,324 +DA:322,324 +DA:327,324 +DA:329,14 +DA:330,14 +DA:334,14 +DA:335,14 +DA:336,14 +DA:337,0 +DA:339,0 +DA:341,14 +DA:347,324 +DA:349,324 +DA:350,5 +DA:352,5 +DA:355,319 +DA:360,319 +DA:361,319 +DA:362,771 +DA:364,487 +DA:365,487 +DA:367,487 +DA:370,284 +DA:374,7726 +DA:375,7407 +DA:376,0 +DA:379,7407 +DA:383,7407 +DA:385,7407 +DA:387,7407 +DA:388,7407 +DA:389,1134 +DA:391,179 +DA:392,91 +DA:393,0 +DA:396,673 +DA:400,955 +DA:401,373 +DA:404,582 +DA:410,461 +DA:411,287 +DA:413,287 +DA:415,0 +DA:416,0 +DA:419,287 +DA:422,174 +DA:424,348 +DA:425,174 +DA:427,174 +DA:429,174 +DA:431,0 +DA:432,0 +DA:436,461 +DA:437,461 +DA:442,461 +DA:443,461 +DA:444,461 +DA:445,461 +DA:446,461 +DA:450,319 +DA:453,319 +DA:454,319 +DA:463,319 +DA:464,0 +DA:468,7726 +DA:469,7407 +DA:471,319 +DA:473,319 +DA:474,319 +DA:490,198 +DA:494,198 +DA:495,198 +DA:496,0 +DA:497,0 +DA:499,198 +DA:500,198 +DA:506,198 +DA:507,198 +DA:526,324 +DA:534,324 +DA:535,324 +DA:536,324 +DA:543,324 +DA:546,323 +DA:547,0 +DA:548,0 +DA:554,323 +DA:555,323 +DA:560,318 +DA:562,779 +DA:563,461 +DA:565,461 +DA:568,461 +DA:572,318 +DA:573,31 +DA:576,31 +DA:577,31 +DA:583,31 +DA:584,31 +DA:587,31 +DA:589,31 +DA:590,0 +DA:591,0 +DA:594,31 +DA:595,31 +DA:596,31 +DA:605,287 +DA:606,285 +DA:607,284 +DA:608,284 +DA:610,285 +DA:612,287 +DA:614,287 +DA:619,287 +DA:624,287 +DA:625,287 +DA:626,122 +DA:627,167 +DA:628,167 +DA:635,120 +DA:638,81 +DA:643,120 +DA:644,14 +DA:649,14 +DA:650,10 +DA:653,10 +DA:654,10 +DA:658,110 +DA:662,110 +DA:664,2 +DA:667,110 +DA:670,110 +DA:671,110 +DA:681,110 +DA:682,110 +DA:683,110 +DA:689,110 +DA:690,1 +DA:691,1 +DA:692,1 +DA:697,110 +DA:699,110 +DA:704,110 +DA:706,110 +DA:707,0 +DA:708,0 +DA:711,110 +DA:712,110 +DA:713,110 +DA:715,110 +DA:718,110 +DA:719,102 +DA:722,69 +DA:727,69 +DA:728,69 +DA:732,69 +DA:733,0 +DA:735,69 +DA:736,69 +DA:737,69 +DA:739,69 +DA:749,308 +DA:751,0 +DA:752,0 +DA:753,0 +DA:754,0 +DA:756,0 +DA:757,0 +DA:760,0 +DA:761,0 +DA:762,0 +DA:765,0 +DA:766,0 +DA:782,270 +DA:786,270 +DA:787,270 +DA:790,284 +DA:791,283 +DA:792,269 +DA:808,86 +DA:812,86 +DA:813,86 +DA:816,6016 +DA:817,5953 +DA:818,23 +DA:834,5 +DA:844,5 +DA:856,200 +DA:859,200 +DA:860,0 +DA:861,0 +DA:864,200 +DA:865,0 +DA:873,0 +DA:874,0 +DA:879,200 +DA:885,200 +DA:886,0 +DA:889,200 +DA:891,0 +DA:892,0 +DA:907,2 +DA:916,183 +DA:917,283 +DA:918,283 +DA:920,2 +DA:935,187 +DA:948,187 +DA:949,186 +DA:951,1 +DA:952,1 +DA:955,186 +DA:960,2 +DA:961,186 +DA:963,186 +DA:965,0 +DA:966,0 +DA:969,186 +DA:973,184 +DA:975,184 +DA:978,84 +DA:980,84 +DA:982,84 +DA:983,84 +DA:985,84 +DA:986,22 +DA:988,22 +DA:989,22 +DA:992,0 +DA:993,22 +DA:995,22 +DA:996,22 +DA:1001,0 +DA:1002,62 +DA:1006,184 +DA:1007,184 +DA:1009,184 +DA:1012,184 +DA:1014,84 +DA:1017,0 +DA:1018,0 +DA:1021,84 +DA:1027,178 +DA:1028,178 +DA:1030,178 +DA:1031,178 +DA:1034,178 +DA:1036,178 +DA:1052,708 +DA:1061,708 +DA:1062,707 +DA:1063,1 +DA:1064,1 +DA:1071,707 +DA:1074,16 +DA:1075,2 +DA:1076,2 +DA:1077,1 +DA:1078,1 +DA:1080,2 +DA:1084,16 +DA:1092,691 +DA:1094,691 +DA:1101,688 +DA:1102,653 +DA:1103,653 +DA:1106,35 +DA:1108,35 +DA:1109,0 +DA:1110,0 +DA:1111,0 +DA:1116,35 +DA:1117,0 +DA:1118,0 +DA:1124,0 +DA:1127,35 +DA:1128,35 +DA:1129,35 +DA:1130,35 +DA:1131,35 +DA:1133,35 +DA:1136,35 +DA:1148,3 +DA:1172,693 +DA:1184,693 +DA:1185,692 +DA:1190,692 +DA:1192,692 +DA:1193,0 +DA:1195,692 +DA:1196,692 +DA:1197,0 +DA:1199,692 +DA:1200,692 +DA:1201,0 +DA:1211,692 +DA:1226,714 +DA:1234,714 +DA:1237,713 +DA:1238,692 +DA:1244,692 +DA:1245,0 +DA:1266,3098 +DA:1272,3098 +DA:1273,3097 +DA:1282,3097 +DA:1283,1675 +DA:1284,1674 +DA:1285,1674 +DA:1286,0 +DA:1287,0 +DA:1289,1675 +DA:1290,1 +DA:1291,1 +DA:1300,3097 +DA:1301,452 +DA:1302,0 +DA:1303,0 +DA:1309,3097 +DA:1310,452 +DA:1311,452 +DA:1313,0 +DA:1316,0 +DA:1319,3097 +DA:1324,29 +DA:1327,4 +DA:1331,25 +DA:1335,29 +DA:1336,29 +DA:1339,5 +DA:1342,5 +DA:1344,24 +DA:1351,24 +DA:1353,24 +DA:1355,0 +DA:1361,24 +DA:1384,3093 +DA:1401,3093 +DA:1402,3092 +DA:1403,3092 +DA:1408,3092 +DA:1411,452 +DA:1415,2640 +DA:1418,3092 +DA:1419,3092 +DA:1420,3092 +DA:1422,3092 +DA:1424,2824 +DA:1425,2824 +DA:1426,2824 +DA:1427,1510 +DA:1431,2824 +DA:1432,2824 +DA:1433,2824 +DA:1434,2824 +DA:1435,2824 +DA:1443,3092 +DA:1446,268 +DA:1448,0 +DA:1449,0 +DA:1453,268 +DA:1456,62 +DA:1460,62 +DA:1462,0 +DA:1463,0 +DA:1466,206 +DA:1470,102 +DA:1474,102 +DA:1476,0 +DA:1477,0 +DA:1480,104 +DA:1481,52 +DA:1482,52 +DA:1485,104 +DA:1488,268 +DA:1491,268 +DA:1492,268 +DA:1493,268 +DA:1496,268 +DA:1497,268 +DA:1498,268 +DA:1499,268 +DA:1500,268 +DA:1519,3299 +DA:1528,3299 +DA:1534,3298 +DA:1536,177 +DA:1538,0 +DA:1540,0 +DA:1543,177 +DA:1546,102 +DA:1550,75 +DA:1553,177 +DA:1556,177 +DA:1559,169 +DA:1563,8 +DA:1564,0 +DA:1568,0 +DA:1570,0 +DA:1571,0 +DA:1578,8 +DA:1580,8 +DA:1581,8 +DA:1586,177 +DA:1587,177 +DA:1590,164 +DA:1594,177 +DA:1597,0 +DA:1598,62 +LF:484 +LH:404 +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:1638,dlt_file_read_raw +FN:1714,dlt_file_close +FN:1729,dlt_file_message +FN:1765,dlt_file_free +FN:1787,dlt_log_set_level +FN:1800,dlt_log_set_filename +FN:1813,dlt_log_set_fifo_basedir +FN:1828,dlt_print_with_attributes +FN:1833,dlt_log_init +FN:1838,dlt_log_init_multiple_logfiles_support +FN:1866,dlt_log_init_single_logfile +FN:1879,dlt_log_init_multiple_logfiles +FN:1914,dlt_log_free +FN:1925,dlt_log_free_single_logfile +FN:1931,dlt_log_free_multiple_logfiles +FN:1939,dlt_user_printf +FN:1966,dlt_log +FN:2042,dlt_vlog +FN:2063,dlt_vnlog +FN:2090,dlt_receiver_init +FN:2127,dlt_receiver_init_global_buffer +FN:2155,dlt_receiver_free +FN:2174,dlt_receiver_free_global_buffer +FN:2190,dlt_receiver_receive +FN:2243,dlt_receiver_remove +FN:2263,dlt_receiver_move_to_begin +FN:2285,dlt_receiver_check_and_get +FN:2319,dlt_set_storageheader +FN:2355,dlt_check_rcv_data_size +FN:2366,dlt_check_storageheader +FN:2378,dlt_buffer_init_static_server +FN:2409,dlt_buffer_init_static_client +FN:2431,dlt_buffer_init_dynamic +FN:2491,dlt_buffer_free_static +FN:2506,dlt_buffer_free_dynamic +FN:2525,dlt_buffer_write_block +FN:2556,dlt_buffer_read_block +FN:2582,dlt_buffer_check_size +FN:2593,dlt_buffer_increase_size +FN:2659,dlt_buffer_minimize_size +FN:2706,dlt_buffer_reset +FN:2729,dlt_buffer_push +FN:2734,dlt_buffer_push3 +FN:2825,dlt_buffer_get +FN:2945,dlt_buffer_pull +FN:2950,dlt_buffer_copy +FN:2955,dlt_buffer_remove +FN:2960,dlt_buffer_info +FN:2973,dlt_buffer_status +FN:2996,dlt_buffer_get_total_size +FN:3005,dlt_buffer_get_used_size +FN:3030,dlt_buffer_get_message_count +FN:3045,dlt_setup_serial +FN:3112,dlt_convert_serial_speed +FN:3285,dlt_get_version +FN:3310,dlt_get_major_version +FN:3320,dlt_get_minor_version +FN:3331,dlt_uptime +FN:3350,dlt_message_print_header +FN:3362,dlt_message_print_hex +FN:3378,dlt_message_print_ascii +FN:3394,dlt_message_print_mixed_plain +FN:3410,dlt_message_print_mixed_html +FN:3427,dlt_message_argument_print +FN:4075,dlt_check_envvar +FN:4119,dlt_set_loginfo_parse_service_id +FN:4147,dlt_getloginfo_conv_ascii_to_uint16_t +FN:4168,dlt_getloginfo_conv_ascii_to_int16_t +FN:4187,dlt_getloginfo_conv_ascii_to_string +FN:4201,dlt_getloginfo_conv_ascii_to_id +FN:4223,dlt_hex_ascii_to_binary +FN:4273,dlt_file_quick_parsing +FN:4349,dlt_execute_command +FN:4415,get_filename_ext +FN:4426,dlt_extract_base_name_without_ext +FN:4439,dlt_log_multiple_files_write +FN:4449,dlt_is_log_in_multiple_files_active +FNDA:9,dlt_receiver_free_global_buffer +FNDA:6207,dlt_strnlen_s +FNDA:6301,dlt_uptime +FNDA:2965,dlt_file_read +FNDA:19,dlt_log_set_level +FNDA:12,dlt_getloginfo_conv_ascii_to_int16_t +FNDA:9,dlt_get_major_version +FNDA:0,dlt_print_with_attributes +FNDA:12,dlt_filter_add +FNDA:2,dlt_buffer_info +FNDA:3551,dlt_message_argument_print +FNDA:6,dlt_file_set_filter +FNDA:9,dlt_receiver_init_global_buffer +FNDA:1661,dlt_print_char_string +FNDA:9,dlt_buffer_reset +FNDA:6,dlt_filter_load +FNDA:3,dlt_file_quick_parsing +FNDA:12,dlt_filter_find +FNDA:7410,dlt_message_get_extraparameters +FNDA:1,dlt_filter_free +FNDA:15284,dlt_buffer_push3 +FNDA:328,dlt_message_print_hex +FNDA:5,get_filename_ext +FNDA:7,dlt_buffer_increase_size +FNDA:53,dlt_buffer_read_block +FNDA:5317,dlt_message_header_flags +FNDA:0,dlt_file_read_header_raw +FNDA:0,dlt_buffer_init_static_server +FNDA:1709,dlt_receiver_receive +FNDA:8528,dlt_buffer_get_message_count +FNDA:5544,dlt_buffer_free_dynamic +FNDA:7516,dlt_buffer_push +FNDA:0,dlt_filter_delete +FNDA:6127,dlt_message_init +FNDA:9,dlt_check_rcv_data_size +FNDA:0,dlt_setup_serial +FNDA:328,dlt_message_print_header +FNDA:0,dlt_buffer_free_static +FNDA:12,dlt_log_init +FNDA:5448,dlt_log_set_fifo_basedir +FNDA:4070,dlt_file_read_data +FNDA:126,dlt_message_free +FNDA:1931922,dlt_vlog +FNDA:5481,dlt_receiver_init +FNDA:2,dlt_log_free_single_logfile +FNDA:37,dlt_is_log_in_multiple_files_active +FNDA:4700,dlt_file_read_header_extended +FNDA:17,dlt_log_set_filename +FNDA:6,dlt_extract_base_name_without_ext +FNDA:6247,dlt_message_set_extraparameters +FNDA:2852,dlt_user_printf +FNDA:69,dlt_file_free +FNDA:2503,dlt_buffer_get_used_size +FNDA:22,dlt_get_version +FNDA:2,dlt_set_loginfo_parse_service_id +FNDA:15,dlt_log_free +FNDA:6979,dlt_check_storageheader +FNDA:2,dlt_buffer_status +FNDA:2733,dlt_print_hex_string_delim +FNDA:8,dlt_buffer_pull +FNDA:8,dlt_buffer_minimize_size +FNDA:2615,dlt_message_header +FNDA:328,dlt_message_print_mixed_html +FNDA:1549,dlt_clean_string +FNDA:54623,dlt_set_id +FNDA:7,dlt_filter_init +FNDA:328,dlt_message_print_mixed_plain +FNDA:3,dlt_log_free_multiple_logfiles +FNDA:41031,dlt_buffer_write_block +FNDA:1703,dlt_receiver_move_to_begin +FNDA:13,dlt_buffer_copy +FNDA:3326,dlt_message_payload +FNDA:5480,dlt_receiver_free +FNDA:12,dlt_log_multiple_files_write +FNDA:9,dlt_get_minor_version +FNDA:5570,dlt_buffer_init_dynamic +FNDA:67,dlt_file_open +FNDA:742,dlt_message_filter_check +FNDA:11,dlt_getloginfo_conv_ascii_to_string +FNDA:5433,dlt_vnlog +FNDA:5439,dlt_check_envvar +FNDA:14,dlt_getloginfo_conv_ascii_to_uint16_t +FNDA:0,dlt_file_read_raw +FNDA:0,dlt_hex_ascii_to_binary +FNDA:133,dlt_receiver_check_and_get +FNDA:71,dlt_file_init +FNDA:3965,dlt_file_message +FNDA:0,dlt_buffer_init_static_client +FNDA:0,dlt_execute_command +FNDA:12103,dlt_set_storageheader +FNDA:328,dlt_message_print_ascii +FNDA:7035,dlt_file_read_header +FNDA:2724,dlt_print_hex_string +FNDA:3,dlt_buffer_get_total_size +FNDA:64,dlt_buffer_get +FNDA:4,dlt_log_init_single_logfile +FNDA:0,dlt_file_close +FNDA:1917449,dlt_log +FNDA:6205,dlt_print_id +FNDA:26,dlt_log_init_multiple_logfiles_support +FNDA:0,dlt_filter_save +FNDA:6671,dlt_message_read +FNDA:7,dlt_buffer_remove +FNDA:859,dlt_buffer_check_size +FNDA:4,dlt_log_init_multiple_logfiles +FNDA:6097,dlt_receiver_remove +FNDA:20,dlt_getloginfo_conv_ascii_to_id +FNDA:0,dlt_print_hex +FNDA:0,dlt_convert_serial_speed +FNDA:1062,dlt_print_mixed_string +FNF:110 +FNH:96 +DA:124,0 +DA:128,0 +DA:131,0 +DA:132,0 +DA:133,0 +DA:135,0 +DA:139,2733 +DA:143,2733 +DA:147,2730 +DA:148,0 +DA:151,0 +DA:154,36449 +DA:155,33719 +DA:156,31017 +DA:157,31017 +DA:160,33719 +DA:161,33719 +DA:167,2724 +DA:169,2724 +DA:172,1062 +DA:177,1062 +DA:181,1056 +DA:182,528 +DA:185,528 +DA:189,528 +DA:192,528 +DA:197,1056 +DA:198,0 +DA:201,0 +DA:205,1728 +DA:208,672 +DA:210,672 +DA:211,0 +DA:213,672 +DA:218,672 +DA:219,672 +DA:222,672 +DA:225,672 +DA:230,672 +DA:235,672 +DA:236,336 +DA:237,336 +DA:240,336 +DA:241,336 +DA:246,1056 +DA:248,1056 +DA:251,984 +DA:253,984 +DA:254,0 +DA:256,984 +DA:261,984 +DA:263,984 +DA:266,984 +DA:268,9450 +DA:269,8466 +DA:270,8466 +DA:273,984 +DA:274,984 +DA:279,984 +DA:282,0 +DA:288,1661 +DA:292,1661 +DA:295,1658 +DA:296,0 +DA:299,0 +DA:302,19729 +DA:303,18071 +DA:304,10240 +DA:308,7831 +DA:309,7831 +DA:311,0 +DA:314,18071 +DA:320,6207 +DA:322,6207 +DA:325,27721 +DA:326,24857 +DA:327,3342 +DA:332,6205 +DA:335,6205 +DA:341,6202 +DA:343,6202 +DA:348,54623 +DA:351,54623 +DA:354,54620 +DA:355,54620 +DA:356,54620 +DA:357,48081 +DA:359,54620 +DA:360,38199 +DA:364,38199 +DA:365,38193 +DA:369,38193 +DA:370,38185 +DA:374,38185 +DA:375,38008 +DA:380,1549 +DA:384,1549 +DA:387,13405 +DA:388,11856 +DA:389,0 +DA:392,7 +DA:394,7 +DA:396,7 +DA:399,7 +DA:401,7 +DA:404,1 +DA:406,1 +DA:408,1 +DA:409,0 +DA:414,6 +DA:416,6 +DA:423,6 +DA:425,6 +DA:427,6 +DA:428,0 +DA:429,0 +DA:436,6 +DA:438,18 +DA:439,18 +DA:441,18 +DA:444,12 +DA:449,12 +DA:450,0 +DA:452,12 +DA:454,12 +DA:456,12 +DA:459,12 +DA:464,12 +DA:465,0 +DA:467,12 +DA:469,12 +DA:470,12 +DA:472,0 +DA:477,6 +DA:479,6 +DA:482,0 +DA:484,0 +DA:491,0 +DA:493,0 +DA:495,0 +DA:496,0 +DA:497,0 +DA:500,0 +DA:501,0 +DA:505,0 +DA:509,0 +DA:513,0 +DA:518,0 +DA:520,0 +DA:523,12 +DA:528,12 +DA:530,12 +DA:533,18 +DA:534,6 +DA:536,0 +DA:539,0 +DA:541,0 +DA:542,0 +DA:543,0 +DA:544,0 +DA:545,0 +DA:547,0 +DA:549,0 +DA:550,0 +DA:551,0 +DA:552,0 +DA:559,12 +DA:562,12 +DA:564,12 +DA:567,12 +DA:568,0 +DA:571,0 +DA:575,12 +DA:577,12 +DA:578,12 +DA:579,12 +DA:580,12 +DA:581,12 +DA:583,12 +DA:585,12 +DA:591,0 +DA:597,0 +DA:599,0 +DA:602,0 +DA:604,0 +DA:605,0 +DA:606,0 +DA:607,0 +DA:608,0 +DA:609,0 +DA:615,0 +DA:619,0 +DA:620,0 +DA:621,0 +DA:622,0 +DA:623,0 +DA:625,0 +DA:626,0 +DA:627,0 +DA:628,0 +DA:629,0 +DA:630,0 +DA:633,0 +DA:634,0 +DA:641,6127 +DA:643,6127 +DA:645,6127 +DA:649,6125 +DA:650,6125 +DA:652,6125 +DA:653,6125 +DA:655,6125 +DA:656,6125 +DA:657,6125 +DA:659,6125 +DA:661,6125 +DA:664,126 +DA:666,126 +DA:668,126 +DA:672,124 +DA:673,101 +DA:674,101 +DA:675,101 +DA:681,2615 +DA:683,2615 +DA:686,5317 +DA:691,5317 +DA:693,5317 +DA:696,5121 +DA:699,5121 +DA:702,5121 +DA:704,5121 +DA:706,3021 +DA:707,3021 +DA:708,3021 +DA:709,3021 +DA:710,3021 +DA:713,5121 +DA:715,3021 +DA:716,842 +DA:718,2179 +DA:721,5121 +DA:723,3021 +DA:725,5121 +DA:727,3021 +DA:728,842 +DA:730,2179 +DA:735,5121 +DA:736,3021 +DA:738,3021 +DA:739,1590 +DA:741,1431 +DA:743,3021 +DA:746,5121 +DA:747,3021 +DA:748,1590 +DA:750,1431 +DA:752,3021 +DA:756,5121 +DA:757,2630 +DA:758,1590 +DA:759,1590 +DA:760,1590 +DA:763,2630 +DA:764,1590 +DA:765,1451 +DA:766,1451 +DA:768,1590 +DA:769,0 +DA:770,0 +DA:772,1590 +DA:773,0 +DA:774,0 +DA:776,1590 +DA:777,139 +DA:778,139 +DA:780,1590 +DA:783,2630 +DA:785,1590 +DA:786,1451 +DA:788,139 +DA:790,1590 +DA:793,2630 +DA:795,1590 +DA:798,2491 +DA:799,1431 +DA:801,2491 +DA:802,1431 +DA:804,2491 +DA:805,1431 +DA:807,2491 +DA:808,1431 +DA:814,3326 +DA:832,3326 +DA:834,3326 +DA:835,3267 +DA:838,3136 +DA:839,10 +DA:840,10 +DA:844,3126 +DA:847,3126 +DA:848,526 +DA:851,2600 +DA:852,526 +DA:854,2074 +DA:855,526 +DA:857,1548 +DA:858,1548 +DA:867,1548 +DA:869,537 +DA:870,537 +DA:872,537 +DA:873,0 +DA:875,0 +DA:876,0 +DA:880,537 +DA:881,60 +DA:882,57 +DA:884,3 +DA:885,3 +DA:887,60 +DA:888,60 +DA:891,477 +DA:895,537 +DA:896,4 +DA:897,4 +DA:899,4 +DA:900,3 +DA:902,1 +DA:904,4 +DA:905,2 +DA:909,537 +DA:910,122 +DA:911,122 +DA:915,122 +DA:917,122 +DA:918,6 +DA:919,6 +DA:922,415 +DA:925,537 +DA:934,4336 +DA:935,3325 +DA:936,2328 +DA:937,2328 +DA:941,3325 +DA:942,3325 +DA:945,3325 +DA:947,3325 +DA:948,3325 +DA:956,742 +DA:962,742 +DA:964,742 +DA:967,736 +DA:971,936 +DA:973,624 +DA:974,624 +DA:975,0 +DA:976,0 +DA:977,0 +DA:978,0 +DA:979,0 +DA:987,6671 +DA:991,6671 +DA:993,6671 +DA:997,6238 +DA:1000,6238 +DA:1004,6238 +DA:1006,0 +DA:1007,0 +DA:1008,0 +DA:1012,6238 +DA:1014,6238 +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,6238 +DA:1044,6238 +DA:1047,6238 +DA:1048,6238 +DA:1051,6238 +DA:1053,6238 +DA:1054,6238 +DA:1058,6238 +DA:1061,6238 +DA:1062,0 +DA:1065,0 +DA:1068,6238 +DA:1072,6238 +DA:1073,0 +DA:1078,6238 +DA:1079,6238 +DA:1082,6238 +DA:1083,6238 +DA:1086,6238 +DA:1087,6238 +DA:1088,6238 +DA:1089,6238 +DA:1091,0 +DA:1093,6238 +DA:1097,6238 +DA:1102,6040 +DA:1103,6027 +DA:1104,6 +DA:1105,6 +DA:1106,6 +DA:1111,13 +DA:1112,13 +DA:1115,6040 +DA:1116,0 +DA:1119,0 +DA:1123,6040 +DA:1125,6040 +DA:1128,7410 +DA:1130,7410 +DA:1132,7410 +DA:1135,7408 +DA:1136,7214 +DA:1140,7408 +DA:1141,6920 +DA:1142,6920 +DA:1143,6920 +DA:1146,7408 +DA:1147,14428 +DA:1148,7214 +DA:1149,7214 +DA:1150,7214 +DA:1156,6247 +DA:1158,6247 +DA:1160,6247 +DA:1163,6245 +DA:1164,6049 +DA:1165,6049 +DA:1168,6245 +DA:1169,5999 +DA:1170,5999 +DA:1171,5999 +DA:1172,5999 +DA:1176,6245 +DA:1177,6049 +DA:1178,12098 +DA:1179,6049 +DA:1180,6049 +DA:1181,6049 +DA:1188,71 +DA:1190,71 +DA:1192,71 +DA:1196,71 +DA:1197,71 +DA:1198,71 +DA:1199,71 +DA:1201,71 +DA:1202,71 +DA:1203,71 +DA:1205,71 +DA:1207,71 +DA:1209,71 +DA:1212,6 +DA:1214,6 +DA:1216,6 +DA:1220,6 +DA:1222,6 +DA:1225,7035 +DA:1227,7035 +DA:1229,7035 +DA:1235,14070 +DA:1238,56 +DA:1239,0 +DA:1241,56 +DA:1243,56 +DA:1247,6979 +DA:1248,6979 +DA:1252,6979 +DA:1254,0 +DA:1257,0 +DA:1258,0 +DA:1268,6979 +DA:1269,6979 +DA:1274,6979 +DA:1277,6979 +DA:1278,0 +DA:1281,0 +DA:1283,6979 +DA:1287,6979 +DA:1288,0 +DA:1295,0 +DA:1299,0 +DA:1301,0 +DA:1305,0 +DA:1307,0 +DA:1308,0 +DA:1310,0 +DA:1313,0 +DA:1320,0 +DA:1322,0 +DA:1328,0 +DA:1332,0 +DA:1339,0 +DA:1346,0 +DA:1347,0 +DA:1348,0 +DA:1350,0 +DA:1354,0 +DA:1355,0 +DA:1361,0 +DA:1366,0 +DA:1367,0 +DA:1372,0 +DA:1375,0 +DA:1376,0 +DA:1379,0 +DA:1382,0 +DA:1386,0 +DA:1387,0 +DA:1394,4700 +DA:1396,4700 +DA:1398,4700 +DA:1402,4700 +DA:1403,1920 +DA:1406,0 +DA:1407,0 +DA:1410,960 +DA:1414,4700 +DA:1418,2368 +DA:1419,2368 +DA:1422,0 +DA:1423,0 +DA:1427,2368 +DA:1428,2368 +DA:1429,2368 +DA:1430,2368 +DA:1432,0 +DA:1437,4070 +DA:1439,4070 +DA:1441,4070 +DA:1445,4070 +DA:1446,129 +DA:1447,129 +DA:1450,4070 +DA:1452,186 +DA:1453,186 +DA:1456,4070 +DA:1457,0 +DA:1460,0 +DA:1464,8140 +DA:1465,52 +DA:1466,0 +DA:1469,0 +DA:1476,67 +DA:1478,67 +DA:1480,67 +DA:1484,61 +DA:1485,61 +DA:1486,61 +DA:1487,61 +DA:1488,61 +DA:1489,61 +DA:1491,61 +DA:1492,0 +DA:1495,61 +DA:1497,61 +DA:1498,0 +DA:1499,0 +DA:1502,61 +DA:1503,0 +DA:1504,0 +DA:1507,61 +DA:1509,61 +DA:1510,0 +DA:1511,0 +DA:1514,61 +DA:1516,1 +DA:1521,2965 +DA:1526,2965 +DA:1529,2965 +DA:1530,0 +DA:1533,2965 +DA:1534,368 +DA:1536,368 +DA:1539,368 +DA:1540,312 +DA:1541,312 +DA:1544,368 +DA:1548,2965 +DA:1549,0 +DA:1551,0 +DA:1555,2965 +DA:1556,0 +DA:1559,2965 +DA:1561,56 +DA:1562,0 +DA:1565,56 +DA:1568,2909 +DA:1570,630 +DA:1572,0 +DA:1573,0 +DA:1575,0 +DA:1579,630 +DA:1582,318 +DA:1583,318 +DA:1584,318 +DA:1590,630 +DA:1592,0 +DA:1596,0 +DA:1597,0 +DA:1599,0 +DA:1605,2279 +DA:1606,2279 +DA:1609,0 +DA:1611,0 +DA:1612,0 +DA:1615,0 +DA:1616,0 +DA:1618,0 +DA:1622,2279 +DA:1623,2279 +DA:1624,2279 +DA:1630,2909 +DA:1633,2909 +DA:1635,2909 +DA:1638,0 +DA:1643,0 +DA:1644,0 +DA:1646,0 +DA:1650,0 +DA:1651,0 +DA:1653,0 +DA:1656,0 +DA:1657,0 +DA:1658,0 +DA:1661,0 +DA:1665,0 +DA:1669,0 +DA:1670,0 +DA:1673,0 +DA:1675,0 +DA:1676,0 +DA:1678,0 +DA:1682,0 +DA:1684,0 +DA:1685,0 +DA:1687,0 +DA:1690,0 +DA:1692,0 +DA:1693,0 +DA:1695,0 +DA:1699,0 +DA:1700,0 +DA:1701,0 +DA:1706,0 +DA:1709,0 +DA:1711,0 +DA:1714,0 +DA:1716,0 +DA:1718,0 +DA:1721,0 +DA:1722,0 +DA:1724,0 +DA:1726,0 +DA:1729,3965 +DA:1731,3965 +DA:1733,3965 +DA:1737,3965 +DA:1738,0 +DA:1739,0 +DA:1743,3965 +DA:1744,0 +DA:1745,0 +DA:1746,0 +DA:1750,3965 +DA:1753,3965 +DA:1756,3965 +DA:1760,3965 +DA:1762,3965 +DA:1765,69 +DA:1767,69 +DA:1769,69 +DA:1773,69 +DA:1774,54 +DA:1776,69 +DA:1779,69 +DA:1780,59 +DA:1782,69 +DA:1784,69 +DA:1787,19 +DA:1789,19 +DA:1790,0 +DA:1791,0 +DA:1793,0 +DA:1796,19 +DA:1798,19 +DA:1800,17 +DA:1803,17 +DA:1804,1 +DA:1805,1 +DA:1809,16 +DA:1813,5448 +DA:1816,5448 +DA:1817,5439 +DA:1828,0 +DA:1830,0 +DA:1831,0 +DA:1833,12 +DA:1835,12 +DA:1838,26 +DA:1841,26 +DA:1842,0 +DA:1843,0 +DA:1846,26 +DA:1848,26 +DA:1852,7 +DA:1853,4 +DA:1854,4 +DA:1855,4 +DA:1858,1 +DA:1859,1 +DA:1861,3 +DA:1862,3 +DA:1866,4 +DA:1869,4 +DA:1870,4 +DA:1872,4 +DA:1873,0 +DA:1874,0 +DA:1879,4 +DA:1883,4 +DA:1885,4 +DA:1886,4 +DA:1889,4 +DA:1891,4 +DA:1893,4 +DA:1895,3 +DA:1896,3 +DA:1898,3 +DA:1908,3 +DA:1914,15 +DA:1916,15 +DA:1917,5 +DA:1918,3 +DA:1920,2 +DA:1923,15 +DA:1925,2 +DA:1927,2 +DA:1928,2 +DA:1929,2 +DA:1931,3 +DA:1933,3 +DA:1936,3 +DA:1939,2852 +DA:1941,2852 +DA:1944,2852 +DA:1948,2852 +DA:1949,8 +DA:1954,8 +DA:1955,8 +DA:1956,2844 +DA:1957,2844 +DA:1958,2844 +DA:1961,2852 +DA:1963,2852 +DA:1966,1917449 +DA:1975,1917449 +DA:1978,1917448 +DA:1981,1916513 +DA:1984,1916513 +DA:1986,1916513 +DA:1987,513 +DA:1989,1026 +DA:1990,513 +DA:1991,513 +DA:1993,513 +DA:1995,513 +DA:1996,513 +DA:1997,1915963 +DA:1999,3831926 +DA:2000,1915963 +DA:2001,1915963 +DA:2003,1915963 +DA:2006,0 +DA:2009,0 +DA:2010,0 +DA:2012,0 +DA:2013,0 +DA:2015,0 +DA:2017,0 +DA:2019,0 +DA:2020,32 +DA:2023,32 +DA:2024,24 +DA:2025,12 +DA:2027,20 +DA:2028,40 +DA:2029,20 +DA:2030,20 +DA:2042,1931922 +DA:2044,1931922 +DA:2048,1931922 +DA:2051,1931922 +DA:2054,1911006 +DA:2056,1911006 +DA:2058,1911006 +DA:2060,1911006 +DA:2063,5433 +DA:2069,5433 +DA:2072,5433 +DA:2075,5433 +DA:2078,5433 +DA:2080,5433 +DA:2082,5433 +DA:2084,5433 +DA:2087,5433 +DA:2090,5481 +DA:2092,5481 +DA:2095,5481 +DA:2096,5481 +DA:2101,5481 +DA:2102,0 +DA:2103,0 +DA:2106,5481 +DA:2107,5481 +DA:2108,5481 +DA:2109,5481 +DA:2110,5481 +DA:2111,5481 +DA:2112,5481 +DA:2113,5481 +DA:2116,5481 +DA:2117,0 +DA:2118,0 +DA:2121,5481 +DA:2124,5481 +DA:2127,9 +DA:2129,9 +DA:2132,9 +DA:2136,9 +DA:2138,9 +DA:2142,9 +DA:2143,9 +DA:2144,9 +DA:2145,9 +DA:2146,9 +DA:2147,9 +DA:2148,9 +DA:2149,9 +DA:2150,9 +DA:2152,9 +DA:2155,5480 +DA:2158,5480 +DA:2161,5480 +DA:2162,5478 +DA:2164,5480 +DA:2165,0 +DA:2167,5480 +DA:2168,5480 +DA:2169,5480 +DA:2171,5480 +DA:2174,9 +DA:2177,9 +DA:2180,9 +DA:2181,0 +DA:2183,9 +DA:2184,9 +DA:2185,9 +DA:2187,9 +DA:2190,1709 +DA:2194,1709 +DA:2197,1709 +DA:2200,1708 +DA:2201,1708 +DA:2203,1708 +DA:2204,0 +DA:2205,0 +DA:2206,0 +DA:2209,1708 +DA:2211,422 +DA:2212,422 +DA:2213,422 +DA:2215,1286 +DA:2217,1286 +DA:2218,1286 +DA:2219,1286 +DA:2223,0 +DA:2224,0 +DA:2225,0 +DA:2226,0 +DA:2228,0 +DA:2232,1708 +DA:2233,7 +DA:2234,7 +DA:2237,1701 +DA:2238,1701 +DA:2240,1701 +DA:2243,6097 +DA:2245,6097 +DA:2248,6140 +DA:2251,6140 +DA:2252,0 +DA:2253,0 +DA:2254,0 +DA:2257,6140 +DA:2258,263 +DA:2260,6097 +DA:2263,1703 +DA:2265,1703 +DA:2268,1703 +DA:2271,1703 +DA:2272,0 +DA:2274,0 +DA:2275,0 +DA:2279,0 +DA:2285,133 +DA:2290,133 +DA:2293,133 +DA:2294,88 +DA:2296,133 +DA:2297,133 +DA:2298,133 +DA:2304,133 +DA:2305,88 +DA:2309,133 +DA:2310,0 +DA:2311,0 +DA:2312,0 +DA:2316,133 +DA:2319,12103 +DA:2326,12103 +DA:2333,12103 +DA:2337,12103 +DA:2338,12103 +DA:2339,12103 +DA:2340,12103 +DA:2342,12103 +DA:2348,12103 +DA:2349,12103 +DA:2352,12103 +DA:2355,9 +DA:2358,9 +DA:2359,1 +DA:2363,9 +DA:2366,6979 +DA:2368,6979 +DA:2371,13958 +DA:2372,6979 +DA:2373,6979 +DA:2374,6979 +DA:2375,13958 +DA:2378,0 +DA:2380,0 +DA:2386,0 +DA:2387,0 +DA:2388,0 +DA:2389,0 +DA:2393,0 +DA:2394,0 +DA:2395,0 +DA:2396,0 +DA:2397,0 +DA:2400,0 +DA:2402,0 +DA:2404,0 +DA:2406,0 +DA:2409,0 +DA:2411,0 +DA:2415,0 +DA:2416,0 +DA:2417,0 +DA:2418,0 +DA:2421,0 +DA:2422,0 +DA:2424,0 +DA:2428,0 +DA:2431,5570 +DA:2437,5570 +DA:2441,5562 +DA:2444,5555 +DA:2447,5555 +DA:2451,5555 +DA:2452,5555 +DA:2453,5555 +DA:2456,5555 +DA:2458,5555 +DA:2459,0 +DA:2462,0 +DA:2467,5555 +DA:2468,5555 +DA:2469,5555 +DA:2470,5555 +DA:2472,5555 +DA:2473,0 +DA:2476,0 +DA:2479,5555 +DA:2481,5555 +DA:2486,5555 +DA:2488,5555 +DA:2491,0 +DA:2494,0 +DA:2497,0 +DA:2499,0 +DA:2500,0 +DA:2506,5544 +DA:2509,5544 +DA:2512,5543 +DA:2514,0 +DA:2515,0 +DA:2518,5543 +DA:2519,5543 +DA:2520,5543 +DA:2522,5543 +DA:2525,41031 +DA:2528,41031 +DA:2529,40012 +DA:2530,40012 +DA:2532,40011 +DA:2533,40011 +DA:2539,1 +DA:2541,1 +DA:2542,1 +DA:2543,1 +DA:2548,0 +DA:2552,1019 +DA:2554,41031 +DA:2556,53 +DA:2559,53 +DA:2560,37 +DA:2562,35 +DA:2563,35 +DA:2569,2 +DA:2571,1 +DA:2572,1 +DA:2573,1 +DA:2578,16 +DA:2580,53 +DA:2582,859 +DA:2584,859 +DA:2587,859 +DA:2588,0 +DA:2593,7 +DA:2599,7 +DA:2600,1 +DA:2601,1 +DA:2605,6 +DA:2610,6 +DA:2615,6 +DA:2617,6 +DA:2618,0 +DA:2621,0 +DA:2625,6 +DA:2628,6 +DA:2629,4 +DA:2630,4 +DA:2631,4 +DA:2632,4 +DA:2635,2 +DA:2636,2 +DA:2637,2 +DA:2638,2 +DA:2639,2 +DA:2643,6 +DA:2646,6 +DA:2647,6 +DA:2648,6 +DA:2650,6 +DA:2656,6 +DA:2659,8 +DA:2664,8 +DA:2665,1 +DA:2666,1 +DA:2669,7 +DA:2674,0 +DA:2676,0 +DA:2677,0 +DA:2680,0 +DA:2684,0 +DA:2687,0 +DA:2688,0 +DA:2689,0 +DA:2692,0 +DA:2693,0 +DA:2694,0 +DA:2696,0 +DA:2701,0 +DA:2703,0 +DA:2706,9 +DA:2709,9 +DA:2710,1 +DA:2711,1 +DA:2714,8 +DA:2716,8 +DA:2719,8 +DA:2720,8 +DA:2721,8 +DA:2724,8 +DA:2726,8 +DA:2729,7516 +DA:2731,7516 +DA:2734,15284 +DA:2747,15284 +DA:2750,15216 +DA:2752,0 +DA:2753,0 +DA:2757,15216 +DA:2758,15216 +DA:2759,15216 +DA:2762,15216 +DA:2763,0 +DA:2766,0 +DA:2767,0 +DA:2771,15216 +DA:2772,0 +DA:2773,15216 +DA:2776,15216 +DA:2779,15220 +DA:2781,4 +DA:2787,4 +DA:2788,4 +DA:2791,4 +DA:2792,0 +DA:2793,4 +DA:2796,4 +DA:2802,15216 +DA:2803,15216 +DA:2806,15216 +DA:2808,15216 +DA:2809,15216 +DA:2811,15216 +DA:2812,7702 +DA:2814,15216 +DA:2815,1877 +DA:2818,15216 +DA:2819,15216 +DA:2821,15216 +DA:2825,64 +DA:2829,64 +DA:2833,64 +DA:2836,47 +DA:2838,0 +DA:2839,0 +DA:2843,47 +DA:2844,47 +DA:2845,47 +DA:2848,47 +DA:2849,3 +DA:2852,3 +DA:2853,3 +DA:2857,44 +DA:2858,22 +DA:2859,1 +DA:2862,1 +DA:2865,22 +DA:2869,22 +DA:2870,21 +DA:2872,1 +DA:2875,22 +DA:2876,1 +DA:2879,1 +DA:2880,1 +DA:2884,21 +DA:2887,21 +DA:2888,1 +DA:2889,1 +DA:2890,1 +DA:2893,20 +DA:2894,0 +DA:2895,0 +DA:2896,0 +DA:2900,20 +DA:2901,1 +DA:2904,1 +DA:2905,1 +DA:2909,19 +DA:2910,1 +DA:2916,19 +DA:2918,14 +DA:2920,14 +DA:2922,3 +DA:2925,5 +DA:2927,5 +DA:2928,5 +DA:2930,0 +DA:2934,19 +DA:2935,8 +DA:2937,8 +DA:2939,5 +DA:2942,19 +DA:2945,8 +DA:2947,8 +DA:2950,13 +DA:2952,13 +DA:2955,7 +DA:2957,7 +DA:2960,2 +DA:2963,2 +DA:2964,1 +DA:2965,1 +DA:2968,1 +DA:2970,1 +DA:2973,2 +DA:2978,2 +DA:2979,1 +DA:2980,1 +DA:2984,1 +DA:2987,1 +DA:2988,1 +DA:2989,1 +DA:2991,1 +DA:2996,3 +DA:2999,3 +DA:3002,2 +DA:3005,2503 +DA:3010,2503 +DA:3014,2502 +DA:3017,2502 +DA:3018,2502 +DA:3019,2502 +DA:3021,2502 +DA:3024,2501 +DA:3025,2501 +DA:3027,0 +DA:3030,8528 +DA:3033,8528 +DA:3037,8528 +DA:3040,8528 +DA:3045,0 +DA:3050,0 +DA:3053,0 +DA:3062,0 +DA:3074,0 +DA:3080,0 +DA:3086,0 +DA:3087,0 +DA:3092,0 +DA:3093,0 +DA:3098,0 +DA:3099,0 +DA:3103,0 +DA:3104,0 +DA:3112,0 +DA:3117,0 +DA:3123,0 +DA:3126,0 +DA:3128,0 +DA:3131,0 +DA:3133,0 +DA:3136,0 +DA:3138,0 +DA:3141,0 +DA:3143,0 +DA:3146,0 +DA:3148,0 +DA:3151,0 +DA:3153,0 +DA:3156,0 +DA:3158,0 +DA:3161,0 +DA:3163,0 +DA:3166,0 +DA:3168,0 +DA:3171,0 +DA:3173,0 +DA:3176,0 +DA:3178,0 +DA:3181,0 +DA:3183,0 +DA:3186,0 +DA:3188,0 +DA:3191,0 +DA:3193,0 +DA:3196,0 +DA:3198,0 +DA:3201,0 +DA:3204,0 +DA:3207,0 +DA:3209,0 +DA:3212,0 +DA:3214,0 +DA:3217,0 +DA:3219,0 +DA:3222,0 +DA:3224,0 +DA:3227,0 +DA:3229,0 +DA:3232,0 +DA:3234,0 +DA:3237,0 +DA:3239,0 +DA:3242,0 +DA:3244,0 +DA:3247,0 +DA:3249,0 +DA:3252,0 +DA:3254,0 +DA:3257,0 +DA:3259,0 +DA:3262,0 +DA:3264,0 +DA:3267,0 +DA:3270,0 +DA:3273,0 +DA:3277,0 +DA:3285,22 +DA:3287,22 +DA:3288,0 +DA:3289,0 +DA:3310,9 +DA:3312,9 +DA:3313,0 +DA:3314,0 +DA:3320,9 +DA:3322,9 +DA:3323,0 +DA:3324,0 +DA:3331,6301 +DA:3341,6301 +DA:3342,6301 +DA:3350,328 +DA:3352,328 +DA:3355,316 +DA:3357,316 +DA:3359,316 +DA:3362,328 +DA:3364,328 +DA:3367,316 +DA:3369,316 +DA:3371,316 +DA:3373,316 +DA:3375,316 +DA:3378,328 +DA:3380,328 +DA:3383,316 +DA:3385,316 +DA:3387,316 +DA:3389,316 +DA:3391,316 +DA:3394,328 +DA:3396,328 +DA:3399,316 +DA:3401,316 +DA:3403,316 +DA:3405,316 +DA:3407,316 +DA:3410,328 +DA:3412,328 +DA:3415,316 +DA:3417,316 +DA:3419,316 +DA:3422,316 +DA:3424,316 +DA:3427,3551 +DA:3437,3551 +DA:3452,3536 +DA:3453,3536 +DA:3454,3536 +DA:3455,3536 +DA:3471,3536 +DA:3472,1549 +DA:3474,1549 +DA:3475,1549 +DA:3477,1549 +DA:3480,1549 +DA:3483,0 +DA:3486,1549 +DA:3487,0 +DA:3489,0 +DA:3492,0 +DA:3494,0 +DA:3497,0 +DA:3499,0 +DA:3500,0 +DA:3501,0 +DA:3502,0 +DA:3506,0 +DA:3507,0 +DA:3510,1549 +DA:3512,1549 +DA:3515,1987 +DA:3518,112 +DA:3519,0 +DA:3521,0 +DA:3524,0 +DA:3526,0 +DA:3529,0 +DA:3531,0 +DA:3532,0 +DA:3533,0 +DA:3534,0 +DA:3538,0 +DA:3539,0 +DA:3543,112 +DA:3545,112 +DA:3548,110 +DA:3550,1875 +DA:3552,0 +DA:3553,0 +DA:3555,0 +DA:3556,0 +DA:3558,0 +DA:3561,0 +DA:3562,0 +DA:3565,0 +DA:3571,0 +DA:3572,0 +DA:3574,0 +DA:3575,0 +DA:3577,0 +DA:3580,0 +DA:3581,0 +DA:3584,0 +DA:3590,1875 +DA:3592,0 +DA:3593,0 +DA:3595,0 +DA:3598,0 +DA:3601,0 +DA:3602,0 +DA:3604,0 +DA:3607,0 +DA:3610,0 +DA:3611,0 +DA:3613,0 +DA:3619,0 +DA:3620,0 +DA:3621,0 +DA:3623,0 +DA:3627,0 +DA:3628,0 +DA:3630,0 +DA:3633,0 +DA:3634,0 +DA:3637,1875 +DA:3640,1748 +DA:3641,0 +DA:3643,0 +DA:3646,0 +DA:3647,0 +DA:3649,0 +DA:3652,0 +DA:3654,0 +DA:3657,0 +DA:3659,0 +DA:3660,0 +DA:3661,0 +DA:3662,0 +DA:3666,0 +DA:3667,0 +DA:3669,0 +DA:3674,0 +DA:3676,0 +DA:3677,0 +DA:3680,1748 +DA:3681,0 +DA:3683,0 +DA:3686,0 +DA:3687,0 +DA:3691,0 +DA:3694,0 +DA:3695,0 +DA:3696,0 +DA:3698,0 +DA:3700,0 +DA:3703,0 +DA:3704,0 +DA:3705,0 +DA:3707,0 +DA:3709,0 +DA:3712,0 +DA:3713,0 +DA:3714,0 +DA:3723,1748 +DA:3724,14 +DA:3726,14 +DA:3728,7 +DA:3730,7 +DA:3733,7 +DA:3737,7 +DA:3739,7 +DA:3742,7 +DA:3747,21 +DA:3749,21 +DA:3752,7 +DA:3754,7 +DA:3757,7 +DA:3758,7 +DA:3763,14 +DA:3765,14 +DA:3768,14 +DA:3769,14 +DA:3774,1699 +DA:3776,1699 +DA:3779,287 +DA:3781,287 +DA:3784,287 +DA:3790,1412 +DA:3792,1412 +DA:3795,1412 +DA:3801,14 +DA:3803,14 +DA:3806,7 +DA:3808,7 +DA:3811,7 +DA:3821,7 +DA:3823,7 +DA:3826,7 +DA:3836,0 +DA:3838,0 +DA:3839,0 +DA:3841,0 +DA:3844,0 +DA:3845,0 +DA:3846,0 +DA:3854,127 +DA:3857,14 +DA:3858,0 +DA:3860,0 +DA:3863,0 +DA:3864,0 +DA:3866,0 +DA:3869,0 +DA:3871,0 +DA:3874,0 +DA:3876,0 +DA:3877,0 +DA:3878,0 +DA:3879,0 +DA:3883,0 +DA:3884,0 +DA:3886,0 +DA:3891,0 +DA:3893,0 +DA:3894,0 +DA:3897,14 +DA:3898,0 +DA:3900,0 +DA:3901,0 +DA:3903,0 +DA:3906,0 +DA:3907,0 +DA:3908,0 +DA:3910,0 +DA:3912,0 +DA:3913,0 +DA:3915,0 +DA:3918,0 +DA:3919,0 +DA:3920,0 +DA:3929,7 +DA:3931,7 +DA:3936,7 +DA:3938,7 +DA:3954,7 +DA:3956,7 +DA:3961,7 +DA:3976,0 +DA:3978,0 +DA:3979,0 +DA:3981,0 +DA:3984,0 +DA:3985,0 +DA:3986,0 +DA:3994,113 +DA:3997,112 +DA:3999,112 +DA:4002,110 +DA:4004,110 +DA:4005,0 +DA:4007,0 +DA:4010,0 +DA:4012,0 +DA:4015,0 +DA:4017,0 +DA:4018,0 +DA:4019,0 +DA:4020,0 +DA:4024,0 +DA:4025,0 +DA:4028,110 +DA:4031,9 +DA:4033,9 +DA:4034,9 +DA:4036,1 +DA:4039,0 +DA:4041,0 +DA:4044,0 +DA:4046,0 +DA:4048,0 +DA:4055,3430 +DA:4056,0 +DA:4057,0 +DA:4061,3430 +DA:4062,0 +DA:4064,0 +DA:4066,0 +DA:4067,0 +DA:4075,5439 +DA:4077,5439 +DA:4079,5439 +DA:4080,0 +DA:4082,5439 +DA:4084,5439 +DA:4085,0 +DA:4087,0 +DA:4088,0 +DA:4091,5439 +DA:4093,5439 +DA:4094,0 +DA:4096,0 +DA:4097,0 +DA:4101,5439 +DA:4103,5439 +DA:4104,0 +DA:4106,5439 +DA:4117,5439 +DA:4119,2 +DA:4127,2 +DA:4133,2 +DA:4135,2 +DA:4136,2 +DA:4138,2 +DA:4139,2 +DA:4140,2 +DA:4141,2 +DA:4147,14 +DA:4149,14 +DA:4152,14 +DA:4158,14 +DA:4159,14 +DA:4160,14 +DA:4161,14 +DA:4163,14 +DA:4165,14 +DA:4168,12 +DA:4170,12 +DA:4173,12 +DA:4179,12 +DA:4180,12 +DA:4182,12 +DA:4184,12 +DA:4187,11 +DA:4189,11 +DA:4195,11 +DA:4196,11 +DA:4198,11 +DA:4201,20 +DA:4203,20 +DA:4207,20 +DA:4213,289 +DA:4214,269 +DA:4215,269 +DA:4216,269 +DA:4217,269 +DA:4223,0 +DA:4225,0 +DA:4227,0 +DA:4232,0 +DA:4233,0 +DA:4234,0 +DA:4239,0 +DA:4240,0 +DA:4243,0 +DA:4245,0 +DA:4248,0 +DA:4250,0 +DA:4255,0 +DA:4260,0 +DA:4262,0 +DA:4265,0 +DA:4269,0 +DA:4273,3 +DA:4276,3 +DA:4278,3 +DA:4280,3 +DA:4283,1 +DA:4285,1 +DA:4286,0 +DA:4287,0 +DA:4290,106 +DA:4292,105 +DA:4293,0 +DA:4296,105 +DA:4298,105 +DA:4301,105 +DA:4303,105 +DA:4306,105 +DA:4308,105 +DA:4311,105 +DA:4313,0 +DA:4315,0 +DA:4316,0 +DA:4319,105 +DA:4322,105 +DA:4327,105 +DA:4330,105 +DA:4336,105 +DA:4337,105 +DA:4339,105 +DA:4341,105 +DA:4344,1 +DA:4345,1 +DA:4349,0 +DA:4354,0 +DA:4356,0 +DA:4360,0 +DA:4362,0 +DA:4364,0 +DA:4367,0 +DA:4368,0 +DA:4370,0 +DA:4372,0 +DA:4373,0 +DA:4375,0 +DA:4378,0 +DA:4380,0 +DA:4383,0 +DA:4386,0 +DA:4387,0 +DA:4389,0 +DA:4390,0 +DA:4391,0 +DA:4394,0 +DA:4398,0 +DA:4400,0 +DA:4402,0 +DA:4406,0 +DA:4407,0 +DA:4411,0 +DA:4412,0 +DA:4415,5 +DA:4417,5 +DA:4418,0 +DA:4419,0 +DA:4422,5 +DA:4423,5 +DA:4426,6 +DA:4427,6 +DA:4429,6 +DA:4430,6 +DA:4431,5 +DA:4432,5 +DA:4434,5 +DA:4435,5 +DA:4436,5 +DA:4439,12 +DA:4441,12 +DA:4443,12 +DA:4445,12 +DA:4446,12 +DA:4447,12 +DA:4449,37 +DA:4451,37 +LF:1754 +LH:1117 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/shared/dlt_config_file_parser.c +FN:51,dlt_config_file_trim_line +FN:95,dlt_config_file_is_section_name +FN:121,dlt_config_file_set_section +FN:171,dlt_config_file_set_section_data +FN:251,dlt_config_file_get_section_name_from_string +FN:281,dlt_config_file_get_key_value +FN:321,dlt_config_file_read_line +FN:354,dlt_config_file_read_file +FN:407,dlt_config_file_find_section +FN:428,dlt_config_file_init +FN:462,dlt_config_file_release +FN:491,dlt_config_file_get_section_name +FN:504,dlt_config_file_get_num_sections +FN:518,dlt_config_file_get_value +FN:555,dlt_config_file_check_section_name_exists +FNDA:540,dlt_config_file_find_section +FNDA:40,dlt_config_file_set_section +FNDA:4,dlt_config_file_check_section_name_exists +FNDA:14,dlt_config_file_get_num_sections +FNDA:339,dlt_config_file_get_key_value +FNDA:40,dlt_config_file_get_section_name +FNDA:536,dlt_config_file_get_value +FNDA:339,dlt_config_file_set_section_data +FNDA:379,dlt_config_file_read_line +FNDA:40,dlt_config_file_get_section_name_from_string +FNDA:14,dlt_config_file_init +FNDA:40,dlt_config_file_is_section_name +FNDA:14,dlt_config_file_read_file +FNDA:14,dlt_config_file_release +FNDA:379,dlt_config_file_trim_line +FNF:15 +FNH:15 +DA:51,379 +DA:53,379 +DA:59,6683 +DA:60,6304 +DA:62,6304 +DA:63,5925 +DA:66,379 +DA:79,406 +DA:95,40 +DA:99,40 +DA:102,179 +DA:103,139 +DA:105,139 +DA:121,40 +DA:123,40 +DA:126,40 +DA:127,0 +DA:128,0 +DA:132,40 +DA:133,0 +DA:134,0 +DA:137,40 +DA:140,40 +DA:142,40 +DA:143,0 +DA:144,0 +DA:147,40 +DA:149,40 +DA:150,0 +DA:151,0 +DA:152,0 +DA:153,0 +DA:157,40 +DA:158,40 +DA:171,339 +DA:175,339 +DA:178,339 +DA:179,339 +DA:181,339 +DA:182,0 +DA:183,0 +DA:187,339 +DA:189,339 +DA:191,40 +DA:193,40 +DA:194,0 +DA:195,0 +DA:198,40 +DA:201,299 +DA:203,1589 +DA:204,1290 +DA:207,299 +DA:209,299 +DA:210,0 +DA:211,0 +DA:215,339 +DA:216,339 +DA:217,339 +DA:219,339 +DA:221,339 +DA:236,379 +DA:251,40 +DA:256,40 +DA:259,386 +DA:260,386 +DA:261,40 +DA:262,346 +DA:265,306 +DA:281,339 +DA:287,339 +DA:290,339 +DA:292,339 +DA:294,339 +DA:299,339 +DA:301,339 +DA:303,339 +DA:308,339 +DA:321,379 +DA:323,379 +DA:333,40 +DA:336,40 +DA:340,339 +DA:341,0 +DA:354,14 +DA:357,14 +DA:358,14 +DA:359,14 +DA:364,434 +DA:365,406 +DA:368,27 +DA:369,27 +DA:372,379 +DA:375,379 +DA:377,379 +DA:378,40 +DA:381,40 +DA:385,339 +DA:387,339 +DA:388,339 +DA:391,0 +DA:392,0 +DA:396,14 +DA:407,540 +DA:412,540 +DA:413,0 +DA:414,0 +DA:417,2490 +DA:418,2486 +DA:420,2486 +DA:421,536 +DA:428,14 +DA:433,14 +DA:434,0 +DA:435,0 +DA:438,14 +DA:440,14 +DA:441,0 +DA:442,0 +DA:445,14 +DA:448,14 +DA:449,0 +DA:450,0 +DA:451,0 +DA:454,14 +DA:457,14 +DA:459,14 +DA:462,14 +DA:466,14 +DA:467,14 +DA:469,54 +DA:470,40 +DA:471,40 +DA:472,40 +DA:474,40 +DA:475,40 +DA:477,379 +DA:479,339 +DA:480,339 +DA:481,339 +DA:482,339 +DA:486,14 +DA:487,14 +DA:489,14 +DA:491,40 +DA:495,40 +DA:498,40 +DA:499,40 +DA:501,40 +DA:504,14 +DA:506,14 +DA:513,14 +DA:515,14 +DA:518,536 +DA:526,536 +DA:532,536 +DA:534,536 +DA:537,536 +DA:539,536 +DA:541,3465 +DA:542,3264 +DA:543,335 +DA:544,335 +DA:547,2929 +DA:551,201 +DA:552,201 +DA:555,4 +DA:560,4 +DA:563,4 +DA:564,4 +DA:565,4 +LF:170 +LH:142 +end_of_record +TN: +SF:/home/runner/work/dlt-daemon/dlt-daemon/src/shared/dlt_multiple_files.c +FN:43,multiple_files_buffer_storage_dir_info +FN:117,multiple_files_buffer_file_name +FN:133,multiple_files_buffer_get_idx_of_log_file +FN:147,multiple_files_buffer_create_new_file +FN:225,multiple_files_buffer_get_total_size +FN:268,multiple_files_buffer_delete_oldest_file +FN:346,multiple_files_buffer_check_size +FN:377,multiple_files_buffer_open_file_for_append +FN:407,multiple_files_buffer_init +FN:439,multiple_files_buffer_rotate_file +FN:455,multiple_files_buffer_write_chunk +FN:473,multiple_files_buffer_write +FN:485,multiple_files_buffer_free +FNDA:12,multiple_files_buffer_check_size +FNDA:9,multiple_files_buffer_create_new_file +FNDA:9,multiple_files_buffer_file_name +FNDA:12,multiple_files_buffer_write +FNDA:21,multiple_files_buffer_get_total_size +FNDA:3,multiple_files_buffer_free +FNDA:3,multiple_files_buffer_open_file_for_append +FNDA:12,multiple_files_buffer_write_chunk +FNDA:12,multiple_files_buffer_storage_dir_info +FNDA:9,multiple_files_buffer_delete_oldest_file +FNDA:3,multiple_files_buffer_init +FNDA:53,multiple_files_buffer_get_idx_of_log_file +FNDA:12,multiple_files_buffer_rotate_file +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,434 +DA:62,422 +DA:64,422 +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,434 +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,779 +DA:246,758 +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,345 +DA:293,336 +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,16 +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:6375,dlt_user_log_out3 +FNDA:6809,dlt_user_set_userheader +FNDA:0,dlt_user_log_out3_with_timeout +FNDA:51,dlt_user_log_out2_with_timeout +FNDA:432,dlt_user_log_out2 +FNDA:11831,dlt_user_check_userheader +FNF:6 +FNH:5 +DA:79,6809 +DA:81,6809 +DA:84,6809 +DA:87,6809 +DA:88,6809 +DA:89,6809 +DA:90,6809 +DA:91,6809 +DA:93,6809 +DA:96,11831 +DA:98,11831 +DA:101,23662 +DA:102,11831 +DA:103,23662 +DA:104,11831 +DA:107,432 +DA:112,432 +DA:116,94 +DA:117,94 +DA:118,94 +DA:119,94 +DA:121,94 +DA:123,94 +DA:124,0 +DA:129,51 +DA:131,51 +DA:136,867 +DA:137,51 +DA:139,51 +DA:140,51 +DA:144,51 +DA:145,51 +DA:151,6375 +DA:156,6375 +DA:160,5856 +DA:161,5856 +DA:162,5856 +DA:163,5856 +DA:164,5856 +DA:165,5856 +DA:167,5856 +DA:169,5856 +DA:170,2 +DA:186,0 +DA:188,0 +DA:197,0 +DA:203,0 +DA:205,0 +DA:210,0 +DA:211,0 +DA:213,0 +DA:214,0 +DA:218,0 +DA:219,0 +LF:54 +LH:42 +end_of_record diff --git a/dlt_lcov_report/emerald.png b/dlt_lcov_report/emerald.png new file mode 100644 index 00000000..38ad4f40 Binary files /dev/null and b/dlt_lcov_report/emerald.png differ 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 00000000..0972b5cc --- /dev/null +++ b/dlt_lcov_report/gateway/dlt_gateway.c.func-sort-c.html @@ -0,0 +1,184 @@ + + + + + + + LCOV - dlt_final_coverage.info - gateway/dlt_gateway.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - gateway - dlt_gateway.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:38563360.8 %
Date:2024-04-29 13:30: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_parse_get_log_info3
dlt_gateway_process_on_demand_request3
dlt_gateway_init4
dlt_gateway_configure5
dlt_gateway_process_passive_node_messages5
dlt_gateway_check_control_messages6
dlt_gateway_check_ecu6
dlt_gateway_check_send_serial6
dlt_gateway_establish_connections6
dlt_gateway_get_connection_receiver6
dlt_gateway_check_connect_trigger7
dlt_gateway_check_ip7
dlt_gateway_check_timeout7
dlt_gateway_store_connection7
dlt_gateway_check_port9
dlt_gateway_deinit10
dlt_gateway_send_control_message12
dlt_gateway_allocate_control_messages17
dlt_gateway_check_param32
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/gateway/dlt_gateway.c.func.html b/dlt_lcov_report/gateway/dlt_gateway.c.func.html new file mode 100644 index 00000000..414ee2c3 --- /dev/null +++ b/dlt_lcov_report/gateway/dlt_gateway.c.func.html @@ -0,0 +1,184 @@ + + + + + + + LCOV - dlt_final_coverage.info - gateway/dlt_gateway.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - gateway - dlt_gateway.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:38563360.8 %
Date:2024-04-29 13:30: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_deinit10
dlt_gateway_establish_connections6
dlt_gateway_forward_control_message0
dlt_gateway_get_connection0
dlt_gateway_get_connection_receiver6
dlt_gateway_init4
dlt_gateway_parse_get_default_log_level0
dlt_gateway_parse_get_log_info3
dlt_gateway_process_gateway_timer2
dlt_gateway_process_on_demand_request3
dlt_gateway_process_passive_node_messages5
dlt_gateway_send_control_message12
dlt_gateway_store_connection7
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/gateway/dlt_gateway.c.gcov.html b/dlt_lcov_report/gateway/dlt_gateway.c.gcov.html new file mode 100644 index 00000000..b3718343 --- /dev/null +++ b/dlt_lcov_report/gateway/dlt_gateway.c.gcov.html @@ -0,0 +1,1857 @@ + + + + + + + LCOV - dlt_final_coverage.info - gateway/dlt_gateway.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - gateway - dlt_gateway.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:38563360.8 %
Date:2024-04-29 13:30: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           7 :     if ((con == NULL) || (value == NULL)) {
+      60           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+      61           1 :         return DLT_RETURN_WRONG_PARAMETER;
+      62             :     }
+      63             : 
+      64             :     int ret = DLT_RETURN_ERROR;
+      65             : #ifdef DLT_USE_IPv6
+      66             :     struct sockaddr_in6 sa6;
+      67           6 :     ret = inet_pton(AF_INET6, value, &(sa6.sin6_addr));
+      68             : #else
+      69             :     struct sockaddr_in sa;
+      70             :     ret = inet_pton(AF_INET, value, &(sa.sin_addr));
+      71             : #endif
+      72             : 
+      73             :     /* valid IP address */
+      74           6 :     if (ret != 0) {
+      75           6 :         con->ip_address = strdup(value);
+      76             : 
+      77           6 :         if (con->ip_address == NULL) {
+      78           0 :             dlt_log(LOG_ERR, "Cannot copy passive node IP address string\n");
+      79           0 :             return DLT_RETURN_ERROR;
+      80             :         }
+      81             : 
+      82             :         return DLT_RETURN_OK;
+      83             :     }
+      84             :     else {
+      85           0 :         dlt_log(LOG_ERR, "IP address is not valid\n");
+      86             :     }
+      87             : 
+      88           0 :     return DLT_RETURN_ERROR;
+      89             : }
+      90             : 
+      91             : /**
+      92             :  * Check port number
+      93             :  *
+      94             :  * @param con     DltGatewayConnection to be updated
+      95             :  * @param value   string to be tested
+      96             :  * @return Value from DltReturnValue enum
+      97             :  */
+      98           9 : DLT_STATIC DltReturnValue dlt_gateway_check_port(DltGatewayConnection *con,
+      99             :                                                  char *value)
+     100             : {
+     101             :     long int tmp = -1;
+     102             : 
+     103           9 :     if ((con == NULL) || (value == NULL)) {
+     104           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     105           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     106             :     }
+     107             : 
+     108           8 :     errno = 0;
+     109           8 :     tmp = strtol(value, NULL, 10);
+     110           8 :     if ((errno == ERANGE && (tmp == LONG_MAX || tmp == LONG_MIN))
+     111           8 :          || (errno != 0 && tmp == 0)) {
+     112           0 :         dlt_vlog(LOG_ERR, "%s: cannot convert port number\n", __func__);
+     113           0 :         return DLT_RETURN_ERROR;
+     114             :     }
+     115             : 
+     116             :     /* port ranges for unprivileged applications */
+     117           8 :     if ((tmp > IPPORT_RESERVED) && ((unsigned)tmp <= USHRT_MAX))
+     118             :     {
+     119           6 :         con->port = (int)tmp;
+     120           6 :         return DLT_RETURN_OK;
+     121             :     }
+     122             :     else {
+     123           2 :         dlt_log(LOG_ERR, "Port number is invalid\n");
+     124             :     }
+     125             : 
+     126           2 :     return DLT_RETURN_ERROR;
+     127             : }
+     128             : 
+     129             : /**
+     130             :  * Check ECU name
+     131             :  *
+     132             :  * @param con     DltGatewayConnection to be updated
+     133             :  * @param value   string to be used as ECU identifier
+     134             :  * @return Value from DltReturnValue enum
+     135             :  */
+     136           6 : DLT_STATIC DltReturnValue dlt_gateway_check_ecu(DltGatewayConnection *con,
+     137             :                                                 char *value)
+     138             : {
+     139           6 :     if ((con == NULL) || (value == NULL)) {
+     140           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     141           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     142             :     }
+     143             : 
+     144           5 :     con->ecuid = strdup(value);
+     145             : 
+     146           5 :     if (con->ecuid == NULL)
+     147           0 :         return DLT_RETURN_ERROR;
+     148             : 
+     149             :     return DLT_RETURN_OK;
+     150             : }
+     151             : 
+     152             : /**
+     153             :  * Check connection trigger
+     154             :  *
+     155             :  * @param con     DltGatewayConnection to be updated
+     156             :  * @param value   string to be tested
+     157             :  * @return Value from DltReturnValue enum
+     158             :  */
+     159           7 : DLT_STATIC DltReturnValue dlt_gateway_check_connect_trigger(DltGatewayConnection *con,
+     160             :                                                             char *value)
+     161             : {
+     162           7 :     if ((con == NULL) || (value == NULL)) {
+     163           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     164           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     165             :     }
+     166             : 
+     167           6 :     if (strncasecmp(value, "OnStartup", strlen("OnStartup")) == 0) {
+     168           5 :         con->trigger = DLT_GATEWAY_ON_STARTUP;
+     169             :     }
+     170           1 :     else if (strncasecmp(value, "OnDemand", strlen("OnDemand")) == 0)
+     171             :     {
+     172           0 :         con->trigger = DLT_GATEWAY_ON_DEMAND;
+     173             :     }
+     174             :     else {
+     175           1 :         dlt_log(LOG_ERR, "Wrong connection trigger state given.\n");
+     176           1 :         con->trigger = DLT_GATEWAY_UNDEFINED;
+     177           1 :         return DLT_RETURN_ERROR;
+     178             :     }
+     179             : 
+     180             :     return DLT_RETURN_OK;
+     181             : }
+     182             : 
+     183             : /**
+     184             :  * Check connection timeout value
+     185             :  *
+     186             :  * @param con     DltGatewayConnection to be updated
+     187             :  * @param value   string to be tested
+     188             :  * @return Value from DltReturnValue enum
+     189             :  */
+     190           7 : DLT_STATIC DltReturnValue dlt_gateway_check_timeout(DltGatewayConnection *con,
+     191             :                                                     char *value)
+     192             : {
+     193           7 :     if ((con == NULL) || (value == NULL)) {
+     194           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     195           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     196             :     }
+     197             : 
+     198           6 :     con->timeout = (int)strtol(value, NULL, 10);
+     199             : 
+     200             : 
+     201           6 :     if (con->timeout >= 0)
+     202           5 :         return DLT_RETURN_OK;
+     203             : 
+     204             :     return DLT_RETURN_ERROR;
+     205             : }
+     206             : 
+     207             : /**
+     208             :  * Check connection interval value in General section
+     209             :  *
+     210             :  * @param con     DltGateway to be updated
+     211             :  * @param value   string to be tested
+     212             :  * @return Value from DltReturnValue enum
+     213             :  */
+     214           0 : DLT_STATIC DltReturnValue dlt_gateway_check_interval(DltGateway *gateway,
+     215             :                                                     char *value)
+     216             : {
+     217           0 :     if ((gateway == NULL) || (value == NULL)) {
+     218           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     219           0 :         return DLT_RETURN_WRONG_PARAMETER;
+     220             :     }
+     221             : 
+     222           0 :     gateway->interval = (int)strtol(value, NULL, 10);
+     223             : 
+     224           0 :     if (gateway->interval > 0)
+     225           0 :         return DLT_RETURN_OK;
+     226             : 
+     227             :     return DLT_RETURN_ERROR;
+     228             : }
+     229             : 
+     230             : /**
+     231             :  * Check the value for SendSerialHeader
+     232             :  *
+     233             :  * @param con   DltGatewayConnection to be updated
+     234             :  * @param value string to be tested
+     235             :  * @return Value from DltReturnValue enum
+     236             :  */
+     237           6 : DLT_STATIC DltReturnValue dlt_gateway_check_send_serial(DltGatewayConnection *con,
+     238             :                                                         char *value)
+     239             : {
+     240           6 :     if ((con == NULL) || (value == NULL)) {
+     241           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     242           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     243             :     }
+     244             : 
+     245           5 :     con->send_serial = !!((int)strtol(value, NULL, 10));
+     246             : 
+     247           5 :     return DLT_RETURN_OK;
+     248             : }
+     249             : 
+     250             : /**
+     251             :  * Allocate passive control messages
+     252             :  *
+     253             :  * @param con   DltGatewayConnection to be updated
+     254             :  * @return Value from DltReturnValue enum
+     255             :  */
+     256          17 : DLT_STATIC DltReturnValue dlt_gateway_allocate_control_messages(DltGatewayConnection *con)
+     257             : {
+     258          17 :     if (con == NULL) {
+     259           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     260           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     261             :     }
+     262             : 
+     263          16 :     if (con->p_control_msgs == NULL) {
+     264           7 :         con->p_control_msgs = calloc(1, sizeof(DltPassiveControlMessage));
+     265             : 
+     266           7 :         if (!con->p_control_msgs) {
+     267           0 :             dlt_log(LOG_ERR,
+     268             :                     "Passive Control Message could not be allocated\n");
+     269           0 :             return DLT_RETURN_ERROR;
+     270             :         }
+     271             :     }
+     272             :     else {
+     273           9 :         con->p_control_msgs->next = calloc(1, sizeof(DltPassiveControlMessage));
+     274             : 
+     275           9 :         if (!con->p_control_msgs->next) {
+     276           0 :             dlt_log(LOG_ERR,
+     277             :                     "Passive Control Message could not be allocated\n");
+     278           0 :             return DLT_RETURN_ERROR;
+     279             :         }
+     280             : 
+     281           9 :         con->p_control_msgs = con->p_control_msgs->next;
+     282             :     }
+     283             : 
+     284             :     return DLT_RETURN_OK;
+     285             : }
+     286             : 
+     287             : /**
+     288             :  * Check the specified control messages identifier
+     289             :  *
+     290             :  * @param con   DltGatewayConnection to be updated
+     291             :  * @param value string to be tested
+     292             :  * @return Value from DltReturnValue enum
+     293             :  */
+     294           6 : DLT_STATIC DltReturnValue dlt_gateway_check_control_messages(DltGatewayConnection *con,
+     295             :                                                              char *value)
+     296             : {
+     297             :     /* list of allowed clients given */
+     298             :     char *token = NULL;
+     299           6 :     char *rest = NULL;
+     300             :     DltPassiveControlMessage *head = NULL;
+     301             : 
+     302           6 :     if ((con == NULL) || (value == NULL)) {
+     303           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     304           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     305             :     }
+     306             : 
+     307           5 :     if (strlen(value) == 0)
+     308             :         return DLT_RETURN_OK;
+     309             : 
+     310             :     /* set on startup control msg id and interval*/
+     311           5 :     token = strtok_r(value, ",", &rest);
+     312             : 
+     313          18 :     while (token != NULL) {
+     314          13 :         if (dlt_gateway_allocate_control_messages(con) != DLT_RETURN_OK) {
+     315           0 :             dlt_log(LOG_ERR,
+     316             :                     "Passive Control Message could not be allocated\n");
+     317           0 :             return DLT_RETURN_ERROR;
+     318             :         }
+     319             : 
+     320          13 :         con->p_control_msgs->id = strtol(token, NULL, 16);
+     321          13 :         con->p_control_msgs->user_id = DLT_SERVICE_ID_PASSIVE_NODE_CONNECT;
+     322          13 :         con->p_control_msgs->type = CONTROL_MESSAGE_ON_STARTUP;
+     323          13 :         con->p_control_msgs->req = CONTROL_MESSAGE_NOT_REQUESTED;
+     324          13 :         con->p_control_msgs->interval = -1;
+     325             : 
+     326          13 :         if (head == NULL)
+     327             :             head = con->p_control_msgs;
+     328             : 
+     329          13 :         if ((errno == EINVAL) || (errno == ERANGE)) {
+     330           0 :             dlt_vlog(LOG_ERR,
+     331             :                      "Control message ID is not an integer: %s\n",
+     332             :                      token);
+     333           0 :             return DLT_RETURN_ERROR;
+     334             :         }
+     335          13 :         else if ((con->p_control_msgs->id < DLT_SERVICE_ID_SET_LOG_LEVEL) ||
+     336             :                  (con->p_control_msgs->id >= DLT_SERVICE_ID_LAST_ENTRY))
+     337             :         {
+     338           0 :             dlt_vlog(LOG_ERR,
+     339             :                      "Control message ID is not valid: %s\n",
+     340             :                      token);
+     341           0 :             return DLT_RETURN_ERROR;
+     342             :         }
+     343             : 
+     344          13 :         token = strtok_r(NULL, ",", &rest);
+     345             :     }
+     346             : 
+     347             :     /* get back to head */
+     348           5 :     con->p_control_msgs = head;
+     349           5 :     con->head = head;
+     350             : 
+     351           5 :     return DLT_RETURN_OK;
+     352             : }
+     353             : 
+     354             : /**
+     355             :  * Check the specified periodic control messages identifier
+     356             :  *
+     357             :  * @param con   DltGatewayConnection to be updated
+     358             :  * @param value string to be tested
+     359             :  * @return Value from DltReturnValue enum
+     360             :  */
+     361           2 : DLT_STATIC DltReturnValue dlt_gateway_check_periodic_control_messages(
+     362             :     DltGatewayConnection *con,
+     363             :     char *value)
+     364             : {
+     365             :     char *token = NULL;
+     366           2 :     char *rest = NULL;
+     367             :     DltPassiveControlMessage *head = NULL;
+     368             : 
+     369           2 :     if ((con == NULL) || (value == NULL)) {
+     370           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     371           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     372             :     }
+     373             : 
+     374           1 :     if (strlen(value) == 0)
+     375             :         return DLT_RETURN_OK;
+     376             : 
+     377             :     /* store head address */
+     378           1 :     head = con->p_control_msgs;
+     379             : 
+     380             :     /* set periodic control msg id and interval*/
+     381           1 :     token = strtok_r(value, ",", &rest);
+     382             : 
+     383           3 :     while (token != NULL) {
+     384             :         char *p_token = NULL;
+     385           2 :         char *p_rest = NULL;
+     386             :         uint32_t id = 0;
+     387             : 
+     388           2 :         p_token = strtok_r(token, ":", &p_rest);
+     389             : 
+     390           2 :         if ((p_token != NULL) && (strlen(p_token) != 0)) {
+     391           2 :             id = strtol(p_token, NULL, 16);
+     392             : 
+     393             :             /* get back to head */
+     394           2 :             con->p_control_msgs = head;
+     395             : 
+     396             :             /* check if there is already id set in p_control_msgs */
+     397           3 :             while (con->p_control_msgs != NULL) {
+     398           1 :                 if (con->p_control_msgs->id == id) {
+     399           0 :                     con->p_control_msgs->type = CONTROL_MESSAGE_BOTH;
+     400           0 :                     con->p_control_msgs->interval = strtol(p_rest, NULL, 10);
+     401             : 
+     402           0 :                     if (con->p_control_msgs->interval <= 0)
+     403           0 :                         dlt_vlog(LOG_WARNING,
+     404             :                                  "%s interval is %d. It won't be send periodically.\n",
+     405             :                                  dlt_get_service_name(con->p_control_msgs->id),
+     406             :                                  con->p_control_msgs->interval);
+     407             : 
+     408             :                     break;
+     409             :                 }
+     410             : 
+     411           1 :                 con->p_control_msgs = con->p_control_msgs->next;
+     412             :             }
+     413             : 
+     414             :             /* if the id is not added yet, p_control_msgs supposed to be NULL */
+     415           2 :             if (con->p_control_msgs == NULL) {
+     416             :                 /* get back to head */
+     417           2 :                 con->p_control_msgs = head;
+     418             : 
+     419             :                 /* go to last pointer */
+     420           2 :                 while (con->p_control_msgs != NULL) {
+     421           1 :                     if (con->p_control_msgs->next == NULL)
+     422             :                         break;
+     423             : 
+     424           0 :                     con->p_control_msgs = con->p_control_msgs->next;
+     425             :                 }
+     426             : 
+     427           2 :                 if (dlt_gateway_allocate_control_messages(con) != DLT_RETURN_OK) {
+     428           0 :                     dlt_log(LOG_ERR,
+     429             :                             "Passive Control Message could not be allocated\n");
+     430           0 :                     return DLT_RETURN_ERROR;
+     431             :                 }
+     432             : 
+     433           2 :                 con->p_control_msgs->id = id;
+     434           2 :                 con->p_control_msgs->user_id = DLT_SERVICE_ID_PASSIVE_NODE_CONNECT;
+     435           2 :                 con->p_control_msgs->type = CONTROL_MESSAGE_PERIODIC;
+     436           2 :                 con->p_control_msgs->req = CONTROL_MESSAGE_NOT_REQUESTED;
+     437           2 :                 con->p_control_msgs->interval = strtol(p_rest, NULL, 10);
+     438             : 
+     439           2 :                 if (con->p_control_msgs->interval <= 0)
+     440           0 :                     dlt_vlog(LOG_WARNING,
+     441             :                              "%s interval is %d. It won't be send periodically.\n",
+     442             :                              dlt_get_service_name(con->p_control_msgs->id),
+     443             :                              con->p_control_msgs->interval);
+     444             : 
+     445           2 :                 if (head == NULL)
+     446           1 :                     head = con->p_control_msgs;
+     447             :             }
+     448             :         }
+     449             : 
+     450           2 :         if ((errno == EINVAL) || (errno == ERANGE)) {
+     451           0 :             dlt_vlog(LOG_ERR,
+     452             :                      "Control message ID is not an integer: %s\n",
+     453             :                      p_token);
+     454           0 :             return DLT_RETURN_ERROR;
+     455             :         }
+     456           2 :         else if ((con->p_control_msgs->id < DLT_SERVICE_ID_SET_LOG_LEVEL) ||
+     457             :                  (con->p_control_msgs->id >= DLT_SERVICE_ID_LAST_ENTRY))
+     458             :         {
+     459           0 :             dlt_vlog(LOG_ERR,
+     460             :                      "Control message ID is not valid: %s\n",
+     461             :                      p_token);
+     462           0 :             return DLT_RETURN_ERROR;
+     463             :         }
+     464             : 
+     465           2 :         token = strtok_r(NULL, ",", &rest);
+     466             :     }
+     467             : 
+     468             :     /* get back to head */
+     469           1 :     con->p_control_msgs = head;
+     470           1 :     con->head = head;
+     471             : 
+     472           1 :     return DLT_RETURN_OK;
+     473             : }
+     474             : 
+     475             : /**
+     476             :  * Expected entries for a passive node configuration
+     477             :  * Caution: after changing entries here,
+     478             :  * dlt_gateway_check_param needs to be updated as well
+     479             :  * */
+     480             : DLT_STATIC DltGatewayConf configuration_entries[GW_CONF_COUNT] = {
+     481             :     [GW_CONF_IP_ADDRESS] = {
+     482             :         .key = "IPaddress",
+     483             :         .func = dlt_gateway_check_ip,
+     484             :         .is_opt = 0
+     485             :     },
+     486             :     [GW_CONF_PORT] = {
+     487             :         .key = "Port",
+     488             :         .func = dlt_gateway_check_port,
+     489             :         .is_opt = 1
+     490             :     },
+     491             :     [GW_CONF_ECUID] = {
+     492             :         .key = "EcuID",
+     493             :         .func = dlt_gateway_check_ecu,
+     494             :         .is_opt = 0
+     495             :     },
+     496             :     [GW_CONF_CONNECT] = {
+     497             :         .key = "Connect",
+     498             :         .func = dlt_gateway_check_connect_trigger,
+     499             :         .is_opt = 1
+     500             :     },
+     501             :     [GW_CONF_TIMEOUT] = {
+     502             :         .key = "Timeout",
+     503             :         .func = dlt_gateway_check_timeout,
+     504             :         .is_opt = 0
+     505             :     },
+     506             :     [GW_CONF_SEND_CONTROL] = {
+     507             :         .key = "SendControl",
+     508             :         .func = dlt_gateway_check_control_messages,
+     509             :         .is_opt = 1
+     510             :     },
+     511             :     [GW_CONF_SEND_PERIODIC_CONTROL] = {
+     512             :         .key = "SendPeriodicControl",
+     513             :         .func = dlt_gateway_check_periodic_control_messages,
+     514             :         .is_opt = 1
+     515             :     },
+     516             :     [GW_CONF_SEND_SERIAL_HEADER] = {
+     517             :         .key = "SendSerialHeader",
+     518             :         .func = dlt_gateway_check_send_serial,
+     519             :         .is_opt = 1
+     520             :     }
+     521             : };
+     522             : 
+     523             : DLT_STATIC DltGatewayGeneralConf general_entries[GW_CONF_COUNT] = {
+     524             :     [GW_CONF_GENERAL_INTERVAL] = {
+     525             :         .key = "Interval",
+     526             :         .func = dlt_gateway_check_interval,
+     527             :         .is_opt = 1
+     528             :     }
+     529             : };
+     530             : 
+     531             : #define DLT_GATEWAY_NUM_PROPERTIES_MAX GW_CONF_COUNT
+     532             : 
+     533             : /**
+     534             :  * Check if gateway connection general configuration parameter is valid.
+     535             :  *
+     536             :  * @param gateway    DltGateway
+     537             :  * @param ctype      DltGatwayGeneralConnection property
+     538             :  * @param value      specified property value from configuration file
+     539             :  * @return Value from DltReturnValue enum
+     540             :  */
+     541           0 : DLT_STATIC DltReturnValue dlt_gateway_check_general_param(DltGateway *gateway,
+     542             :                                                   DltGatewayGeneralConfType ctype,
+     543             :                                                   char *value)
+     544             : {
+     545           0 :     if ((gateway == NULL) || (value == NULL)) {
+     546           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     547           0 :         return DLT_RETURN_WRONG_PARAMETER;
+     548             :     }
+     549             : 
+     550           0 :     if (ctype < GW_CONF_GENEREL_COUNT)
+     551           0 :         return general_entries[ctype].func(gateway, value);
+     552             : 
+     553             :     return DLT_RETURN_ERROR;
+     554             : }
+     555             : 
+     556             : /**
+     557             :  * Check if gateway connection configuration parameter is valid.
+     558             :  *
+     559             :  * @param gateway    DltGateway
+     560             :  * @param con        DltGatewayConnection
+     561             :  * @param ctype      DltGatwayConnection property
+     562             :  * @param value      specified property value from configuration file
+     563             :  * @return Value from DltReturnValue enum
+     564             :  */
+     565          32 : DLT_STATIC DltReturnValue dlt_gateway_check_param(DltGateway *gateway,
+     566             :                                                   DltGatewayConnection *con,
+     567             :                                                   DltGatewayConfType ctype,
+     568             :                                                   char *value)
+     569             : {
+     570          32 :     if ((gateway == NULL) || (con == NULL) || (value == NULL)) {
+     571           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     572           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     573             :     }
+     574             : 
+     575          31 :     if (ctype < GW_CONF_COUNT)
+     576          31 :         return configuration_entries[ctype].func(con, value);
+     577             : 
+     578             :     return DLT_RETURN_ERROR;
+     579             : }
+     580             : 
+     581             : /**
+     582             :  * Store gateway connection in internal data structure
+     583             :  *
+     584             :  * @param gateway    DltGatway
+     585             :  * @param tmp        DltGatewayConnection
+     586             :  * @param verbose    verbose flag
+     587             :  * @return 0 on success, -1 otherwise
+     588             :  */
+     589           7 : int dlt_gateway_store_connection(DltGateway *gateway,
+     590             :                                  DltGatewayConnection *tmp,
+     591             :                                  int verbose)
+     592             : {
+     593             :     int i = 0;
+     594             : 
+     595           7 :     PRINT_FUNCTION_VERBOSE(verbose);
+     596             : 
+     597           7 :     if ((gateway == NULL) || (tmp == NULL)) {
+     598           2 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     599           2 :         return DLT_RETURN_WRONG_PARAMETER;
+     600             :     }
+     601             : 
+     602             :     /* find next free entry in connection array */
+     603           5 :     while (i < gateway->num_connections) {
+     604           5 :         if (gateway->connections[i].status == DLT_GATEWAY_UNINITIALIZED)
+     605             :             break;
+     606             : 
+     607           0 :         i++;
+     608             :     }
+     609             : 
+     610             :     /* store values */
+     611           5 :     gateway->connections[i].ip_address = strdup(tmp->ip_address);
+     612           5 :     gateway->connections[i].ecuid = strdup(tmp->ecuid);
+     613           5 :     gateway->connections[i].sock_domain = tmp->sock_domain;
+     614           5 :     gateway->connections[i].sock_type = tmp->sock_type;
+     615           5 :     gateway->connections[i].sock_protocol = tmp->sock_protocol;
+     616           5 :     gateway->connections[i].port = tmp->port;
+     617           5 :     gateway->connections[i].trigger = tmp->trigger;
+     618           5 :     gateway->connections[i].timeout = tmp->timeout;
+     619           5 :     gateway->connections[i].handle = 0;
+     620           5 :     gateway->connections[i].status = DLT_GATEWAY_INITIALIZED;
+     621           5 :     gateway->connections[i].p_control_msgs = tmp->p_control_msgs;
+     622           5 :     gateway->connections[i].head = tmp->head;
+     623           5 :     gateway->connections[i].send_serial = tmp->send_serial;
+     624             : 
+     625           5 :     if (dlt_client_init_port(&gateway->connections[i].client,
+     626             :                              gateway->connections[i].port,
+     627             :                              verbose) != 0) {
+     628           0 :         free(gateway->connections[i].ip_address);
+     629           0 :         gateway->connections[i].ip_address = NULL;
+     630           0 :         free(gateway->connections[i].ecuid);
+     631           0 :         gateway->connections[i].ecuid = NULL;
+     632           0 :         free(gateway->connections[i].p_control_msgs);
+     633           0 :         gateway->connections[i].p_control_msgs = NULL;
+     634           0 :         dlt_log(LOG_CRIT, "dlt_client_init_port() failed for gateway connection\n");
+     635           0 :         return DLT_RETURN_ERROR;
+     636             :     }
+     637             : 
+     638             :     /* setup DltClient Structure */
+     639           5 :     if (dlt_client_set_server_ip(&gateway->connections[i].client,
+     640           5 :                                  gateway->connections[i].ip_address) == -1) {
+     641           0 :         dlt_log(LOG_ERR,
+     642             :                 "dlt_client_set_server_ip() failed for gateway connection \n");
+     643           0 :         return DLT_RETURN_ERROR;
+     644             :     }
+     645             : 
+     646             :     return DLT_RETURN_OK;
+     647             : }
+     648             : 
+     649             : /**
+     650             :  * Read configuration file and initialize connection data structures
+     651             :  *
+     652             :  * @param gateway       DltGateway
+     653             :  * @param config_file   Gateway configuration
+     654             :  * @param verbose       verbose flag
+     655             :  * @return 0 on success, -1 otherwise
+     656             :  */
+     657           5 : int dlt_gateway_configure(DltGateway *gateway, char *config_file, int verbose)
+     658             : {
+     659             :     int ret = 0;
+     660             :     int i = 0;
+     661             :     DltConfigFile *file = NULL;
+     662           5 :     int num_sections = 0;
+     663             : 
+     664           5 :     PRINT_FUNCTION_VERBOSE(verbose);
+     665             : 
+     666           5 :     if ((gateway == NULL) || (config_file == 0) || (config_file[0] == '\0')) {
+     667           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     668           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     669             :     }
+     670             : 
+     671             :     /* read configuration file */
+     672           4 :     file = dlt_config_file_init(config_file);
+     673           4 :     if(file == NULL) {
+     674             :         return DLT_RETURN_ERROR;
+     675             :     }
+     676             : 
+     677             :     /* get number of entries and allocate memory to store information */
+     678           4 :     ret = dlt_config_file_get_num_sections(file, &num_sections);
+     679           4 :     if (ret != 0) {
+     680           0 :         dlt_config_file_release(file);
+     681           0 :         dlt_log(LOG_ERR, "Invalid number of sections in configuration file\n");
+     682           0 :         return DLT_RETURN_ERROR;
+     683             :     }
+     684             : 
+     685           4 :     ret = dlt_config_file_check_section_name_exists(file, DLT_GATEWAY_GENERAL_SECTION_NAME);
+     686           4 :     if (ret == -1) {
+     687             :         /*
+     688             :          * No General section in configuration file.
+     689             :          * Try to use default for interval.
+     690             :          */
+     691           4 :         gateway->num_connections = num_sections;
+     692           4 :         dlt_vlog(LOG_WARNING,
+     693             :                 "Missing General section in gateway. Using default interval %d (secs)\n",
+     694             :                 gateway->interval);
+     695             :     }
+     696             :     else {
+     697             :         /*
+     698             :          * Since the General section is also counted in num_sections,
+     699             :          * so number of connections must be number of sections - 1.
+     700             :          */
+     701           0 :         gateway->num_connections = num_sections - 1;
+     702             :     }
+     703             : 
+     704           4 :     gateway->connections = calloc(gateway->num_connections,
+     705             :                                 sizeof(DltGatewayConnection));
+     706             : 
+     707           4 :     if (gateway->connections == NULL) {
+     708           0 :         dlt_config_file_release(file);
+     709           0 :         dlt_log(LOG_CRIT, "Memory allocation for gateway connections failed\n");
+     710           0 :         return DLT_RETURN_ERROR;
+     711             :     }
+     712             : 
+     713           8 :     for (i = 0; i < num_sections; i++) {
+     714             :         DltGatewayConnection tmp;
+     715             :         int invalid = 0;
+     716             :         DltGatewayConfType j = 0;
+     717             :         DltGatewayGeneralConfType g = 0;
+     718           4 :         char section[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = { '\0' };
+     719           4 :         char value[DLT_CONFIG_FILE_ENTRY_MAX_LEN] = { '\0' };
+     720             : 
+     721             :         memset(&tmp, 0, sizeof(tmp));
+     722             : 
+     723             :         /* Set default */
+     724           4 :         tmp.send_serial = gateway->send_serial;
+     725           4 :         tmp.port = DLT_DAEMON_TCP_PORT;
+     726             : 
+     727           4 :         ret = dlt_config_file_get_section_name(file, i, section);
+     728           4 :         if (ret != 0) {
+     729           0 :             dlt_log(LOG_WARNING, "Get section name failed\n");
+     730           0 :             continue;
+     731             :         }
+     732             : 
+     733           4 :         if (strncmp(section, DLT_GATEWAY_GENERAL_SECTION_NAME,
+     734             :                 sizeof(DLT_GATEWAY_GENERAL_SECTION_NAME)) == 0) {
+     735           0 :             for (g = 0; g < GW_CONF_GENEREL_COUNT; g++) {
+     736           0 :                 ret = dlt_config_file_get_value(file,
+     737             :                                                 section,
+     738           0 :                                                 general_entries[g].key,
+     739             :                                                 value);
+     740             : 
+     741           0 :                 if ((ret != 0) && general_entries[g].is_opt) {
+     742             :                     /* Use default values for this key */
+     743           0 :                     dlt_vlog(LOG_WARNING,
+     744             :                              "Using default for %s.\n",
+     745             :                              general_entries[g].key);
+     746           0 :                     continue;
+     747             :                 }
+     748           0 :                 else if (ret != 0)
+     749             :                 {
+     750           0 :                     dlt_vlog(LOG_WARNING,
+     751             :                              "Missing configuration for %s.\n",
+     752             :                              general_entries[g].key);
+     753           0 :                     break;
+     754             :                 }
+     755             : 
+     756             :                 /* check value and store general configuration */
+     757           0 :                 ret = dlt_gateway_check_general_param(gateway, g, value);
+     758             : 
+     759           0 :                 if (ret != 0)
+     760           0 :                     dlt_vlog(LOG_ERR,
+     761             :                              "Configuration %s = %s is invalid. Using default.\n",
+     762             :                              general_entries[g].key, value);
+     763             :             }
+     764             :         }
+     765             :         else {
+     766          36 :             for (j = 0; j < GW_CONF_COUNT; j++) {
+     767          32 :                 ret = dlt_config_file_get_value(file,
+     768             :                                                 section,
+     769          32 :                                                 configuration_entries[j].key,
+     770             :                                                 value);
+     771             : 
+     772          32 :                 if ((ret != 0) && configuration_entries[j].is_opt) {
+     773             :                     /* Use default values for this key */
+     774           4 :                     dlt_vlog(LOG_WARNING,
+     775             :                              "Using default for %s.\n",
+     776             :                              configuration_entries[j].key);
+     777           4 :                     continue;
+     778             :                 }
+     779          28 :                 else if (ret != 0)
+     780             :                 {
+     781           0 :                     dlt_vlog(LOG_WARNING,
+     782             :                              "Missing configuration for %s.\n",
+     783             :                              configuration_entries[j].key);
+     784             :                     invalid = 1;
+     785           0 :                     break;
+     786             :                 }
+     787             : 
+     788             :                 /* check value and store temporary */
+     789          28 :                 ret = dlt_gateway_check_param(gateway, &tmp, j, value);
+     790             : 
+     791          28 :                 if (ret != 0)
+     792           0 :                     dlt_vlog(LOG_ERR,
+     793             :                              "Configuration %s = %s is invalid.\n"
+     794             :                              "Using default.\n",
+     795             :                              configuration_entries[j].key, value);
+     796             :             }
+     797             : 
+     798           4 :             if (!tmp.ip_address) {
+     799             :                 invalid = 1;
+     800             :             }
+     801             : 
+     802           4 :             if (invalid) {
+     803           0 :                 dlt_vlog(LOG_ERR,
+     804             :                          "%s configuration is invalid.\n"
+     805             :                          "Ignoring.\n",
+     806             :                          section);
+     807             :             }
+     808             :             else {
+     809           4 :                 ret = dlt_gateway_store_connection(gateway, &tmp, verbose);
+     810             : 
+     811           4 :                 if (ret != 0)
+     812           0 :                     dlt_log(LOG_ERR, "Storing gateway connection data failed\n");
+     813             :             }
+     814             :         }
+     815             : 
+     816             :         /* strdup used inside some get_value function */
+     817           4 :         if (tmp.ecuid != NULL) {
+     818           4 :             free(tmp.ecuid);
+     819           4 :             tmp.ecuid = NULL;
+     820             :         }
+     821           4 :         if (tmp.ip_address != NULL) {
+     822           4 :             free(tmp.ip_address);
+     823             :             tmp.ip_address = NULL;
+     824             :         }
+     825             :     }
+     826             : 
+     827           4 :     dlt_config_file_release(file);
+     828           4 :     return ret;
+     829             : }
+     830             : 
+     831           4 : int dlt_gateway_init(DltDaemonLocal *daemon_local, int verbose)
+     832             : {
+     833           4 :     PRINT_FUNCTION_VERBOSE(verbose);
+     834             : 
+     835           4 :     if (daemon_local == NULL) {
+     836           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     837           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     838             :     }
+     839             : 
+     840           3 :     DltGateway *gateway = &daemon_local->pGateway;
+     841             : 
+     842             :     if (gateway != NULL) {
+     843             :         /* Get default value from daemon_local */
+     844           3 :         gateway->send_serial = daemon_local->flags.lflag;
+     845           3 :         gateway->interval = DLT_GATEWAY_TIMER_DEFAULT_INTERVAL;
+     846             : 
+     847           3 :         if (dlt_gateway_configure(gateway,
+     848           3 :                                   daemon_local->flags.gatewayConfigFile,
+     849             :                                   verbose) != 0) {
+     850           0 :             dlt_log(LOG_ERR, "Gateway initialization failed\n");
+     851           0 :             return DLT_RETURN_ERROR;
+     852             :         }
+     853             :     }
+     854             :     else {
+     855             :         dlt_log(LOG_CRIT, "Pointer to Gateway structure is NULL\n");
+     856             :         return DLT_RETURN_ERROR;
+     857             :     }
+     858             : 
+     859             :     /* ignore return value */
+     860           3 :     dlt_gateway_establish_connections(gateway, daemon_local, verbose);
+     861             : 
+     862           3 :     return DLT_RETURN_OK;
+     863             : }
+     864             : 
+     865          10 : void dlt_gateway_deinit(DltGateway *gateway, int verbose)
+     866             : {
+     867             :     DltPassiveControlMessage *msg;
+     868             :     int i = 0;
+     869             : 
+     870          10 :     if (gateway == NULL) {
+     871           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     872           0 :         return;
+     873             :     }
+     874             : 
+     875          10 :     PRINT_FUNCTION_VERBOSE(verbose);
+     876             : 
+     877          12 :     for (i = 0; i < gateway->num_connections; i++) {
+     878           2 :         DltGatewayConnection *c = &gateway->connections[i];
+     879           2 :         dlt_client_cleanup(&c->client, verbose);
+     880           2 :         free(c->ip_address);
+     881           2 :         c->ip_address = NULL;
+     882           2 :         free(c->ecuid);
+     883           2 :         c->ecuid = NULL;
+     884             : 
+     885           6 :         while (c->p_control_msgs != NULL) {
+     886           4 :             msg = c->p_control_msgs->next;
+     887           4 :             free(c->p_control_msgs);
+     888           4 :             c->p_control_msgs = msg;
+     889             :         }
+     890             :     }
+     891             : 
+     892          10 :     free(gateway->connections);
+     893          10 :     gateway->connections = NULL;
+     894             : }
+     895             : 
+     896             : /**
+     897             :  * If connection to passive node established, add to event loop
+     898             :  *
+     899             :  * @param daemon_local  DltDaemonLocal
+     900             :  * @param con           DltGatewayConnection
+     901             :  * @param verbose       verbose flag
+     902             :  * @return 0 on success, -1 otherwise
+     903             :  */
+     904           3 : DLT_STATIC int dlt_gateway_add_to_event_loop(DltDaemonLocal *daemon_local,
+     905             :                                              DltGatewayConnection *con,
+     906             :                                              int verbose)
+     907             : {
+     908             :     DltPassiveControlMessage *control_msg = NULL;
+     909             :     int sendtime = 1;
+     910             : 
+     911           3 :     if ((daemon_local == NULL) || (con == NULL)) {
+     912           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     913           0 :         return DLT_RETURN_WRONG_PARAMETER;
+     914             :     }
+     915             : 
+     916             :     /* connection to passive node established, add to event loop */
+     917           3 :     con->status = DLT_GATEWAY_CONNECTED;
+     918           3 :     con->reconnect_cnt = 0;
+     919           3 :     con->timeout_cnt = 0;
+     920           3 :     con->sendtime_cnt = 0;
+     921             : 
+     922             :     /* setup dlt connection and add to poll event loop here */
+     923           3 :     if (dlt_connection_create(daemon_local,
+     924             :                               &daemon_local->pEvent,
+     925             :                               con->client.sock,
+     926             :                               POLLIN,
+     927             :                               DLT_CONNECTION_GATEWAY) != 0) {
+     928           0 :         dlt_log(LOG_ERR, "Gateway connection creation failed\n");
+     929           0 :         return DLT_RETURN_ERROR;
+     930             :     }
+     931             : 
+     932             :     /* immediately send configured control messages */
+     933           3 :     control_msg = con->p_control_msgs;
+     934             : 
+     935           9 :     while (control_msg != NULL) {
+     936           6 :         if ((control_msg->type == CONTROL_MESSAGE_ON_STARTUP) ||
+     937             :             (control_msg->type == CONTROL_MESSAGE_BOTH)) {
+     938           6 :             if (dlt_gateway_send_control_message(con,
+     939             :                                                  control_msg,
+     940             :                                                  NULL,
+     941             :                                                  verbose) == DLT_RETURN_OK)
+     942           6 :                 control_msg->req = CONTROL_MESSAGE_REQUESTED;
+     943             :         }
+     944             : 
+     945             :         /* multiply periodic sending time */
+     946           6 :         if (((control_msg->type == CONTROL_MESSAGE_PERIODIC) ||
+     947           0 :              (control_msg->type == CONTROL_MESSAGE_BOTH)) &&
+     948           0 :             (control_msg->interval > 0))
+     949           0 :             sendtime *= control_msg->interval;
+     950             : 
+     951           6 :         control_msg = control_msg->next;
+     952             :     }
+     953             : 
+     954             :     /* set periodic sending time */
+     955           3 :     con->sendtime = sendtime;
+     956           3 :     con->sendtime_cnt = con->sendtime;
+     957             : 
+     958           3 :     return DLT_RETURN_OK;
+     959             : }
+     960             : 
+     961           6 : int dlt_gateway_establish_connections(DltGateway *gateway,
+     962             :                                       DltDaemonLocal *daemon_local,
+     963             :                                       int verbose)
+     964             : {
+     965             :     int i = 0;
+     966             :     int ret = 0;
+     967             : 
+     968           6 :     PRINT_FUNCTION_VERBOSE(verbose);
+     969             : 
+     970           6 :     if ((gateway == NULL) || (daemon_local == NULL)) {
+     971           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+     972           1 :         return DLT_RETURN_WRONG_PARAMETER;
+     973             :     }
+     974             : 
+     975          10 :     for (i = 0; i < gateway->num_connections; i++) {
+     976           5 :         DltGatewayConnection *con = &(gateway->connections[i]);
+     977             :         DltPassiveControlMessage *control_msg = NULL;
+     978             : 
+     979           5 :         if ((con->status != DLT_GATEWAY_CONNECTED) &&
+     980           5 :             (con->trigger != DLT_GATEWAY_ON_DEMAND) &&
+     981             :             (con->trigger != DLT_GATEWAY_DISABLED)) {
+     982           5 :             ret = dlt_client_connect(&con->client, verbose);
+     983             : 
+     984           5 :             if (ret == 0) {
+     985             :                 /* setup dlt connection and add to poll event loop here */
+     986           3 :                 if (dlt_gateway_add_to_event_loop(daemon_local, con, verbose) != DLT_RETURN_OK) {
+     987           0 :                     dlt_log(LOG_ERR, "Gateway connection creation failed\n");
+     988           0 :                     return DLT_RETURN_ERROR;
+     989             :                 }
+     990             :             }
+     991             :             else {
+     992           2 :                 dlt_log(LOG_DEBUG,
+     993             :                         "Passive Node is not up. Connection failed.\n");
+     994             : 
+     995           2 :                 con->timeout_cnt++;
+     996             : 
+     997           2 :                 if (con->timeout > 0) {
+     998           0 :                     if (con->timeout_cnt > con->timeout) {
+     999           0 :                         con->trigger = DLT_GATEWAY_DISABLED;
+    1000           0 :                         dlt_log(LOG_WARNING,
+    1001             :                                 "Passive Node connection retry timed out. "
+    1002             :                                 "Give up.\n");
+    1003             :                     }
+    1004             :                 }
+    1005           2 :                 else if (con->timeout == 0) {
+    1006           2 :                     dlt_vlog(LOG_DEBUG, "Retried [%d] times\n", con->timeout_cnt);
+    1007             :                 }
+    1008             :             }
+    1009             :         }
+    1010           0 :         else if ((con->status == DLT_GATEWAY_CONNECTED) &&
+    1011           0 :                  (con->trigger != DLT_GATEWAY_DISABLED))
+    1012             :         {
+    1013             :             /* setup dlt connection and add to poll event loop here */
+    1014           0 :             if (dlt_connection_create(daemon_local,
+    1015             :                                       &daemon_local->pEvent,
+    1016             :                                       con->client.sock,
+    1017             :                                       POLLIN,
+    1018             :                                       DLT_CONNECTION_GATEWAY) != 0) {
+    1019           0 :                 dlt_log(LOG_ERR, "Gateway connection creation failed\n");
+    1020           0 :                 return DLT_RETURN_ERROR;
+    1021             :             }
+    1022             : 
+    1023             :             /* immediately send periodic configured control messages */
+    1024           0 :             control_msg = con->p_control_msgs;
+    1025             : 
+    1026           0 :             while (control_msg != NULL) {
+    1027           0 :                 if ((control_msg->type == CONTROL_MESSAGE_PERIODIC) ||
+    1028             :                     (control_msg->type == CONTROL_MESSAGE_BOTH)) {
+    1029           0 :                     if (dlt_gateway_send_control_message(con,
+    1030             :                                                          control_msg,
+    1031             :                                                          NULL,
+    1032             :                                                          verbose) == DLT_RETURN_OK)
+    1033           0 :                         control_msg->req = CONTROL_MESSAGE_REQUESTED;
+    1034             :                 }
+    1035             : 
+    1036           0 :                 control_msg = control_msg->next;
+    1037             :             }
+    1038             : 
+    1039             :             /* check sendtime counter */
+    1040           0 :             if (con->sendtime_cnt > 0)
+    1041           0 :                 con->sendtime_cnt--;
+    1042             : 
+    1043           0 :             if (con->sendtime_cnt == 0)
+    1044           0 :                 con->sendtime_cnt = con->sendtime;
+    1045             :         }
+    1046             :     }
+    1047             : 
+    1048             :     return DLT_RETURN_OK;
+    1049             : }
+    1050             : 
+    1051           6 : DltReceiver *dlt_gateway_get_connection_receiver(DltGateway *gateway, int fd)
+    1052             : {
+    1053             :     int i = 0;
+    1054             : 
+    1055           6 :     if (gateway == NULL) {
+    1056           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+    1057           1 :         return NULL;
+    1058             :     }
+    1059             : 
+    1060           6 :     for (i = 0; i < gateway->num_connections; i++) {
+    1061           5 :         DltGatewayConnection *c = &gateway->connections[i];
+    1062             : 
+    1063           5 :         if ((c->status == DLT_GATEWAY_CONNECTED) && (c->client.sock == fd))
+    1064           4 :             return &c->client.receiver;
+    1065             :     }
+    1066             : 
+    1067             :     return NULL;
+    1068             : }
+    1069             : 
+    1070             : /**
+    1071             :  * Parse GET_LOG_INFO
+    1072             :  *
+    1073             :  * @param daemon          DltDaemon
+    1074             :  * @param ecu             Ecu ID
+    1075             :  * @param msg             DltMessage
+    1076             :  * @param req             1 if requested from gateway, 0 otherwise
+    1077             :  * @param verbose verbose flag
+    1078             :  * @return Value from DltReturnValue enum
+    1079             :  */
+    1080           3 : DLT_STATIC DltReturnValue dlt_gateway_parse_get_log_info(DltDaemon *daemon,
+    1081             :                                                          char *ecu,
+    1082             :                                                          DltMessage *msg,
+    1083             :                                                          int req,
+    1084             :                                                          int verbose)
+    1085             : {
+    1086           3 :     char resp_text[DLT_RECEIVE_BUFSIZE] = { '\0' };
+    1087             :     DltServiceGetLogInfoResponse *resp = NULL;
+    1088             :     AppIDsType app;
+    1089             :     ContextIDsInfoType con;
+    1090             :     int i = 0;
+    1091             :     int j = 0;
+    1092             : 
+    1093           3 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1094             : 
+    1095           3 :     if ((msg == NULL) || (msg->databuffer == NULL)) {
+    1096           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+    1097           1 :         return DLT_RETURN_WRONG_PARAMETER;
+    1098             :     }
+    1099             : 
+    1100           2 :     if (dlt_check_rcv_data_size(msg->datasize, sizeof(DltServiceGetLogInfoResponse)) < 0)
+    1101             :         return DLT_RETURN_ERROR;
+    1102             : 
+    1103             :     /* if the request was send from gateway, clear all application and context list */
+    1104           1 :     if (req == CONTROL_MESSAGE_REQUESTED) {
+    1105             :         /* clear application list */
+    1106           0 :         if (dlt_daemon_applications_clear(daemon, ecu, verbose) == DLT_RETURN_ERROR) {
+    1107           0 :             dlt_log(LOG_ERR, "Cannot clear applications list\n");
+    1108           0 :             return DLT_RETURN_ERROR;
+    1109             :         }
+    1110             : 
+    1111             :         /* clear context list */
+    1112           0 :         if (dlt_daemon_contexts_clear(daemon, ecu, verbose) == DLT_RETURN_ERROR) {
+    1113           0 :             dlt_log(LOG_ERR, "Cannot clear contexts list\n");
+    1114           0 :             return DLT_RETURN_ERROR;
+    1115             :         }
+    1116             :     }
+    1117             : 
+    1118             :     /* check response */
+    1119           1 :     if (dlt_message_payload(msg,
+    1120             :                             resp_text,
+    1121             :                             DLT_RECEIVE_BUFSIZE,
+    1122             :                             DLT_OUTPUT_ASCII, 0) != DLT_RETURN_OK) {
+    1123           0 :         dlt_log(LOG_ERR, "GET_LOG_INFO payload failed\n");
+    1124           0 :         return DLT_RETURN_ERROR;
+    1125             :     }
+    1126             : 
+    1127             :     /* prepare pointer to message request */
+    1128           1 :     resp = (DltServiceGetLogInfoResponse *)calloc(1, sizeof(DltServiceGetLogInfoResponse));
+    1129             : 
+    1130           1 :     if (resp == NULL) {
+    1131           0 :         dlt_log(LOG_ERR,
+    1132             :                 "Get Log Info Response could not be allocated\n");
+    1133           0 :         return DLT_RETURN_ERROR;
+    1134             :     }
+    1135             : 
+    1136           1 :     if (dlt_set_loginfo_parse_service_id(resp_text, &resp->service_id, &resp->status) != DLT_RETURN_OK) {
+    1137           0 :         dlt_log(LOG_ERR, "Parsing GET_LOG_INFO failed\n");
+    1138           0 :         dlt_client_cleanup_get_log_info(resp);
+    1139           0 :         return DLT_RETURN_ERROR;
+    1140             :     }
+    1141             : 
+    1142           1 :     if (dlt_client_parse_get_log_info_resp_text(resp, resp_text) != DLT_RETURN_OK) {
+    1143           0 :         dlt_log(LOG_ERR, "Parsing GET_LOG_INFO failed\n");
+    1144           0 :         dlt_client_cleanup_get_log_info(resp);
+    1145           0 :         return DLT_RETURN_ERROR;
+    1146             :     }
+    1147             : 
+    1148           2 :     for (i = 0; i < resp->log_info_type.count_app_ids; i++) {
+    1149           1 :         app = resp->log_info_type.app_ids[i];
+    1150             : 
+    1151             :         /* add application */
+    1152           1 :         if (dlt_daemon_application_add(daemon,
+    1153             :                                        app.app_id,
+    1154             :                                        0,
+    1155             :                                        app.app_description,
+    1156             :                                        -1,
+    1157             :                                        ecu,
+    1158             :                                        verbose) == 0) {
+    1159           0 :             dlt_vlog(LOG_WARNING,
+    1160             :                      "%s: dlt_daemon_application_add failed\n",
+    1161             :                      __func__);
+    1162           0 :             dlt_client_cleanup_get_log_info(resp);
+    1163           0 :             return DLT_RETURN_ERROR;
+    1164             :         }
+    1165             : 
+    1166           2 :         for (j = 0; j < app.count_context_ids; j++) {
+    1167           1 :             con = app.context_id_info[j];
+    1168             : 
+    1169             :             /* add context */
+    1170           1 :             if (dlt_daemon_context_add(daemon,
+    1171             :                                        app.app_id,
+    1172             :                                        con.context_id,
+    1173           1 :                                        con.log_level,
+    1174           1 :                                        con.trace_status,
+    1175             :                                        0,
+    1176             :                                        -1,
+    1177             :                                        con.context_description,
+    1178             :                                        ecu,
+    1179             :                                        verbose) == 0) {
+    1180           0 :                 dlt_vlog(LOG_WARNING,
+    1181             :                          "%s: dlt_daemon_context_add failed for %4s\n",
+    1182             :                          __func__,
+    1183             :                          app.app_id);
+    1184           0 :                 dlt_client_cleanup_get_log_info(resp);
+    1185           0 :                 return DLT_RETURN_ERROR;
+    1186             :             }
+    1187             :         }
+    1188             :     }
+    1189             : 
+    1190             :     /* free response */
+    1191           1 :     dlt_client_cleanup_get_log_info(resp);
+    1192             : 
+    1193           1 :     return DLT_RETURN_OK;
+    1194             : }
+    1195             : 
+    1196             : /**
+    1197             :  * Parse GET_DEFAULT_LOG_LEVEL
+    1198             :  *
+    1199             :  * @param daemon          DltDaemon
+    1200             :  * @param daemon_local    DltDaemonLocal
+    1201             :  * @param ecu             Ecu ID
+    1202             :  * @param msg             DltMessage
+    1203             :  * @param verbose verbose flag
+    1204             :  * @return 0 on success, -1 otherwise
+    1205             :  */
+    1206           0 : DLT_STATIC int dlt_gateway_parse_get_default_log_level(DltDaemon *daemon,
+    1207             :                                                        DltDaemonLocal *daemon_local,
+    1208             :                                                        char *ecu,
+    1209             :                                                        DltMessage *msg,
+    1210             :                                                        int verbose)
+    1211             : {
+    1212             :     DltServiceGetDefaultLogLevelResponse *resp = NULL;
+    1213             :     DltGatewayConnection *con = NULL;
+    1214             : 
+    1215           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1216             : 
+    1217           0 :     if ((daemon == NULL) || (daemon_local == NULL)) {
+    1218           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+    1219           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    1220             :     }
+    1221             : 
+    1222           0 :     if (dlt_check_rcv_data_size(msg->datasize,
+    1223             :                                 sizeof(DltServiceGetDefaultLogLevelResponse)) < 0) {
+    1224           0 :         dlt_log(LOG_ERR, "Received data incomplete.\n");
+    1225           0 :         return DLT_RETURN_ERROR;
+    1226             :     }
+    1227             : 
+    1228             :     /* prepare pointer to message request */
+    1229           0 :     resp = (DltServiceGetDefaultLogLevelResponse *)(msg->databuffer);
+    1230             : 
+    1231           0 :     con = dlt_gateway_get_connection(&daemon_local->pGateway,
+    1232             :                                      ecu,
+    1233             :                                      verbose);
+    1234             : 
+    1235           0 :     if (con == NULL) {
+    1236           0 :         dlt_vlog(LOG_ERR, "No information about passive ECU: %s\n",
+    1237             :                  ecu);
+    1238             : 
+    1239           0 :         return DLT_RETURN_ERROR;
+    1240             :     }
+    1241             : 
+    1242           0 :     con->default_log_level = resp->log_level;
+    1243             : 
+    1244           0 :     return DLT_RETURN_OK;
+    1245             : }
+    1246             : 
+    1247             : /**
+    1248             :  * Service offline logstorage
+    1249             :  *
+    1250             :  * @param daemon       DltDaemon
+    1251             :  * @param daemon_local DltDaemonLocal
+    1252             :  * @param verbose      int
+    1253             :  * @return 0 on success, -1 otherwise
+    1254             :  */
+    1255           1 : DLT_STATIC int dlt_gateway_control_service_logstorage(DltDaemon *daemon,
+    1256             :                                                       DltDaemonLocal *daemon_local,
+    1257             :                                                       int verbose)
+    1258             : {
+    1259             :     unsigned int connection_type = 0;
+    1260             :     int i = 0;
+    1261             : 
+    1262           1 :     if (daemon_local->flags.offlineLogstorageMaxDevices <= 0) {
+    1263           1 :         dlt_log(LOG_INFO,
+    1264             :                 "Logstorage functionality not enabled or MAX device set is 0\n");
+    1265           1 :         return DLT_RETURN_ERROR;
+    1266             :     }
+    1267             : 
+    1268           0 :     for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++) {
+    1269           0 :         connection_type = daemon->storage_handle[i].connection_type;
+    1270             : 
+    1271           0 :         if (connection_type == DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED)
+    1272             :             /* Check if log level of running application needs an update */
+    1273           0 :             dlt_daemon_logstorage_update_application_loglevel(daemon,
+    1274             :                                                               daemon_local,
+    1275             :                                                               i,
+    1276             :                                                               verbose);
+    1277             :     }
+    1278             : 
+    1279             :     return DLT_RETURN_OK;
+    1280             : }
+    1281             : 
+    1282           5 : DltReturnValue dlt_gateway_process_passive_node_messages(DltDaemon *daemon,
+    1283             :                                                          DltDaemonLocal *daemon_local,
+    1284             :                                                          DltReceiver *receiver,
+    1285             :                                                          int verbose)
+    1286             : {
+    1287             :     int i = 0;
+    1288             :     DltGateway *gateway = NULL;
+    1289             :     DltGatewayConnection *con = NULL;
+    1290           5 :     DltMessage msg = { 0 };
+    1291             :     bool b_reset_receiver = false;
+    1292             : 
+    1293           5 :     if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
+    1294           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+    1295           1 :         return DLT_RETURN_WRONG_PARAMETER;
+    1296             :     }
+    1297             : 
+    1298           4 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1299             : 
+    1300             :     gateway = &daemon_local->pGateway;
+    1301             : 
+    1302             :     if (gateway == NULL) {
+    1303             :         dlt_log(LOG_ERR, "Gateway structure is NULL\n");
+    1304             :         return DLT_RETURN_ERROR;
+    1305             :     }
+    1306             : 
+    1307           4 :     for (i = 0; i < gateway->num_connections; i++)
+    1308           4 :         if ((gateway->connections[i].status == DLT_GATEWAY_CONNECTED) && (gateway->connections[i].client.sock == receiver->fd)) {
+    1309             :             con = &gateway->connections[i];
+    1310             :             break;
+    1311             :         }
+    1312             : 
+    1313           4 :     if (con == NULL) {
+    1314           0 :         dlt_log(LOG_ERR, "Cannot associate fd to passive Node connection\n");
+    1315           0 :         return DLT_RETURN_ERROR;
+    1316             :     }
+    1317             : 
+    1318             :     /* now the corresponding passive node connection is available */
+    1319           4 :     if (dlt_message_init(&msg, verbose) == -1) {
+    1320           0 :         dlt_log(LOG_ERR,
+    1321             :                 "Cannot initialize DLT message for passive node forwarding\n");
+    1322           0 :         return DLT_RETURN_ERROR;
+    1323             :     }
+    1324             : 
+    1325             :     /* nearly copy and paste of dlt_client_main_loop function */
+    1326           4 :     if (dlt_receiver_receive(receiver) <= 0) {
+    1327             :         /* No more data to be received */
+    1328           1 :         if (dlt_message_free(&msg, verbose) < 0) {
+    1329           0 :             dlt_log(LOG_ERR, "Cannot free DLT message\n");
+    1330           0 :             return DLT_RETURN_ERROR;
+    1331             :         }
+    1332             : 
+    1333           1 :         dlt_log(LOG_WARNING, "Connection to passive node lost\n");
+    1334             : 
+    1335           1 :         if (con->reconnect_cnt < DLT_GATEWAY_RECONNECT_MAX) {
+    1336           1 :             dlt_log(LOG_WARNING, "Try to reconnect.\n");
+    1337           1 :             con->reconnect_cnt += 1;
+    1338           1 :             con->timeout_cnt = 0;
+    1339             :         }
+    1340             :         else {
+    1341           0 :             con->status = DLT_GATEWAY_DISCONNECTED;
+    1342             : 
+    1343           0 :             if (dlt_event_handler_unregister_connection(&daemon_local->pEvent,
+    1344             :                                                         daemon_local,
+    1345             :                                                         receiver->fd) != 0)
+    1346           0 :                 dlt_log(LOG_ERR, "Remove passive node Connection failed\n");
+    1347             :         }
+    1348             : 
+    1349           1 :         return DLT_RETURN_OK;
+    1350             :     }
+    1351             : 
+    1352          14 :     while (dlt_message_read(&msg,
+    1353          14 :                             (unsigned char *)receiver->buf,
+    1354          14 :                             receiver->bytesRcvd,
+    1355             :                             0,
+    1356          14 :                             verbose) == DLT_MESSAGE_ERROR_OK) {
+    1357             :         DltStandardHeaderExtra *header = (DltStandardHeaderExtra *)
+    1358             :             (msg.headerbuffer +
+    1359             :              sizeof(DltStorageHeader) +
+    1360             :              sizeof(DltStandardHeader));
+    1361             : 
+    1362             :         /* only forward messages if the received ECUid is the expected one */
+    1363          11 :         if (strncmp(header->ecu, con->ecuid, DLT_ID_SIZE) == 0) {
+    1364             :             uint32_t id;
+    1365             :             uint32_t id_tmp;
+    1366          11 :             DltPassiveControlMessage *control_msg = con->p_control_msgs;
+    1367             : 
+    1368          11 :             dlt_vlog(LOG_DEBUG,
+    1369             :                      "Received ECUid (%.*s) similar to configured ECUid(%s). "
+    1370             :                      "Forwarding message (%s).\n",
+    1371             :                      DLT_ID_SIZE,
+    1372             :                      header->ecu,
+    1373             :                      con->ecuid,
+    1374             :                      msg.databuffer);
+    1375             : 
+    1376          11 :             id_tmp = *((uint32_t *)(msg.databuffer));
+    1377          11 :             id = DLT_ENDIAN_GET_32(msg.standardheader->htyp, id_tmp);
+    1378             : 
+    1379             :             /* if ID is GET_LOG_INFO, parse msg */
+    1380          11 :             if (id == DLT_SERVICE_ID_GET_LOG_INFO) {
+    1381           1 :                 while (control_msg) {
+    1382           1 :                     if (control_msg->id == id) {
+    1383           1 :                         if (dlt_gateway_parse_get_log_info(daemon,
+    1384             :                                                            header->ecu,
+    1385             :                                                            &msg,
+    1386           1 :                                                            control_msg->req,
+    1387             :                                                            verbose) == DLT_RETURN_ERROR)
+    1388           1 :                             dlt_log(LOG_WARNING, "Parsing GET_LOG_INFO message failed!\n");
+    1389             : 
+    1390             :                         /* Check for logstorage */
+    1391           1 :                         dlt_gateway_control_service_logstorage(daemon,
+    1392             :                                                                daemon_local,
+    1393             :                                                                verbose);
+    1394             : 
+    1395             :                         /* initialize the flag */
+    1396           1 :                         control_msg->req = CONTROL_MESSAGE_NOT_REQUESTED;
+    1397           1 :                         break;
+    1398             :                     }
+    1399             : 
+    1400           0 :                     control_msg = control_msg->next;
+    1401             :                 }
+    1402             :             }
+    1403          10 :             else if (id == DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL)
+    1404             :             {
+    1405           0 :                 if (dlt_gateway_parse_get_default_log_level(
+    1406             :                         daemon,
+    1407             :                         daemon_local,
+    1408             :                         header->ecu,
+    1409             :                         &msg,
+    1410             :                         verbose) == DLT_RETURN_ERROR)
+    1411           0 :                     dlt_log(LOG_WARNING,
+    1412             :                             "Parsing GET_DEFAULT_LOG_LEVEL message failed!\n");
+    1413             :             }
+    1414             : 
+    1415             :             /* prepare storage header */
+    1416          11 :             if (dlt_set_storageheader(msg.storageheader,
+    1417             :                                       msg.headerextra.ecu) == DLT_RETURN_ERROR) {
+    1418           0 :                 dlt_vlog(LOG_ERR, "%s: Can't set storage header\n", __func__);
+    1419           0 :                 return DLT_RETURN_ERROR;
+    1420             :             }
+    1421             : 
+    1422          11 :             dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL,
+    1423             :                                        daemon,
+    1424             :                                        daemon_local,
+    1425             :                                        msg.headerbuffer,
+    1426             :                                        sizeof(DltStorageHeader),
+    1427             :                                        msg.headerbuffer + sizeof(DltStorageHeader),
+    1428          11 :                                        msg.headersize - sizeof(DltStorageHeader),
+    1429          11 :                                        msg.databuffer,
+    1430             :                                        msg.datasize,
+    1431             :                                        verbose);
+    1432             :         } else { /* otherwise remove this connection and do not connect again */
+    1433           0 :             dlt_vlog(LOG_WARNING,
+    1434             :                      "Received ECUid (%.*s) differs to configured ECUid(%s). "
+    1435             :                      "Discard this message.\n",
+    1436             :                      DLT_ID_SIZE,
+    1437             :                      header->ecu,
+    1438             :                      con->ecuid);
+    1439             : 
+    1440             :             /* disconnect from passive node */
+    1441           0 :             con->status = DLT_GATEWAY_DISCONNECTED;
+    1442           0 :             con->trigger = DLT_GATEWAY_DISABLED;
+    1443             : 
+    1444           0 :             if (dlt_event_handler_unregister_connection(&daemon_local->pEvent,
+    1445             :                                                         daemon_local,
+    1446             :                                                         receiver->fd)
+    1447             :                 != 0)
+    1448           0 :                 dlt_log(LOG_ERR, "Remove passive node Connection failed\n");
+    1449             : 
+    1450           0 :             dlt_log(LOG_WARNING,
+    1451             :                     "Disconnect from passive node due to invalid ECUid\n");
+    1452             : 
+    1453             :             /* it is possible that a partial log was received through the last recv call */
+    1454             :             /* however, the rest will never be received since the socket will be closed by above method */
+    1455             :             /* as such, we need to reset the receiver to prevent permanent corruption */
+    1456             :             b_reset_receiver = true;
+    1457             :         }
+    1458             : 
+    1459          11 :         if (msg.found_serialheader) {
+    1460           0 :             if (dlt_receiver_remove(receiver,
+    1461           0 :                                     msg.headersize +
+    1462           0 :                                     msg.datasize -
+    1463           0 :                                     sizeof(DltStorageHeader) +
+    1464             :                                     sizeof(dltSerialHeader)) == -1) {
+    1465             :                 /* Return value ignored */
+    1466           0 :                 dlt_message_free(&msg, verbose);
+    1467           0 :                 return DLT_RETURN_ERROR;
+    1468             :             }
+    1469             :         }
+    1470          11 :         else if (dlt_receiver_remove(receiver,
+    1471          11 :                                      msg.headersize +
+    1472          11 :                                      msg.datasize -
+    1473             :                                      sizeof(DltStorageHeader)) == -1) {
+    1474             :             /* Return value ignored */
+    1475           0 :             dlt_message_free(&msg, verbose);
+    1476           0 :             return DLT_RETURN_ERROR;
+    1477             :         }
+    1478             :     }
+    1479             : 
+    1480           3 :     if (b_reset_receiver)
+    1481           0 :         dlt_receiver_remove(receiver, receiver->bytesRcvd);
+    1482             : 
+    1483           3 :     if (dlt_receiver_move_to_begin(receiver) == -1) {
+    1484             :         /* Return value ignored */
+    1485           0 :         dlt_message_free(&msg, verbose);
+    1486           0 :         return DLT_RETURN_ERROR;
+    1487             :     }
+    1488             : 
+    1489           3 :     if (dlt_message_free(&msg, verbose) == -1)
+    1490           0 :         return DLT_RETURN_ERROR;
+    1491             : 
+    1492             :     return DLT_RETURN_OK;
+    1493             : }
+    1494             : 
+    1495           2 : int dlt_gateway_process_gateway_timer(DltDaemon *daemon,
+    1496             :                                       DltDaemonLocal *daemon_local,
+    1497             :                                       DltReceiver *receiver,
+    1498             :                                       int verbose)
+    1499             : {
+    1500           2 :     uint64_t expir = 0;
+    1501             :     ssize_t res = 0;
+    1502             : 
+    1503           2 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1504             : 
+    1505           2 :     if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
+    1506           1 :         dlt_vlog(LOG_ERR,
+    1507             :                  "%s: invalid parameters\n",
+    1508             :                  __func__);
+    1509           1 :         return DLT_RETURN_WRONG_PARAMETER;
+    1510             :     }
+    1511             : 
+    1512           1 :     res = read(receiver->fd, &expir, sizeof(expir));
+    1513             : 
+    1514           1 :     if (res < 0)
+    1515           1 :         dlt_vlog(LOG_WARNING,
+    1516             :                  "%s: Fail to read timer (%s)\n",
+    1517             :                  __func__,
+    1518           1 :                  strerror(errno));
+    1519             :         /* Activity received on timer_wd, but unable to read the fd:
+    1520             :          * let's go on sending notification */
+    1521             : 
+    1522             :     /* try to connect to passive nodes */
+    1523           1 :     dlt_gateway_establish_connections(&daemon_local->pGateway,
+    1524             :                                       daemon_local,
+    1525             :                                       verbose);
+    1526             : 
+    1527           1 :     dlt_log(LOG_DEBUG, "Gateway Timer\n");
+    1528             : 
+    1529           1 :     return DLT_RETURN_OK;
+    1530             : }
+    1531             : 
+    1532           0 : int dlt_gateway_forward_control_message(DltGateway *gateway,
+    1533             :                                         DltDaemonLocal *daemon_local,
+    1534             :                                         DltMessage *msg,
+    1535             :                                         char *ecu,
+    1536             :                                         int verbose)
+    1537             : {
+    1538             :     int i = 0;
+    1539             :     int ret = 0;
+    1540             :     DltGatewayConnection *con = NULL;
+    1541             :     uint32_t id_tmp;
+    1542             :     uint32_t id;
+    1543             : 
+    1544           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1545             : 
+    1546           0 :     if ((gateway == NULL) || (daemon_local == NULL) || (msg == NULL) || (ecu == NULL)) {
+    1547           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+    1548           0 :         return DLT_RETURN_WRONG_PARAMETER;
+    1549             :     }
+    1550             : 
+    1551           0 :     for (i = 0; i < gateway->num_connections; i++)
+    1552           0 :         if (strncmp(gateway->connections[i].ecuid,
+    1553             :                     ecu,
+    1554             :                     DLT_ID_SIZE) == 0) {
+    1555             :             con = &gateway->connections[i];
+    1556             :             break;
+    1557             :         }
+    1558             : 
+    1559             : 
+    1560             : 
+    1561           0 :     if (con == NULL) {
+    1562           0 :         dlt_log(LOG_WARNING, "Unknown passive node identifier\n");
+    1563           0 :         return DLT_RETURN_ERROR;
+    1564             :     }
+    1565             : 
+    1566           0 :     if (con->status != DLT_GATEWAY_CONNECTED) {
+    1567           0 :         dlt_log(LOG_INFO, "Passive node is not connected\n");
+    1568           0 :         return DLT_RETURN_ERROR;
+    1569             :     }
+    1570             : 
+    1571           0 :     if (con->send_serial) { /* send serial header */
+    1572           0 :         ret = send(con->client.sock,
+    1573             :                    (void *)dltSerialHeader,
+    1574             :                    sizeof(dltSerialHeader),
+    1575             :                    0);
+    1576             : 
+    1577           0 :         if (ret == -1) {
+    1578           0 :             dlt_log(LOG_ERR, "Sending message to passive DLT Daemon failed\n");
+    1579           0 :             return DLT_RETURN_ERROR;
+    1580             :         }
+    1581             :     }
+    1582             : 
+    1583           0 :     ret = send(con->client.sock,
+    1584             :                msg->headerbuffer + sizeof(DltStorageHeader),
+    1585           0 :                msg->headersize - sizeof(DltStorageHeader),
+    1586             :                0);
+    1587             : 
+    1588           0 :     if (ret == -1) {
+    1589           0 :         dlt_log(LOG_ERR, "Sending message to passive DLT Daemon failed\n");
+    1590           0 :         return DLT_RETURN_ERROR;
+    1591             :     }
+    1592             :     else {
+    1593           0 :         ret = send(con->client.sock, msg->databuffer, msg->datasize, 0);
+    1594             : 
+    1595           0 :         if (ret == -1) {
+    1596           0 :             dlt_log(LOG_ERR, "Sending message to passive DLT Daemon failed\n");
+    1597           0 :             return DLT_RETURN_ERROR;
+    1598             :         }
+    1599             :     }
+    1600             : 
+    1601           0 :     id_tmp = *((uint32_t *)(msg->databuffer));
+    1602           0 :     id = DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp);
+    1603             : 
+    1604           0 :     dlt_vlog(LOG_INFO,
+    1605             :              "Control message forwarded : %s\n",
+    1606             :              dlt_get_service_name(id));
+    1607           0 :     return DLT_RETURN_OK;
+    1608             : }
+    1609             : 
+    1610           3 : int dlt_gateway_process_on_demand_request(DltGateway *gateway,
+    1611             :                                           DltDaemonLocal *daemon_local,
+    1612             :                                           char node_id[DLT_ID_SIZE],
+    1613             :                                           int connection_status,
+    1614             :                                           int verbose)
+    1615             : {
+    1616             :     int i = 0;
+    1617             :     DltGatewayConnection *con = NULL;
+    1618             : 
+    1619           3 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1620             : 
+    1621           3 :     if ((gateway == NULL) || (daemon_local == NULL) || (node_id == NULL)) {
+    1622           1 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+    1623           1 :         return DLT_RETURN_WRONG_PARAMETER;
+    1624             :     }
+    1625             : 
+    1626             :     /* find connection by ECU id */
+    1627           2 :     for (i = 0; i < gateway->num_connections; i++) {
+    1628           2 :         if (strncmp(node_id, gateway->connections[i].ecuid, DLT_ID_SIZE) == 0) {
+    1629             :             con = &gateway->connections[i];
+    1630             :             break;
+    1631             :         }
+    1632             :     }
+    1633             : 
+    1634           2 :     if (con == NULL) {
+    1635           0 :         dlt_log(LOG_WARNING, "Specified ECUid not found\n");
+    1636           0 :         return DLT_RETURN_ERROR;
+    1637             :     }
+    1638             : 
+    1639           2 :     if (connection_status == 1) { /* try to connect */
+    1640             : 
+    1641           2 :         if (con->status != DLT_GATEWAY_CONNECTED) {
+    1642           1 :             if (dlt_client_connect(&con->client, verbose) == 0) {
+    1643             :                 /* setup dlt connection and add to poll event loop here */
+    1644           0 :                 if (dlt_gateway_add_to_event_loop(daemon_local, con, verbose) != DLT_RETURN_OK) {
+    1645           0 :                     dlt_log(LOG_ERR, "Gateway connection creation failed\n");
+    1646           0 :                     return DLT_RETURN_ERROR;
+    1647             :                 }
+    1648             :             }
+    1649             :             else {
+    1650           1 :                 dlt_log(LOG_ERR, "Could not connect to passive node\n");
+    1651           1 :                 return DLT_RETURN_ERROR;
+    1652             :             }
+    1653             :         }
+    1654             :         else {
+    1655           1 :             dlt_log(LOG_INFO, "Passive node already connected\n");
+    1656             :         }
+    1657             :     }
+    1658           0 :     else if (connection_status == 0) /* disconnect*/
+    1659             :     {
+    1660             : 
+    1661           0 :         con->status = DLT_GATEWAY_DISCONNECTED;
+    1662           0 :         con->trigger = DLT_GATEWAY_ON_DEMAND;
+    1663             : 
+    1664           0 :         if (dlt_event_handler_unregister_connection(&daemon_local->pEvent,
+    1665             :                                                     daemon_local,
+    1666             :                                                     con->client.sock) != 0)
+    1667           0 :             dlt_log(LOG_ERR,
+    1668             :                     "Remove passive node event handler connection failed\n");
+    1669             :     }
+    1670             :     else {
+    1671           0 :         dlt_log(LOG_ERR, "Unknown command (connection_status)\n");
+    1672           0 :         return DLT_RETURN_ERROR;
+    1673             :     }
+    1674             : 
+    1675             :     return DLT_RETURN_OK;
+    1676             : }
+    1677             : 
+    1678          12 : int dlt_gateway_send_control_message(DltGatewayConnection *con,
+    1679             :                                      DltPassiveControlMessage *control_msg,
+    1680             :                                      void *data,
+    1681             :                                      int verbose)
+    1682             : {
+    1683             :     int ret = DLT_RETURN_OK;
+    1684             : 
+    1685          12 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1686             : 
+    1687          12 :     if (con == NULL) {
+    1688           1 :         dlt_vlog(LOG_WARNING,
+    1689             :                  "%s: Invalid parameter given\n",
+    1690             :                  __func__);
+    1691           1 :         return DLT_RETURN_WRONG_PARAMETER;
+    1692             :     }
+    1693             : 
+    1694             :     /* no (more) control message to be send */
+    1695          11 :     if (control_msg->id == 0)
+    1696             :         return DLT_RETURN_ERROR;
+    1697             : 
+    1698             :     /* check sendtime counter and message interval */
+    1699             :     /* sendtime counter is 0 on startup, otherwise positive value */
+    1700          11 :     if ((control_msg->type != CONTROL_MESSAGE_ON_DEMAND) && (con->sendtime_cnt > 0)) {
+    1701           0 :         if (control_msg->interval <= 0)
+    1702             :             return DLT_RETURN_ERROR;
+    1703             : 
+    1704           0 :         if ((control_msg->type == CONTROL_MESSAGE_PERIODIC) ||
+    1705             :             (control_msg->type == CONTROL_MESSAGE_BOTH)) {
+    1706           0 :             if ((con->sendtime_cnt - 1) % control_msg->interval != 0)
+    1707             :                 return DLT_RETURN_ERROR;
+    1708             :         }
+    1709             :     }
+    1710             : 
+    1711          11 :     if (con->send_serial) { /* send serial header */
+    1712           0 :         ret = send(con->client.sock,
+    1713             :                    (void *)dltSerialHeader,
+    1714             :                    sizeof(dltSerialHeader),
+    1715             :                    0);
+    1716             : 
+    1717           0 :         if (ret == -1) {
+    1718           0 :             dlt_log(LOG_ERR, "Sending message to passive DLT Daemon failed\n");
+    1719           0 :             return DLT_RETURN_ERROR;
+    1720             :         }
+    1721             :     }
+    1722             : 
+    1723          11 :     switch (control_msg->id) {
+    1724           4 :     case DLT_SERVICE_ID_GET_LOG_INFO:
+    1725           4 :         return dlt_client_get_log_info(&con->client);
+    1726             :         break;
+    1727           1 :     case DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL:
+    1728           1 :         return dlt_client_get_default_log_level(&con->client);
+    1729             :         break;
+    1730           4 :     case DLT_SERVICE_ID_GET_SOFTWARE_VERSION:
+    1731           4 :         return dlt_client_get_software_version(&con->client);
+    1732             :         break;
+    1733           2 :     case DLT_SERVICE_ID_SET_LOG_LEVEL:
+    1734             : 
+    1735           2 :         if (data == NULL) {
+    1736           1 :             dlt_vlog(LOG_WARNING,
+    1737             :                      "Insufficient data for %s received. Send control request failed.\n",
+    1738             :                      dlt_get_service_name(control_msg->id));
+    1739           1 :             return DLT_RETURN_ERROR;
+    1740             :         }
+    1741             : 
+    1742             :         DltServiceSetLogLevel *req = (DltServiceSetLogLevel *)data;
+    1743           1 :         return dlt_client_send_log_level(&con->client,
+    1744           1 :                                          req->apid,
+    1745           1 :                                          req->ctid,
+    1746           1 :                                          req->log_level);
+    1747             :         break;
+    1748           0 :     default:
+    1749           0 :         dlt_vlog(LOG_WARNING,
+    1750             :                  "Cannot forward request: %s.\n",
+    1751             :                  dlt_get_service_name(control_msg->id));
+    1752             :     }
+    1753             : 
+    1754           0 :     return DLT_RETURN_OK;
+    1755             : }
+    1756             : 
+    1757           0 : DltGatewayConnection *dlt_gateway_get_connection(DltGateway *gateway,
+    1758             :                                                  char *ecu,
+    1759             :                                                  int verbose)
+    1760             : {
+    1761             :     DltGatewayConnection *con = NULL;
+    1762             :     int i = 0;
+    1763             : 
+    1764           0 :     PRINT_FUNCTION_VERBOSE(verbose);
+    1765             : 
+    1766           0 :     if ((gateway == NULL) || (ecu == NULL)) {
+    1767           0 :         dlt_vlog(LOG_ERR, "%s: wrong parameter\n", __func__);
+    1768           0 :         return con;
+    1769             :     }
+    1770             : 
+    1771           0 :     for (i = 0; i < gateway->num_connections; i++) {
+    1772           0 :         con = &gateway->connections[i];
+    1773             : 
+    1774           0 :         if (strncmp(con->ecuid, ecu, DLT_ID_SIZE) == 0)
+    1775           0 :             return con;
+    1776             :     }
+    1777             : 
+    1778           0 :     dlt_vlog(LOG_ERR, "%s: No connection found\n", ecu);
+    1779             : 
+    1780           0 :     return con;
+    1781             : }
+
+
+
+ + + + +
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 00000000..fd7ad92c --- /dev/null +++ b/dlt_lcov_report/gateway/index-sort-f.html @@ -0,0 +1,93 @@ + + + + + + + LCOV - dlt_final_coverage.info - gateway + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - gatewayHitTotalCoverage
Test:dlt_final_coverage.infoLines:38563360.8 %
Date:2024-04-29 13:30: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 %385 / 63382.1 %23 / 28
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/gateway/index-sort-l.html b/dlt_lcov_report/gateway/index-sort-l.html new file mode 100644 index 00000000..d3a4d132 --- /dev/null +++ b/dlt_lcov_report/gateway/index-sort-l.html @@ -0,0 +1,93 @@ + + + + + + + LCOV - dlt_final_coverage.info - gateway + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - gatewayHitTotalCoverage
Test:dlt_final_coverage.infoLines:38563360.8 %
Date:2024-04-29 13:30: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 %385 / 63382.1 %23 / 28
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/gateway/index.html b/dlt_lcov_report/gateway/index.html new file mode 100644 index 00000000..e14f8254 --- /dev/null +++ b/dlt_lcov_report/gateway/index.html @@ -0,0 +1,93 @@ + + + + + + + LCOV - dlt_final_coverage.info - gateway + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - gatewayHitTotalCoverage
Test:dlt_final_coverage.infoLines:38563360.8 %
Date:2024-04-29 13:30: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 %385 / 63382.1 %23 / 28
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/gcov.css b/dlt_lcov_report/gcov.css new file mode 100644 index 00000000..bfd0a83e --- /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 00000000..e1abc006 Binary files /dev/null and b/dlt_lcov_report/glass.png differ diff --git a/dlt_lcov_report/index-sort-f.html b/dlt_lcov_report/index-sort-f.html new file mode 100644 index 00000000..f3519da2 --- /dev/null +++ b/dlt_lcov_report/index-sort-f.html @@ -0,0 +1,153 @@ + + + + + + + LCOV - dlt_final_coverage.info + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top levelHitTotalCoverage
Test:dlt_final_coverage.infoLines:61271114455.0 %
Date:2024-04-29 13:30:27Functions:49066573.7 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Directory Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
console/logstorage +
22.7%22.7%
+
22.7 %75 / 33034.4 %11 / 32
lib +
48.1%48.1%
+
48.1 %1258 / 261364.3 %128 / 199
daemon +
49.6%49.6%
+
49.6 %1699 / 342370.1 %110 / 157
console +
42.3%42.3%
+
42.3 %268 / 63375.9 %22 / 29
gateway +
60.8%60.8%
+
60.8 %385 / 63382.1 %23 / 28
shared +
65.9%65.9%
+
65.9 %1440 / 218489.0 %130 / 146
offlinelogstorage +
75.5%75.5%
+
75.5 %1002 / 132889.2 %66 / 74
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/index-sort-l.html b/dlt_lcov_report/index-sort-l.html new file mode 100644 index 00000000..846da767 --- /dev/null +++ b/dlt_lcov_report/index-sort-l.html @@ -0,0 +1,153 @@ + + + + + + + LCOV - dlt_final_coverage.info + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top levelHitTotalCoverage
Test:dlt_final_coverage.infoLines:61271114455.0 %
Date:2024-04-29 13:30:27Functions:49066573.7 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Directory Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
console/logstorage +
22.7%22.7%
+
22.7 %75 / 33034.4 %11 / 32
console +
42.3%42.3%
+
42.3 %268 / 63375.9 %22 / 29
lib +
48.1%48.1%
+
48.1 %1258 / 261364.3 %128 / 199
daemon +
49.6%49.6%
+
49.6 %1699 / 342370.1 %110 / 157
gateway +
60.8%60.8%
+
60.8 %385 / 63382.1 %23 / 28
shared +
65.9%65.9%
+
65.9 %1440 / 218489.0 %130 / 146
offlinelogstorage +
75.5%75.5%
+
75.5 %1002 / 132889.2 %66 / 74
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/index.html b/dlt_lcov_report/index.html new file mode 100644 index 00000000..96ee83f1 --- /dev/null +++ b/dlt_lcov_report/index.html @@ -0,0 +1,153 @@ + + + + + + + LCOV - dlt_final_coverage.info + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top levelHitTotalCoverage
Test:dlt_final_coverage.infoLines:61271114455.0 %
Date:2024-04-29 13:30:27Functions:49066573.7 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Directory Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
console +
42.3%42.3%
+
42.3 %268 / 63375.9 %22 / 29
console/logstorage +
22.7%22.7%
+
22.7 %75 / 33034.4 %11 / 32
daemon +
49.6%49.6%
+
49.6 %1699 / 342370.1 %110 / 157
gateway +
60.8%60.8%
+
60.8 %385 / 63382.1 %23 / 28
lib +
48.1%48.1%
+
48.1 %1258 / 261364.3 %128 / 199
offlinelogstorage +
75.5%75.5%
+
75.5 %1002 / 132889.2 %66 / 74
shared +
65.9%65.9%
+
65.9 %1440 / 218489.0 %130 / 146
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/lib/dlt_client.c.func-sort-c.html b/dlt_lcov_report/lib/dlt_client.c.func-sort-c.html new file mode 100644 index 00000000..e4e28b98 --- /dev/null +++ b/dlt_lcov_report/lib/dlt_client.c.func-sort-c.html @@ -0,0 +1,196 @@ + + + + + + + LCOV - dlt_final_coverage.info - lib/dlt_client.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - lib - dlt_client.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:24053444.9 %
Date:2024-04-29 13:30:27Functions:153148.4 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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

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

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

Function Name Sort by function nameHit count Sort by hit count
dlt_env_adjust_ll_from_env205
dlt_env_extract_id0
dlt_env_extract_ll0
dlt_env_extract_ll_item0
dlt_env_extract_ll_set0
dlt_env_extract_symbolic_ll0
dlt_env_free_ll_set5439
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 00000000..3dec3e7f --- /dev/null +++ b/dlt_lcov_report/lib/dlt_env_ll.c.gcov.html @@ -0,0 +1,576 @@ + + + + + + + LCOV - dlt_final_coverage.info - lib/dlt_env_ll.c + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - lib - dlt_env_ll.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:81326.1 %
Date:2024-04-29 13:30: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        5439 : void dlt_env_free_ll_set(dlt_env_ll_set *const ll_set)
+     308             : {
+     309        5439 :     if (!ll_set) {
+     310             :         return;
+     311             :     }
+     312             : 
+     313        5439 :     if (ll_set->item != NULL) {
+     314           0 :         free(ll_set->item);
+     315           0 :         ll_set->item = NULL;
+     316             :     }
+     317             : 
+     318        5439 :     ll_set->array_size = 0u;
+     319        5439 :     ll_set->num_elem = 0u;
+     320             : }
+     321             : 
+     322             : 
+     323             : /**
+     324             :  * @brief increase size of ll_set by LL_SET_INCREASE elements
+     325             :  *
+     326             :  * @return -1 if memory could not be allocated
+     327             :  * @return 0 on success
+     328             :  */
+     329           0 : int dlt_env_increase_ll_set(dlt_env_ll_set *const ll_set)
+     330             : {
+     331             :     dlt_env_ll_item *old_set;
+     332             :     size_t old_size;
+     333             : 
+     334           0 :     if (!ll_set) {
+     335             :         return -1;
+     336             :     }
+     337             : 
+     338           0 :     old_set = ll_set->item;
+     339           0 :     old_size = ll_set->array_size;
+     340             : 
+     341           0 :     ll_set->array_size += DLT_ENV_LL_SET_INCREASE;
+     342           0 :     ll_set->item = (dlt_env_ll_item *)malloc(sizeof(dlt_env_ll_item) * ll_set->array_size);
+     343             : 
+     344           0 :     if (!ll_set->item) {
+     345             :         /* should trigger a warning: no memory left */
+     346           0 :         ll_set->array_size -= DLT_ENV_LL_SET_INCREASE;
+     347           0 :         return -1;
+     348             :     } else {
+     349           0 :         memcpy(ll_set->item, old_set, sizeof(dlt_env_ll_item) * old_size);
+     350           0 :         free(old_set);
+     351           0 :         return 0;
+     352             :     }
+     353             : }
+     354             : 
+     355             : 
+     356             : /**
+     357             :  * @brief extract all items out of string
+     358             :  *
+     359             :  * The given set is initialized within this function (memory is allocated).
+     360             :  * Make sure, that the caller frees this memory when it is no longer needed!
+     361             :  *
+     362             :  * @return 0 if successful, -1 else
+     363             :  */
+     364           0 : int dlt_env_extract_ll_set(char **const env, dlt_env_ll_set *const ll_set)
+     365             : {
+     366           0 :     if (!env || !ll_set) {
+     367             :         return -1;
+     368             :     }
+     369             : 
+     370           0 :     if (!(*env)) {
+     371             :         return -1;
+     372             :     }
+     373             : 
+     374           0 :     if (dlt_env_init_ll_set(ll_set) == -1) {
+     375             :         return -1;
+     376             :     }
+     377             : 
+     378             :     do {
+     379           0 :         if (ll_set->num_elem == ll_set->array_size) {
+     380           0 :             if (dlt_env_increase_ll_set(ll_set) == -1) {
+     381             :                 return -1;
+     382             :             }
+     383             :         }
+     384             : 
+     385           0 :         if (dlt_env_extract_ll_item(env, &ll_set->item[ll_set->num_elem++]) == -1) {
+     386             :             return -1;
+     387             :         }
+     388             : 
+     389           0 :         if (**env == ';') {
+     390           0 :             (*env)++;
+     391             :         }
+     392           0 :     } while (**env != 0);
+     393             : 
+     394             :     return 0;
+     395             : }
+     396             : 
+     397             : 
+     398             : /**
+     399             :  * @brief check if two ids match
+     400             :  *
+     401             :  * @return 1 if matching, 0 if not
+     402             :  */
+     403           0 : int dlt_env_ids_match(char const *const a, char const *const b)
+     404             : {
+     405           0 :     if (a[0] != b[0]) {
+     406             :         return 0;
+     407             :     }
+     408             : 
+     409           0 :     if (a[1] != b[1]) {
+     410             :         return 0;
+     411             :     }
+     412             : 
+     413           0 :     if (a[2] != b[2]) {
+     414             :         return 0;
+     415             :     }
+     416             : 
+     417           0 :     if (a[3] != b[3]) {
+     418           0 :         return 0;
+     419             :     }
+     420             : 
+     421             :     return 1;
+     422             : }
+     423             : 
+     424             : 
+     425             : /**
+     426             :  * @brief check if (and how) apid and ctid match with given item
+     427             :  *
+     428             :  * Resulting priorities:
+     429             :  * - no apid, no ctid only ll given in item: use ll with prio 1
+     430             :  * - no apid, ctid matches: use ll with prio 2
+     431             :  * - no ctid, apid matches: use ll with prio 3
+     432             :  * - apid, ctid matches: use ll with prio 4
+     433             :  *
+     434             :  * In case of error, -1 is returned.
+     435             :  */
+     436           0 : int dlt_env_ll_item_get_matching_prio(dlt_env_ll_item const *const item,
+     437             :                                       char const *const apid,
+     438             :                                       char const *const ctid)
+     439             : {
+     440           0 :     if ((!item) || (!apid) || (!ctid)) {
+     441             :         return -1;
+     442             :     }
+     443             : 
+     444           0 :     if (item->appId[0] == 0) {
+     445           0 :         if (item->ctxId[0] == 0) {
+     446             :             return 1;
+     447           0 :         } else if (dlt_env_ids_match(item->ctxId, ctid)) {
+     448           0 :             return 2;
+     449             :         }
+     450           0 :     } else if (dlt_env_ids_match(item->appId, apid)) {
+     451           0 :         if (item->ctxId[0] == 0) {
+     452             :             return 3;
+     453           0 :         } else if (dlt_env_ids_match(item->ctxId, ctid)) {
+     454           0 :             return 4;
+     455             :         }
+     456             :     }
+     457             : 
+     458             :     return 0;
+     459             : }
+     460             : 
+     461             : 
+     462             : /**
+     463             :  * @brief adjust log-level based on values given through environment
+     464             :  *
+     465             :  * Iterate over the set of items, and find the best match (\see ll_item_get_matching_prio)
+     466             :  * For any item that matches, the one with the highest priority is selected and that
+     467             :  * log-level is returned.
+     468             :  *
+     469             :  * If no item matches or in case of error, the original log-level (\param ll) is returned
+     470             :  */
+     471         205 : int dlt_env_adjust_ll_from_env(dlt_env_ll_set const *const ll_set,
+     472             :                                char const *const apid,
+     473             :                                char const *const ctid,
+     474             :                                int const ll)
+     475             : {
+     476         205 :     if ((!ll_set) || (!apid) || (!ctid)) {
+     477             :         return ll;
+     478             :     }
+     479             : 
+     480             :     int res = ll;
+     481             :     int prio = 0; /* no match so far */
+     482             :     size_t i;
+     483             : 
+     484         205 :     for (i = 0; i < ll_set->num_elem; ++i) {
+     485           0 :         int p = dlt_env_ll_item_get_matching_prio(&ll_set->item[i], apid, ctid);
+     486             : 
+     487           0 :         if (p > prio) {
+     488             :             prio = p;
+     489           0 :             res = ll_set->item[i].ll;
+     490             : 
+     491           0 :             if (p == 4) { /* maximum reached, immediate return */
+     492           0 :                 return res;
+     493             :             }
+     494             :         }
+     495             :     }
+     496             : 
+     497             :     return res;
+     498             : }
+     499             : 
+     500             : 
+
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/lib/dlt_filetransfer.c.func-sort-c.html b/dlt_lcov_report/lib/dlt_filetransfer.c.func-sort-c.html new file mode 100644 index 00000000..67bc700a --- /dev/null +++ b/dlt_lcov_report/lib/dlt_filetransfer.c.func-sort-c.html @@ -0,0 +1,144 @@ + + + + + + + LCOV - dlt_final_coverage.info - lib/dlt_filetransfer.c - functions + + + + + + + + + + + + + + +
LCOV - code coverage report
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Current view:top level - lib - dlt_filetransfer.c (source / functions)HitTotalCoverage
Test:dlt_final_coverage.infoLines:01990.0 %
Date:2024-04-29 13:30:27Functions:0180.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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

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

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

Function Name Sort by function nameHit count Sort by hit count
check_buffer0
dlt_disable_local_print0
dlt_enable_local_print0
dlt_fork_child_fork_handler0
dlt_get_appid0
dlt_init_file0
dlt_init_message_queue0
dlt_register_context_llccb0
dlt_register_injection_callback0
dlt_register_injection_callback_with_id0
dlt_send_app_ll_ts_limit0
dlt_set_application_ll_ts_limit0
dlt_set_filesize_max0
dlt_set_resend_timeout_atexit0
dlt_user_check_buffer0
dlt_user_log_send_overflow0
dlt_user_log_write_finish_w_given_buffer0
dlt_user_log_write_ptr0
dlt_user_log_write_start_w_given_buffer0
dlt_user_print_msg0
dlt_user_trace_network_segmented_end0
dlt_user_trace_network_segmented_segment0
dlt_user_trace_network_segmented_start0
dlt_user_trace_network_segmented_thread_segmenter0
dlt_with_ecu_id0
dlt_with_session_id0
dlt_with_timestamp0
dlt_get_log_state1
dlt_log_marker1
dlt_register_log_level_changed_callback1
dlt_user_log_send_marker1
dlt_user_log_write_sized_constant_string1
dlt_use_extended_header_for_non_verbose2
dlt_user_log_write_sized_string2
dlt_user_log_write_bool3
dlt_user_log_write_bool_attr3
dlt_user_log_write_raw_attr3
dlt_user_log_write_raw_formatted_attr3
dlt_user_log_write_sized_constant_string_attr3
dlt_set_log_mode4
dlt_user_log_send_log_mode4
dlt_user_log_write_constant_utf8_string_attr4
dlt_user_log_write_sized_constant_utf8_string_attr4
dlt_user_log_write_uint164
dlt_user_log_write_uint644
dlt_user_log_write_uint84
dlt_user_log_write_constant_string_attr5
dlt_user_log_write_constant_utf8_string5
dlt_user_log_write_sized_constant_utf8_string5
dlt_user_log_write_int166
dlt_user_log_write_int646
dlt_user_log_write_int86
dlt_user_log_write_sized_string_attr6
dlt_check_library_version7
dlt_unregister_app_flush_buffered_logs7
dlt_user_atexit_blow_out_user_buffer7
dlt_user_check_library_version7
dlt_user_log_write_constant_string7
dlt_user_log_write_float327
dlt_user_log_write_float32_attr7
dlt_user_log_write_float647
dlt_user_log_write_float64_attr7
dlt_user_log_write_int16_attr7
dlt_user_log_write_int64_attr7
dlt_user_log_write_int8_attr7
dlt_user_log_write_int_attr7
dlt_user_log_write_sized_utf8_string_attr7
dlt_user_log_write_string_attr7
dlt_user_log_write_uint16_attr7
dlt_user_log_write_uint64_attr7
dlt_user_log_write_uint8_attr7
dlt_user_log_write_uint_attr7
dlt_user_log_write_utf8_string_attr7
dlt_user_trace_network_segmented7
dlt_user_atexit_handler8
dlt_user_log_write_sized_utf8_string8
dlt_nonverbose_mode10
dlt_verbose_mode10
dlt_log_raw11
dlt_user_log_write_raw13
dlt_user_log_write_int32_attr14
dlt_user_trace_network14
dlt_log_string18
dlt_user_log_write_uint32_attr18
dlt_user_log_write_raw_formatted19
dlt_user_log_write_utf8_string21
dlt_user_trace_network_truncated21
dlt_log_int22
dlt_log_uint22
dlt_user_log_write_start_id23
dlt_log_string_int25
dlt_log_string_uint25
dlt_user_log_write_uint16_formatted28
dlt_user_log_write_uint32_formatted28
dlt_user_log_write_uint64_formatted28
dlt_user_log_write_uint8_formatted28
dlt_user_log_write_uint35
dlt_user_log_write_int37
dlt_user_log_write_raw_internal38
dlt_user_log_write_int3242
dlt_user_log_write_generic_formatted112
dlt_user_log_reattach_to_daemon121
dlt_unregister_app167
dlt_user_log_send_register_application171
dlt_register_app176
dlt_unregister_app_util181
dlt_user_log_send_unregister_application181
dlt_register_context203
dlt_unregister_context204
dlt_user_log_send_unregister_context204
dlt_user_log_send_register_context205
dlt_register_context_ll_ts216
dlt_register_context_ll_ts_llccb216
dlt_user_log_out_error_handling859
dlt_initialize_fifo_connection5439
dlt_start_threads5439
dlt_stop_threads5439
dlt_init_common5440
dlt_user_log_check_user_message5455
dlt_user_log_resend_buffer5834
dlt_user_log_write_start5926
dlt_user_log_write_start_init6001
dlt_user_log_send_log6008
dlt_user_log_write_finish6008
dlt_user_log_write_start_internal6059
dlt_user_log_init6411
dlt_lock_mutex10878
dlt_user_cleanup_handler10878
dlt_user_housekeeperthread_function10878
dlt_user_trace_network_segmented_thread10878
dlt_user_log_write_uint3211580
dlt_user_log_write_string11686
dlt_user_log_write_string_utils_attr11721
dlt_user_log_write_sized_string_utils_attr11729
dlt_user_log_write_generic_attr11760
dlt_unlock_mutex16317
dlt_free23947
dlt_init4559601
+
+
+ + + +
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 00000000..a1604763 --- /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:1010174857.8 %
Date:2024-04-29 13:30:27Functions:11113880.4 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
check_buffer0
dlt_check_library_version7
dlt_disable_local_print0
dlt_enable_local_print0
dlt_fork_child_fork_handler0
dlt_free23947
dlt_get_appid0
dlt_get_log_state1
dlt_init4559601
dlt_init_common5440
dlt_init_file0
dlt_init_message_queue0
dlt_initialize_fifo_connection5439
dlt_lock_mutex10878
dlt_log_int22
dlt_log_marker1
dlt_log_raw11
dlt_log_string18
dlt_log_string_int25
dlt_log_string_uint25
dlt_log_uint22
dlt_nonverbose_mode10
dlt_register_app176
dlt_register_context203
dlt_register_context_ll_ts216
dlt_register_context_ll_ts_llccb216
dlt_register_context_llccb0
dlt_register_injection_callback0
dlt_register_injection_callback_with_id0
dlt_register_log_level_changed_callback1
dlt_send_app_ll_ts_limit0
dlt_set_application_ll_ts_limit0
dlt_set_filesize_max0
dlt_set_log_mode4
dlt_set_resend_timeout_atexit0
dlt_start_threads5439
dlt_stop_threads5439
dlt_unlock_mutex16317
dlt_unregister_app167
dlt_unregister_app_flush_buffered_logs7
dlt_unregister_app_util181
dlt_unregister_context204
dlt_use_extended_header_for_non_verbose2
dlt_user_atexit_blow_out_user_buffer7
dlt_user_atexit_handler8
dlt_user_check_buffer0
dlt_user_check_library_version7
dlt_user_cleanup_handler10878
dlt_user_housekeeperthread_function10878
dlt_user_log_check_user_message5455
dlt_user_log_init6411
dlt_user_log_out_error_handling859
dlt_user_log_reattach_to_daemon121
dlt_user_log_resend_buffer5834
dlt_user_log_send_log6008
dlt_user_log_send_log_mode4
dlt_user_log_send_marker1
dlt_user_log_send_overflow0
dlt_user_log_send_register_application171
dlt_user_log_send_register_context205
dlt_user_log_send_unregister_application181
dlt_user_log_send_unregister_context204
dlt_user_log_write_bool3
dlt_user_log_write_bool_attr3
dlt_user_log_write_constant_string7
dlt_user_log_write_constant_string_attr5
dlt_user_log_write_constant_utf8_string5
dlt_user_log_write_constant_utf8_string_attr4
dlt_user_log_write_finish6008
dlt_user_log_write_finish_w_given_buffer0
dlt_user_log_write_float327
dlt_user_log_write_float32_attr7
dlt_user_log_write_float647
dlt_user_log_write_float64_attr7
dlt_user_log_write_generic_attr11760
dlt_user_log_write_generic_formatted112
dlt_user_log_write_int37
dlt_user_log_write_int166
dlt_user_log_write_int16_attr7
dlt_user_log_write_int3242
dlt_user_log_write_int32_attr14
dlt_user_log_write_int646
dlt_user_log_write_int64_attr7
dlt_user_log_write_int86
dlt_user_log_write_int8_attr7
dlt_user_log_write_int_attr7
dlt_user_log_write_ptr0
dlt_user_log_write_raw13
dlt_user_log_write_raw_attr3
dlt_user_log_write_raw_formatted19
dlt_user_log_write_raw_formatted_attr3
dlt_user_log_write_raw_internal38
dlt_user_log_write_sized_constant_string1
dlt_user_log_write_sized_constant_string_attr3
dlt_user_log_write_sized_constant_utf8_string5
dlt_user_log_write_sized_constant_utf8_string_attr4
dlt_user_log_write_sized_string2
dlt_user_log_write_sized_string_attr6
dlt_user_log_write_sized_string_utils_attr11729
dlt_user_log_write_sized_utf8_string8
dlt_user_log_write_sized_utf8_string_attr7
dlt_user_log_write_start5926
dlt_user_log_write_start_id23
dlt_user_log_write_start_init6001
dlt_user_log_write_start_internal6059
dlt_user_log_write_start_w_given_buffer0
dlt_user_log_write_string11686
dlt_user_log_write_string_attr7
dlt_user_log_write_string_utils_attr11721
dlt_user_log_write_uint35
dlt_user_log_write_uint164
dlt_user_log_write_uint16_attr7
dlt_user_log_write_uint16_formatted28
dlt_user_log_write_uint3211580
dlt_user_log_write_uint32_attr18
dlt_user_log_write_uint32_formatted28
dlt_user_log_write_uint644
dlt_user_log_write_uint64_attr7
dlt_user_log_write_uint64_formatted28
dlt_user_log_write_uint84
dlt_user_log_write_uint8_attr7
dlt_user_log_write_uint8_formatted28
dlt_user_log_write_uint_attr7
dlt_user_log_write_utf8_string21
dlt_user_log_write_utf8_string_attr7
dlt_user_print_msg0
dlt_user_trace_network14
dlt_user_trace_network_segmented7
dlt_user_trace_network_segmented_end0
dlt_user_trace_network_segmented_segment0
dlt_user_trace_network_segmented_start0
dlt_user_trace_network_segmented_thread10878
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 00000000..5f02e400 --- /dev/null +++ b/dlt_lcov_report/lib/dlt_user.c.gcov.html @@ -0,0 +1,5281 @@ + + + + + + + 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:1010174857.8 %
Date:2024-04-29 13:30:27Functions:11113880.4 %
+
+ + + + + + + + +

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

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_filetransfer.c +
0.0%
+
0.0 %0 / 1990.0 %0 / 18
dlt_env_ll.c +
6.1%6.1%
+
6.1 %8 / 13216.7 %2 / 12
dlt_client.c +
44.9%44.9%
+
44.9 %240 / 53448.4 %15 / 31
dlt_user.c +
57.8%57.8%
+
57.8 %1010 / 174880.4 %111 / 138
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/lib/index-sort-l.html b/dlt_lcov_report/lib/index-sort-l.html new file mode 100644 index 00000000..73741c2c --- /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:1258261348.1 %
Date:2024-04-29 13:30:27Functions:12819964.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_filetransfer.c +
0.0%
+
0.0 %0 / 1990.0 %0 / 18
dlt_env_ll.c +
6.1%6.1%
+
6.1 %8 / 13216.7 %2 / 12
dlt_client.c +
44.9%44.9%
+
44.9 %240 / 53448.4 %15 / 31
dlt_user.c +
57.8%57.8%
+
57.8 %1010 / 174880.4 %111 / 138
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/lib/index.html b/dlt_lcov_report/lib/index.html new file mode 100644 index 00000000..67968966 --- /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:1258261348.1 %
Date:2024-04-29 13:30:27Functions:12819964.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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

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

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

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

Function Name Sort by function nameHit count Sort by hit count
dlt_logstorage_close_file2
dlt_logstorage_rearrange_file_name3
dlt_logstorage_write_to_log5
dlt_logstorage_find_last_dlt_header86
dlt_logstorage_log_file_name147
dlt_logstorage_sync_to_file187
dlt_logstorage_open_log_output_file198
dlt_logstorage_check_write_ret200
dlt_logstorage_find_dlt_header270
dlt_logstorage_concat_logfile_name297
dlt_logstorage_sort_file_name321
dlt_logstorage_open_log_file324
dlt_logstorage_storage_dir_info325
dlt_logstorage_get_idx_of_log_file457
dlt_logstorage_write_on_msg693
dlt_logstorage_prepare_on_msg708
dlt_logstorage_sync_on_msg714
dlt_logstorage_write_msg_cache3093
dlt_logstorage_prepare_msg_cache3098
dlt_logstorage_sync_msg_cache3299
+
+
+ + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage_behavior.c.func.html b/dlt_lcov_report/offlinelogstorage/dlt_offline_logstorage_behavior.c.func.html new file mode 100644 index 00000000..4d904a3a --- /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:40448483.5 %
Date:2024-04-29 13:30:27Functions:2020100.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

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

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_offline_logstorage.c +
70.9%70.9%
+
70.9 %598 / 84485.2 %46 / 54
dlt_offline_logstorage_behavior.c +
83.5%83.5%
+
83.5 %404 / 484100.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 00000000..088f2467 --- /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:1002132875.5 %
Date:2024-04-29 13:30:27Functions:667489.2 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_offline_logstorage.c +
70.9%70.9%
+
70.9 %598 / 84485.2 %46 / 54
dlt_offline_logstorage_behavior.c +
83.5%83.5%
+
83.5 %404 / 484100.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 00000000..286e32ba --- /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:1002132875.5 %
Date:2024-04-29 13:30:27Functions:667489.2 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_offline_logstorage.c +
70.9%70.9%
+
70.9 %598 / 84485.2 %46 / 54
dlt_offline_logstorage_behavior.c +
83.5%83.5%
+
83.5 %404 / 484100.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 00000000..991b6d4e Binary files /dev/null and b/dlt_lcov_report/ruby.png differ 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 00000000..7bcbcc7f --- /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:1117175463.7 %
Date:2024-04-29 13:30:27Functions:9611087.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_buffer_free_static0
dlt_buffer_init_static_client0
dlt_buffer_init_static_server0
dlt_convert_serial_speed0
dlt_execute_command0
dlt_file_close0
dlt_file_read_header_raw0
dlt_file_read_raw0
dlt_filter_delete0
dlt_filter_save0
dlt_hex_ascii_to_binary0
dlt_print_hex0
dlt_print_with_attributes0
dlt_setup_serial0
dlt_filter_free1
dlt_buffer_info2
dlt_buffer_status2
dlt_log_free_single_logfile2
dlt_set_loginfo_parse_service_id2
dlt_buffer_get_total_size3
dlt_file_quick_parsing3
dlt_log_free_multiple_logfiles3
dlt_log_init_multiple_logfiles4
dlt_log_init_single_logfile4
get_filename_ext5
dlt_extract_base_name_without_ext6
dlt_file_set_filter6
dlt_filter_load6
dlt_buffer_increase_size7
dlt_buffer_remove7
dlt_filter_init7
dlt_buffer_minimize_size8
dlt_buffer_pull8
dlt_buffer_reset9
dlt_check_rcv_data_size9
dlt_get_major_version9
dlt_get_minor_version9
dlt_receiver_free_global_buffer9
dlt_receiver_init_global_buffer9
dlt_getloginfo_conv_ascii_to_string11
dlt_filter_add12
dlt_filter_find12
dlt_getloginfo_conv_ascii_to_int16_t12
dlt_log_init12
dlt_log_multiple_files_write12
dlt_buffer_copy13
dlt_getloginfo_conv_ascii_to_uint16_t14
dlt_log_free15
dlt_log_set_filename17
dlt_log_set_level19
dlt_getloginfo_conv_ascii_to_id20
dlt_get_version22
dlt_log_init_multiple_logfiles_support26
dlt_is_log_in_multiple_files_active37
dlt_buffer_read_block53
dlt_buffer_get64
dlt_file_open67
dlt_file_free69
dlt_file_init71
dlt_message_free126
dlt_receiver_check_and_get133
dlt_message_print_ascii328
dlt_message_print_header328
dlt_message_print_hex328
dlt_message_print_mixed_html328
dlt_message_print_mixed_plain328
dlt_message_filter_check742
dlt_buffer_check_size859
dlt_print_mixed_string1062
dlt_clean_string1549
dlt_print_char_string1661
dlt_receiver_move_to_begin1703
dlt_receiver_receive1709
dlt_buffer_get_used_size2503
dlt_message_header2615
dlt_print_hex_string2724
dlt_print_hex_string_delim2733
dlt_user_printf2852
dlt_file_read2965
dlt_message_payload3326
dlt_message_argument_print3551
dlt_file_message3965
dlt_file_read_data4070
dlt_file_read_header_extended4700
dlt_message_header_flags5317
dlt_vnlog5433
dlt_check_envvar5439
dlt_log_set_fifo_basedir5448
dlt_receiver_free5480
dlt_receiver_init5481
dlt_buffer_free_dynamic5544
dlt_buffer_init_dynamic5570
dlt_receiver_remove6097
dlt_message_init6127
dlt_print_id6205
dlt_strnlen_s6207
dlt_message_set_extraparameters6247
dlt_uptime6301
dlt_message_read6671
dlt_check_storageheader6979
dlt_file_read_header7035
dlt_message_get_extraparameters7410
dlt_buffer_push7516
dlt_buffer_get_message_count8528
dlt_set_storageheader12103
dlt_buffer_push315284
dlt_buffer_write_block41031
dlt_set_id54623
dlt_log1917449
dlt_vlog1931922
+
+
+ + + +
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 00000000..05c9201a --- /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:1117175463.7 %
Date:2024-04-29 13:30:27Functions:9611087.3 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Function Name Sort by function nameHit count Sort by hit count
dlt_buffer_check_size859
dlt_buffer_copy13
dlt_buffer_free_dynamic5544
dlt_buffer_free_static0
dlt_buffer_get64
dlt_buffer_get_message_count8528
dlt_buffer_get_total_size3
dlt_buffer_get_used_size2503
dlt_buffer_increase_size7
dlt_buffer_info2
dlt_buffer_init_dynamic5570
dlt_buffer_init_static_client0
dlt_buffer_init_static_server0
dlt_buffer_minimize_size8
dlt_buffer_pull8
dlt_buffer_push7516
dlt_buffer_push315284
dlt_buffer_read_block53
dlt_buffer_remove7
dlt_buffer_reset9
dlt_buffer_status2
dlt_buffer_write_block41031
dlt_check_envvar5439
dlt_check_rcv_data_size9
dlt_check_storageheader6979
dlt_clean_string1549
dlt_convert_serial_speed0
dlt_execute_command0
dlt_extract_base_name_without_ext6
dlt_file_close0
dlt_file_free69
dlt_file_init71
dlt_file_message3965
dlt_file_open67
dlt_file_quick_parsing3
dlt_file_read2965
dlt_file_read_data4070
dlt_file_read_header7035
dlt_file_read_header_extended4700
dlt_file_read_header_raw0
dlt_file_read_raw0
dlt_file_set_filter6
dlt_filter_add12
dlt_filter_delete0
dlt_filter_find12
dlt_filter_free1
dlt_filter_init7
dlt_filter_load6
dlt_filter_save0
dlt_get_major_version9
dlt_get_minor_version9
dlt_get_version22
dlt_getloginfo_conv_ascii_to_id20
dlt_getloginfo_conv_ascii_to_int16_t12
dlt_getloginfo_conv_ascii_to_string11
dlt_getloginfo_conv_ascii_to_uint16_t14
dlt_hex_ascii_to_binary0
dlt_is_log_in_multiple_files_active37
dlt_log1917449
dlt_log_free15
dlt_log_free_multiple_logfiles3
dlt_log_free_single_logfile2
dlt_log_init12
dlt_log_init_multiple_logfiles4
dlt_log_init_multiple_logfiles_support26
dlt_log_init_single_logfile4
dlt_log_multiple_files_write12
dlt_log_set_fifo_basedir5448
dlt_log_set_filename17
dlt_log_set_level19
dlt_message_argument_print3551
dlt_message_filter_check742
dlt_message_free126
dlt_message_get_extraparameters7410
dlt_message_header2615
dlt_message_header_flags5317
dlt_message_init6127
dlt_message_payload3326
dlt_message_print_ascii328
dlt_message_print_header328
dlt_message_print_hex328
dlt_message_print_mixed_html328
dlt_message_print_mixed_plain328
dlt_message_read6671
dlt_message_set_extraparameters6247
dlt_print_char_string1661
dlt_print_hex0
dlt_print_hex_string2724
dlt_print_hex_string_delim2733
dlt_print_id6205
dlt_print_mixed_string1062
dlt_print_with_attributes0
dlt_receiver_check_and_get133
dlt_receiver_free5480
dlt_receiver_free_global_buffer9
dlt_receiver_init5481
dlt_receiver_init_global_buffer9
dlt_receiver_move_to_begin1703
dlt_receiver_receive1709
dlt_receiver_remove6097
dlt_set_id54623
dlt_set_loginfo_parse_service_id2
dlt_set_storageheader12103
dlt_setup_serial0
dlt_strnlen_s6207
dlt_uptime6301
dlt_user_printf2852
dlt_vlog1931922
dlt_vnlog5433
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 00000000..ea4d9c90 --- /dev/null +++ b/dlt_lcov_report/shared/dlt_common.c.gcov.html @@ -0,0 +1,4528 @@ + + + + + + + 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:1117175463.7 %
Date:2024-04-29 13:30:27Functions:9611087.3 %
+
+ + + + + + + + +

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

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

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

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

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_offline_trace.c +
0.0%
+
0.0 %0 / 60.0 %0 / 1
dlt_user_shared.c +
77.8%77.8%
+
77.8 %42 / 5483.3 %5 / 6
dlt_common.c +
63.7%63.7%
+
63.7 %1117 / 175487.3 %96 / 110
dlt_protocol.c +
85.7%85.7%
+
85.7 %6 / 7100.0 %1 / 1
dlt_multiple_files.c +
68.9%68.9%
+
68.9 %133 / 193100.0 %13 / 13
dlt_config_file_parser.c +
83.5%83.5%
+
83.5 %142 / 170100.0 %15 / 15
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/index-sort-l.html b/dlt_lcov_report/shared/index-sort-l.html new file mode 100644 index 00000000..f9e31d2e --- /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:1440218465.9 %
Date:2024-04-29 13:30:27Functions:13014689.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_offline_trace.c +
0.0%
+
0.0 %0 / 60.0 %0 / 1
dlt_common.c +
63.7%63.7%
+
63.7 %1117 / 175487.3 %96 / 110
dlt_multiple_files.c +
68.9%68.9%
+
68.9 %133 / 193100.0 %13 / 13
dlt_user_shared.c +
77.8%77.8%
+
77.8 %42 / 5483.3 %5 / 6
dlt_config_file_parser.c +
83.5%83.5%
+
83.5 %142 / 170100.0 %15 / 15
dlt_protocol.c +
85.7%85.7%
+
85.7 %6 / 7100.0 %1 / 1
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/shared/index.html b/dlt_lcov_report/shared/index.html new file mode 100644 index 00000000..0588d3f7 --- /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:1440218465.9 %
Date:2024-04-29 13:30:27Functions:13014689.0 %
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Filename Sort by nameLine Coverage Sort by line coverageFunctions Sort by function coverage
dlt_common.c +
63.7%63.7%
+
63.7 %1117 / 175487.3 %96 / 110
dlt_config_file_parser.c +
83.5%83.5%
+
83.5 %142 / 170100.0 %15 / 15
dlt_multiple_files.c +
68.9%68.9%
+
68.9 %133 / 193100.0 %13 / 13
dlt_offline_trace.c +
0.0%
+
0.0 %0 / 60.0 %0 / 1
dlt_protocol.c +
85.7%85.7%
+
85.7 %6 / 7100.0 %1 / 1
dlt_user_shared.c +
77.8%77.8%
+
77.8 %42 / 5483.3 %5 / 6
+
+
+ + + + +
Generated by: LCOV version 1.14
+
+ + + diff --git a/dlt_lcov_report/snow.png b/dlt_lcov_report/snow.png new file mode 100644 index 00000000..2cdae107 Binary files /dev/null and b/dlt_lcov_report/snow.png differ diff --git a/dlt_lcov_report/updown.png b/dlt_lcov_report/updown.png new file mode 100644 index 00000000..aa56a238 Binary files /dev/null and b/dlt_lcov_report/updown.png differ diff --git a/googletest b/googletest deleted file mode 160000 index b796f7d4..00000000 --- a/googletest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b796f7d44681514f58a683a3a71ff17c94edb0c1