summaryrefslogtreecommitdiff
path: root/src/daemon
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon')
-rw-r--r--src/daemon/dlt-daemon.c2217
-rw-r--r--src/daemon/dlt-daemon.h85
-rw-r--r--src/daemon/dlt_daemon_client.c2017
-rw-r--r--src/daemon/dlt_daemon_client.h116
-rw-r--r--src/daemon/dlt_daemon_common.c1023
-rw-r--r--src/daemon/dlt_daemon_common.h112
-rw-r--r--src/daemon/dlt_daemon_common_cfg.h18
-rw-r--r--src/daemon/dlt_daemon_connection.c122
-rw-r--r--src/daemon/dlt_daemon_connection.h16
-rw-r--r--src/daemon/dlt_daemon_event_handler.c155
-rw-r--r--src/daemon/dlt_daemon_event_handler.h20
-rw-r--r--src/daemon/dlt_daemon_event_handler_types.h6
-rw-r--r--src/daemon/dlt_daemon_offline_logstorage.c509
-rw-r--r--src/daemon/dlt_daemon_offline_logstorage_internal.h8
-rw-r--r--src/daemon/dlt_daemon_serial.c24
-rw-r--r--src/daemon/dlt_daemon_serial.h2
-rw-r--r--src/daemon/dlt_daemon_socket.c66
-rw-r--r--src/daemon/dlt_daemon_socket.h4
-rw-r--r--src/daemon/dlt_daemon_unix_socket.c15
19 files changed, 3025 insertions, 3510 deletions
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c
index e3475d4..b7766f0 100644
--- a/src/daemon/dlt-daemon.c
+++ b/src/daemon/dlt-daemon.c
@@ -43,12 +43,12 @@
#include <pthread.h>
#ifdef linux
-#include <sys/timerfd.h>
+# include <sys/timerfd.h>
#endif
#include <sys/stat.h>
#include <sys/time.h>
#if defined(linux) && defined(__NR_statx)
-#include <linux/stat.h>
+# include <linux/stat.h>
#endif
#include "dlt_types.h"
@@ -67,14 +67,14 @@
#include "dlt_gateway.h"
#if defined(DLT_SYSTEMD_WATCHDOG_ENABLE) || defined(DLT_SYSTEMD_ENABLE)
-#include "sd-daemon.h"
+# include "sd-daemon.h"
#endif
/**
- \defgroup daemon DLT Daemon
- \addtogroup daemon
- \{
-*/
+ * \defgroup daemon DLT Daemon
+ * \addtogroup daemon
+ \{
+ */
/** Global text output buffer, mainly used for creation of error/warning strings */
static char str[DLT_DAEMON_TEXTBUFSIZE];
@@ -82,7 +82,7 @@ static char str[DLT_DAEMON_TEXTBUFSIZE];
static int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, char *str, int verbose);
#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
-static uint32_t watchdog_trigger_interval; // watchdog trigger interval in [s]
+static uint32_t watchdog_trigger_interval; /* watchdog trigger interval in [s] */
#endif
/* used in main event loop and signal handler */
@@ -96,10 +96,10 @@ int g_signo = 0;
void usage()
{
char version[DLT_DAEMON_TEXTBUFSIZE];
- dlt_get_version(version,DLT_DAEMON_TEXTBUFSIZE);
+ dlt_get_version(version, DLT_DAEMON_TEXTBUFSIZE);
- //printf("DLT logging daemon %s %s\n", _DLT_PACKAGE_VERSION, _DLT_PACKAGE_VERSION_STATE);
- //printf("Compile options: %s %s %s %s",_DLT_SYSTEMD_ENABLE, _DLT_SYSTEMD_WATCHDOG_ENABLE, _DLT_TEST_ENABLE, _DLT_SHM_ENABLE);
+ /*printf("DLT logging daemon %s %s\n", _DLT_PACKAGE_VERSION, _DLT_PACKAGE_VERSION_STATE); */
+ /*printf("Compile options: %s %s %s %s",_DLT_SYSTEMD_ENABLE, _DLT_SYSTEMD_WATCHDOG_ENABLE, _DLT_TEST_ENABLE, _DLT_SHM_ENABLE); */
printf("%s", version);
printf("Usage: dlt-daemon [options]\n");
printf("Options:\n");
@@ -119,18 +119,17 @@ void usage()
/**
* Option handling
*/
-int option_handling(DltDaemonLocal *daemon_local,int argc, char* argv[])
- {
+int option_handling(DltDaemonLocal *daemon_local, int argc, char *argv[])
+{
int c;
- if (daemon_local==0)
- {
+ if (daemon_local == 0) {
fprintf (stderr, "Invalid parameter passed to option_handling()\n");
return -1;
}
/* Initialize flags */
- memset(daemon_local,0,sizeof(DltDaemonLocal));
+ memset(daemon_local, 0, sizeof(DltDaemonLocal));
/* default values */
daemon_local->flags.port = DLT_DAEMON_TCP_PORT;
@@ -139,9 +138,7 @@ int option_handling(DltDaemonLocal *daemon_local,int argc, char* argv[])
opterr = 0;
while ((c = getopt (argc, argv, "hdc:t:p:")) != -1)
- {
- switch (c)
- {
+ switch (c) {
case 'd':
{
daemon_local->flags.dflag = 1;
@@ -149,7 +146,7 @@ int option_handling(DltDaemonLocal *daemon_local,int argc, char* argv[])
}
case 'c':
{
- strncpy(daemon_local->flags.cvalue,optarg,NAME_MAX);
+ strncpy(daemon_local->flags.cvalue, optarg, NAME_MAX);
break;
}
case 't':
@@ -160,11 +157,12 @@ int option_handling(DltDaemonLocal *daemon_local,int argc, char* argv[])
case 'p':
{
daemon_local->flags.port = atoi(optarg);
- if (daemon_local->flags.port == 0)
- {
- fprintf (stderr, "Invalid port `%s' specified.\n", optarg);
- return -1;
+
+ if (daemon_local->flags.port == 0) {
+ fprintf (stderr, "Invalid port `%s' specified.\n", optarg);
+ return -1;
}
+
break;
}
case 'h':
@@ -174,18 +172,13 @@ int option_handling(DltDaemonLocal *daemon_local,int argc, char* argv[])
}
case '?':
{
- if (optopt == 'c' || optopt == 't' || optopt == 'p')
- {
+ if ((optopt == 'c') || (optopt == 't') || (optopt == 'p'))
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
- }
else if (isprint (optopt))
- {
fprintf (stderr, "Unknown option `-%c'.\n", optopt);
- }
else
- {
- fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt);
- }
+ fprintf (stderr, "Unknown option character `\\x%x'.\n", optopt);
+
/* unknown or wrong option used, show usage information and terminate */
usage();
return -1;
@@ -196,7 +189,7 @@ int option_handling(DltDaemonLocal *daemon_local,int argc, char* argv[])
return -1;
}
} /* switch() */
- }
+
#ifndef DLT_USE_UNIX_SOCKET_IPC
snprintf(daemon_local->flags.userPipesDir, NAME_MAX + 1, "%s/dltpipes", dltFifoBaseDir);
@@ -205,385 +198,388 @@ int option_handling(DltDaemonLocal *daemon_local,int argc, char* argv[])
return 0;
- } /* option_handling() */
+} /* option_handling() */
/**
* Option file parser
*/
int option_file_parser(DltDaemonLocal *daemon_local)
{
- FILE * pFile;
- int value_length = 1024;
- char line[value_length-1];
- char token[value_length];
- char value[value_length];
+ FILE *pFile;
+ int value_length = 1024;
+ char line[value_length - 1];
+ char token[value_length];
+ char value[value_length];
char *pch;
const char *filename;
- /* set default values for configuration */
- daemon_local->flags.sharedMemorySize = DLT_SHM_SIZE;
- daemon_local->flags.sendMessageTime = 0;
- daemon_local->flags.offlineTraceDirectory[0] = 0;
- daemon_local->flags.offlineTraceFileSize = 1000000;
- daemon_local->flags.offlineTraceMaxSize = 0;
- daemon_local->flags.offlineTraceFilenameTimestampBased = 1;
- daemon_local->flags.loggingMode = DLT_LOG_TO_CONSOLE;
- daemon_local->flags.loggingLevel = LOG_INFO;
- snprintf(daemon_local->flags.loggingFilename, sizeof(daemon_local->flags.loggingFilename)-1, "%s/dlt.log", dltFifoBaseDir);
- daemon_local->flags.loggingFilename[sizeof(daemon_local->flags.loggingFilename)-1]=0;
- daemon_local->timeoutOnSend = 4;
- daemon_local->RingbufferMinSize = DLT_DAEMON_RINGBUFFER_MIN_SIZE;
- daemon_local->RingbufferMaxSize = DLT_DAEMON_RINGBUFFER_MAX_SIZE;
- daemon_local->RingbufferStepSize = DLT_DAEMON_RINGBUFFER_STEP_SIZE;
- daemon_local->daemonFifoSize = 0;
- daemon_local->flags.sendECUSoftwareVersion = 0;
- memset(daemon_local->flags.pathToECUSoftwareVersion, 0, sizeof(daemon_local->flags.pathToECUSoftwareVersion));
- daemon_local->flags.sendTimezone = 0;
- daemon_local->flags.offlineLogstorageMaxDevices = 0;
- daemon_local->flags.offlineLogstorageDirPath[0] = 0;
- daemon_local->flags.offlineLogstorageMaxDevices = 0;
- daemon_local->flags.offlineLogstorageTimestamp = 1;
- daemon_local->flags.offlineLogstorageDelimiter = '_';
- daemon_local->flags.offlineLogstorageMaxCounter = UINT_MAX;
- daemon_local->flags.offlineLogstorageMaxCounterIdx = 0;
- daemon_local->flags.offlineLogstorageCacheSize = 30000; /* 30MB */
- dlt_daemon_logstorage_set_logstorage_cache_size(
- daemon_local->flags.offlineLogstorageCacheSize);
- strncpy(daemon_local->flags.ctrlSockPath,
+ /* set default values for configuration */
+ daemon_local->flags.sharedMemorySize = DLT_SHM_SIZE;
+ daemon_local->flags.sendMessageTime = 0;
+ daemon_local->flags.offlineTraceDirectory[0] = 0;
+ daemon_local->flags.offlineTraceFileSize = 1000000;
+ daemon_local->flags.offlineTraceMaxSize = 0;
+ daemon_local->flags.offlineTraceFilenameTimestampBased = 1;
+ daemon_local->flags.loggingMode = DLT_LOG_TO_CONSOLE;
+ daemon_local->flags.loggingLevel = LOG_INFO;
+ snprintf(daemon_local->flags.loggingFilename,
+ sizeof(daemon_local->flags.loggingFilename) - 1,
+ "%s/dlt.log",
+ dltFifoBaseDir);
+ daemon_local->flags.loggingFilename[sizeof(daemon_local->flags.loggingFilename) - 1] = 0;
+ daemon_local->timeoutOnSend = 4;
+ daemon_local->RingbufferMinSize = DLT_DAEMON_RINGBUFFER_MIN_SIZE;
+ daemon_local->RingbufferMaxSize = DLT_DAEMON_RINGBUFFER_MAX_SIZE;
+ daemon_local->RingbufferStepSize = DLT_DAEMON_RINGBUFFER_STEP_SIZE;
+ daemon_local->daemonFifoSize = 0;
+ daemon_local->flags.sendECUSoftwareVersion = 0;
+ memset(daemon_local->flags.pathToECUSoftwareVersion, 0, sizeof(daemon_local->flags.pathToECUSoftwareVersion));
+ daemon_local->flags.sendTimezone = 0;
+ daemon_local->flags.offlineLogstorageMaxDevices = 0;
+ daemon_local->flags.offlineLogstorageDirPath[0] = 0;
+ daemon_local->flags.offlineLogstorageMaxDevices = 0;
+ daemon_local->flags.offlineLogstorageTimestamp = 1;
+ daemon_local->flags.offlineLogstorageDelimiter = '_';
+ daemon_local->flags.offlineLogstorageMaxCounter = UINT_MAX;
+ daemon_local->flags.offlineLogstorageMaxCounterIdx = 0;
+ daemon_local->flags.offlineLogstorageCacheSize = 30000; /* 30MB */
+ dlt_daemon_logstorage_set_logstorage_cache_size(
+ daemon_local->flags.offlineLogstorageCacheSize);
+ strncpy(daemon_local->flags.ctrlSockPath,
DLT_DAEMON_DEFAULT_CTRL_SOCK_PATH,
sizeof(daemon_local->flags.ctrlSockPath) - 1);
#ifdef DLT_USE_UNIX_SOCKET_IPC
- snprintf(daemon_local->flags.appSockPath, DLT_IPC_PATH_MAX, "%s/dlt", DLT_USER_IPC_PATH);
- if (strlen(DLT_USER_IPC_PATH) > DLT_IPC_PATH_MAX)
- {
- fprintf(stderr,"Provided path too long...trimming it to path[%s]\n",
- daemon_local->flags.appSockPath);
- }
+ snprintf(daemon_local->flags.appSockPath, DLT_IPC_PATH_MAX, "%s/dlt", DLT_USER_IPC_PATH);
+
+ if (strlen(DLT_USER_IPC_PATH) > DLT_IPC_PATH_MAX)
+ fprintf(stderr, "Provided path too long...trimming it to path[%s]\n",
+ daemon_local->flags.appSockPath);
+
#endif
- daemon_local->flags.gatewayMode = 0;
+ daemon_local->flags.gatewayMode = 0;
strncpy(daemon_local->flags.gatewayConfigFile,
DLT_GATEWAY_CONFIG_PATH,
DLT_DAEMON_FLAG_MAX - 1);
- daemon_local->flags.autoResponseGetLogInfoOption = 7;
- daemon_local->flags.contextLogLevel = DLT_LOG_INFO;
- daemon_local->flags.contextTraceStatus = DLT_TRACE_STATUS_OFF;
- daemon_local->flags.enforceContextLLAndTS = 0; /* default is off */
-
- /* open configuration file */
- if(daemon_local->flags.cvalue[0])
- filename = daemon_local->flags.cvalue;
- else
- filename = CONFIGURATION_FILES_DIR "/dlt.conf";
- //printf("Load configuration from file: %s\n",filename);
- pFile = fopen (filename,"r");
-
- if (pFile!=NULL)
- {
- while(1)
- {
+ daemon_local->flags.autoResponseGetLogInfoOption = 7;
+ daemon_local->flags.contextLogLevel = DLT_LOG_INFO;
+ daemon_local->flags.contextTraceStatus = DLT_TRACE_STATUS_OFF;
+ daemon_local->flags.enforceContextLLAndTS = 0; /* default is off */
+
+ /* open configuration file */
+ if (daemon_local->flags.cvalue[0])
+ filename = daemon_local->flags.cvalue;
+ else
+ filename = CONFIGURATION_FILES_DIR "/dlt.conf";
+
+ /*printf("Load configuration from file: %s\n",filename); */
+ pFile = fopen (filename, "r");
+
+ if (pFile != NULL) {
+ while (1) {
/* fetch line from configuration file */
- if ( fgets (line , value_length - 1 , pFile) != NULL )
- {
- pch = strtok (line," =\r\n");
- token[0]=0;
- value[0]=0;
-
- while (pch != NULL)
- {
- if(strcmp(pch,"#")==0)
+ if (fgets (line, value_length - 1, pFile) != NULL) {
+ pch = strtok (line, " =\r\n");
+ token[0] = 0;
+ value[0] = 0;
+
+ while (pch != NULL) {
+ if (strcmp(pch, "#") == 0)
break;
- if(token[0]==0)
- {
- strncpy(token,pch,sizeof(token) - 1);
- token[sizeof(token) - 1]=0;
+ if (token[0] == 0) {
+ strncpy(token, pch, sizeof(token) - 1);
+ token[sizeof(token) - 1] = 0;
}
- else
- {
- strncpy(value,pch,sizeof(value) - 1);
- value[sizeof(value) - 1]=0;
+ else {
+ strncpy(value, pch, sizeof(value) - 1);
+ value[sizeof(value) - 1] = 0;
break;
}
pch = strtok (NULL, " =\r\n");
- }
-
- if(token[0] && value[0])
- {
- /* parse arguments here */
- if(strcmp(token,"Verbose")==0)
- {
- daemon_local->flags.vflag = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"PrintASCII")==0)
- {
- daemon_local->flags.aflag = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"PrintHex")==0)
- {
- daemon_local->flags.xflag = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"PrintHeadersOnly")==0)
- {
- daemon_local->flags.sflag = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"SendSerialHeader")==0)
- {
- daemon_local->flags.lflag = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"SendContextRegistration")==0)
- {
- daemon_local->flags.rflag = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"SendContextRegistrationOption")==0)
- {
- daemon_local->flags.autoResponseGetLogInfoOption = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"SendMessageTime")==0)
- {
- daemon_local->flags.sendMessageTime = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"RS232SyncSerialHeader")==0)
- {
- daemon_local->flags.mflag = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"TCPSyncSerialHeader")==0)
- {
- daemon_local->flags.nflag = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"RS232DeviceName")==0)
- {
- strncpy(daemon_local->flags.yvalue,value,NAME_MAX);
- daemon_local->flags.yvalue[NAME_MAX]=0;
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"RS232Baudrate")==0)
- {
- strncpy(daemon_local->flags.bvalue,value,NAME_MAX);
- daemon_local->flags.bvalue[NAME_MAX]=0;
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"ECUId")==0)
- {
- strncpy(daemon_local->flags.evalue,value,NAME_MAX);
- daemon_local->flags.evalue[NAME_MAX]=0;
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"PersistanceStoragePath")==0)
- {
- strncpy(daemon_local->flags.ivalue,value,NAME_MAX);
- daemon_local->flags.ivalue[NAME_MAX]=0;
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"LoggingMode")==0)
- {
- daemon_local->flags.loggingMode = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"LoggingLevel")==0)
- {
- daemon_local->flags.loggingLevel = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"LoggingFilename")==0)
- {
- strncpy(daemon_local->flags.loggingFilename,value,sizeof(daemon_local->flags.loggingFilename) - 1);
- daemon_local->flags.loggingFilename[sizeof(daemon_local->flags.loggingFilename) - 1]=0;
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"TimeOutOnSend")==0)
- {
- daemon_local->timeoutOnSend = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"RingbufferMinSize")==0)
- {
- sscanf(value,"%lu",&(daemon_local->RingbufferMinSize));
- }
- else if(strcmp(token,"RingbufferMaxSize")==0)
- {
- sscanf(value,"%lu",&(daemon_local->RingbufferMaxSize));
- }
- else if(strcmp(token,"RingbufferStepSize")==0)
- {
- sscanf(value,"%lu",&(daemon_local->RingbufferStepSize));
- }
- else if(strcmp(token,"DaemonFIFOSize")==0)
- {
- sscanf(value,"%lu",&(daemon_local->daemonFifoSize));
- }
- else if(strcmp(token,"SharedMemorySize")==0)
- {
- daemon_local->flags.sharedMemorySize = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"OfflineTraceDirectory")==0)
- {
- strncpy(daemon_local->flags.offlineTraceDirectory,value,sizeof(daemon_local->flags.offlineTraceDirectory) - 1);
- daemon_local->flags.offlineTraceDirectory[sizeof(daemon_local->flags.offlineTraceDirectory) - 1]=0;
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"OfflineTraceFileSize")==0)
- {
- daemon_local->flags.offlineTraceFileSize = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"OfflineTraceMaxSize")==0)
- {
- daemon_local->flags.offlineTraceMaxSize = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"OfflineTraceFileNameTimestampBased")==0)
- {
- daemon_local->flags.offlineTraceFilenameTimestampBased = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"SendECUSoftwareVersion")==0)
- {
- daemon_local->flags.sendECUSoftwareVersion = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"PathToECUSoftwareVersion")==0)
- {
- strncpy(daemon_local->flags.pathToECUSoftwareVersion,value,sizeof(daemon_local->flags.pathToECUSoftwareVersion) - 1);
- daemon_local->flags.pathToECUSoftwareVersion[sizeof(daemon_local->flags.pathToECUSoftwareVersion) - 1]=0;
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"SendTimezone")==0)
- {
- daemon_local->flags.sendTimezone = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token, "OfflineLogstorageMaxDevices") == 0)
- {
- daemon_local->flags.offlineLogstorageMaxDevices = atoi(value);
- }
- else if(strcmp(token, "OfflineLogstorageDirPath") == 0)
- {
- strncpy(daemon_local->flags.offlineLogstorageDirPath,
- value,
- sizeof(daemon_local->flags.offlineLogstorageDirPath) - 1);
- }
- else if(strcmp(token, "OfflineLogstorageTimestamp") == 0)
- {
- /* Check if set to 0, default otherwise */
- if(atoi(value) == 0)
- {
- daemon_local->flags.offlineLogstorageTimestamp = 0;
- }
- }
- else if(strcmp(token, "OfflineLogstorageDelimiter") == 0)
- {
- /* Check if valid punctuation, default otherwise*/
- if(ispunct((char)value[0]))
- {
- daemon_local->flags.offlineLogstorageDelimiter = (char)value[0];
- }
- }
- else if(strcmp(token, "OfflineLogstorageMaxCounter") == 0)
- {
- daemon_local->flags.offlineLogstorageMaxCounter = atoi(value);
- daemon_local->flags.offlineLogstorageMaxCounterIdx = strlen(value);
- }
- else if(strcmp(token, "OfflineLogstorageCacheSize") == 0)
- {
- daemon_local->flags.offlineLogstorageCacheSize =
- (unsigned int)atoi(value);
- dlt_daemon_logstorage_set_logstorage_cache_size(
- daemon_local->flags.offlineLogstorageCacheSize);
- }
- else if(strcmp(token,"ControlSocketPath") == 0)
- {
- memset(
- daemon_local->flags.ctrlSockPath,
- 0,
- DLT_DAEMON_FLAG_MAX);
- strncpy(
- daemon_local->flags.ctrlSockPath,
+ }
+
+ if (token[0] && value[0]) {
+ /* parse arguments here */
+ if (strcmp(token, "Verbose") == 0) {
+ daemon_local->flags.vflag = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "PrintASCII") == 0)
+ {
+ daemon_local->flags.aflag = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "PrintHex") == 0)
+ {
+ daemon_local->flags.xflag = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "PrintHeadersOnly") == 0)
+ {
+ daemon_local->flags.sflag = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "SendSerialHeader") == 0)
+ {
+ daemon_local->flags.lflag = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "SendContextRegistration") == 0)
+ {
+ daemon_local->flags.rflag = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "SendContextRegistrationOption") == 0)
+ {
+ daemon_local->flags.autoResponseGetLogInfoOption = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "SendMessageTime") == 0)
+ {
+ daemon_local->flags.sendMessageTime = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "RS232SyncSerialHeader") == 0)
+ {
+ daemon_local->flags.mflag = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "TCPSyncSerialHeader") == 0)
+ {
+ daemon_local->flags.nflag = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "RS232DeviceName") == 0)
+ {
+ strncpy(daemon_local->flags.yvalue, value, NAME_MAX);
+ daemon_local->flags.yvalue[NAME_MAX] = 0;
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "RS232Baudrate") == 0)
+ {
+ strncpy(daemon_local->flags.bvalue, value, NAME_MAX);
+ daemon_local->flags.bvalue[NAME_MAX] = 0;
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "ECUId") == 0)
+ {
+ strncpy(daemon_local->flags.evalue, value, NAME_MAX);
+ daemon_local->flags.evalue[NAME_MAX] = 0;
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "PersistanceStoragePath") == 0)
+ {
+ strncpy(daemon_local->flags.ivalue, value, NAME_MAX);
+ daemon_local->flags.ivalue[NAME_MAX] = 0;
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "LoggingMode") == 0)
+ {
+ daemon_local->flags.loggingMode = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "LoggingLevel") == 0)
+ {
+ daemon_local->flags.loggingLevel = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "LoggingFilename") == 0)
+ {
+ strncpy(daemon_local->flags.loggingFilename,
value,
- DLT_DAEMON_FLAG_MAX-1);
- }
- else if(strcmp(token,"GatewayMode")==0)
- {
- daemon_local->flags.gatewayMode = atoi(value);
- //printf("Option: %s=%s\n",token,value);
- }
- else if(strcmp(token,"GatewayConfigFile")==0)
- {
- memset(
- daemon_local->flags.gatewayConfigFile,
- 0,
- DLT_DAEMON_FLAG_MAX);
- strncpy(
- daemon_local->flags.gatewayConfigFile,
+ sizeof(daemon_local->flags.loggingFilename) - 1);
+ daemon_local->flags.loggingFilename[sizeof(daemon_local->flags.loggingFilename) - 1] = 0;
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "TimeOutOnSend") == 0)
+ {
+ daemon_local->timeoutOnSend = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "RingbufferMinSize") == 0)
+ {
+ sscanf(value, "%lu", &(daemon_local->RingbufferMinSize));
+ }
+ else if (strcmp(token, "RingbufferMaxSize") == 0)
+ {
+ sscanf(value, "%lu", &(daemon_local->RingbufferMaxSize));
+ }
+ else if (strcmp(token, "RingbufferStepSize") == 0)
+ {
+ sscanf(value, "%lu", &(daemon_local->RingbufferStepSize));
+ }
+ else if (strcmp(token, "DaemonFIFOSize") == 0)
+ {
+ sscanf(value, "%lu", &(daemon_local->daemonFifoSize));
+ }
+ else if (strcmp(token, "SharedMemorySize") == 0)
+ {
+ daemon_local->flags.sharedMemorySize = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "OfflineTraceDirectory") == 0)
+ {
+ strncpy(daemon_local->flags.offlineTraceDirectory, value,
+ sizeof(daemon_local->flags.offlineTraceDirectory) - 1);
+ daemon_local->flags.offlineTraceDirectory[sizeof(daemon_local->flags.offlineTraceDirectory) -
+ 1] = 0;
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "OfflineTraceFileSize") == 0)
+ {
+ daemon_local->flags.offlineTraceFileSize = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "OfflineTraceMaxSize") == 0)
+ {
+ daemon_local->flags.offlineTraceMaxSize = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "OfflineTraceFileNameTimestampBased") == 0)
+ {
+ daemon_local->flags.offlineTraceFilenameTimestampBased = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "SendECUSoftwareVersion") == 0)
+ {
+ daemon_local->flags.sendECUSoftwareVersion = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "PathToECUSoftwareVersion") == 0)
+ {
+ strncpy(daemon_local->flags.pathToECUSoftwareVersion, value,
+ sizeof(daemon_local->flags.pathToECUSoftwareVersion) - 1);
+ daemon_local->flags.pathToECUSoftwareVersion[sizeof(daemon_local->flags.pathToECUSoftwareVersion)
+ - 1] = 0;
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "SendTimezone") == 0)
+ {
+ daemon_local->flags.sendTimezone = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "OfflineLogstorageMaxDevices") == 0)
+ {
+ daemon_local->flags.offlineLogstorageMaxDevices = atoi(value);
+ }
+ else if (strcmp(token, "OfflineLogstorageDirPath") == 0)
+ {
+ strncpy(daemon_local->flags.offlineLogstorageDirPath,
value,
- DLT_DAEMON_FLAG_MAX-1);
+ sizeof(daemon_local->flags.offlineLogstorageDirPath) - 1);
+ }
+ else if (strcmp(token, "OfflineLogstorageTimestamp") == 0)
+ {
+ /* Check if set to 0, default otherwise */
+ if (atoi(value) == 0)
+ daemon_local->flags.offlineLogstorageTimestamp = 0;
+ }
+ else if (strcmp(token, "OfflineLogstorageDelimiter") == 0)
+ {
+ /* Check if valid punctuation, default otherwise*/
+ if (ispunct((char)value[0]))
+ daemon_local->flags.offlineLogstorageDelimiter = (char)value[0];
+ }
+ else if (strcmp(token, "OfflineLogstorageMaxCounter") == 0)
+ {
+ daemon_local->flags.offlineLogstorageMaxCounter = atoi(value);
+ daemon_local->flags.offlineLogstorageMaxCounterIdx = strlen(value);
+ }
+ else if (strcmp(token, "OfflineLogstorageCacheSize") == 0)
+ {
+ daemon_local->flags.offlineLogstorageCacheSize =
+ (unsigned int)atoi(value);
+ dlt_daemon_logstorage_set_logstorage_cache_size(
+ daemon_local->flags.offlineLogstorageCacheSize);
+ }
+ else if (strcmp(token, "ControlSocketPath") == 0)
+ {
+ memset(
+ daemon_local->flags.ctrlSockPath,
+ 0,
+ DLT_DAEMON_FLAG_MAX);
+ strncpy(
+ daemon_local->flags.ctrlSockPath,
+ value,
+ DLT_DAEMON_FLAG_MAX - 1);
+ }
+ else if (strcmp(token, "GatewayMode") == 0)
+ {
+ daemon_local->flags.gatewayMode = atoi(value);
+ /*printf("Option: %s=%s\n",token,value); */
+ }
+ else if (strcmp(token, "GatewayConfigFile") == 0)
+ {
+ memset(
+ daemon_local->flags.gatewayConfigFile,
+ 0,
+ DLT_DAEMON_FLAG_MAX);
+ strncpy(
+ daemon_local->flags.gatewayConfigFile,
+ value,
+ DLT_DAEMON_FLAG_MAX - 1);
+ }
+ else if (strcmp(token, "ContextLogLevel") == 0)
+ {
+ int const intval = atoi(value);
+
+ if ((intval >= DLT_LOG_OFF) && (intval <= DLT_LOG_VERBOSE)) {
+ daemon_local->flags.contextLogLevel = intval;
+ printf("Option: %s=%s\n", token, value);
}
- else if(strcmp(token,"ContextLogLevel")==0)
- {
- int const intval = atoi(value);
- if ( (intval >= DLT_LOG_OFF) && (intval <= DLT_LOG_VERBOSE))
- {
- daemon_local->flags.contextLogLevel = intval;
- printf("Option: %s=%s\n",token,value);
- }
- else
- {
- fprintf(stderr, "Invalid value for ContextLogLevel: %i. Must be in range [%i..%i]\n", intval, DLT_LOG_OFF, DLT_LOG_VERBOSE);
- }
+ else {
+ fprintf(stderr,
+ "Invalid value for ContextLogLevel: %i. Must be in range [%i..%i]\n",
+ intval,
+ DLT_LOG_OFF,
+ DLT_LOG_VERBOSE);
}
- else if(strcmp(token,"ContextTraceStatus")==0)
- {
- int const intval = atoi(value);
- if ( (intval >= DLT_TRACE_STATUS_OFF) && (intval <= DLT_TRACE_STATUS_ON))
- {
- daemon_local->flags.contextTraceStatus = intval;
- printf("Option: %s=%s\n",token,value);
- }
- else
- {
- fprintf(stderr, "Invalid value for ContextTraceStatus: %i. Must be in range [%i..%i]\n", intval, DLT_TRACE_STATUS_OFF, DLT_TRACE_STATUS_ON);
- }
+ }
+ else if (strcmp(token, "ContextTraceStatus") == 0)
+ {
+ int const intval = atoi(value);
+
+ if ((intval >= DLT_TRACE_STATUS_OFF) && (intval <= DLT_TRACE_STATUS_ON)) {
+ daemon_local->flags.contextTraceStatus = intval;
+ printf("Option: %s=%s\n", token, value);
}
- else if(strcmp(token,"ForceContextLogLevelAndTraceStatus")==0)
- {
- int const intval = atoi(value);
- if ( (intval >= 0) && (intval <= 1))
- {
- daemon_local->flags.enforceContextLLAndTS = intval;
- printf("Option: %s=%s\n",token,value);
- }
- else
- {
- fprintf(stderr, "Invalid value for ForceContextLogLevelAndTraceStatus: %i. Must be 0, 1\n", intval);
- }
+ else {
+ fprintf(stderr,
+ "Invalid value for ContextTraceStatus: %i. Must be in range [%i..%i]\n",
+ intval,
+ DLT_TRACE_STATUS_OFF,
+ DLT_TRACE_STATUS_ON);
+ }
+ }
+ else if (strcmp(token, "ForceContextLogLevelAndTraceStatus") == 0)
+ {
+ int const intval = atoi(value);
+
+ if ((intval >= 0) && (intval <= 1)) {
+ daemon_local->flags.enforceContextLLAndTS = intval;
+ printf("Option: %s=%s\n", token, value);
}
- else
- {
- fprintf(stderr, "Unknown option: %s=%s\n",token,value);
+ else {
+ fprintf(stderr,
+ "Invalid value for ForceContextLogLevelAndTraceStatus: %i. Must be 0, 1\n",
+ intval);
}
}
+ else {
+ fprintf(stderr, "Unknown option: %s=%s\n", token, value);
+ }
+ }
}
- else
- {
+ else {
break;
}
}
+
fclose (pFile);
}
- else
- {
- fprintf(stderr, "Cannot open configuration file: %s\n",filename);
+ else {
+ fprintf(stderr, "Cannot open configuration file: %s\n", filename);
}
return 0;
@@ -594,18 +590,16 @@ static DltReturnValue dlt_daemon_create_pipes_dir(char *dir)
{
int ret = DLT_RETURN_OK;
- if (dir == NULL)
- {
+ if (dir == NULL) {
dlt_vlog(LOG_ERR, "%s: Invalid parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
/* create dlt pipes directory */
ret = mkdir(dir,
- S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH|S_ISVTX);
+ S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_ISVTX);
- if ((ret == -1) && (errno != EEXIST))
- {
+ if ((ret == -1) && (errno != EEXIST)) {
dlt_vlog(LOG_ERR,
"FIFO user dir %s cannot be created (%s)!\n",
dir,
@@ -614,12 +608,12 @@ static DltReturnValue dlt_daemon_create_pipes_dir(char *dir)
return DLT_RETURN_ERROR;
}
- // S_ISGID cannot be set by mkdir, let's reassign right bits
+ /* S_ISGID cannot be set by mkdir, let's reassign right bits */
ret = chmod(dir,
- S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH|S_ISGID|S_ISVTX);
+ S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH | S_ISGID |
+ S_ISVTX);
- if (ret == -1)
- {
+ if (ret == -1) {
dlt_vlog(LOG_ERR,
"FIFO user dir %s cannot be chmoded (%s)!\n",
dir,
@@ -635,7 +629,7 @@ static DltReturnValue dlt_daemon_create_pipes_dir(char *dir)
/**
* Main function of tool.
*/
-int main(int argc, char* argv[])
+int main(int argc, char *argv[])
{
char version[DLT_DAEMON_TEXTBUFSIZE];
DltDaemonLocal daemon_local;
@@ -646,20 +640,18 @@ int main(int argc, char* argv[])
memset(&daemon, 0, sizeof(DltDaemon));
/* Command line option handling */
- if ((back = option_handling(&daemon_local,argc,argv))<0)
- {
- if(back!=-2) {
+ if ((back = option_handling(&daemon_local, argc, argv)) < 0) {
+ if (back != -2)
fprintf (stderr, "option_handling() failed!\n");
- }
+
return -1;
}
/* Configuration file option handling */
- if ((back = option_file_parser(&daemon_local))<0)
- {
- if(back!=-2) {
+ if ((back = option_file_parser(&daemon_local)) < 0) {
+ if (back != -2)
fprintf (stderr, "option_file_parser() failed!\n");
- }
+
return -1;
}
@@ -669,78 +661,75 @@ int main(int argc, char* argv[])
dlt_log_init(daemon_local.flags.loggingMode);
/* Print version information */
- dlt_get_version(version,DLT_DAEMON_TEXTBUFSIZE);
+ dlt_get_version(version, DLT_DAEMON_TEXTBUFSIZE);
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"Starting DLT Daemon; %s\n", version );
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "Starting DLT Daemon; %s\n", version);
dlt_log(LOG_NOTICE, str);
PRINT_FUNCTION_VERBOSE(daemon_local.flags.vflag);
#ifndef DLT_USE_UNIX_SOCKET_IPC
+
/* Make sure the parent user directory is created */
- if (dlt_mkdir_recursive(dltFifoBaseDir) != 0)
- {
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE, "Base dir %s cannot be created!\n", dltFifoBaseDir);
- dlt_log(LOG_ERR, str);
- return -1;
+ if (dlt_mkdir_recursive(dltFifoBaseDir) != 0) {
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "Base dir %s cannot be created!\n", dltFifoBaseDir);
+ dlt_log(LOG_ERR, str);
+ return -1;
}
+
#endif
/* --- Daemon init phase 1 begin --- */
- if (dlt_daemon_local_init_p1(&daemon, &daemon_local, daemon_local.flags.vflag)==-1)
- {
- dlt_log(LOG_CRIT,"Initialization of phase 1 failed!\n");
+ if (dlt_daemon_local_init_p1(&daemon, &daemon_local, daemon_local.flags.vflag) == -1) {
+ dlt_log(LOG_CRIT, "Initialization of phase 1 failed!\n");
return -1;
}
+
/* --- Daemon init phase 1 end --- */
- if (dlt_daemon_prepare_event_handling(&daemon_local.pEvent))
- {
+ if (dlt_daemon_prepare_event_handling(&daemon_local.pEvent)) {
/* TODO: Perform clean-up */
- dlt_log(LOG_CRIT,"Initialization of event handling failed!\n");
+ dlt_log(LOG_CRIT, "Initialization of event handling failed!\n");
return -1;
}
/* --- Daemon connection init begin */
- if (dlt_daemon_local_connection_init(&daemon, &daemon_local, daemon_local.flags.vflag)==-1)
- {
- dlt_log(LOG_CRIT,"Initialization of local connections failed!\n");
+ if (dlt_daemon_local_connection_init(&daemon, &daemon_local, daemon_local.flags.vflag) == -1) {
+ dlt_log(LOG_CRIT, "Initialization of local connections failed!\n");
return -1;
}
+
/* --- Daemon connection init end */
/* --- Daemon init phase 2 begin --- */
- if (dlt_daemon_local_init_p2(&daemon, &daemon_local, daemon_local.flags.vflag)==-1)
- {
- dlt_log(LOG_CRIT,"Initialization of phase 2 failed!\n");
+ if (dlt_daemon_local_init_p2(&daemon, &daemon_local, daemon_local.flags.vflag) == -1) {
+ dlt_log(LOG_CRIT, "Initialization of phase 2 failed!\n");
return -1;
}
+
/* --- Daemon init phase 2 end --- */
- if(daemon_local.flags.offlineLogstorageDirPath[0])
- {
+ if (daemon_local.flags.offlineLogstorageDirPath[0]) {
if (dlt_daemon_logstorage_setup_internal_storage(
&daemon,
&daemon_local,
daemon_local.flags.offlineLogstorageDirPath,
daemon_local.flags.vflag) == -1)
- {
dlt_log(LOG_INFO,
"Setting up internal offline log storage failed!\n");
- }
}
- // create fd for watchdog
+ /* create fd for watchdog */
#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
{
- char* watchdogUSec = getenv("WATCHDOG_USEC");
+ char *watchdogUSec = getenv("WATCHDOG_USEC");
int watchdogTimeoutSeconds = 0;
dlt_log(LOG_DEBUG, "Systemd watchdog initialization\n");
- if( watchdogUSec )
- {
- watchdogTimeoutSeconds = atoi(watchdogUSec)/2000000;
- }
+
+ if (watchdogUSec)
+ watchdogTimeoutSeconds = atoi(watchdogUSec) / 2000000;
+
watchdog_trigger_interval = watchdogTimeoutSeconds;
create_timer_fd(&daemon_local,
watchdogTimeoutSeconds,
@@ -749,21 +738,17 @@ int main(int argc, char* argv[])
}
#endif
- // create fd for timer timing packets
+ /* create fd for timer timing packets */
create_timer_fd(&daemon_local, 1, 1, DLT_TIMER_PACKET);
- // create fd for timer ecu version
- if((daemon_local.flags.sendECUSoftwareVersion > 0) ||
- (daemon_local.flags.sendTimezone > 0))
- {
+ /* create fd for timer ecu version */
+ if ((daemon_local.flags.sendECUSoftwareVersion > 0) ||
+ (daemon_local.flags.sendTimezone > 0))
create_timer_fd(&daemon_local, 60, 60, DLT_TIMER_ECU);
- }
/* initiate gateway */
- if (daemon_local.flags.gatewayMode == 1)
- {
- if (dlt_gateway_init(&daemon_local, daemon_local.flags.vflag) == -1)
- {
+ if (daemon_local.flags.gatewayMode == 1) {
+ if (dlt_gateway_init(&daemon_local, daemon_local.flags.vflag) == -1) {
dlt_log(LOG_CRIT, "Fail to create gateway\n");
return -1;
}
@@ -775,36 +760,36 @@ int main(int argc, char* argv[])
DLT_TIMER_GATEWAY);
}
- // For offline tracing we still can use the same states
- // as for socket sending. Using this trick we see the traces
- // In the offline trace AND in the socket stream.
- if(daemon_local.flags.yvalue[0])
- dlt_daemon_change_state(&daemon,DLT_DAEMON_STATE_SEND_DIRECT);
+ /* For offline tracing we still can use the same states */
+ /* as for socket sending. Using this trick we see the traces */
+ /* In the offline trace AND in the socket stream. */
+ if (daemon_local.flags.yvalue[0])
+ dlt_daemon_change_state(&daemon, DLT_DAEMON_STATE_SEND_DIRECT);
else
- dlt_daemon_change_state(&daemon,DLT_DAEMON_STATE_BUFFER);
+ dlt_daemon_change_state(&daemon, DLT_DAEMON_STATE_BUFFER);
dlt_daemon_init_user_information(&daemon,
&daemon_local.pGateway,
daemon_local.flags.gatewayMode,
daemon_local.flags.vflag);
- if (dlt_daemon_load_runtime_configuration(&daemon, daemon_local.flags.ivalue,daemon_local.flags.vflag)==-1)
- {
- dlt_log(LOG_ERR,"Could not load runtime config\n");
+ if (dlt_daemon_load_runtime_configuration(&daemon, daemon_local.flags.ivalue, daemon_local.flags.vflag) == -1) {
+ dlt_log(LOG_ERR, "Could not load runtime config\n");
return -1;
}
- dlt_daemon_log_internal(&daemon, &daemon_local, "Daemon launched. Starting to output traces...", daemon_local.flags.vflag);
+ dlt_daemon_log_internal(&daemon,
+ &daemon_local,
+ "Daemon launched. Starting to output traces...",
+ daemon_local.flags.vflag);
/* Even handling loop. */
while ((back >= 0) && (g_exit >= 0))
- {
back = dlt_daemon_handle_event(&daemon_local.pEvent,
&daemon,
&daemon_local);
- }
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"Exiting DLT daemon... [%d]", g_signo);
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "Exiting DLT daemon... [%d]", g_signo);
dlt_daemon_log_internal(&daemon, &daemon_local, str, daemon_local.flags.vflag);
dlt_log(LOG_NOTICE, str);
@@ -825,8 +810,7 @@ int dlt_daemon_local_init_p1(DltDaemon *daemon, DltDaemonLocal *daemon_local, in
PRINT_FUNCTION_VERBOSE(verbose);
int ret = DLT_RETURN_OK;
- if ((daemon==0) || (daemon_local==0))
- {
+ if ((daemon == 0) || (daemon_local == 0)) {
dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_local_init_p1()\n");
return -1;
}
@@ -834,50 +818,47 @@ int dlt_daemon_local_init_p1(DltDaemon *daemon, DltDaemonLocal *daemon_local, in
#if defined(DLT_SYSTEMD_WATCHDOG_ENABLE) || defined(DLT_SYSTEMD_ENABLE)
ret = sd_booted();
- if (ret == 0)
- {
+ if (ret == 0) {
dlt_log(LOG_CRIT, "System not booted with systemd!\n");
}
- else if(ret < 0)
+ else if (ret < 0)
{
dlt_log(LOG_CRIT, "sd_booted failed!\n");
return -1;
}
- else
- {
+ else {
dlt_log(LOG_INFO, "System booted with systemd\n");
}
+
#endif
#ifndef DLT_USE_UNIX_SOCKET_IPC
+
if (dlt_daemon_create_pipes_dir(daemon_local->flags.userPipesDir) == DLT_RETURN_ERROR)
- {
return DLT_RETURN_ERROR;
- }
+
#endif
/* Check for daemon mode */
if (daemon_local->flags.dflag)
- {
dlt_daemon_daemonize(daemon_local->flags.vflag);
- }
/* initialise structure to use DLT file */
- ret = dlt_file_init(&(daemon_local->file),daemon_local->flags.vflag);
- if (ret == DLT_RETURN_ERROR)
- {
- dlt_log(LOG_ERR,"Could not initialize file structure\n");
+ ret = dlt_file_init(&(daemon_local->file), daemon_local->flags.vflag);
+
+ if (ret == DLT_RETURN_ERROR) {
+ dlt_log(LOG_ERR, "Could not initialize file structure\n");
/* Return value ignored, dlt daemon will exit */
- dlt_file_free(&(daemon_local->file),daemon_local->flags.vflag);
+ dlt_file_free(&(daemon_local->file), daemon_local->flags.vflag);
return ret;
}
- signal(SIGPIPE,SIG_IGN);
+ signal(SIGPIPE, SIG_IGN);
signal(SIGTERM, dlt_daemon_signal_handler); /* software termination signal from kill */
- signal(SIGHUP, dlt_daemon_signal_handler); /* hangup signal */
+ signal(SIGHUP, dlt_daemon_signal_handler); /* hangup signal */
signal(SIGQUIT, dlt_daemon_signal_handler);
- signal(SIGINT, dlt_daemon_signal_handler);
+ signal(SIGINT, dlt_daemon_signal_handler);
return DLT_RETURN_OK;
}
@@ -886,98 +867,91 @@ int dlt_daemon_local_init_p2(DltDaemon *daemon, DltDaemonLocal *daemon_local, in
{
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon==0) || (daemon_local==0))
- {
+ if ((daemon == 0) || (daemon_local == 0)) {
dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_local_init_p2()\n");
return -1;
}
/* Daemon data */
- if (dlt_daemon_init(daemon,daemon_local->RingbufferMinSize,daemon_local->RingbufferMaxSize,daemon_local->RingbufferStepSize, daemon_local->flags.ivalue,daemon_local->flags.contextLogLevel, daemon_local->flags.contextTraceStatus,daemon_local->flags.enforceContextLLAndTS,daemon_local->flags.vflag)==-1)
- {
- dlt_log(LOG_ERR,"Could not initialize daemon data\n");
+ if (dlt_daemon_init(daemon, daemon_local->RingbufferMinSize, daemon_local->RingbufferMaxSize,
+ daemon_local->RingbufferStepSize, daemon_local->flags.ivalue,
+ daemon_local->flags.contextLogLevel,
+ daemon_local->flags.contextTraceStatus, daemon_local->flags.enforceContextLLAndTS,
+ daemon_local->flags.vflag) == -1) {
+ dlt_log(LOG_ERR, "Could not initialize daemon data\n");
return -1;
}
/* init offline trace */
- if(((daemon->mode == DLT_USER_MODE_INTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH)) && daemon_local->flags.offlineTraceDirectory[0])
- {
+ if (((daemon->mode == DLT_USER_MODE_INTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH)) &&
+ daemon_local->flags.offlineTraceDirectory[0]) {
if (dlt_offline_trace_init(&(daemon_local->offlineTrace),
- daemon_local->flags.offlineTraceDirectory,
- daemon_local->flags.offlineTraceFileSize,
- daemon_local->flags.offlineTraceMaxSize,
- daemon_local->flags.offlineTraceFilenameTimestampBased)==-1)
- {
- dlt_log(LOG_ERR,"Could not initialize offline trace\n");
+ daemon_local->flags.offlineTraceDirectory,
+ daemon_local->flags.offlineTraceFileSize,
+ daemon_local->flags.offlineTraceMaxSize,
+ daemon_local->flags.offlineTraceFilenameTimestampBased) == -1) {
+ dlt_log(LOG_ERR, "Could not initialize offline trace\n");
return -1;
}
}
/* Init offline logstorage for MAX devices */
- if(daemon_local->flags.offlineLogstorageMaxDevices > 0)
- {
+ if (daemon_local->flags.offlineLogstorageMaxDevices > 0) {
daemon->storage_handle = malloc(sizeof(DltLogStorage) * daemon_local->flags.offlineLogstorageMaxDevices);
- if(daemon->storage_handle == NULL)
- {
- dlt_log(LOG_ERR,"Could not initialize offline logstorage\n");
+ if (daemon->storage_handle == NULL) {
+ dlt_log(LOG_ERR, "Could not initialize offline logstorage\n");
return -1;
}
+
memset(daemon->storage_handle, 0, (sizeof(DltLogStorage) * daemon_local->flags.offlineLogstorageMaxDevices));
}
/* Set ECU id of daemon */
if (daemon_local->flags.evalue[0])
- {
- dlt_set_id(daemon->ecuid,daemon_local->flags.evalue);
- }
+ dlt_set_id(daemon->ecuid, daemon_local->flags.evalue);
else
- {
- dlt_set_id(daemon->ecuid,DLT_DAEMON_ECU_ID);
- }
+ dlt_set_id(daemon->ecuid, DLT_DAEMON_ECU_ID);
/* Set flag for optional sending of serial header */
daemon->sendserialheader = daemon_local->flags.lflag;
#ifdef DLT_SHM_ENABLE
+
/* init shared memory */
- if (dlt_shm_init_server(&(daemon_local->dlt_shm),DLT_SHM_KEY,daemon_local->flags.sharedMemorySize)==-1)
- {
- dlt_log(LOG_ERR,"Could not initialize shared memory\n");
+ if (dlt_shm_init_server(&(daemon_local->dlt_shm), DLT_SHM_KEY, daemon_local->flags.sharedMemorySize) == -1) {
+ dlt_log(LOG_ERR, "Could not initialize shared memory\n");
return -1;
}
+
#endif
/* prepare main loop */
- if (dlt_message_init(&(daemon_local->msg),daemon_local->flags.vflag) == DLT_RETURN_ERROR)
- {
- dlt_log(LOG_ERR,"Could not initialize message\n");
+ if (dlt_message_init(&(daemon_local->msg), daemon_local->flags.vflag) == DLT_RETURN_ERROR) {
+ dlt_log(LOG_ERR, "Could not initialize message\n");
return -1;
}
/* configure sending timing packets */
if (daemon_local->flags.sendMessageTime)
- {
daemon->timingpackets = 1;
- }
/* Binary semaphore for thread */
- if (sem_init(&dlt_daemon_mutex, 0, 1)==-1)
- {
- dlt_log(LOG_ERR,"Could not initialize binary semaphore\n");
+ if (sem_init(&dlt_daemon_mutex, 0, 1) == -1) {
+ dlt_log(LOG_ERR, "Could not initialize binary semaphore\n");
return -1;
}
/* Get ECU version info from a file. If it fails, use dlt_version as fallback. */
- if(dlt_daemon_local_ecu_version_init(daemon, daemon_local, daemon_local->flags.vflag) < 0)
- {
+ if (dlt_daemon_local_ecu_version_init(daemon, daemon_local, daemon_local->flags.vflag) < 0) {
daemon->ECUVersionString = malloc(DLT_DAEMON_TEXTBUFSIZE);
- if(daemon->ECUVersionString==0)
- {
- dlt_log(LOG_WARNING,"Could not allocate memory for version string\n");
+
+ if (daemon->ECUVersionString == 0) {
+ dlt_log(LOG_WARNING, "Could not allocate memory for version string\n");
return -1;
}
- dlt_get_version(daemon->ECUVersionString,DLT_DAEMON_TEXTBUFSIZE);
+
+ dlt_get_version(daemon->ECUVersionString, DLT_DAEMON_TEXTBUFSIZE);
}
return 0;
@@ -989,13 +963,12 @@ static int dlt_daemon_init_serial(DltDaemonLocal *daemon_local)
/* open serial connection */
int fd = -1;
- if (daemon_local->flags.yvalue[0] == '\0') {
+ if (daemon_local->flags.yvalue[0] == '\0')
return 0;
- }
fd = open(daemon_local->flags.yvalue, O_RDWR);
- if (fd < 0)
- {
+
+ if (fd < 0) {
snprintf(str,
DLT_DAEMON_TEXTBUFSIZE,
"Failed to open serial device %s\n",
@@ -1006,19 +979,15 @@ static int dlt_daemon_init_serial(DltDaemonLocal *daemon_local)
return -1;
}
- if (isatty(fd))
- {
+ if (isatty(fd)) {
int speed = DLT_DAEMON_SERIAL_DEFAULT_BAUDRATE;
if (daemon_local->flags.bvalue[0])
- {
speed = atoi(daemon_local->flags.bvalue);
- }
daemon_local->baudrate = dlt_convert_serial_speed(speed);
- if (dlt_setup_serial(fd, daemon_local->baudrate) < 0)
- {
+ if (dlt_setup_serial(fd, daemon_local->baudrate) < 0) {
close(fd);
daemon_local->flags.yvalue[0] = 0;
@@ -1033,12 +1002,9 @@ static int dlt_daemon_init_serial(DltDaemonLocal *daemon_local)
}
if (daemon_local->flags.vflag)
- {
dlt_log(LOG_DEBUG, "Serial init done\n");
- }
}
- else
- {
+ else {
close(fd);
fprintf(stderr,
"Device is not a serial device, device = %s (%s) \n",
@@ -1070,9 +1036,9 @@ static int dlt_daemon_init_fifo(DltDaemonLocal *daemon_local)
const char *tmpFifo = daemon_local->flags.daemonFifoName;
unlink(tmpFifo);
- ret=mkfifo(tmpFifo, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP );
- if (ret == -1)
- {
+ ret = mkfifo(tmpFifo, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+
+ if (ret == -1) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"FIFO user %s cannot be created (%s)!\n",
@@ -1083,8 +1049,8 @@ static int dlt_daemon_init_fifo(DltDaemonLocal *daemon_local)
} /* if */
fd = open(tmpFifo, O_RDWR);
- if (fd == -1)
- {
+
+ if (fd == -1) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"FIFO user %s cannot be opened (%s)!\n",
@@ -1094,25 +1060,21 @@ static int dlt_daemon_init_fifo(DltDaemonLocal *daemon_local)
return -1;
} /* if */
- if (daemon_local->daemonFifoSize != 0)
- {
+ if (daemon_local->daemonFifoSize != 0) {
/* Set Daemon FIFO size */
- if (fcntl(fd, F_SETPIPE_SZ , daemon_local->daemonFifoSize) == -1)
- {
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"set FIFO size error: %s\n",strerror(errno));
+ if (fcntl(fd, F_SETPIPE_SZ, daemon_local->daemonFifoSize) == -1) {
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "set FIFO size error: %s\n", strerror(errno));
dlt_log(LOG_ERR, str);
}
}
/* Get Daemon FIFO size */
- if ((fifo_size = fcntl(fd, F_GETPIPE_SZ , 0)) == -1)
- {
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"get FIFO size error: %s\n",strerror(errno));
+ if ((fifo_size = fcntl(fd, F_GETPIPE_SZ, 0)) == -1) {
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "get FIFO size error: %s\n", strerror(errno));
dlt_log(LOG_ERR, str);
}
- else
- {
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"FIFO size: %d\n",fifo_size);
+ else {
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "FIFO size: %d\n", fifo_size);
dlt_log(LOG_INFO, str);
}
@@ -1138,8 +1100,7 @@ int dlt_daemon_local_connection_init(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL)) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"%s: Invalid function parameters\n",
@@ -1153,51 +1114,49 @@ int dlt_daemon_local_connection_init(DltDaemon *daemon,
/* create and open socket to receive incoming connections from user application
* socket access permission set to srw-rw-rw- (666) */
mask = S_IXUSR | S_IXGRP | S_IXOTH;
+
if (dlt_daemon_unix_socket_open(&fd,
daemon_local->flags.appSockPath,
SOCK_STREAM,
- mask) == DLT_RETURN_OK)
- {
+ mask) == DLT_RETURN_OK) {
if (dlt_connection_create(daemon_local,
&daemon_local->pEvent,
fd,
POLLIN,
- DLT_CONNECTION_APP_CONNECT))
- {
+ DLT_CONNECTION_APP_CONNECT)) {
dlt_log(LOG_CRIT, "Could not initialize app socket.\n");
return DLT_RETURN_ERROR;
}
}
- else
- {
+ else {
dlt_log(LOG_CRIT, "Could not initialize app socket.\n");
return DLT_RETURN_ERROR;
}
+
#else
- if (dlt_daemon_init_fifo(daemon_local))
- {
+
+ if (dlt_daemon_init_fifo(daemon_local)) {
dlt_log(LOG_ERR, "Unable to initialize fifo.\n");
return DLT_RETURN_ERROR;
}
+
#endif
/* create and open socket to receive incoming connections from client */
daemon_local->client_connections = 0;
- if (dlt_daemon_socket_open(&fd, daemon_local->flags.port) == DLT_RETURN_OK)
- {
+
+ if (dlt_daemon_socket_open(&fd, daemon_local->flags.port) == DLT_RETURN_OK) {
if (dlt_connection_create(daemon_local,
&daemon_local->pEvent,
fd,
POLLIN,
- DLT_CONNECTION_CLIENT_CONNECT))
- {
- dlt_log(LOG_ERR,"Could not initialize main socket.\n");
+ DLT_CONNECTION_CLIENT_CONNECT)) {
+ dlt_log(LOG_ERR, "Could not initialize main socket.\n");
return DLT_RETURN_ERROR;
}
}
- else
- {
- dlt_log(LOG_ERR,"Could not initialize main socket.\n");
+ else {
+ dlt_log(LOG_ERR, "Could not initialize main socket.\n");
return DLT_RETURN_ERROR;
}
@@ -1205,31 +1164,28 @@ int dlt_daemon_local_connection_init(DltDaemon *daemon,
* control application
* socket access permission set to srw-rw---- (660) */
mask = S_IXUSR | S_IXGRP | S_IROTH | S_IWOTH | S_IXOTH;
+
if (dlt_daemon_unix_socket_open(&fd,
daemon_local->flags.ctrlSockPath,
SOCK_STREAM,
- mask) == DLT_RETURN_OK)
- {
+ mask) == DLT_RETURN_OK) {
if (dlt_connection_create(daemon_local,
&daemon_local->pEvent,
fd,
POLLIN,
- DLT_CONNECTION_CONTROL_CONNECT))
- {
+ DLT_CONNECTION_CONTROL_CONNECT)) {
dlt_log(LOG_ERR, "Could not initialize control socket.\n");
return DLT_RETURN_ERROR;
}
}
- else
- {
+ else {
dlt_log(LOG_ERR, "Could not initialize control socket.\n");
return DLT_RETURN_ERROR;
}
/* Init serial */
- if (dlt_daemon_init_serial(daemon_local) < 0)
- {
- dlt_log(LOG_ERR,"Could not initialize daemon data\n");
+ if (dlt_daemon_init_serial(daemon_local) < 0) {
+ dlt_log(LOG_ERR, "Could not initialize daemon data\n");
return DLT_RETURN_ERROR;
}
@@ -1238,8 +1194,8 @@ int dlt_daemon_local_connection_init(DltDaemon *daemon,
int dlt_daemon_local_ecu_version_init(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
{
- char *version = NULL;
- FILE *f = NULL;
+ char *version = NULL;
+ FILE *f = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
@@ -1248,8 +1204,8 @@ int dlt_daemon_local_ecu_version_init(DltDaemon *daemon, DltDaemonLocal *daemon_
/* Open the file. Bail out if error occurs */
f = fopen(daemon_local->flags.pathToECUSoftwareVersion, "r");
- if(f == NULL)
- {
+
+ if (f == NULL) {
/* Error level notice, because this might be deliberate choice */
dlt_log(LOG_NOTICE, "Failed to open ECU Software version file.\n");
return -1;
@@ -1258,8 +1214,8 @@ int dlt_daemon_local_ecu_version_init(DltDaemon *daemon, DltDaemonLocal *daemon_
/* Get the file size. Bail out if stat fails. */
int fd = fileno(f);
struct stat s_buf;
- if(fstat(fd, &s_buf) < 0)
- {
+
+ if (fstat(fd, &s_buf) < 0) {
dlt_log(LOG_WARNING, "Failed to stat ECU Software version file.\n");
fclose(f);
return -1;
@@ -1268,8 +1224,8 @@ int dlt_daemon_local_ecu_version_init(DltDaemon *daemon, DltDaemonLocal *daemon_
/* Bail out if file is too large. Use DLT_DAEMON_TEXTBUFSIZE max.
* Reserve one byte for trailing '\0' */
off_t size = s_buf.st_size;
- if(size >= DLT_DAEMON_TEXTBUFSIZE)
- {
+
+ if (size >= DLT_DAEMON_TEXTBUFSIZE) {
dlt_log(LOG_WARNING, "Too large file for ECU version.\n");
fclose(f);
return -1;
@@ -1277,32 +1233,34 @@ int dlt_daemon_local_ecu_version_init(DltDaemon *daemon, DltDaemonLocal *daemon_
/* Allocate permanent buffer for version info */
version = malloc(size + 1);
- if(version==0)
- {
+
+ if (version == 0) {
dlt_log(LOG_WARNING, "Cannot allocate memory for ECU version.\n");
fclose(f);
return -1;
}
+
off_t offset = 0;
- while(!feof(f))
- {
+
+ while (!feof(f)) {
offset += fread(version + offset, 1, size, f);
- if(ferror(f))
- {
+
+ if (ferror(f)) {
dlt_log(LOG_WARNING, "Failed to read ECU Software version file.\n");
free(version);
fclose(f);
return -1;
}
- if(offset > size)
- {
+
+ if (offset > size) {
dlt_log(LOG_WARNING, "Too long file for ECU Software version info.\n");
free(version);
fclose(f);
return -1;
}
}
- version[offset] = '\0';//append null termination at end of version string
+
+ version[offset] = '\0';/*append null termination at end of version string */
daemon->ECUVersionString = version;
fclose(f);
return 0;
@@ -1312,8 +1270,7 @@ void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, i
{
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon==0) || (daemon_local==0))
- {
+ if ((daemon == 0) || (daemon_local == 0)) {
dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_local_cleanup()\n");
return;
}
@@ -1321,14 +1278,14 @@ void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, i
/* Don't receive event anymore */
dlt_event_handler_cleanup_connections(&daemon_local->pEvent);
- dlt_message_free(&(daemon_local->msg),daemon_local->flags.vflag);
+ dlt_message_free(&(daemon_local->msg), daemon_local->flags.vflag);
/* free shared memory */
- if(daemon_local->flags.offlineTraceDirectory[0])
+ if (daemon_local->flags.offlineTraceDirectory[0])
dlt_offline_trace_free(&(daemon_local->offlineTrace));
/* Ignore result */
- dlt_file_free(&(daemon_local->file),daemon_local->flags.vflag);
+ dlt_file_free(&(daemon_local->file), daemon_local->flags.vflag);
/* Try to delete existing pipe, ignore result of unlink() */
unlink(daemon_local->flags.daemonFifoName);
@@ -1338,8 +1295,7 @@ void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, i
dlt_shm_free_server(&(daemon_local->dlt_shm));
#endif
- if (daemon_local->flags.offlineLogstorageMaxDevices > 0)
- {
+ if (daemon_local->flags.offlineLogstorageMaxDevices > 0) {
/* disconnect all logstorage devices */
dlt_daemon_logstorage_cleanup(daemon,
daemon_local,
@@ -1349,9 +1305,7 @@ void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, i
}
if (daemon->ECUVersionString != NULL)
- {
free(daemon->ECUVersionString);
- }
unlink(daemon_local->flags.ctrlSockPath);
@@ -1359,7 +1313,7 @@ void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, i
void dlt_daemon_exit_trigger()
{
- char tmp[PATH_MAX + 1] = {0};
+ char tmp[PATH_MAX + 1] = { 0 };
snprintf(tmp, PATH_MAX, "%s/dlt", dltFifoBaseDir);
(void)unlink(tmp);
@@ -1371,8 +1325,8 @@ void dlt_daemon_exit_trigger()
void dlt_daemon_signal_handler(int sig)
{
g_signo = sig;
- switch (sig)
- {
+
+ switch (sig) {
case SIGHUP:
case SIGTERM:
case SIGINT:
@@ -1390,6 +1344,7 @@ void dlt_daemon_signal_handler(int sig)
break;
}
} /* switch */
+
} /* dlt_daemon_signal_handler() */
void dlt_daemon_daemonize(int verbose)
@@ -1402,48 +1357,41 @@ void dlt_daemon_daemonize(int verbose)
dlt_log(LOG_NOTICE, "Daemon mode\n");
/* Daemonize */
- i=fork();
- if (i<0)
- {
+ i = fork();
+
+ if (i < 0) {
dlt_log(LOG_CRIT, "Unable to fork(), exiting DLT daemon\n");
exit(-1); /* fork error */
}
- if (i>0)
- {
+ if (i > 0)
exit(0); /* parent exits */
- }
+
/* child (daemon) continues */
/* Process independency */
- /* obtain a new process group */
- if (setsid()==-1)
- {
+ /* obtain a new process group */
+ if (setsid() == -1) {
dlt_log(LOG_CRIT, "setsid() failed, exiting DLT daemon\n");
exit(-1); /* fork error */
}
/* Open standard descriptors stdin, stdout, stderr */
fd = open("/dev/null", O_RDWR);
- if (fd != -1)
- {
+
+ if (fd != -1) {
/* Redirect STDOUT to /dev/null */
if (dup2(fd, STDOUT_FILENO) < 0)
- {
dlt_vlog(LOG_WARNING, "Failed to direct stdout to /dev/null. Error: %s\n", strerror(errno));
- }
/* Redirect STDERR to /dev/null */
if (dup2(fd, STDERR_FILENO) < 0)
- {
dlt_vlog(LOG_WARNING, "Failed to direct stderr to /dev/null. Error: %s\n", strerror(errno));
- }
close(fd);
}
- else
- {
+ else {
dlt_log(LOG_CRIT, "Error opening /dev/null, exiting DLT daemon\n");
exit(-1); /* fork error */
}
@@ -1453,27 +1401,25 @@ void dlt_daemon_daemonize(int verbose)
/* Change to root directory */
if (chdir("/") < 0)
- {
dlt_log(LOG_WARNING, "Failed to chdir to root\n");
- }
/* Catch signals */
- signal(SIGCHLD,SIG_IGN); /* ignore child */
- signal(SIGTSTP,SIG_IGN); /* ignore tty signals */
- signal(SIGTTOU,SIG_IGN);
- signal(SIGTTIN,SIG_IGN);
+ signal(SIGCHLD, SIG_IGN); /* ignore child */
+ signal(SIGTSTP, SIG_IGN); /* ignore tty signals */
+ signal(SIGTTOU, SIG_IGN);
+ signal(SIGTTIN, SIG_IGN);
} /* dlt_daemon_daemonize() */
/* This function logs str to the configured output sink (socket, serial, offline trace).
- To avoid recursion this function must be called only from DLT highlevel functions.
- E. g. calling it to output a failure when the open of the offline trace file fails
- would cause an endless loop because dlt_daemon_log_internal() would itself again try
- to open the offline trace file.
- This is a dlt-daemon only function. The libdlt has no equivalent function available. */
+ * To avoid recursion this function must be called only from DLT highlevel functions.
+ * E. g. calling it to output a failure when the open of the offline trace file fails
+ * would cause an endless loop because dlt_daemon_log_internal() would itself again try
+ * to open the offline trace file.
+ * This is a dlt-daemon only function. The libdlt has no equivalent function available. */
int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, char *str, int verbose)
{
- DltMessage msg = {0};
+ DltMessage msg = { 0 };
static uint8_t uiMsgCount = 0;
DltStandardHeaderExtra *pStandardExtra = NULL;
uint32_t uiType;
@@ -1483,41 +1429,47 @@ int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, cha
PRINT_FUNCTION_VERBOSE(verbose);
- // Set storageheader
+ /* Set storageheader */
msg.storageheader = (DltStorageHeader *)(msg.headerbuffer);
dlt_set_storageheader(msg.storageheader, daemon->ecuid);
- // Set standardheader
+ /* Set standardheader */
msg.standardheader = (DltStandardHeader *)(msg.headerbuffer + sizeof(DltStorageHeader));
- msg.standardheader->htyp = DLT_HTYP_UEH | DLT_HTYP_WEID | DLT_HTYP_WSID | DLT_HTYP_WTMS | DLT_HTYP_PROTOCOL_VERSION1;
+ msg.standardheader->htyp = DLT_HTYP_UEH | DLT_HTYP_WEID | DLT_HTYP_WSID | DLT_HTYP_WTMS |
+ DLT_HTYP_PROTOCOL_VERSION1;
msg.standardheader->mcnt = uiMsgCount++;
- uiExtraSize = DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp)+(DLT_IS_HTYP_UEH(msg.standardheader->htyp) ? sizeof(DltExtendedHeader) : 0);
+ uiExtraSize = DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp) +
+ (DLT_IS_HTYP_UEH(msg.standardheader->htyp) ? sizeof(DltExtendedHeader) : 0);
msg.headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + uiExtraSize;
- // Set extraheader
- pStandardExtra = (DltStandardHeaderExtra *)(msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader));
+ /* Set extraheader */
+ pStandardExtra =
+ (DltStandardHeaderExtra *)(msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader));
dlt_set_id(pStandardExtra->ecu, daemon->ecuid);
pStandardExtra->tmsp = DLT_HTOBE_32(dlt_uptime());
pStandardExtra->seid = DLT_HTOBE_32(getpid());
- // Set extendedheader
- msg.extendedheader = (DltExtendedHeader *)(msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp));
- msg.extendedheader->msin = DLT_MSIN_VERB | (DLT_TYPE_LOG << DLT_MSIN_MSTP_SHIFT) | ((DLT_LOG_INFO << DLT_MSIN_MTIN_SHIFT) & DLT_MSIN_MTIN);
+ /* Set extendedheader */
+ msg.extendedheader =
+ (DltExtendedHeader *)(msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+ DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp));
+ msg.extendedheader->msin = DLT_MSIN_VERB | (DLT_TYPE_LOG << DLT_MSIN_MSTP_SHIFT) |
+ ((DLT_LOG_INFO << DLT_MSIN_MTIN_SHIFT) & DLT_MSIN_MTIN);
msg.extendedheader->noar = 1;
dlt_set_id(msg.extendedheader->apid, "DLTD");
dlt_set_id(msg.extendedheader->ctid, "INTM");
- // Set payload data...
+ /* Set payload data... */
uiType = DLT_TYPE_INFO_STRG;
uiSize = strlen(str) + 1;
msg.datasize = sizeof(uint32_t) + sizeof(uint16_t) + uiSize;
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
msg.databuffersize = msg.datasize;
- if (msg.databuffer==0)
- {
- dlt_log(LOG_WARNING,"Can't allocate buffer for get log info message\n");
+
+ if (msg.databuffer == 0) {
+ dlt_log(LOG_WARNING, "Can't allocate buffer for get log info message\n");
return -1;
}
@@ -1529,33 +1481,30 @@ int dlt_daemon_log_internal(DltDaemon *daemon, DltDaemonLocal *daemon_local, cha
memcpy((uint8_t *)(msg.databuffer + msg.datasize), str, uiSize);
msg.datasize += uiSize;
- // Calc lengths
+ /* Calc lengths */
msg.standardheader->len = DLT_HTOBE_16(msg.headersize - sizeof(DltStorageHeader) + msg.datasize);
- // Sending data...
+ /* Sending data... */
{
/* check if overflow occurred */
- if(daemon->overflow_counter)
- {
- if(dlt_daemon_send_message_overflow(daemon,daemon_local,verbose)==0)
- {
- sprintf(str,"%u messages discarded!\n",daemon->overflow_counter);
- dlt_log(LOG_WARNING, str);
- daemon->overflow_counter=0;
+ if (daemon->overflow_counter) {
+ if (dlt_daemon_send_message_overflow(daemon, daemon_local, verbose) == 0) {
+ sprintf(str, "%u messages discarded!\n", daemon->overflow_counter);
+ dlt_log(LOG_WARNING, str);
+ daemon->overflow_counter = 0;
}
}
/* look if TCP connection to client is available */
- if((daemon->mode == DLT_USER_MODE_EXTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH))
- {
-
- if((ret = dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL,daemon,daemon_local,msg.headerbuffer,sizeof(DltStorageHeader),msg.headerbuffer+sizeof(DltStorageHeader),msg.headersize-sizeof(DltStorageHeader),
- msg.databuffer,msg.datasize,verbose)))
- {
- if(ret == DLT_DAEMON_ERROR_BUFFER_FULL)
- {
+ if ((daemon->mode == DLT_USER_MODE_EXTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH)) {
+
+ if ((ret =
+ dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL, daemon, daemon_local, msg.headerbuffer,
+ sizeof(DltStorageHeader), msg.headerbuffer + sizeof(DltStorageHeader),
+ msg.headersize - sizeof(DltStorageHeader),
+ msg.databuffer, msg.datasize, verbose))) {
+ if (ret == DLT_DAEMON_ERROR_BUFFER_FULL)
daemon->overflow_counter++;
- }
}
}
}
@@ -1578,8 +1527,7 @@ int dlt_daemon_process_client_connect(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
dlt_log(LOG_ERR,
"Invalid function parameters used for function "
"dlt_daemon_process_client_connect()\n");
@@ -1588,10 +1536,10 @@ int dlt_daemon_process_client_connect(DltDaemon *daemon,
/* event from TCP server socket, new connection */
cli_size = sizeof(cli);
- if ((in_sock = accept(receiver->fd,&cli, &cli_size)) < 0)
- {
+
+ if ((in_sock = accept(receiver->fd, &cli, &cli_size)) < 0) {
dlt_vlog(LOG_ERR, "accept() for socket %d failed: %s\n", receiver->fd, strerror(errno));
- return -1 ;
+ return -1;
}
/* check if file file descriptor was already used, and make it invalid if it
@@ -1604,27 +1552,25 @@ int dlt_daemon_process_client_connect(DltDaemon *daemon,
struct timeval timeout_send;
timeout_send.tv_sec = daemon_local->timeoutOnSend;
timeout_send.tv_usec = 0;
+
if (setsockopt (in_sock,
SOL_SOCKET,
SO_SNDTIMEO,
(char *)&timeout_send,
sizeof(timeout_send)) < 0)
- {
dlt_log(LOG_WARNING, "setsockopt failed\n");
- }
if (dlt_connection_create(daemon_local,
- &daemon_local->pEvent,
- in_sock,
- POLLIN,
- DLT_CONNECTION_CLIENT_MSG_TCP))
- {
+ &daemon_local->pEvent,
+ in_sock,
+ POLLIN,
+ DLT_CONNECTION_CLIENT_MSG_TCP)) {
dlt_log(LOG_ERR, "Failed to register new client. \n");
/* TODO: Perform clean-up */
return -1;
}
- // send connection info about connected
+ /* send connection info about connected */
dlt_daemon_control_message_connection_info(in_sock,
daemon,
daemon_local,
@@ -1632,24 +1578,19 @@ int dlt_daemon_process_client_connect(DltDaemon *daemon,
"",
verbose);
- // send ecu version string
- if (daemon_local->flags.sendECUSoftwareVersion > 0)
- {
+ /* send ecu version string */
+ if (daemon_local->flags.sendECUSoftwareVersion > 0) {
if (daemon_local->flags.sendECUSoftwareVersion > 0)
- {
dlt_daemon_control_get_software_version(DLT_DAEMON_SEND_TO_ALL,
daemon,
daemon_local,
daemon_local->flags.vflag);
- }
if (daemon_local->flags.sendTimezone > 0)
- {
dlt_daemon_control_message_timezone(DLT_DAEMON_SEND_TO_ALL,
daemon,
daemon_local,
daemon_local->flags.vflag);
- }
}
snprintf(local_str,
@@ -1660,22 +1601,20 @@ int dlt_daemon_process_client_connect(DltDaemon *daemon,
dlt_log(LOG_DEBUG, local_str);
dlt_daemon_log_internal(daemon, daemon_local, local_str, daemon_local->flags.vflag);
- if (daemon_local->client_connections == 1)
- {
+ if (daemon_local->client_connections == 1) {
if (daemon_local->flags.vflag)
- {
dlt_log(LOG_DEBUG, "Send ring-buffer to client\n");
- }
+
dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_SEND_BUFFER);
- if (dlt_daemon_send_ringbuffer_to_client(daemon, daemon_local, verbose)==-1)
- {
- dlt_log(LOG_WARNING,"Can't send contents of ringbuffer to clients\n");
+
+ if (dlt_daemon_send_ringbuffer_to_client(daemon, daemon_local, verbose) == -1) {
+ dlt_log(LOG_WARNING, "Can't send contents of ringbuffer to clients\n");
return -1;
}
/* send new log state to all applications */
daemon->connectionState = 1;
- dlt_daemon_user_send_all_log_state(daemon,verbose);
+ dlt_daemon_user_send_all_log_state(daemon, verbose);
}
return 0;
@@ -1686,13 +1625,12 @@ int dlt_daemon_process_client_messages(DltDaemon *daemon,
DltReceiver *receiver,
int verbose)
{
- int bytes_to_be_removed=0;
+ int bytes_to_be_removed = 0;
int must_close_socket = -1;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
dlt_log(LOG_ERR,
"Invalid function parameters used for function "
"dlt_daemon_process_client_messages()\n");
@@ -1700,8 +1638,8 @@ int dlt_daemon_process_client_messages(DltDaemon *daemon,
}
must_close_socket = dlt_receiver_receive(receiver, DLT_RECEIVE_SOCKET);
- if (must_close_socket < 0)
- {
+
+ if (must_close_socket < 0) {
dlt_daemon_close_socket(receiver->fd,
daemon,
daemon_local,
@@ -1712,51 +1650,43 @@ int dlt_daemon_process_client_messages(DltDaemon *daemon,
/* Process all received messages */
while (dlt_message_read(&(daemon_local->msg),
- (uint8_t*)receiver->buf,
+ (uint8_t *)receiver->buf,
receiver->bytesRcvd,
daemon_local->flags.nflag,
- daemon_local->flags.vflag) == DLT_MESSAGE_ERROR_OK)
- {
+ daemon_local->flags.vflag) == DLT_MESSAGE_ERROR_OK) {
/* Check for control message */
- if (0 < receiver->fd &&
+ if ((0 < receiver->fd) &&
DLT_MSG_IS_CONTROL_REQUEST(&(daemon_local->msg)))
- {
dlt_daemon_client_process_control(receiver->fd,
daemon,
daemon_local,
&(daemon_local->msg),
daemon_local->flags.vflag);
- }
bytes_to_be_removed = daemon_local->msg.headersize +
- daemon_local->msg.datasize -
- sizeof(DltStorageHeader);
+ daemon_local->msg.datasize -
+ sizeof(DltStorageHeader);
+
if (daemon_local->msg.found_serialheader)
- {
bytes_to_be_removed += sizeof(dltSerialHeader);
- }
+
if (daemon_local->msg.resync_offset)
- {
bytes_to_be_removed += daemon_local->msg.resync_offset;
- }
- if (dlt_receiver_remove(receiver, bytes_to_be_removed) == -1)
- {
+ if (dlt_receiver_remove(receiver, bytes_to_be_removed) == -1) {
dlt_log(LOG_WARNING,
"Can't remove bytes from receiver for sockets\n");
return -1;
}
-
} /* while */
- if (dlt_receiver_move_to_begin(receiver) == -1)
- {
+ if (dlt_receiver_move_to_begin(receiver) == -1) {
dlt_log(LOG_WARNING,
"Can't move bytes to beginning of receiver buffer for sockets\n");
return -1;
}
- if (must_close_socket == 0) {
+ if (must_close_socket == 0)
/* FIXME: Why the hell do we need to close the socket
* on control message reception ??
*/
@@ -1764,7 +1694,6 @@ int dlt_daemon_process_client_messages(DltDaemon *daemon,
daemon,
daemon_local,
verbose);
- }
return 0;
}
@@ -1774,20 +1703,18 @@ int dlt_daemon_process_client_messages_serial(DltDaemon *daemon,
DltReceiver *receiver,
int verbose)
{
- int bytes_to_be_removed=0;
+ int bytes_to_be_removed = 0;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
dlt_log(LOG_ERR,
"Invalid function parameters used for function "
"dlt_daemon_process_client_messages_serial()\n");
return -1;
}
- if (dlt_receiver_receive(receiver, DLT_RECEIVE_FD) <= 0)
- {
+ if (dlt_receiver_receive(receiver, DLT_RECEIVE_FD) <= 0) {
dlt_log(LOG_WARNING,
"dlt_receiver_receive_fd() for messages from serial interface "
"failed!\n");
@@ -1796,50 +1723,41 @@ int dlt_daemon_process_client_messages_serial(DltDaemon *daemon,
/* Process all received messages */
while (dlt_message_read(&(daemon_local->msg),
- (uint8_t*)receiver->buf,
+ (uint8_t *)receiver->buf,
receiver->bytesRcvd,
daemon_local->flags.mflag,
- daemon_local->flags.vflag) == DLT_MESSAGE_ERROR_OK)
- {
+ daemon_local->flags.vflag) == DLT_MESSAGE_ERROR_OK) {
/* Check for control message */
- if (DLT_MSG_IS_CONTROL_REQUEST(&(daemon_local->msg)))
- {
+ if (DLT_MSG_IS_CONTROL_REQUEST(&(daemon_local->msg))) {
if (dlt_daemon_client_process_control(receiver->fd,
daemon,
daemon_local,
&(daemon_local->msg),
daemon_local->flags.vflag)
- == -1)
- {
+ == -1) {
dlt_log(LOG_WARNING, "Can't process control messages\n");
return -1;
}
}
bytes_to_be_removed = daemon_local->msg.headersize +
- daemon_local->msg.datasize -
- sizeof(DltStorageHeader);
+ daemon_local->msg.datasize -
+ sizeof(DltStorageHeader);
if (daemon_local->msg.found_serialheader)
- {
bytes_to_be_removed += sizeof(dltSerialHeader);
- }
+
if (daemon_local->msg.resync_offset)
- {
bytes_to_be_removed += daemon_local->msg.resync_offset;
- }
- if (dlt_receiver_remove(receiver, bytes_to_be_removed) == -1)
- {
+ if (dlt_receiver_remove(receiver, bytes_to_be_removed) == -1) {
dlt_log(LOG_WARNING,
"Can't remove bytes from receiver for serial connection\n");
return -1;
}
-
} /* while */
- if (dlt_receiver_move_to_begin(receiver) == -1)
- {
+ if (dlt_receiver_move_to_begin(receiver) == -1) {
dlt_log(LOG_WARNING,
"Can't move bytes to beginning of receiver buffer for serial "
"connection\n");
@@ -1850,10 +1768,10 @@ int dlt_daemon_process_client_messages_serial(DltDaemon *daemon,
}
int dlt_daemon_process_control_connect(
- DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- DltReceiver *receiver,
- int verbose)
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *receiver,
+ int verbose)
{
socklen_t ctrl_size;
struct sockaddr_un ctrl;
@@ -1861,8 +1779,7 @@ int dlt_daemon_process_control_connect(
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
dlt_log(LOG_ERR,
"Invalid function parameters used for function "
"dlt_daemon_process_control_connect()\n");
@@ -1871,10 +1788,10 @@ int dlt_daemon_process_control_connect(
/* event from UNIX server socket, new connection */
ctrl_size = sizeof(ctrl);
- if ((in_sock = accept(receiver->fd, &ctrl, &ctrl_size)) < 0)
- {
+
+ if ((in_sock = accept(receiver->fd, &ctrl, &ctrl_size)) < 0) {
dlt_vlog(LOG_ERR, "accept() on UNIX control socket %d failed: %s\n", receiver->fd, strerror(errno));
- return -1 ;
+ return -1;
}
/* check if file file descriptor was already used, and make it invalid if it
@@ -1884,19 +1801,17 @@ int dlt_daemon_process_control_connect(
dlt_daemon_contexts_invalidate_fd(daemon, daemon->ecuid, in_sock, verbose);
if (dlt_connection_create(daemon_local,
- &daemon_local->pEvent,
- in_sock,
- POLLIN,
- DLT_CONNECTION_CONTROL_MSG))
- {
+ &daemon_local->pEvent,
+ in_sock,
+ POLLIN,
+ DLT_CONNECTION_CONTROL_MSG)) {
dlt_log(LOG_ERR, "Failed to register new client. \n");
/* TODO: Perform clean-up */
return -1;
}
- if (verbose)
- {
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,
+ if (verbose) {
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE,
"New connection to control client established\n");
dlt_log(LOG_INFO, str);
}
@@ -1906,10 +1821,10 @@ int dlt_daemon_process_control_connect(
#ifdef DLT_USE_UNIX_SOCKET_IPC
int dlt_daemon_process_app_connect(
- DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- DltReceiver *receiver,
- int verbose)
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *receiver,
+ int verbose)
{
socklen_t app_size;
struct sockaddr_un app;
@@ -1917,41 +1832,38 @@ int dlt_daemon_process_app_connect(
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
dlt_vlog(LOG_ERR,
- "%s: Invalid parameters\n",
- __func__);
+ "%s: Invalid parameters\n",
+ __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
/* event from UNIX server socket, new connection */
app_size = sizeof(app);
- if ((in_sock = accept(receiver->fd, &app, &app_size)) < 0)
- {
+
+ if ((in_sock = accept(receiver->fd, &app, &app_size)) < 0) {
dlt_vlog(LOG_ERR, "accept() on UNIX socket %d failed: %s\n", receiver->fd, strerror(errno));
- return -1 ;
+ return -1;
}
/* check if file file descriptor was already used, and make it invalid if it
* is reused. This prevents sending messages to wrong file descriptor */
dlt_daemon_applications_invalidate_fd(daemon, daemon->ecuid, in_sock, verbose);
- dlt_daemon_contexts_invalidate_fd(daemon,daemon->ecuid, in_sock, verbose);
+ dlt_daemon_contexts_invalidate_fd(daemon, daemon->ecuid, in_sock, verbose);
if (dlt_connection_create(daemon_local,
- &daemon_local->pEvent,
- in_sock,
- POLLIN,
- DLT_CONNECTION_APP_MSG))
- {
+ &daemon_local->pEvent,
+ in_sock,
+ POLLIN,
+ DLT_CONNECTION_APP_MSG)) {
dlt_log(LOG_ERR, "Failed to register new application. \n");
close(in_sock);
return -1;
}
- if (verbose)
- {
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,
+ if (verbose) {
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE,
"New connection to application established\n");
dlt_log(LOG_INFO, str);
}
@@ -1961,25 +1873,23 @@ int dlt_daemon_process_app_connect(
#endif
int dlt_daemon_process_control_messages(
- DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- DltReceiver *receiver,
- int verbose)
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *receiver,
+ int verbose)
{
- int bytes_to_be_removed=0;
+ int bytes_to_be_removed = 0;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
dlt_log(LOG_ERR,
"Invalid function parameters used for function "
"dlt_daemon_process_control_messages()\n");
return -1;
}
- if (dlt_receiver_receive(receiver, DLT_RECEIVE_SOCKET) <= 0)
- {
+ if (dlt_receiver_receive(receiver, DLT_RECEIVE_SOCKET) <= 0) {
dlt_daemon_close_socket(receiver->fd,
daemon,
daemon_local,
@@ -1993,47 +1903,38 @@ int dlt_daemon_process_control_messages(
/* Process all received messages */
while (dlt_message_read(
- &(daemon_local->msg),
- (uint8_t*)receiver->buf,
- receiver->bytesRcvd,
- daemon_local->flags.nflag,
- daemon_local->flags.vflag) == DLT_MESSAGE_ERROR_OK)
- {
+ &(daemon_local->msg),
+ (uint8_t *)receiver->buf,
+ receiver->bytesRcvd,
+ daemon_local->flags.nflag,
+ daemon_local->flags.vflag) == DLT_MESSAGE_ERROR_OK) {
/* Check for control message */
- if (receiver->fd > 0 &&
+ if ((receiver->fd > 0) &&
DLT_MSG_IS_CONTROL_REQUEST(&(daemon_local->msg)))
- {
dlt_daemon_client_process_control(receiver->fd,
- daemon,daemon_local,
+ daemon, daemon_local,
&(daemon_local->msg),
daemon_local->flags.vflag);
- }
bytes_to_be_removed = daemon_local->msg.headersize +
- daemon_local->msg.datasize -
- sizeof(DltStorageHeader);
+ daemon_local->msg.datasize -
+ sizeof(DltStorageHeader);
if (daemon_local->msg.found_serialheader)
- {
bytes_to_be_removed += sizeof(dltSerialHeader);
- }
+
if (daemon_local->msg.resync_offset)
- {
bytes_to_be_removed += daemon_local->msg.resync_offset;
- }
- if (dlt_receiver_remove(receiver, bytes_to_be_removed) == -1)
- {
+ if (dlt_receiver_remove(receiver, bytes_to_be_removed) == -1) {
dlt_log(LOG_WARNING,
"Can't remove bytes from receiver for sockets\n");
return -1;
}
-
} /* while */
- if (dlt_receiver_move_to_begin(receiver) == -1)
- {
- dlt_log(LOG_WARNING,"Can't move bytes to beginning of receiver buffer for sockets\n");
+ if (dlt_receiver_move_to_begin(receiver) == -1) {
+ dlt_log(LOG_WARNING, "Can't move bytes to beginning of receiver buffer for sockets\n");
return -1;
}
@@ -2046,7 +1947,7 @@ static int dlt_daemon_process_user_message_not_sup(DltDaemon *daemon,
int verbose)
{
char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
- DltUserHeader *userheader = (DltUserHeader*) (receiver->buf);
+ DltUserHeader *userheader = (DltUserHeader *)(receiver->buf);
(void)daemon;
(void)daemon_local;
@@ -2060,10 +1961,8 @@ static int dlt_daemon_process_user_message_not_sup(DltDaemon *daemon,
/* remove user header */
if (dlt_receiver_remove(receiver, sizeof(DltUserHeader)) == -1)
- {
dlt_log(LOG_WARNING,
"Can't remove bytes from receiver for user messages\n");
- }
return -1;
}
@@ -2104,8 +2003,7 @@ int dlt_daemon_process_user_messages(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (receiver == NULL)) {
dlt_log(LOG_ERR,
"Invalid function parameters used for function "
"dlt_daemon_process_user_messages()\n");
@@ -2114,8 +2012,8 @@ int dlt_daemon_process_user_messages(DltDaemon *daemon,
#ifdef DLT_USE_UNIX_SOCKET_IPC
recv = dlt_receiver_receive(receiver, DLT_RECEIVE_SOCKET);
- if (recv <= 0)
- {
+
+ if (recv <= 0) {
dlt_daemon_close_socket(receiver->fd,
daemon,
daemon_local,
@@ -2123,66 +2021,54 @@ int dlt_daemon_process_user_messages(DltDaemon *daemon,
receiver->fd = -1;
return 0;
}
+
#else
recv = dlt_receiver_receive(receiver, DLT_RECEIVE_FD);
- if (recv < 0)
- {
+
+ if (recv < 0) {
dlt_log(LOG_WARNING,
"dlt_receiver_receive_fd() for user messages failed!\n");
return -1;
}
+
#endif
/* look through buffer as long as data is in there */
- while ((receiver->bytesRcvd >= min_size) && run_loop)
- {
+ while ((receiver->bytesRcvd >= min_size) && run_loop) {
dlt_daemon_process_user_message_func func = NULL;
offset = 0;
userheader = (DltUserHeader *)(receiver->buf + offset);
while (!dlt_user_check_userheader(userheader) &&
- (offset + min_size <= receiver->bytesRcvd))
- /* resync if necessary */
- {
+ (offset + min_size <= receiver->bytesRcvd)) {
+ /* resync if necessary */
offset++;
userheader = (DltUserHeader *)(receiver->buf + offset);
}
/* Check for user header pattern */
if (!dlt_user_check_userheader(userheader))
- {
break;
- }
/* Set new start offset */
if (offset > 0)
- {
dlt_receiver_remove(receiver, offset);
- }
-
if (userheader->message >= DLT_USER_MESSAGE_NOT_SUPPORTED)
- {
func = dlt_daemon_process_user_message_not_sup;
- }
else
- {
func = process_user_func[userheader->message];
- }
if (func(daemon,
daemon_local,
receiver,
daemon_local->flags.vflag) == -1)
- {
run_loop = 0;
- }
}
/* keep not read data in buffer */
- if (dlt_receiver_move_to_begin(receiver) == -1)
- {
+ if (dlt_receiver_move_to_begin(receiver) == -1) {
dlt_log(LOG_WARNING,
"Can't move bytes to beginning of receiver buffer for user "
"messages\n");
@@ -2203,8 +2089,7 @@ int dlt_daemon_process_user_message_overflow(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Invalid function parameters used for %s\n",
@@ -2218,24 +2103,20 @@ int dlt_daemon_process_user_message_overflow(DltDaemon *daemon,
&userpayload,
len,
DLT_RCV_SKIP_HEADER | DLT_RCV_REMOVE) < 0)
- {
/* Not enough bytes received */
return -1;
- }
/* Store in daemon, that a message buffer overflow has occured */
/* look if TCP connection to client is available or it least message can be put into buffer */
- if(dlt_daemon_control_message_buffer_overflow(DLT_DAEMON_SEND_TO_ALL,
- daemon,
- daemon_local,
- userpayload.overflow_counter,
- userpayload.apid,
- verbose))
- {
+ if (dlt_daemon_control_message_buffer_overflow(DLT_DAEMON_SEND_TO_ALL,
+ daemon,
+ daemon_local,
+ userpayload.overflow_counter,
+ userpayload.apid,
+ verbose))
/* there was an error when storing message */
/* add the counter of lost messages to the daemon counter */
daemon->overflow_counter += userpayload.overflow_counter;
- }
return 0;
}
@@ -2245,17 +2126,17 @@ int dlt_daemon_send_message_overflow(DltDaemon *daemon, DltDaemonLocal *daemon_l
int ret;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon==0) || (daemon_local==0))
- {
+ if ((daemon == 0) || (daemon_local == 0)) {
dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_process_user_message_overflow()\n");
return DLT_DAEMON_ERROR_UNKNOWN;
}
/* Store in daemon, that a message buffer overflow has occured */
- if((ret=dlt_daemon_control_message_buffer_overflow(DLT_DAEMON_SEND_TO_ALL, daemon,daemon_local,daemon->overflow_counter,"", verbose)))
- {
+ if ((ret =
+ dlt_daemon_control_message_buffer_overflow(DLT_DAEMON_SEND_TO_ALL, daemon, daemon_local,
+ daemon->overflow_counter,
+ "", verbose)))
return ret;
- }
return DLT_DAEMON_ERROR_OK;
}
@@ -2277,8 +2158,7 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Invalid function parameters used for %s\n",
@@ -2296,15 +2176,14 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
&userapp,
len,
DLT_RCV_SKIP_HEADER);
+
if (to_remove < 0)
- {
/* Not enough bytes received */
return -1;
- }
len = userapp.description_length;
- if (len > DLT_DAEMON_DESCSIZE)
- {
+
+ if (len > DLT_DAEMON_DESCSIZE) {
len = DLT_DAEMON_DESCSIZE;
dlt_log(LOG_WARNING, "Application description exceeds limit\n");
}
@@ -2312,8 +2191,7 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
/* adjust buffer pointer */
rec->buf += to_remove + sizeof(DltUserHeader);
- if (dlt_receiver_check_and_get(rec, description, len, DLT_RCV_NONE) < 0)
- {
+ if (dlt_receiver_check_and_get(rec, description, len, DLT_RCV_NONE) < 0) {
dlt_log(LOG_ERR, "Unable to get application description\n");
/* in case description was not readable, set dummy description */
strncpy(description, "Unknown", sizeof("Unknown"));
@@ -2329,17 +2207,16 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
rec->buf = origin;
/* We can now remove data. */
- if (dlt_receiver_remove(rec, to_remove) != DLT_RETURN_OK)
- {
- dlt_log(LOG_WARNING,"Can't remove bytes from receiver\n");
+ if (dlt_receiver_remove(rec, to_remove) != DLT_RETURN_OK) {
+ dlt_log(LOG_WARNING, "Can't remove bytes from receiver\n");
return -1;
}
old_application = dlt_daemon_application_find(daemon, userapp.apid, daemon->ecuid, verbose);
+
if (old_application != NULL)
- {
old_pid = old_application->pid;
- }
+
application = dlt_daemon_application_add(daemon,
userapp.apid,
userapp.pid,
@@ -2351,32 +2228,27 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
/* send log state to new application */
dlt_daemon_user_send_log_state(daemon, application, verbose);
- if (application == NULL)
- {
+ if (application == NULL) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Can't add ApplicationID '%.4s' for PID %d\n",
userapp.apid,
userapp.pid);
- dlt_log(LOG_WARNING,local_str);
+ dlt_log(LOG_WARNING, local_str);
return -1;
}
- else
- {
- if (old_pid != application->pid)
- {
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "ApplicationID '%.4s' registered for PID %d, Description=%s\n",
- application->apid,
- application->pid,
- application->application_description);
- dlt_daemon_log_internal(daemon,
- daemon_local,
- local_str,
- daemon_local->flags.vflag);
- dlt_log(LOG_DEBUG, local_str);
- }
+ else if (old_pid != application->pid) {
+ snprintf(local_str,
+ DLT_DAEMON_TEXTBUFSIZE,
+ "ApplicationID '%.4s' registered for PID %d, Description=%s\n",
+ application->apid,
+ application->pid,
+ application->application_description);
+ dlt_daemon_log_internal(daemon,
+ daemon_local,
+ local_str,
+ daemon_local->flags.vflag);
+ dlt_log(LOG_DEBUG, local_str);
}
return 0;
@@ -2401,8 +2273,7 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Invalid function parameters used for %s\n",
@@ -2421,15 +2292,12 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
DLT_RCV_SKIP_HEADER);
if (to_remove < 0)
- {
/* Not enough bytes received */
return -1;
- }
len = userctxt.description_length;
- if (len > DLT_DAEMON_DESCSIZE)
- {
+ if (len > DLT_DAEMON_DESCSIZE) {
dlt_vlog(LOG_WARNING, "Context description exceeds limit: %d\n", len);
len = DLT_DAEMON_DESCSIZE;
}
@@ -2437,8 +2305,7 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
/* adjust buffer pointer */
rec->buf += to_remove + sizeof(DltUserHeader);
- if (dlt_receiver_check_and_get(rec, description, len, DLT_RCV_NONE) < 0)
- {
+ if (dlt_receiver_check_and_get(rec, description, len, DLT_RCV_NONE) < 0) {
dlt_log(LOG_ERR, "Unable to get context description\n");
/* in case description was not readable, set dummy description */
strncpy(description, "Unknown", sizeof("Unknown"));
@@ -2454,9 +2321,8 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
rec->buf = origin;
/* We can now remove data. */
- if (dlt_receiver_remove(rec, to_remove) != DLT_RETURN_OK)
- {
- dlt_log(LOG_WARNING,"Can't remove bytes from receiver\n");
+ if (dlt_receiver_remove(rec, to_remove) != DLT_RETURN_OK) {
+ dlt_log(LOG_WARNING, "Can't remove bytes from receiver\n");
return -1;
}
@@ -2465,8 +2331,7 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
daemon->ecuid,
verbose);
- if (application == 0)
- {
+ if (application == 0) {
dlt_vlog(LOG_WARNING,
"ApID '%.4s' not found for new ContextID '%.4s' in %s\n",
userctxt.apid,
@@ -2477,34 +2342,24 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
}
/* Set log level */
- if (userctxt.log_level == DLT_USER_LOG_LEVEL_NOT_SET)
- {
+ if (userctxt.log_level == DLT_USER_LOG_LEVEL_NOT_SET) {
userctxt.log_level = DLT_LOG_DEFAULT;
}
else
- {
- /* Plausibility check */
- if ((userctxt.log_level < DLT_LOG_DEFAULT) ||
- (userctxt.log_level > DLT_LOG_VERBOSE))
- {
- return -1;
- }
- }
+ /* Plausibility check */
+ if ((userctxt.log_level < DLT_LOG_DEFAULT) ||
+ (userctxt.log_level > DLT_LOG_VERBOSE))
+ return -1;
/* Set trace status */
- if (userctxt.trace_status == DLT_USER_TRACE_STATUS_NOT_SET)
- {
+ if (userctxt.trace_status == DLT_USER_TRACE_STATUS_NOT_SET) {
userctxt.trace_status = DLT_TRACE_STATUS_DEFAULT;
}
else
- {
- /* Plausibility check */
- if ((userctxt.trace_status < DLT_TRACE_STATUS_DEFAULT) ||
- (userctxt.trace_status > DLT_TRACE_STATUS_ON))
- {
- return -1;
- }
- }
+ /* Plausibility check */
+ if ((userctxt.trace_status < DLT_TRACE_STATUS_DEFAULT) ||
+ (userctxt.trace_status > DLT_TRACE_STATUS_ON))
+ return -1;
context = dlt_daemon_context_add(daemon,
userctxt.apid,
@@ -2517,8 +2372,7 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
daemon->ecuid,
verbose);
- if (context==0)
- {
+ if (context == 0) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Can't add ContextID '%.4s' for ApID '%.4s'\n in %s",
@@ -2528,80 +2382,72 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
dlt_log(LOG_WARNING, local_str);
return -1;
}
- else
- {
+ else {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"ContextID '%.4s' registered for ApID '%.4s', Description=%s\n",
context->ctid,
context->apid,
context->context_description);
+
if (verbose)
- {
dlt_daemon_log_internal(daemon, daemon_local, local_str, verbose);
- }
+
dlt_log(LOG_DEBUG, local_str);
}
- if(daemon_local->flags.offlineLogstorageMaxDevices)
- {
+ if (daemon_local->flags.offlineLogstorageMaxDevices)
/* Store log level set for offline logstorage into context structure*/
context->storage_log_level =
dlt_daemon_logstorage_get_loglevel(daemon,
daemon_local->flags.offlineLogstorageMaxDevices,
userctxt.apid,
userctxt.ctid);
- }
else
- {
context->storage_log_level = DLT_LOG_DEFAULT;
- }
+
/* Create automatic get log info response for registered context */
- if (daemon_local->flags.rflag)
- {
+ if (daemon_local->flags.rflag) {
/* Prepare request for get log info with one application and one context */
- if (dlt_message_init(&msg, verbose)==-1)
- {
- dlt_log(LOG_WARNING,"Can't initialize message");
+ if (dlt_message_init(&msg, verbose) == -1) {
+ dlt_log(LOG_WARNING, "Can't initialize message");
return -1;
}
msg.datasize = sizeof(DltServiceGetLogInfoRequest);
- if (msg.databuffer && (msg.databuffersize < msg.datasize))
- {
+
+ if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
free(msg.databuffer);
- msg.databuffer=0;
+ msg.databuffer = 0;
}
- if (msg.databuffer == 0){
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
+
+ if (msg.databuffer == 0) {
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
msg.databuffersize = msg.datasize;
}
- if (msg.databuffer==0)
- {
- dlt_log(LOG_WARNING,"Can't allocate buffer for get log info message\n");
+
+ if (msg.databuffer == 0) {
+ dlt_log(LOG_WARNING, "Can't allocate buffer for get log info message\n");
return -1;
}
- req = (DltServiceGetLogInfoRequest*) msg.databuffer;
+ req = (DltServiceGetLogInfoRequest *)msg.databuffer;
req->service_id = DLT_SERVICE_ID_GET_LOG_INFO;
req->options = daemon_local->flags.autoResponseGetLogInfoOption;
dlt_set_id(req->apid, userctxt.apid);
dlt_set_id(req->ctid, userctxt.ctid);
- dlt_set_id(req->com,"remo");
+ dlt_set_id(req->com, "remo");
- dlt_daemon_control_get_log_info(DLT_DAEMON_SEND_TO_ALL , daemon,daemon_local, &msg, verbose);
+ dlt_daemon_control_get_log_info(DLT_DAEMON_SEND_TO_ALL, daemon, daemon_local, &msg, verbose);
dlt_message_free(&msg, verbose);
}
- if (context->user_handle >= DLT_FD_MINIMUM)
- {
- if ((userctxt.log_level == DLT_LOG_DEFAULT) || (userctxt.trace_status == DLT_TRACE_STATUS_DEFAULT))
- {
+ if (context->user_handle >= DLT_FD_MINIMUM) {
+ if ((userctxt.log_level == DLT_LOG_DEFAULT) || (userctxt.trace_status == DLT_TRACE_STATUS_DEFAULT)) {
/* This call also replaces the default values with the values defined for default */
- if (dlt_daemon_user_send_log_level(daemon, context, verbose)==-1)
- {
+ if (dlt_daemon_user_send_log_level(daemon, context, verbose) == -1) {
dlt_vlog(LOG_WARNING, "Can't send current log level as response to %s for (%.4s;%.4s)\n",
__func__,
context->apid,
@@ -2629,8 +2475,7 @@ int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
dlt_vlog(LOG_ERR,
"Invalid function parameters used for %s\n",
__func__);
@@ -2641,19 +2486,15 @@ int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon,
&userapp,
len,
DLT_RCV_SKIP_HEADER | DLT_RCV_REMOVE) < 0)
- {
/* Not enough bytes received */
return -1;
- }
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return -1;
- }
- if (user_list->num_applications > 0)
- {
+ if (user_list->num_applications > 0) {
/* Delete this application and all corresponding contexts
* for this application from internal table.
*/
@@ -2662,26 +2503,22 @@ int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon,
daemon->ecuid,
verbose);
- if (application)
- {
+ if (application) {
/* Calculate start offset within contexts[] */
- offset_base=0;
+ offset_base = 0;
+
for (i = 0; i < (application - (user_list->applications)); i++)
- {
offset_base += user_list->applications[i].num_contexts;
- }
- for (i = (application->num_contexts) - 1; i >= 0; i--)
- {
+ for (i = (application->num_contexts) - 1; i >= 0; i--) {
context = &(user_list->contexts[offset_base + i]);
- if (context)
- {
+
+ if (context) {
/* Delete context */
if (dlt_daemon_context_del(daemon,
context,
daemon->ecuid,
- verbose) == -1)
- {
+ verbose) == -1) {
dlt_vlog(LOG_WARNING,
"Can't delete CtID '%.4s' for ApID '%.4s' in %s\n",
context->ctid,
@@ -2696,16 +2533,14 @@ int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon,
if (dlt_daemon_application_del(daemon,
application,
daemon->ecuid,
- verbose) == -1)
- {
+ verbose) == -1) {
dlt_vlog(LOG_WARNING,
"Can't delete ApID '%.4s' in %s\n",
application->apid,
__func__);
return -1;
}
- else
- {
+ else {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Unregistered ApID '%.4s'\n",
@@ -2734,8 +2569,7 @@ int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
dlt_vlog(LOG_ERR,
"Invalid function parameters used for %s\n",
__func__);
@@ -2747,10 +2581,8 @@ int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon,
&userctxt,
len,
DLT_RCV_SKIP_HEADER | DLT_RCV_REMOVE) < 0)
- {
/* Not enough bytes received */
return -1;
- }
context = dlt_daemon_context_find(daemon,
userctxt.apid,
@@ -2758,11 +2590,9 @@ int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon,
daemon->ecuid,
verbose);
- if (context)
- {
+ if (context) {
/* Delete this connection entry from internal table*/
- if (dlt_daemon_context_del(daemon, context, daemon->ecuid, verbose) == -1)
- {
+ if (dlt_daemon_context_del(daemon, context, daemon->ecuid, verbose) == -1) {
dlt_vlog(LOG_WARNING,
"Can't delete CtID '%.4s' for ApID '%.4s' in %s\n",
userctxt.ctid,
@@ -2770,27 +2600,25 @@ int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon,
__func__);
return -1;
}
- else
- {
+ else {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Unregistered CtID '%.4s' for ApID '%.4s'\n",
userctxt.ctid,
userctxt.apid);
+
if (verbose)
- {
dlt_daemon_log_internal(daemon,
daemon_local,
local_str,
verbose);
- }
+
dlt_log(LOG_DEBUG, local_str);
}
}
/* Create automatic unregister context response for unregistered context */
if (daemon_local->flags.rflag)
- {
dlt_daemon_control_message_unregister_context(DLT_DAEMON_SEND_TO_ALL,
daemon,
daemon_local,
@@ -2798,7 +2626,6 @@ int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon,
userctxt.ctid,
"remo",
verbose);
- }
return 0;
}
@@ -2815,42 +2642,39 @@ int dlt_daemon_process_user_message_log(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_process_user_message_log()\n");
return DLT_DAEMON_ERROR_UNKNOWN;
}
ret = dlt_message_read(&(daemon_local->msg),
- (unsigned char*)rec->buf + sizeof(DltUserHeader),
+ (unsigned char *)rec->buf + sizeof(DltUserHeader),
rec->bytesRcvd - sizeof(DltUserHeader),
0,
verbose);
- if(ret!=DLT_MESSAGE_ERROR_OK)
- {
- if(ret!=DLT_MESSAGE_ERROR_SIZE)
- {
+
+ if (ret != DLT_MESSAGE_ERROR_OK) {
+ if (ret != DLT_MESSAGE_ERROR_SIZE)
/* This is a normal usecase: The daemon reads the data in 10kb chunks.
- Thus the last trace in this chunk is probably not complete and will be completed
- with the next chunk read. This happens always when the FIFO is filled with more than 10kb before
- the daemon is able to read from the FIFO.
- Thus the loglevel of this message is set to DEBUG.
- A cleaner solution would be to check more in detail whether the message is not complete (normal usecase)
- or the headers are corrupted (error case). */
- dlt_log(LOG_DEBUG,"Can't read messages from receiver\n");
- }
+ * Thus the last trace in this chunk is probably not complete and will be completed
+ * with the next chunk read. This happens always when the FIFO is filled with more than 10kb before
+ * the daemon is able to read from the FIFO.
+ * Thus the loglevel of this message is set to DEBUG.
+ * A cleaner solution would be to check more in detail whether the message is not complete (normal usecase)
+ * or the headers are corrupted (error case). */
+ dlt_log(LOG_DEBUG, "Can't read messages from receiver\n");
+
return DLT_DAEMON_ERROR_UNKNOWN;
}
/* set overwrite ecu id */
- if ((daemon_local->flags.evalue[0]) && (strncmp(daemon_local->msg.headerextra.ecu,DLT_DAEMON_ECU_ID,4)==0))
- {
+ if ((daemon_local->flags.evalue[0]) && (strncmp(daemon_local->msg.headerextra.ecu, DLT_DAEMON_ECU_ID, 4) == 0)) {
/* Set header extra parameters */
- dlt_set_id(daemon_local->msg.headerextra.ecu, daemon->ecuid );
- //msg.headerextra.seid = 0;
- if (dlt_message_set_extraparameters(&(daemon_local->msg),0) == DLT_RETURN_ERROR)
- {
- dlt_log(LOG_WARNING,"Can't set message extra parameters in process user message log\n");
+ dlt_set_id(daemon_local->msg.headerextra.ecu, daemon->ecuid);
+
+ /*msg.headerextra.seid = 0; */
+ if (dlt_message_set_extraparameters(&(daemon_local->msg), 0) == DLT_RETURN_ERROR) {
+ dlt_log(LOG_WARNING, "Can't set message extra parameters in process user message log\n");
return DLT_DAEMON_ERROR_UNKNOWN;
}
@@ -2859,81 +2683,67 @@ int dlt_daemon_process_user_message_log(DltDaemon *daemon,
}
/* prepare storage header */
- if (DLT_IS_HTYP_WEID(daemon_local->msg.standardheader->htyp))
- {
- if (dlt_set_storageheader(daemon_local->msg.storageheader,daemon_local->msg.headerextra.ecu) == DLT_RETURN_ERROR)
- {
- dlt_log(LOG_WARNING,"Can't set storage header in process user message log\n");
+ if (DLT_IS_HTYP_WEID(daemon_local->msg.standardheader->htyp)) {
+ if (dlt_set_storageheader(daemon_local->msg.storageheader,
+ daemon_local->msg.headerextra.ecu) == DLT_RETURN_ERROR) {
+ dlt_log(LOG_WARNING, "Can't set storage header in process user message log\n");
return DLT_DAEMON_ERROR_UNKNOWN;
}
}
- else
- {
- if (dlt_set_storageheader(daemon_local->msg.storageheader,daemon->ecuid) == DLT_RETURN_ERROR)
- {
- dlt_log(LOG_WARNING,"Can't set storage header in process user message log\n");
- return DLT_DAEMON_ERROR_UNKNOWN;
- }
+ else if (dlt_set_storageheader(daemon_local->msg.storageheader, daemon->ecuid) == DLT_RETURN_ERROR) {
+ dlt_log(LOG_WARNING, "Can't set storage header in process user message log\n");
+ return DLT_DAEMON_ERROR_UNKNOWN;
}
{
/* if no filter set or filter is matching display message */
- if (daemon_local->flags.xflag)
- {
- if (dlt_message_print_hex(&(daemon_local->msg),text,DLT_DAEMON_TEXTSIZE,verbose) == DLT_RETURN_ERROR)
- {
- dlt_log(LOG_WARNING,"dlt_message_print_hex() failed!\n");
- }
+ if (daemon_local->flags.xflag) {
+ if (dlt_message_print_hex(&(daemon_local->msg), text, DLT_DAEMON_TEXTSIZE, verbose) == DLT_RETURN_ERROR)
+ dlt_log(LOG_WARNING, "dlt_message_print_hex() failed!\n");
} /* if */
else if (daemon_local->flags.aflag)
{
- if (dlt_message_print_ascii(&(daemon_local->msg),text,DLT_DAEMON_TEXTSIZE,verbose) == DLT_RETURN_ERROR)
- {
- dlt_log(LOG_WARNING,"dlt_message_print_ascii() failed!\n");
- }
+ if (dlt_message_print_ascii(&(daemon_local->msg), text, DLT_DAEMON_TEXTSIZE, verbose) == DLT_RETURN_ERROR)
+ dlt_log(LOG_WARNING, "dlt_message_print_ascii() failed!\n");
} /* if */
else if (daemon_local->flags.sflag)
{
- if (dlt_message_print_header(&(daemon_local->msg),text,DLT_DAEMON_TEXTSIZE,verbose) == DLT_RETURN_ERROR)
- {
- dlt_log(LOG_WARNING,"dlt_message_print_header() failed!\n");
- }
+ if (dlt_message_print_header(&(daemon_local->msg), text, DLT_DAEMON_TEXTSIZE, verbose) == DLT_RETURN_ERROR)
+ dlt_log(LOG_WARNING, "dlt_message_print_header() failed!\n");
+
/* print message header only */
} /* if */
-
/* check if overflow occurred */
- if(daemon->overflow_counter)
- {
- if(dlt_daemon_send_message_overflow(daemon,daemon_local,verbose)==0)
- {
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"%u messages discarded!\n",daemon->overflow_counter);
+ if (daemon->overflow_counter) {
+ if (dlt_daemon_send_message_overflow(daemon, daemon_local, verbose) == 0) {
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "%u messages discarded!\n", daemon->overflow_counter);
dlt_log(LOG_WARNING, str);
- daemon->overflow_counter=0;
+ daemon->overflow_counter = 0;
}
}
/* send message to client or write to log file */
- if((ret = dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL,daemon,daemon_local,daemon_local->msg.headerbuffer,sizeof(DltStorageHeader),daemon_local->msg.headerbuffer+sizeof(DltStorageHeader),daemon_local->msg.headersize-sizeof(DltStorageHeader),
- daemon_local->msg.databuffer,daemon_local->msg.datasize,verbose)))
- {
- if(ret == DLT_DAEMON_ERROR_BUFFER_FULL)
- {
+ if ((ret =
+ dlt_daemon_client_send(DLT_DAEMON_SEND_TO_ALL, daemon, daemon_local, daemon_local->msg.headerbuffer,
+ sizeof(DltStorageHeader),
+ daemon_local->msg.headerbuffer + sizeof(DltStorageHeader),
+ daemon_local->msg.headersize - sizeof(DltStorageHeader),
+ daemon_local->msg.databuffer, daemon_local->msg.datasize, verbose))) {
+ if (ret == DLT_DAEMON_ERROR_BUFFER_FULL)
daemon->overflow_counter++;
- }
}
-
}
+
/* keep not read data in buffer */
- bytes_to_be_removed = daemon_local->msg.headersize+daemon_local->msg.datasize-sizeof(DltStorageHeader)+sizeof(DltUserHeader);
+ bytes_to_be_removed = daemon_local->msg.headersize + daemon_local->msg.datasize - sizeof(DltStorageHeader) +
+ sizeof(DltUserHeader);
+
if (daemon_local->msg.found_serialheader)
- {
bytes_to_be_removed += sizeof(dltSerialHeader);
- }
- if (dlt_receiver_remove(rec, bytes_to_be_removed) == -1)
- {
- dlt_log(LOG_WARNING,"Can't remove bytes from receiver\n");
+ if (dlt_receiver_remove(rec, bytes_to_be_removed) == -1) {
+ dlt_log(LOG_WARNING, "Can't remove bytes from receiver\n");
return DLT_DAEMON_ERROR_UNKNOWN;
}
@@ -2941,14 +2751,14 @@ int dlt_daemon_process_user_message_log(DltDaemon *daemon,
}
#ifdef DLT_SHM_ENABLE
-#define DLT_SHM_RCV_BUFFER_SIZE 10000
+# define DLT_SHM_RCV_BUFFER_SIZE 10000
int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon,
DltDaemonLocal *daemon_local,
DltReceiver *rec,
int verbose)
{
char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
- int j,sent,third_value;
+ int j, sent, third_value;
ssize_t ret;
uint8_t *rcv_buffer = NULL;
int size;
@@ -2959,8 +2769,7 @@ int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Invalid function parameters used for %s\n",
@@ -2972,8 +2781,7 @@ int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon,
rcv_buffer = calloc(1, DLT_SHM_RCV_BUFFER_SIZE);
- if (!rcv_buffer)
- {
+ if (!rcv_buffer) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"No memory to allocate receiver buffer in %s.\n",
@@ -2987,110 +2795,97 @@ int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon,
memset(&userheader, 0, len);
if (dlt_receiver_check_and_get(rec, &userheader, len, DLT_RCV_REMOVE) < 0)
- {
/* Not enough bytes received */
return -1;
- }
- //dlt_shm_status(&(daemon_local->dlt_shm));
- while (1)
- {
+ /*dlt_shm_status(&(daemon_local->dlt_shm)); */
+ while (1) {
/* log message in SHM */
size = dlt_shm_copy(&(daemon_local->dlt_shm),
rcv_buffer,
DLT_SHM_RCV_BUFFER_SIZE);
- if(size <= 0)
+
+ if (size <= 0)
break;
- if (dlt_message_read(&(daemon_local->msg),rcv_buffer,size,0,verbose)!=0) {
- break;
- dlt_log(LOG_WARNING,"Can't read messages from shm\n");
- return -1;
- }
-
- /* set overwrite ecu id */
- if ((daemon_local->flags.evalue[0]) && (strncmp(daemon_local->msg.headerextra.ecu,DLT_DAEMON_ECU_ID,4)==0))
- {
- /* Set header extra parameters */
- dlt_set_id(daemon_local->msg.headerextra.ecu, daemon->ecuid );
- //msg.headerextra.seid = 0;
- if (dlt_message_set_extraparameters(&(daemon_local->msg),0)==-1)
- {
- dlt_log(LOG_WARNING,"Can't set message extra parameters in process user message log\n");
- dlt_shm_remove(&(daemon_local->dlt_shm));
- return -1;
- }
-
- /* Correct value of timestamp, this was changed by dlt_message_set_extraparameters() */
- daemon_local->msg.headerextra.tmsp = DLT_BETOH_32(daemon_local->msg.headerextra.tmsp);
- }
-
- /* prepare storage header */
- if (DLT_IS_HTYP_WEID(daemon_local->msg.standardheader->htyp))
- {
- if (dlt_set_storageheader(daemon_local->msg.storageheader,daemon_local->msg.headerextra.ecu)==-1)
- {
- dlt_log(LOG_WARNING,"Can't set storage header in process user message log\n");
- dlt_shm_remove(&(daemon_local->dlt_shm));
- return -1;
- }
- }
- else
- {
- if (dlt_set_storageheader(daemon_local->msg.storageheader,daemon->ecuid)==-1)
- {
- dlt_log(LOG_WARNING,"Can't set storage header in process user message log\n");
- dlt_shm_remove(&(daemon_local->dlt_shm));
- return -1;
- }
- }
-
- /* display message */
- if (daemon_local->flags.xflag)
- {
- if (dlt_message_print_hex(&(daemon_local->msg),text,DLT_DAEMON_TEXTSIZE,verbose)==-1)
- {
- dlt_log(LOG_WARNING,"dlt_message_print_hex() failed!\n");
- }
- } /* if */
- else if (daemon_local->flags.aflag)
- {
- if (dlt_message_print_ascii(&(daemon_local->msg),text,DLT_DAEMON_TEXTSIZE,verbose)==-1)
- {
- dlt_log(LOG_WARNING,"dlt_message_print_ascii() failed!\n");
- }
- } /* if */
- else if (daemon_local->flags.sflag)
- {
- if (dlt_message_print_header(&(daemon_local->msg),text,DLT_DAEMON_TEXTSIZE,verbose)==-1)
- {
- dlt_log(LOG_WARNING,"dlt_message_print_header() failed!\n");
- }
- /* print message header only */
- } /* if */
-
- sent=0;
-
- /* write message to offline trace */
- if(daemon_local->flags.offlineTraceDirectory[0])
- {
- dlt_offline_trace_write(&(daemon_local->offlineTrace),daemon_local->msg.headerbuffer,daemon_local->msg.headersize,
- daemon_local->msg.databuffer,daemon_local->msg.datasize,0,0);
- sent = 1;
- }
+ if (dlt_message_read(&(daemon_local->msg), rcv_buffer, size, 0, verbose) != 0) {
+ break;
+ dlt_log(LOG_WARNING, "Can't read messages from shm\n");
+ return -1;
+ }
+
+ /* set overwrite ecu id */
+ if ((daemon_local->flags.evalue[0]) &&
+ (strncmp(daemon_local->msg.headerextra.ecu, DLT_DAEMON_ECU_ID, 4) == 0)) {
+ /* Set header extra parameters */
+ dlt_set_id(daemon_local->msg.headerextra.ecu, daemon->ecuid);
+
+ /*msg.headerextra.seid = 0; */
+ if (dlt_message_set_extraparameters(&(daemon_local->msg), 0) == -1) {
+ dlt_log(LOG_WARNING, "Can't set message extra parameters in process user message log\n");
+ dlt_shm_remove(&(daemon_local->dlt_shm));
+ return -1;
+ }
+
+ /* Correct value of timestamp, this was changed by dlt_message_set_extraparameters() */
+ daemon_local->msg.headerextra.tmsp = DLT_BETOH_32(daemon_local->msg.headerextra.tmsp);
+ }
+
+ /* prepare storage header */
+ if (DLT_IS_HTYP_WEID(daemon_local->msg.standardheader->htyp)) {
+ if (dlt_set_storageheader(daemon_local->msg.storageheader, daemon_local->msg.headerextra.ecu) == -1) {
+ dlt_log(LOG_WARNING, "Can't set storage header in process user message log\n");
+ dlt_shm_remove(&(daemon_local->dlt_shm));
+ return -1;
+ }
+ }
+ else if (dlt_set_storageheader(daemon_local->msg.storageheader, daemon->ecuid) == -1) {
+ dlt_log(LOG_WARNING, "Can't set storage header in process user message log\n");
+ dlt_shm_remove(&(daemon_local->dlt_shm));
+ return -1;
+ }
+
+ /* display message */
+ if (daemon_local->flags.xflag) {
+ if (dlt_message_print_hex(&(daemon_local->msg), text, DLT_DAEMON_TEXTSIZE, verbose) == -1)
+ dlt_log(LOG_WARNING, "dlt_message_print_hex() failed!\n");
+ } /* if */
+ else if (daemon_local->flags.aflag)
+ {
+ if (dlt_message_print_ascii(&(daemon_local->msg), text, DLT_DAEMON_TEXTSIZE, verbose) == -1)
+ dlt_log(LOG_WARNING, "dlt_message_print_ascii() failed!\n");
+ } /* if */
+ else if (daemon_local->flags.sflag)
+ {
+ if (dlt_message_print_header(&(daemon_local->msg), text, DLT_DAEMON_TEXTSIZE, verbose) == -1)
+ dlt_log(LOG_WARNING, "dlt_message_print_header() failed!\n");
+
+ /* print message header only */
+ } /* if */
+
+ sent = 0;
+
+ /* write message to offline trace */
+ if (daemon_local->flags.offlineTraceDirectory[0]) {
+ dlt_offline_trace_write(&(daemon_local->offlineTrace),
+ daemon_local->msg.headerbuffer,
+ daemon_local->msg.headersize,
+ daemon_local->msg.databuffer,
+ daemon_local->msg.datasize,
+ 0,
+ 0);
+ sent = 1;
+ }
sent = dlt_daemon_client_send_all(daemon, daemon_local, verbose);
/* Message was not sent to client, so store it in client ringbuffer */
- if (sent == 1)
- {
- if(userheader.message == DLT_USER_MESSAGE_LOG_SHM) {
+ if (sent == 1) {
+ if (userheader.message == DLT_USER_MESSAGE_LOG_SHM)
/* dlt message was sent, remove from buffer if log message from shm */
dlt_shm_remove(&(daemon_local->dlt_shm));
- }
}
- else
- {
+ else {
/* dlt message was not sent, keep in buffer */
break;
}
@@ -3098,7 +2893,7 @@ int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon,
return 0;
}
-#undef DLT_SHM_RCV_BUFFER_SIZE
+# undef DLT_SHM_RCV_BUFFER_SIZE
#endif
int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon,
@@ -3112,12 +2907,11 @@ int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon,
DltDaemonContext *context;
int i, offset_base;
int8_t old_log_level, old_trace_status;
- DltDaemonRegisteredUsers* user_list = NULL;
+ DltDaemonRegisteredUsers *user_list = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
dlt_vlog(LOG_ERR,
"Invalid function parameters used for %s\n",
__func__);
@@ -3125,42 +2919,37 @@ int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon,
}
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return DLT_RETURN_ERROR;
- }
memset(&userctxt, 0, len);
+
if (dlt_receiver_check_and_get(rec,
&userctxt,
len,
DLT_RCV_SKIP_HEADER | DLT_RCV_REMOVE) < 0)
- {
/* Not enough bytes received */
return DLT_RETURN_ERROR;
- }
- if (user_list->num_applications > 0)
- {
+ if (user_list->num_applications > 0) {
/* Get all contexts with application id matching the received application id */
application = dlt_daemon_application_find(daemon,
userctxt.apid,
daemon->ecuid,
verbose);
- if (application)
- {
+
+ if (application) {
/* Calculate start offset within contexts[] */
- offset_base=0;
+ offset_base = 0;
+
for (i = 0; i < (application - (user_list->applications)); i++)
- {
offset_base += user_list->applications[i].num_contexts;
- }
- for (i = 0; i < application->num_contexts; i++)
- {
+ for (i = 0; i < application->num_contexts; i++) {
context = &(user_list->contexts[offset_base + i]);
- if (context)
- {
+
+ if (context) {
old_log_level = context->log_level;
context->log_level = userctxt.log_level; /* No endianess conversion necessary*/
@@ -3171,8 +2960,7 @@ int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon,
if ((context->user_handle >= DLT_FD_MINIMUM) &&
(dlt_daemon_user_send_log_level(daemon,
context,
- verbose) != 0))
- {
+ verbose) != 0)) {
context->log_level = old_log_level;
context->trace_status = old_trace_status;
}
@@ -3194,21 +2982,19 @@ int dlt_daemon_process_user_message_log_mode(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon==0) || (daemon_local==0))
- {
+ if ((daemon == 0) || (daemon_local == 0)) {
dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_process_log_mode()\n");
return -1;
}
memset(&userctxt, 0, len);
+
if (dlt_receiver_check_and_get(rec,
&userctxt,
len,
DLT_RCV_SKIP_HEADER | DLT_RCV_REMOVE) < 0)
- {
/* Not enough bytes received */
return -1;
- }
/* set the new log mode */
daemon->mode = userctxt.log_mode;
@@ -3229,8 +3015,7 @@ int dlt_daemon_process_user_message_marker(DltDaemon *daemon,
DltUserControlMsgLogMode userctxt;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (rec == NULL)) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Invalid function parameters used for %s\n",
@@ -3241,17 +3026,16 @@ int dlt_daemon_process_user_message_marker(DltDaemon *daemon,
}
memset(&userctxt, 0, len);
+
if (dlt_receiver_check_and_get(rec,
&userctxt,
len,
DLT_RCV_SKIP_HEADER | DLT_RCV_REMOVE) < 0)
- {
/* Not enough bytes received */
return -1;
- }
/* Create automatic unregister context response for unregistered context */
- dlt_daemon_control_message_marker(DLT_DAEMON_SEND_TO_ALL,daemon,daemon_local,verbose);
+ dlt_daemon_control_message_marker(DLT_DAEMON_SEND_TO_ALL, daemon, daemon_local, verbose);
return 0;
}
@@ -3267,49 +3051,48 @@ int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daem
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon==0) || (daemon_local==0))
- {
+ if ((daemon == 0) || (daemon_local == 0)) {
dlt_log(LOG_ERR, "Invalid function parameters used for function dlt_daemon_send_ringbuffer_to_client()\n");
return DLT_DAEMON_ERROR_UNKNOWN;
}
- if(dlt_buffer_get_message_count(&(daemon->client_ringbuffer)) <= 0)
- {
+ if (dlt_buffer_get_message_count(&(daemon->client_ringbuffer)) <= 0) {
dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_SEND_DIRECT);
return DLT_DAEMON_ERROR_OK;
}
#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
- if(sd_notify(0, "WATCHDOG=1") < 0)
- {
+
+ if (sd_notify(0, "WATCHDOG=1") < 0)
dlt_log(LOG_WARNING, "Could not reset systemd watchdog\n");
- }
+
curr_time = dlt_uptime();
#endif
- while ( (length = dlt_buffer_copy(&(daemon->client_ringbuffer), data, sizeof(data)) ) > 0)
- {
+
+ while ((length = dlt_buffer_copy(&(daemon->client_ringbuffer), data, sizeof(data))) > 0) {
#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
- if ((dlt_uptime() - curr_time) / 10000 >= watchdog_trigger_interval)
- {
- if(sd_notify(0, "WATCHDOG=1") < 0)
- {
+
+ if ((dlt_uptime() - curr_time) / 10000 >= watchdog_trigger_interval) {
+ if (sd_notify(0, "WATCHDOG=1") < 0)
dlt_log(LOG_WARNING, "Could not reset systemd watchdog\n");
- }
+
curr_time = dlt_uptime();
}
+
#endif
- if((ret = dlt_daemon_client_send(DLT_DAEMON_SEND_FORCE,daemon,daemon_local,0,0,data,length,0,0,verbose)))
- {
+ if ((ret =
+ dlt_daemon_client_send(DLT_DAEMON_SEND_FORCE, daemon, daemon_local, 0, 0, data, length, 0, 0,
+ verbose)))
return ret;
- }
+
dlt_buffer_remove(&(daemon->client_ringbuffer));
- if(daemon->state != DLT_DAEMON_STATE_SEND_BUFFER)
- dlt_daemon_change_state(daemon,DLT_DAEMON_STATE_SEND_BUFFER);
- if(dlt_buffer_get_message_count(&(daemon->client_ringbuffer)) <= 0)
- {
- dlt_daemon_change_state(daemon,DLT_DAEMON_STATE_SEND_DIRECT);
+ if (daemon->state != DLT_DAEMON_STATE_SEND_BUFFER)
+ dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_SEND_BUFFER);
+
+ if (dlt_buffer_get_message_count(&(daemon->client_ringbuffer)) <= 0) {
+ dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_SEND_DIRECT);
return DLT_DAEMON_ERROR_OK;
}
}
@@ -3318,8 +3101,8 @@ int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daem
}
static char dlt_timer_conn_types[DLT_TIMER_UNKNOWN + 1] = {
- [DLT_TIMER_PACKET] = DLT_CONNECTION_ONE_S_TIMER,
- [DLT_TIMER_ECU] = DLT_CONNECTION_SIXTY_S_TIMER,
+ [DLT_TIMER_PACKET] = DLT_CONNECTION_ONE_S_TIMER,
+ [DLT_TIMER_ECU] = DLT_CONNECTION_SIXTY_S_TIMER,
#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
[DLT_TIMER_SYSTEMD] = DLT_CONNECTION_SYSTEMD_TIMER,
#endif
@@ -3328,8 +3111,8 @@ static char dlt_timer_conn_types[DLT_TIMER_UNKNOWN + 1] = {
};
static char dlt_timer_names[DLT_TIMER_UNKNOWN + 1][32] = {
- [DLT_TIMER_PACKET] = "Timing packet",
- [DLT_TIMER_ECU] = "ECU version",
+ [DLT_TIMER_PACKET] = "Timing packet",
+ [DLT_TIMER_ECU] = "ECU version",
#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
[DLT_TIMER_SYSTEMD] = "Systemd watchdog",
#endif
@@ -3353,17 +3136,16 @@ int create_timer_fd(DltDaemonLocal *daemon_local,
timer_name = dlt_timer_names[timer_id];
- if(daemon_local == NULL)
- {
+ if (daemon_local == NULL) {
dlt_log(DLT_LOG_ERROR, "Daemaon local structure is NULL");
return -1;
}
- if(period_sec > 0) {
+ if (period_sec > 0) {
#ifdef linux
local_fd = timerfd_create(CLOCK_MONOTONIC, 0);
- if( local_fd < 0)
- {
+
+ if (local_fd < 0) {
snprintf(str,
sizeof(str),
"<%s> timerfd_create failed: %s\n",
@@ -3377,8 +3159,7 @@ int create_timer_fd(DltDaemonLocal *daemon_local,
l_timer_spec.it_value.tv_sec = starts_in;
l_timer_spec.it_value.tv_nsec = 0;
- if( timerfd_settime(local_fd, 0, &l_timer_spec, NULL) < 0)
- {
+ if (timerfd_settime(local_fd, 0, &l_timer_spec, NULL) < 0) {
snprintf(str,
sizeof(str),
"<%s> timerfd_settime failed: %s\n",
@@ -3387,10 +3168,11 @@ int create_timer_fd(DltDaemonLocal *daemon_local,
dlt_log(LOG_WARNING, str);
local_fd = -1;
}
+
#endif
}
else {
- // timer not activated via the service file
+ /* timer not activated via the service file */
snprintf(str, sizeof(str), "<%s> not set: period=0\n", timer_name);
dlt_log(LOG_INFO, str);
local_fd = -1;
@@ -3399,8 +3181,7 @@ int create_timer_fd(DltDaemonLocal *daemon_local,
/* If fully initialized we are done.
* Event handling registration is done later on with other connections.
*/
- if(local_fd > 0)
- {
+ if (local_fd > 0) {
snprintf(str,
sizeof(str),
"<%s> initialized with %d timer\n",
@@ -3423,32 +3204,34 @@ int dlt_daemon_close_socket(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_
PRINT_FUNCTION_VERBOSE(verbose);
- if((daemon_local == NULL)|| (daemon == NULL))
- {
+ if ((daemon_local == NULL) || (daemon == NULL)) {
dlt_log(LOG_ERR, "dlt_daemon_close_socket: Invalid input parmeters\n");
return -1;
}
/* Closure is done while unregistering has for any connection */
dlt_event_handler_unregister_connection(&daemon_local->pEvent,
- daemon_local,
- sock);
+ daemon_local,
+ sock);
-
- if(daemon_local->client_connections==0)
- {
+ if (daemon_local->client_connections == 0) {
/* send new log state to all applications */
daemon->connectionState = 0;
- dlt_daemon_user_send_all_log_state(daemon,verbose);
+ dlt_daemon_user_send_all_log_state(daemon, verbose);
- // For offline tracing we still can use the same states
- // as for socket sending. Using this trick we see the traces
- // In the offline trace AND in the socket stream.
- if(daemon_local->flags.yvalue[0] == 0)
- dlt_daemon_change_state(daemon,DLT_DAEMON_STATE_BUFFER);
+ /* For offline tracing we still can use the same states */
+ /* as for socket sending. Using this trick we see the traces */
+ /* In the offline trace AND in the socket stream. */
+ if (daemon_local->flags.yvalue[0] == 0)
+ dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_BUFFER);
}
- dlt_daemon_control_message_connection_info(DLT_DAEMON_SEND_TO_ALL,daemon,daemon_local,DLT_CONNECTION_STATUS_DISCONNECTED,"",verbose);
+ dlt_daemon_control_message_connection_info(DLT_DAEMON_SEND_TO_ALL,
+ daemon,
+ daemon_local,
+ DLT_CONNECTION_STATUS_DISCONNECTED,
+ "",
+ verbose);
snprintf(local_str, DLT_DAEMON_TEXTBUFSIZE,
"Client connection #%d closed. Total Clients : %d\n",
@@ -3461,5 +3244,5 @@ int dlt_daemon_close_socket(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_
}
/**
- \}
-*/
+ \}
+ */
diff --git a/src/daemon/dlt-daemon.h b/src/daemon/dlt-daemon.h
index 3370680..c813b42 100644
--- a/src/daemon/dlt-daemon.h
+++ b/src/daemon/dlt-daemon.h
@@ -100,21 +100,21 @@ typedef struct
char yvalue[NAME_MAX + 1]; /**< (String: Devicename) Additional support for serial device */
char ivalue[NAME_MAX + 1]; /**< (String: Directory) Directory where to store the persistant configuration (Default: /tmp) */
char cvalue[NAME_MAX + 1]; /**< (String: Directory) Filename of DLT configuration file (Default: /etc/dlt.conf) */
- int sharedMemorySize; /**< (int) Size of shared memory (Default: 100000) */
- int sendMessageTime; /**< (Boolean) Send periodic Message Time if client is connected (Default: 0) */
+ int sharedMemorySize; /**< (int) Size of shared memory (Default: 100000) */
+ int sendMessageTime; /**< (Boolean) Send periodic Message Time if client is connected (Default: 0) */
char offlineTraceDirectory[DLT_DAEMON_FLAG_MAX]; /**< (String: Directory) Store DLT messages to local directory (Default: /etc/dlt.conf) */
- int offlineTraceFileSize; /**< (int) Maximum size in bytes of one trace file (Default: 1000000) */
- int offlineTraceMaxSize; /**< (int) Maximum size of all trace files (Default: 4000000) */
- int offlineTraceFilenameTimestampBased; /**< (int) timestamp based or index based (Default: 1 Timestamp based) */
- int loggingMode; /**< (int) The logging console for internal logging of dlt-daemon (Default: 0) */
- int loggingLevel; /**< (int) The logging level for internal logging of dlt-daemon (Default: 6) */
+ int offlineTraceFileSize; /**< (int) Maximum size in bytes of one trace file (Default: 1000000) */
+ int offlineTraceMaxSize; /**< (int) Maximum size of all trace files (Default: 4000000) */
+ int offlineTraceFilenameTimestampBased; /**< (int) timestamp based or index based (Default: 1 Timestamp based) */
+ int loggingMode; /**< (int) The logging console for internal logging of dlt-daemon (Default: 0) */
+ int loggingLevel; /**< (int) The logging level for internal logging of dlt-daemon (Default: 6) */
char loggingFilename[DLT_DAEMON_FLAG_MAX]; /**< (String: Filename) The logging filename if internal logging mode is log to file (Default: /tmp/log) */
- int sendECUSoftwareVersion; /**< (Boolean) Send ECU software version perdiodically */
+ int sendECUSoftwareVersion; /**< (Boolean) Send ECU software version perdiodically */
char pathToECUSoftwareVersion[DLT_DAEMON_FLAG_MAX]; /**< (String: Filename) The file from which to read the ECU version from. */
- int sendTimezone; /**< (Boolean) Send Timezone perdiodically */
- int offlineLogstorageMaxDevices; /**< (int) Maximum devices to be used as offline logstorage devices */
+ int sendTimezone; /**< (Boolean) Send Timezone perdiodically */
+ int offlineLogstorageMaxDevices; /**< (int) Maximum devices to be used as offline logstorage devices */
char offlineLogstorageDirPath[DLT_MOUNT_PATH_MAX]; /**< (String: Directory) DIR path to store offline logs */
- int offlineLogstorageTimestamp; /**< (int) Append timestamp in offline logstorage filename */
+ int offlineLogstorageTimestamp; /**< (int) Append timestamp in offline logstorage filename */
char offlineLogstorageDelimiter; /**< (char) Append delimeter character in offline logstorage filename */
unsigned int offlineLogstorageMaxCounter; /**< (int) Maximum offline logstorage file counter index until wraparound */
unsigned int offlineLogstorageMaxCounterIdx; /**< (int) String len of offlineLogstorageMaxCounter*/
@@ -125,14 +125,14 @@ typedef struct
char userPipesDir[NAME_MAX + 1]; /**< (String: Directory) directory where dltpipes reside (Default: /tmp/dltpipes) */
#endif
char daemonFifoName[NAME_MAX + 1]; /**< (String: Filename) name of local fifo (Default: /tmp/dlt) */
- unsigned int port; /**< port number */
+ unsigned int port; /**< port number */
char ctrlSockPath[DLT_DAEMON_FLAG_MAX]; /**< Path to Control socket */
int gatewayMode; /**< (Boolean) Gateway Mode */
char gatewayConfigFile[DLT_DAEMON_FLAG_MAX]; /**< Gateway config file path */
- int autoResponseGetLogInfoOption; /**< (int) The Option of automatic get log info response during context registration. (Default: 7)*/
- int contextLogLevel; /**< (int) log level sent to context if registered with default log-level or if enforced*/
- int contextTraceStatus; /**< (int) trace status sent to context if registered with default trace status or if enforced*/
- int enforceContextLLAndTS; /**< (Boolean) Enforce log-level, trace-status not to exceed contextLogLevel, contextTraceStatus */
+ int autoResponseGetLogInfoOption; /**< (int) The Option of automatic get log info response during context registration. (Default: 7)*/
+ int contextLogLevel; /**< (int) log level sent to context if registered with default log-level or if enforced*/
+ int contextTraceStatus; /**< (int) trace status sent to context if registered with default trace status or if enforced*/
+ int enforceContextLLAndTS; /**< (Boolean) Enforce log-level, trace-status not to exceed contextLogLevel, contextTraceStatus */
} DltDaemonFlags;
/**
* The global parameters of a dlt daemon.
@@ -189,7 +189,10 @@ void dlt_daemon_exit_trigger();
void dlt_daemon_signal_handler(int sig);
int dlt_daemon_process_client_connect(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
int dlt_daemon_process_client_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *revc, int verbose);
-int dlt_daemon_process_client_messages_serial(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
+int dlt_daemon_process_client_messages_serial(DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *recv,
+ int verbose);
int dlt_daemon_process_user_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
int dlt_daemon_process_one_s_timer(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
int dlt_daemon_process_sixty_s_timer(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
@@ -199,28 +202,54 @@ int dlt_daemon_process_control_connect(DltDaemon *daemon, DltDaemonLocal *daemon
#ifdef DLT_USE_UNIX_SOCKET_IPC
int dlt_daemon_process_app_connect(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
#endif
-int dlt_daemon_process_control_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
+int dlt_daemon_process_control_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv,
+ int verbose);
-typedef int (*dlt_daemon_process_user_message_func)(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
+typedef int (*dlt_daemon_process_user_message_func)(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec,
+ int verbose);
-int dlt_daemon_process_user_message_overflow(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
+int dlt_daemon_process_user_message_overflow(DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *rec,
+ int verbose);
int dlt_daemon_send_message_overflow(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
-int dlt_daemon_process_user_message_register_application(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
-int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
-int dlt_daemon_process_user_message_register_context(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
-int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
+int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *rec,
+ int verbose);
+int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *rec,
+ int verbose);
+int dlt_daemon_process_user_message_register_context(DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *rec,
+ int verbose);
+int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *rec,
+ int verbose);
int dlt_daemon_process_user_message_log(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
#ifdef DLT_SHM_ENABLE
-int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
+int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *rec,
+ int verbose);
#endif
-int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
-int dlt_daemon_process_user_message_marker(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
+int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *rec,
+ int verbose);
+int dlt_daemon_process_user_message_marker(DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltReceiver *rec,
+ int verbose);
int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
void dlt_daemon_timingpacket_thread(void *ptr);
void dlt_daemon_ecu_version_thread(void *ptr);
#if defined(DLT_SYSTEMD_WATCHDOG_ENABLE)
- void dlt_daemon_systemd_watchdog_thread(void *ptr);
+void dlt_daemon_systemd_watchdog_thread(void *ptr);
#endif
int create_timer_fd(DltDaemonLocal *daemon_local, int period_sec, int starts_in, DltTimers timer);
diff --git a/src/daemon/dlt_daemon_client.c b/src/daemon/dlt_daemon_client.c
index 55b775b..55afd7c 100644
--- a/src/daemon/dlt_daemon_client.c
+++ b/src/daemon/dlt_daemon_client.c
@@ -25,7 +25,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt_daemon_client.c
-*/
+ */
#include <netdb.h>
#include <ctype.h>
@@ -42,16 +42,16 @@
#include <pthread.h>
#ifdef linux
-#include <sys/timerfd.h>
+# include <sys/timerfd.h>
#endif
#include <sys/stat.h>
#include <sys/time.h>
#if defined(linux) && defined(__NR_statx)
-#include <linux/stat.h>
+# include <linux/stat.h>
#endif
#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
-#include <systemd/sd-daemon.h>
+# include <systemd/sd-daemon.h>
#endif
#include "dlt_types.h"
@@ -79,10 +79,10 @@ static char str[DLT_DAEMON_TEXTBUFSIZE];
* @param context_log The default log level (or) trace status
*
* @return The log level if requested log level is lower or equal to ContextLogLevel
-*/
+ */
static inline int8_t getStatus(uint8_t request_log, int context_log)
{
- return (request_log <= context_log)? request_log : context_log;
+ return (request_log <= context_log) ? request_log : context_log;
}
/** @brief Sends up to 2 messages to all the clients.
@@ -103,9 +103,9 @@ static inline int8_t getStatus(uint8_t request_log, int context_log)
*/
static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon,
DltDaemonLocal *daemon_local,
- void* data1,
+ void *data1,
int size1,
- void* data2,
+ void *data2,
int size2,
int verbose)
{
@@ -115,8 +115,7 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon,
(DLT_CON_MASK_CLIENT_MSG_TCP | DLT_CON_MASK_CLIENT_MSG_SERIAL);
uint8_t *tmp_buffer = NULL;
- if ((daemon == NULL) || (daemon_local == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL)) {
dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
return 0;
}
@@ -128,50 +127,48 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon,
* can be affect between each iteration, but
* dlt_daemon_close_socket may call us too ...
*/
- for (j = 0; ((j < daemon_local->client_connections) && (temp != NULL)); j++)
- {
+ for (j = 0; ((j < daemon_local->client_connections) && (temp != NULL)); j++) {
int ret = 0;
DLT_DAEMON_SEM_LOCK();
DltConnection *next = dlt_connection_get_next(temp->next, type_mask);
ret = dlt_connection_send_multiple(temp,
- data1,
- size1,
- data2,
- size2,
- daemon->sendserialheader);
+ data1,
+ size1,
+ data2,
+ size2,
+ daemon->sendserialheader);
DLT_DAEMON_SEM_FREE();
if ((ret != DLT_DAEMON_ERROR_OK) &&
- (DLT_CONNECTION_CLIENT_MSG_TCP == temp->type))
- {
- if (daemon->state != DLT_DAEMON_STATE_BUFFER_FULL)
- {
- if (temp->receiver->bytes_sent < (size1 + size2))
- {
- tmp_buffer = (uint8_t*)calloc(size1 + size2, sizeof(uint8_t));
-
- if (tmp_buffer == NULL)
- {
+ (DLT_CONNECTION_CLIENT_MSG_TCP == temp->type)) {
+ if (daemon->state != DLT_DAEMON_STATE_BUFFER_FULL) {
+ if (temp->receiver->bytes_sent < (size1 + size2)) {
+ tmp_buffer = (uint8_t *)calloc(size1 + size2, sizeof(uint8_t));
+
+ if (tmp_buffer == NULL) {
dlt_vlog(LOG_ERR, "%s: Memory allocation failed.\n", __func__);
return 0;
}
+
memcpy(tmp_buffer, data1, size1);
memcpy(tmp_buffer + size1, data2, size2);
DLT_DAEMON_SEM_LOCK();
+
/* Store message in history buffer */
if (dlt_buffer_push3(&(daemon->client_ringbuffer),
tmp_buffer + temp->receiver->bytes_sent,
(size1 + size2 - temp->receiver->bytes_sent),
- 0, 0, 0, 0) < DLT_RETURN_OK)
- {
+ 0, 0, 0, 0) < DLT_RETURN_OK) {
dlt_vlog(LOG_DEBUG, "%s: Buffer is full! Message discarded.\n", __func__);
dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_BUFFER_FULL);
}
+
free(tmp_buffer);
DLT_DAEMON_SEM_FREE();
}
}
+
dlt_daemon_close_socket(temp->receiver->fd,
daemon,
daemon_local,
@@ -179,16 +176,12 @@ static int dlt_daemon_client_send_all_multiple(DltDaemon *daemon,
}
if (ret != DLT_DAEMON_ERROR_OK)
- {
dlt_vlog(LOG_WARNING, "%s: send dlt message failed\n", __func__);
- }
else
- {
/* If sent to at least one client,
* then do not store in ring buffer
*/
sent = 1;
- }
temp = next;
} /* for */
@@ -213,8 +206,7 @@ int dlt_daemon_client_send_all(DltDaemon *daemon,
int ret = 0;
char local_str[DLT_DAEMON_TEXTBUFSIZE];
- if ((daemon == NULL) || (daemon_local == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL)) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"%s: Invalid parameters\n",
@@ -234,77 +226,81 @@ int dlt_daemon_client_send_all(DltDaemon *daemon,
DLT_DAEMON_SEM_FREE();
ret = dlt_daemon_client_send_all_multiple(daemon,
- daemon_local,
- msg1,
- msg1_sz,
- msg2,
- msg2_sz,
- verbose);
+ daemon_local,
+ msg1,
+ msg1_sz,
+ msg2,
+ msg2_sz,
+ verbose);
return ret;
}
-int dlt_daemon_client_send(int sock,DltDaemon *daemon,DltDaemonLocal *daemon_local,void* storage_header,int storage_header_size,void* data1,int size1,void* data2,int size2,int verbose)
+int dlt_daemon_client_send(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ void *storage_header,
+ int storage_header_size,
+ void *data1,
+ int size1,
+ void *data2,
+ int size2,
+ int verbose)
{
- int sent,ret;
+ int sent, ret;
- if (sock!=DLT_DAEMON_SEND_TO_ALL && sock!=DLT_DAEMON_SEND_FORCE)
- {
+ if ((sock != DLT_DAEMON_SEND_TO_ALL) && (sock != DLT_DAEMON_SEND_FORCE)) {
/* Send message to specific socket */
- if (isatty(sock))
- {
+ if (isatty(sock)) {
DLT_DAEMON_SEM_LOCK();
- if((ret=dlt_daemon_serial_send(sock,data1,size1,data2,size2,daemon->sendserialheader)))
- {
+ if ((ret = dlt_daemon_serial_send(sock, data1, size1, data2, size2, daemon->sendserialheader))) {
DLT_DAEMON_SEM_FREE();
- dlt_log(LOG_WARNING,"dlt_daemon_client_send: serial send dlt message failed\n");
+ dlt_log(LOG_WARNING, "dlt_daemon_client_send: serial send dlt message failed\n");
return ret;
- }
+ }
DLT_DAEMON_SEM_FREE();
}
- else
- {
+ else {
DLT_DAEMON_SEM_LOCK();
- if((ret=dlt_daemon_socket_send(sock,data1,size1,data2,size2,daemon->sendserialheader)))
- {
+ if ((ret = dlt_daemon_socket_send(sock, data1, size1, data2, size2, daemon->sendserialheader))) {
DLT_DAEMON_SEM_FREE();
- dlt_log(LOG_WARNING,"dlt_daemon_client_send: socket send dlt message failed\n");
+ dlt_log(LOG_WARNING, "dlt_daemon_client_send: socket send dlt message failed\n");
return ret;
}
DLT_DAEMON_SEM_FREE();
}
+
return DLT_DAEMON_ERROR_OK;
}
- /* write message to offline trace */
- // In the SEND_BUFFER state we must skip offline tracing because the offline traces
- // are going without buffering directly to the offline trace. Thus we have to filter out
- // the traces that are coming from the buffer.
- if ((sock!=DLT_DAEMON_SEND_FORCE) && (daemon->state != DLT_DAEMON_STATE_SEND_BUFFER))
- {
- if(((daemon->mode == DLT_USER_MODE_INTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH))
- && daemon_local->flags.offlineTraceDirectory[0])
- {
- if(dlt_offline_trace_write(&(daemon_local->offlineTrace),storage_header,storage_header_size,data1,size1,data2,size2))
- {
- static int error_dlt_offline_trace_write_failed = 0;
- if(!error_dlt_offline_trace_write_failed)
- {
- dlt_log(LOG_ERR,"dlt_daemon_client_send: dlt_offline_trace_write failed!\n");
- error_dlt_offline_trace_write_failed = 1;
+ /* write message to offline trace */
+ /* In the SEND_BUFFER state we must skip offline tracing because the offline traces */
+ /* are going without buffering directly to the offline trace. Thus we have to filter out */
+ /* the traces that are coming from the buffer. */
+ if ((sock != DLT_DAEMON_SEND_FORCE) && (daemon->state != DLT_DAEMON_STATE_SEND_BUFFER)) {
+ if (((daemon->mode == DLT_USER_MODE_INTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH))
+ && daemon_local->flags.offlineTraceDirectory[0]) {
+ if (dlt_offline_trace_write(&(daemon_local->offlineTrace), storage_header, storage_header_size, data1,
+ size1, data2, size2)) {
+ static int error_dlt_offline_trace_write_failed = 0;
+
+ if (!error_dlt_offline_trace_write_failed) {
+ dlt_log(LOG_ERR, "dlt_daemon_client_send: dlt_offline_trace_write failed!\n");
+ error_dlt_offline_trace_write_failed = 1;
}
- //return DLT_DAEMON_ERROR_WRITE_FAILED;
- }
- }
+
+ /*return DLT_DAEMON_ERROR_WRITE_FAILED; */
+ }
+ }
+
/* write messages to offline logstorage only if there is an extended header set
* this need to be checked because the function is dlt_daemon_client_send is called by
* newly introduced dlt_daemon_log_internal */
- if(daemon_local->flags.offlineLogstorageMaxDevices > 0)
- {
+ if (daemon_local->flags.offlineLogstorageMaxDevices > 0)
dlt_daemon_logstorage_write(daemon,
&daemon_local->flags,
storage_header,
@@ -313,14 +309,11 @@ int dlt_daemon_client_send(int sock,DltDaemon *daemon,DltDaemonLocal *daemon_loc
size1,
data2,
size2);
- }
- }
+ }
- /* send messages to daemon socket */
- if((daemon->mode == DLT_USER_MODE_EXTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH))
- {
- if ((sock==DLT_DAEMON_SEND_FORCE) || (daemon->state == DLT_DAEMON_STATE_SEND_DIRECT))
- {
+ /* send messages to daemon socket */
+ if ((daemon->mode == DLT_USER_MODE_EXTERNAL) || (daemon->mode == DLT_USER_MODE_BOTH)) {
+ if ((sock == DLT_DAEMON_SEND_FORCE) || (daemon->state == DLT_DAEMON_STATE_SEND_DIRECT)) {
sent = dlt_daemon_client_send_all_multiple(daemon,
daemon_local,
data1,
@@ -329,28 +322,28 @@ int dlt_daemon_client_send(int sock,DltDaemon *daemon,DltDaemonLocal *daemon_loc
size2,
verbose);
- if((sock==DLT_DAEMON_SEND_FORCE) && !sent)
- {
- return DLT_DAEMON_ERROR_SEND_FAILED;
- }
- }
+ if ((sock == DLT_DAEMON_SEND_FORCE) && !sent)
+ return DLT_DAEMON_ERROR_SEND_FAILED;
+ }
}
/* Message was not sent to client, so store it in client ringbuffer */
- if ((sock!=DLT_DAEMON_SEND_FORCE) && (daemon->state == DLT_DAEMON_STATE_BUFFER || daemon->state == DLT_DAEMON_STATE_SEND_BUFFER || daemon->state == DLT_DAEMON_STATE_BUFFER_FULL))
- {
- if(daemon->state == DLT_DAEMON_STATE_BUFFER_FULL)
- return DLT_DAEMON_ERROR_BUFFER_FULL;
+ if ((sock != DLT_DAEMON_SEND_FORCE) &&
+ ((daemon->state == DLT_DAEMON_STATE_BUFFER) || (daemon->state == DLT_DAEMON_STATE_SEND_BUFFER) ||
+ (daemon->state == DLT_DAEMON_STATE_BUFFER_FULL))) {
+ if (daemon->state == DLT_DAEMON_STATE_BUFFER_FULL)
+ return DLT_DAEMON_ERROR_BUFFER_FULL;
DLT_DAEMON_SEM_LOCK();
+
/* Store message in history buffer */
- if (dlt_buffer_push3(&(daemon->client_ringbuffer),data1,size1,data2,size2,0, 0) < DLT_RETURN_OK)
- {
- DLT_DAEMON_SEM_FREE();
- dlt_log(LOG_DEBUG,"dlt_daemon_client_send: Buffer is full! Message discarded.\n");
- dlt_daemon_change_state(daemon,DLT_DAEMON_STATE_BUFFER_FULL);
- return DLT_DAEMON_ERROR_BUFFER_FULL;
- }
+ if (dlt_buffer_push3(&(daemon->client_ringbuffer), data1, size1, data2, size2, 0, 0) < DLT_RETURN_OK) {
+ DLT_DAEMON_SEM_FREE();
+ dlt_log(LOG_DEBUG, "dlt_daemon_client_send: Buffer is full! Message discarded.\n");
+ dlt_daemon_change_state(daemon, DLT_DAEMON_STATE_BUFFER_FULL);
+ return DLT_DAEMON_ERROR_BUFFER_FULL;
+ }
+
DLT_DAEMON_SEM_FREE();
}
@@ -358,136 +351,133 @@ int dlt_daemon_client_send(int sock,DltDaemon *daemon,DltDaemonLocal *daemon_loc
}
-int dlt_daemon_client_send_control_message( int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, char* appid, char* ctid, int verbose)
+int dlt_daemon_client_send_control_message(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ char *appid,
+ char *ctid,
+ int verbose)
{
- int ret;
+ int ret;
int32_t len;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon==0) || (msg==0) || (appid==0) || (ctid==0))
- {
+ if ((daemon == 0) || (msg == 0) || (appid == 0) || (ctid == 0))
return DLT_DAEMON_ERROR_UNKNOWN;
- }
/* prepare storage header */
- msg->storageheader = (DltStorageHeader*)msg->headerbuffer;
+ msg->storageheader = (DltStorageHeader *)msg->headerbuffer;
- if (dlt_set_storageheader(msg->storageheader,daemon->ecuid) == DLT_RETURN_ERROR)
- {
- return DLT_DAEMON_ERROR_UNKNOWN;
- }
+ if (dlt_set_storageheader(msg->storageheader, daemon->ecuid) == DLT_RETURN_ERROR)
+ return DLT_DAEMON_ERROR_UNKNOWN;
/* prepare standard header */
- msg->standardheader = (DltStandardHeader*)(msg->headerbuffer + sizeof(DltStorageHeader));
- msg->standardheader->htyp = DLT_HTYP_WEID | DLT_HTYP_WTMS | DLT_HTYP_UEH | DLT_HTYP_PROTOCOL_VERSION1 ;
+ msg->standardheader = (DltStandardHeader *)(msg->headerbuffer + sizeof(DltStorageHeader));
+ msg->standardheader->htyp = DLT_HTYP_WEID | DLT_HTYP_WTMS | DLT_HTYP_UEH | DLT_HTYP_PROTOCOL_VERSION1;
-#if (BYTE_ORDER==BIG_ENDIAN)
- msg->standardheader->htyp = ( msg->standardheader->htyp | DLT_HTYP_MSBF);
+#if (BYTE_ORDER == BIG_ENDIAN)
+ msg->standardheader->htyp = (msg->standardheader->htyp | DLT_HTYP_MSBF);
#endif
msg->standardheader->mcnt = 0;
/* Set header extra parameters */
- dlt_set_id(msg->headerextra.ecu,daemon->ecuid);
+ dlt_set_id(msg->headerextra.ecu, daemon->ecuid);
- //msg->headerextra.seid = 0;
+ /*msg->headerextra.seid = 0; */
msg->headerextra.tmsp = dlt_uptime();
dlt_message_set_extraparameters(msg, verbose);
/* prepare extended header */
- msg->extendedheader = (DltExtendedHeader*)(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp));
+ msg->extendedheader =
+ (DltExtendedHeader *)(msg->headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+ DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp));
msg->extendedheader->msin = DLT_MSIN_CONTROL_RESPONSE;
msg->extendedheader->noar = 1; /* number of arguments */
- if (strcmp(appid,"")==0)
- {
- dlt_set_id(msg->extendedheader->apid,DLT_DAEMON_CTRL_APID); /* application id */
- }
+
+ if (strcmp(appid, "") == 0)
+ dlt_set_id(msg->extendedheader->apid, DLT_DAEMON_CTRL_APID); /* application id */
else
- {
dlt_set_id(msg->extendedheader->apid, appid);
- }
- if (strcmp(ctid,"")==0)
- {
- dlt_set_id(msg->extendedheader->ctid,DLT_DAEMON_CTRL_CTID); /* context id */
- }
+
+ if (strcmp(ctid, "") == 0)
+ dlt_set_id(msg->extendedheader->ctid, DLT_DAEMON_CTRL_CTID); /* context id */
else
- {
dlt_set_id(msg->extendedheader->ctid, ctid);
- }
/* prepare length information */
- msg->headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) + DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp);
+ msg->headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) +
+ DLT_STANDARD_HEADER_EXTRA_SIZE(msg->standardheader->htyp);
- len=msg->headersize - sizeof(DltStorageHeader) + msg->datasize;
- if (len>UINT16_MAX)
- {
- dlt_log(LOG_WARNING,"Huge control message discarded!\n");
+ len = msg->headersize - sizeof(DltStorageHeader) + msg->datasize;
+
+ if (len > UINT16_MAX) {
+ dlt_log(LOG_WARNING, "Huge control message discarded!\n");
return DLT_DAEMON_ERROR_UNKNOWN;
}
msg->standardheader->len = DLT_HTOBE_16(((uint16_t)len));
- if((ret=dlt_daemon_client_send(sock,daemon,daemon_local,msg->headerbuffer,sizeof(DltStorageHeader),msg->headerbuffer+sizeof(DltStorageHeader),msg->headersize-sizeof(DltStorageHeader),
- msg->databuffer,msg->datasize,verbose)))
- {
- dlt_log(LOG_DEBUG,"dlt_daemon_control_send_control_message: DLT message send to all failed!.\n");
- return ret;
- }
+ if ((ret =
+ dlt_daemon_client_send(sock, daemon, daemon_local, msg->headerbuffer, sizeof(DltStorageHeader),
+ msg->headerbuffer + sizeof(DltStorageHeader),
+ msg->headersize - sizeof(DltStorageHeader),
+ msg->databuffer, msg->datasize, verbose))) {
+ dlt_log(LOG_DEBUG, "dlt_daemon_control_send_control_message: DLT message send to all failed!.\n");
+ return ret;
+ }
return DLT_DAEMON_ERROR_OK;
}
-int dlt_daemon_client_process_control(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose)
+int dlt_daemon_client_process_control(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose)
{
- uint32_t id,id_tmp=0;
+ uint32_t id, id_tmp = 0;
DltStandardHeaderExtra extra;
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon == NULL || daemon_local == NULL|| msg == NULL)
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (msg == NULL))
return -1;
- }
if (msg->datasize < (int32_t)sizeof(uint32_t))
- {
return -1;
- }
extra = msg->headerextra;
/* check if the message needs to be forwarded */
- if (daemon_local->flags.gatewayMode == 1)
- {
+ if (daemon_local->flags.gatewayMode == 1) {
if (strcmp(daemon_local->flags.evalue, extra.ecu) != 0)
- {
return dlt_gateway_forward_control_message(&daemon_local->pGateway,
daemon_local,
msg,
extra.ecu,
verbose);
- }
}
- id_tmp = *((uint32_t*)(msg->databuffer));
- id=DLT_ENDIAN_GET_32(msg->standardheader->htyp ,id_tmp);
- if ((id > 0) && (id < DLT_SERVICE_ID_CALLSW_CINJECTION))
- {
+ id_tmp = *((uint32_t *)(msg->databuffer));
+ id = DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp);
+
+ if ((id > 0) && (id < DLT_SERVICE_ID_CALLSW_CINJECTION)) {
/* Control message handling */
- switch (id)
- {
+ switch (id) {
case DLT_SERVICE_ID_SET_LOG_LEVEL:
{
- dlt_daemon_control_set_log_level(sock, daemon, daemon_local, msg, verbose);
+ dlt_daemon_control_set_log_level(sock, daemon, daemon_local, msg, verbose);
break;
}
case DLT_SERVICE_ID_SET_TRACE_STATUS:
{
- dlt_daemon_control_set_trace_status(sock, daemon, daemon_local, msg, verbose);
+ dlt_daemon_control_set_trace_status(sock, daemon, daemon_local, msg, verbose);
break;
}
case DLT_SERVICE_ID_GET_LOG_INFO:
@@ -502,100 +492,157 @@ int dlt_daemon_client_process_control(int sock, DltDaemon *daemon, DltDaemonLoca
}
case DLT_SERVICE_ID_STORE_CONFIG:
{
- if (dlt_daemon_applications_save(daemon, daemon->runtime_application_cfg, verbose)==0)
- {
- if (dlt_daemon_contexts_save(daemon, daemon->runtime_context_cfg, verbose)==0)
- {
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+ if (dlt_daemon_applications_save(daemon, daemon->runtime_application_cfg, verbose) == 0) {
+ if (dlt_daemon_contexts_save(daemon, daemon->runtime_context_cfg, verbose) == 0) {
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK,
+ verbose);
}
- else
- {
+ else {
/* Delete saved files */
- dlt_daemon_control_reset_to_factory_default(daemon, daemon->runtime_application_cfg, daemon->runtime_context_cfg, daemon_local->flags.contextLogLevel, daemon_local->flags.contextTraceStatus, daemon_local->flags.enforceContextLLAndTS, verbose);
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ dlt_daemon_control_reset_to_factory_default(daemon,
+ daemon->runtime_application_cfg,
+ daemon->runtime_context_cfg,
+ daemon_local->flags.contextLogLevel,
+ daemon_local->flags.contextTraceStatus,
+ daemon_local->flags.enforceContextLLAndTS,
+ verbose);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ id,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
}
}
- else
- {
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ else {
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
}
+
break;
}
case DLT_SERVICE_ID_RESET_TO_FACTORY_DEFAULT:
{
- dlt_daemon_control_reset_to_factory_default(daemon, daemon->runtime_application_cfg, daemon->runtime_context_cfg, daemon_local->flags.contextLogLevel, daemon_local->flags.contextTraceStatus, daemon_local->flags.enforceContextLLAndTS, verbose);
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+ dlt_daemon_control_reset_to_factory_default(daemon,
+ daemon->runtime_application_cfg,
+ daemon->runtime_context_cfg,
+ daemon_local->flags.contextLogLevel,
+ daemon_local->flags.contextTraceStatus,
+ daemon_local->flags.enforceContextLLAndTS,
+ verbose);
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
break;
}
case DLT_SERVICE_ID_SET_COM_INTERFACE_STATUS:
{
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED, verbose);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ id,
+ DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+ verbose);
break;
}
case DLT_SERVICE_ID_SET_COM_INTERFACE_MAX_BANDWIDTH:
{
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED, verbose);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ id,
+ DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+ verbose);
break;
}
case DLT_SERVICE_ID_SET_VERBOSE_MODE:
{
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED, verbose);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ id,
+ DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+ verbose);
break;
}
case DLT_SERVICE_ID_SET_MESSAGE_FILTERING:
{
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED, verbose);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ id,
+ DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+ verbose);
break;
}
case DLT_SERVICE_ID_SET_TIMING_PACKETS:
{
- dlt_daemon_control_set_timing_packets(sock, daemon, daemon_local, msg, verbose);
+ dlt_daemon_control_set_timing_packets(sock, daemon, daemon_local, msg, verbose);
break;
}
case DLT_SERVICE_ID_GET_LOCAL_TIME:
{
/* Send response with valid timestamp (TMSP) field */
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
break;
}
case DLT_SERVICE_ID_USE_ECU_ID:
{
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED, verbose);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ id,
+ DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+ verbose);
break;
}
case DLT_SERVICE_ID_USE_SESSION_ID:
{
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED, verbose);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ id,
+ DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+ verbose);
break;
}
case DLT_SERVICE_ID_USE_TIMESTAMP:
{
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED, verbose);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ id,
+ DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+ verbose);
break;
}
case DLT_SERVICE_ID_USE_EXTENDED_HEADER:
{
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED, verbose);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ id,
+ DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+ verbose);
break;
}
case DLT_SERVICE_ID_SET_DEFAULT_LOG_LEVEL:
{
- dlt_daemon_control_set_default_log_level(sock, daemon, daemon_local, msg, verbose);
+ dlt_daemon_control_set_default_log_level(sock, daemon, daemon_local, msg, verbose);
break;
}
case DLT_SERVICE_ID_SET_DEFAULT_TRACE_STATUS:
{
- dlt_daemon_control_set_default_trace_status(sock, daemon, daemon_local, msg, verbose);
+ dlt_daemon_control_set_default_trace_status(sock, daemon, daemon_local, msg, verbose);
break;
}
case DLT_SERVICE_ID_GET_SOFTWARE_VERSION:
{
- dlt_daemon_control_get_software_version(sock, daemon, daemon_local, verbose);
+ dlt_daemon_control_get_software_version(sock, daemon, daemon_local, verbose);
break;
}
case DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW:
{
- dlt_daemon_control_message_buffer_overflow(sock, daemon, daemon_local, daemon->overflow_counter,"",verbose);
+ dlt_daemon_control_message_buffer_overflow(sock, daemon, daemon_local, daemon->overflow_counter, "",
+ verbose);
break;
}
case DLT_SERVICE_ID_SET_ALL_LOG_LEVEL:
@@ -625,22 +672,26 @@ int dlt_daemon_client_process_control(int sock, DltDaemon *daemon, DltDaemonLoca
case DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS:
{
dlt_daemon_control_passive_node_connect_status(sock,
- daemon,
- daemon_local,
- verbose);
+ daemon,
+ daemon_local,
+ verbose);
break;
}
default:
{
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED, verbose);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ id,
+ DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+ verbose);
break;
}
}
}
- else
- {
+ else {
/* Injection handling */
- dlt_daemon_control_callsw_cinjection(sock, daemon, daemon_local, msg, verbose);
+ dlt_daemon_control_callsw_cinjection(sock, daemon, daemon_local, msg, verbose);
}
return 0;
@@ -650,194 +701,213 @@ void dlt_daemon_control_get_software_version(int sock, DltDaemon *daemon, DltDae
{
DltMessage msg;
uint32_t len;
- DltServiceGetSoftwareVersionResponse *resp;
+ DltServiceGetSoftwareVersionResponse *resp;
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon==0)
- {
+ if (daemon == 0)
return;
- }
/* initialise new message */
- if (dlt_message_init(&msg,0) == DLT_RETURN_ERROR)
- {
- dlt_daemon_control_service_response(sock, daemon,daemon_local, DLT_SERVICE_ID_GET_SOFTWARE_VERSION, DLT_SERVICE_RESPONSE_ERROR, verbose);
- return;
+ if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR) {
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_GET_SOFTWARE_VERSION,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
+ return;
}
/* prepare payload of data */
len = strlen(daemon->ECUVersionString);
msg.datasize = sizeof(DltServiceGetSoftwareVersionResponse) + len;
- if (msg.databuffer && (msg.databuffersize < msg.datasize))
- {
+
+ if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
free(msg.databuffer);
- msg.databuffer=0;
+ msg.databuffer = 0;
}
- if (msg.databuffer == 0){
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
- msg.databuffersize = msg.datasize;
+
+ if (msg.databuffer == 0) {
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
+ msg.databuffersize = msg.datasize;
}
- if (msg.databuffer==0)
- {
- dlt_daemon_control_service_response(sock, daemon,daemon_local, DLT_SERVICE_ID_GET_SOFTWARE_VERSION, DLT_SERVICE_RESPONSE_ERROR, verbose);
+
+ if (msg.databuffer == 0) {
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_GET_SOFTWARE_VERSION,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
return;
}
- resp = (DltServiceGetSoftwareVersionResponse*) msg.databuffer;
+ resp = (DltServiceGetSoftwareVersionResponse *)msg.databuffer;
resp->service_id = DLT_SERVICE_ID_GET_SOFTWARE_VERSION;
resp->status = DLT_SERVICE_RESPONSE_OK;
resp->length = len;
- memcpy(msg.databuffer+sizeof(DltServiceGetSoftwareVersionResponse),daemon->ECUVersionString,len);
+ memcpy(msg.databuffer + sizeof(DltServiceGetSoftwareVersionResponse), daemon->ECUVersionString, len);
/* send message */
- dlt_daemon_client_send_control_message(sock, daemon,daemon_local, &msg,"","", verbose);
+ dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose);
/* free message */
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
}
void dlt_daemon_control_get_default_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
{
DltMessage msg;
- DltServiceGetDefaultLogLevelResponse *resp;
+ DltServiceGetDefaultLogLevelResponse *resp;
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon==0)
- {
+ if (daemon == 0)
return;
- }
/* initialise new message */
- if (dlt_message_init(&msg,0) == DLT_RETURN_ERROR)
- {
- dlt_daemon_control_service_response(sock, daemon,daemon_local, DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR) {
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
return;
}
msg.datasize = sizeof(DltServiceGetDefaultLogLevelResponse);
- if (msg.databuffer && (msg.databuffersize<msg.datasize))
- {
+
+ if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
free(msg.databuffer);
- msg.databuffer=0;
+ msg.databuffer = 0;
}
- if (msg.databuffer == 0){
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
- msg.databuffersize = msg.datasize;
+
+ if (msg.databuffer == 0) {
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
+ msg.databuffersize = msg.datasize;
}
- if (msg.databuffer==0)
- {
- dlt_daemon_control_service_response(sock, daemon,daemon_local, DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL, DLT_SERVICE_RESPONSE_ERROR, verbose);
+
+ if (msg.databuffer == 0) {
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
return;
}
- resp = (DltServiceGetDefaultLogLevelResponse*) msg.databuffer;
+ resp = (DltServiceGetDefaultLogLevelResponse *)msg.databuffer;
resp->service_id = DLT_SERVICE_ID_GET_DEFAULT_LOG_LEVEL;
resp->status = DLT_SERVICE_RESPONSE_OK;
resp->log_level = daemon->default_log_level;
/* send message */
- dlt_daemon_client_send_control_message(sock,daemon,daemon_local,&msg,"","", verbose);
+ dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose);
/* free message */
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
}
-void dlt_daemon_control_get_log_info(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose)
+void dlt_daemon_control_get_log_info(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose)
{
DltServiceGetLogInfoRequest *req;
DltMessage resp;
- DltDaemonContext *context=0;
- DltDaemonApplication *application=0;
+ DltDaemonContext *context = 0;
+ DltDaemonApplication *application = 0;
- int num_applications=0, num_contexts=0;
- uint16_t count_app_ids=0, count_con_ids=0;
+ int num_applications = 0, num_contexts = 0;
+ uint16_t count_app_ids = 0, count_con_ids = 0;
-#if (DLT_DEBUG_GETLOGINFO==1)
+#if (DLT_DEBUG_GETLOGINFO == 1)
char buf[255];
#endif
- int32_t i,j,offset=0;
- char *apid=0;
- int8_t ll,ts;
+ int32_t i, j, offset = 0;
+ char *apid = 0;
+ int8_t ll, ts;
uint16_t len;
int8_t value;
- int32_t sizecont=0;
+ int32_t sizecont = 0;
int offset_base;
uint32_t sid;
- DltDaemonRegisteredUsers* user_list = NULL;
+ DltDaemonRegisteredUsers *user_list = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
- {
return;
- }
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize, sizeof(DltServiceGetLogInfoRequest)) < 0)
- {
return;
- }
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return;
- }
/* prepare pointer to message request */
- req = (DltServiceGetLogInfoRequest*) (msg->databuffer);
+ req = (DltServiceGetLogInfoRequest *)(msg->databuffer);
/* initialise new message */
- if (dlt_message_init(&resp,0) == DLT_RETURN_ERROR)
- {
- dlt_daemon_control_service_response(sock, daemon,daemon_local, DLT_SERVICE_ID_GET_LOG_INFO, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ if (dlt_message_init(&resp, 0) == DLT_RETURN_ERROR) {
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_GET_LOG_INFO,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
return;
}
/* check request */
- if ((req->options < 3 ) || (req->options>7))
- {
- dlt_daemon_control_service_response(sock, daemon,daemon_local, DLT_SERVICE_ID_GET_LOG_INFO, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ if ((req->options < 3) || (req->options > 7)) {
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_GET_LOG_INFO,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
return;
}
- if (req->apid[0]!='\0')
- {
+ if (req->apid[0] != '\0') {
application = dlt_daemon_application_find(daemon,
req->apid,
daemon->ecuid,
verbose);
- if (application)
- {
+
+ if (application) {
num_applications = 1;
- if (req->ctid[0]!='\0')
- {
+
+ if (req->ctid[0] != '\0') {
context = dlt_daemon_context_find(daemon,
req->apid,
req->ctid,
daemon->ecuid,
verbose);
- num_contexts = ((context)?1:0);
+ num_contexts = ((context) ? 1 : 0);
}
- else
- {
+ else {
num_contexts = application->num_contexts;
}
}
- else
- {
+ else {
num_applications = 0;
num_contexts = 0;
}
}
- else
- {
+ else {
/* Request all applications and contexts */
num_applications = user_list->num_applications;
num_contexts = user_list->num_contexts;
@@ -851,161 +921,134 @@ void dlt_daemon_control_get_log_info(int sock, DltDaemon *daemon, DltDaemonLocal
sizecont = sizeof(uint32_t) /* context_id */;
/* Add additional size for response of Mode 4, 6, 7 */
- if ((req->options==4) || (req->options==6) || (req->options==7))
- {
+ if ((req->options == 4) || (req->options == 6) || (req->options == 7))
sizecont += sizeof(int8_t); /* log level */
- }
/* Add additional size for response of Mode 5, 6, 7 */
- if ((req->options==5) || (req->options==6) || (req->options==7))
- {
- sizecont+= sizeof(int8_t); /* trace status */
- }
+ if ((req->options == 5) || (req->options == 6) || (req->options == 7))
+ sizecont += sizeof(int8_t); /* trace status */
- resp.datasize+= (num_applications * (sizeof(uint32_t) /* app_id */ + sizeof(uint16_t) /* count_con_ids */)) +
- (num_contexts * sizecont);
+ resp.datasize += (num_applications * (sizeof(uint32_t) /* app_id */ + sizeof(uint16_t) /* count_con_ids */)) +
+ (num_contexts * sizecont);
- resp.datasize+= sizeof(uint16_t) /* count_app_ids */;
+ resp.datasize += sizeof(uint16_t) /* count_app_ids */;
/* Add additional size for response of Mode 7 */
- if (req->options==7)
- {
- if (req->apid[0]!='\0')
- {
- if (req->ctid[0]!='\0')
- {
+ if (req->options == 7) {
+ if (req->apid[0] != '\0') {
+ if (req->ctid[0] != '\0') {
/* One application, one context */
- // context = dlt_daemon_context_find(daemon, req->apid, req->ctid, verbose);
- if (context)
- {
- resp.datasize+=sizeof(uint16_t) /* len_context_description */;
- if (context->context_description!=0)
- {
- resp.datasize+=strlen(context->context_description); /* context_description */
- }
+ /* context = dlt_daemon_context_find(daemon, req->apid, req->ctid, verbose); */
+ if (context) {
+ resp.datasize += sizeof(uint16_t) /* len_context_description */;
+
+ if (context->context_description != 0)
+ resp.datasize += strlen(context->context_description); /* context_description */
}
}
else
- {
- /* One application, all contexts */
- if ((user_list->applications) && (application))
- {
- /* Calculate start offset within contexts[] */
- offset_base=0;
- for (i = 0; i < (application - (user_list->applications)); i++)
- {
- offset_base += user_list->applications[i].num_contexts;
- }
+ /* One application, all contexts */
+ if ((user_list->applications) && (application)) {
+ /* Calculate start offset within contexts[] */
+ offset_base = 0;
- /* Iterate over all contexts belonging to this application */
- for (j=0;j<application->num_contexts;j++)
- {
+ for (i = 0; i < (application - (user_list->applications)); i++)
+ offset_base += user_list->applications[i].num_contexts;
- context = &(user_list->contexts[offset_base + j]);
- if (context)
- {
- resp.datasize+=sizeof(uint16_t) /* len_context_description */;
- if (context->context_description!=0)
- {
- resp.datasize+=strlen(context->context_description); /* context_description */
- }
- }
+ /* Iterate over all contexts belonging to this application */
+ for (j = 0; j < application->num_contexts; j++) {
+
+ context = &(user_list->contexts[offset_base + j]);
+
+ if (context) {
+ resp.datasize += sizeof(uint16_t) /* len_context_description */;
+
+ if (context->context_description != 0)
+ resp.datasize += strlen(context->context_description); /* context_description */
}
}
}
/* Space for application description */
- if (application)
- {
- resp.datasize+=sizeof(uint16_t) /* len_app_description */;
- if (application->application_description!=0)
- {
- resp.datasize+=strlen(application->application_description); /* app_description */
- }
+ if (application) {
+ resp.datasize += sizeof(uint16_t) /* len_app_description */;
+
+ if (application->application_description != 0)
+ resp.datasize += strlen(application->application_description); /* app_description */
}
}
- else
- {
+ else {
/* All applications, all contexts */
- for (i = 0; i < user_list->num_contexts; i++)
- {
- resp.datasize+=sizeof(uint16_t) /* len_context_description */;
+ for (i = 0; i < user_list->num_contexts; i++) {
+ resp.datasize += sizeof(uint16_t) /* len_context_description */;
+
if (user_list->contexts[i].context_description != 0)
- {
resp.datasize +=
- strlen(user_list->contexts[i].context_description);
- }
+ strlen(user_list->contexts[i].context_description);
}
- for (i = 0; i < user_list->num_applications; i++)
- {
+ for (i = 0; i < user_list->num_applications; i++) {
resp.datasize += sizeof(uint16_t) /* len_app_description */;
+
if (user_list->applications[i].application_description != 0)
- {
resp.datasize += strlen(user_list->applications[i].application_description); /* app_description */
- }
}
}
}
if (verbose)
- {
dlt_vlog(LOG_DEBUG,
"Allocate %d bytes for response msg databuffer\n",
resp.datasize);
- }
/* Allocate buffer for response message */
- resp.databuffer = (uint8_t *) malloc(resp.datasize);
+ resp.databuffer = (uint8_t *)malloc(resp.datasize);
resp.databuffersize = resp.datasize;
- if (resp.databuffer==0)
- {
- dlt_daemon_control_service_response(sock, daemon,daemon_local, DLT_SERVICE_ID_GET_LOG_INFO, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ if (resp.databuffer == 0) {
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_GET_LOG_INFO,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
return;
}
- memset(resp.databuffer,0,resp.datasize);
+
+ memset(resp.databuffer, 0, resp.datasize);
/* Preparation finished */
/* Prepare response */
sid = DLT_SERVICE_ID_GET_LOG_INFO;
- memcpy(resp.databuffer,&sid,sizeof(uint32_t));
- offset+=sizeof(uint32_t);
+ memcpy(resp.databuffer, &sid, sizeof(uint32_t));
+ offset += sizeof(uint32_t);
- value = (((num_applications!=0)&&(num_contexts!=0))?req->options:8); /* 8 = no matching context found */
+ value = (((num_applications != 0) && (num_contexts != 0)) ? req->options : 8); /* 8 = no matching context found */
- memcpy(resp.databuffer+offset,&value,sizeof(int8_t));
- offset+=sizeof(int8_t);
+ memcpy(resp.databuffer + offset, &value, sizeof(int8_t));
+ offset += sizeof(int8_t);
count_app_ids = num_applications;
- if (count_app_ids!=0)
- {
- memcpy(resp.databuffer+offset,&count_app_ids,sizeof(uint16_t));
- offset+=sizeof(uint16_t);
+ if (count_app_ids != 0) {
+ memcpy(resp.databuffer + offset, &count_app_ids, sizeof(uint16_t));
+ offset += sizeof(uint16_t);
-#if (DLT_DEBUG_GETLOGINFO==1)
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"#apid: %d \n", count_app_ids);
+#if (DLT_DEBUG_GETLOGINFO == 1)
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "#apid: %d \n", count_app_ids);
dlt_log(LOG_DEBUG, str);
#endif
- for (i=0;i<count_app_ids;i++)
- {
- if (req->apid[0]!='\0')
- {
+ for (i = 0; i < count_app_ids; i++) {
+ if (req->apid[0] != '\0') {
apid = req->apid;
}
- else
- {
+ else {
if (user_list->applications)
- {
apid = user_list->applications[i].apid;
- }
else
- {
/* This should never occur! */
- apid=0;
- }
+ apid = 0;
}
application = dlt_daemon_application_find(daemon,
@@ -1013,349 +1056,345 @@ void dlt_daemon_control_get_log_info(int sock, DltDaemon *daemon, DltDaemonLocal
daemon->ecuid,
verbose);
- if (application)
- {
+ if (application) {
/* Calculate start offset within contexts[] */
- offset_base=0;
- for (j = 0; j < (application-(user_list->applications)); j++)
- {
+ offset_base = 0;
+
+ for (j = 0; j < (application - (user_list->applications)); j++)
offset_base += user_list->applications[j].num_contexts;
- }
- dlt_set_id((char*)(resp.databuffer + offset), apid);
+ dlt_set_id((char *)(resp.databuffer + offset), apid);
offset += sizeof(ID4);
-#if (DLT_DEBUG_GETLOGINFO==1)
+#if (DLT_DEBUG_GETLOGINFO == 1)
dlt_print_id(buf, apid);
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"apid: %s\n",buf);
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "apid: %s\n", buf);
dlt_log(LOG_DEBUG, str);
#endif
if (req->apid[0] != '\0')
- {
count_con_ids = num_contexts;
- }
else
- {
count_con_ids = application->num_contexts;
- }
- memcpy(resp.databuffer + offset,&count_con_ids, sizeof(uint16_t));
+ memcpy(resp.databuffer + offset, &count_con_ids, sizeof(uint16_t));
offset += sizeof(uint16_t);
-#if (DLT_DEBUG_GETLOGINFO==1)
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"#ctid: %d \n", count_con_ids);
+#if (DLT_DEBUG_GETLOGINFO == 1)
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "#ctid: %d \n", count_con_ids);
dlt_log(LOG_DEBUG, str);
#endif
- for (j = 0;j < count_con_ids; j++)
- {
-#if (DLT_DEBUG_GETLOGINFO==1)
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"j: %d \n",j);
+ for (j = 0; j < count_con_ids; j++) {
+#if (DLT_DEBUG_GETLOGINFO == 1)
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "j: %d \n", j);
dlt_log(LOG_DEBUG, str);
#endif
+
if (!((count_con_ids == 1) && (req->apid[0] != '\0') &&
- (req->ctid[0] != '\0')))
- {
+ (req->ctid[0] != '\0')))
context = &(user_list->contexts[offset_base + j]);
- }
+
/* else: context was already searched and found
- (one application (found) with one context (found))*/
+ * (one application (found) with one context (found))*/
if ((context) &&
- ((req->ctid[0]=='\0') || ((req->ctid[0]!='\0') &&
- (memcmp(context->ctid,req->ctid,DLT_ID_SIZE)==0)))
- )
- {
- dlt_set_id((char*)(resp.databuffer+offset), context->ctid);
+ ((req->ctid[0] == '\0') || ((req->ctid[0] != '\0') &&
+ (memcmp(context->ctid, req->ctid, DLT_ID_SIZE) == 0)))
+ ) {
+ dlt_set_id((char *)(resp.databuffer + offset), context->ctid);
offset += sizeof(ID4);
-#if (DLT_DEBUG_GETLOGINFO==1)
+#if (DLT_DEBUG_GETLOGINFO == 1)
dlt_print_id(buf, context->ctid);
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"ctid: %s \n",buf);
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "ctid: %s \n", buf);
dlt_log(LOG_DEBUG, str);
#endif
/* Mode 4, 6, 7 */
- if ((req->options==4) || (req->options==6) || (req->options==7))
- {
- ll=context->log_level;
- memcpy(resp.databuffer+offset,&ll,sizeof(int8_t));
- offset+=sizeof(int8_t);
+ if ((req->options == 4) || (req->options == 6) || (req->options == 7)) {
+ ll = context->log_level;
+ memcpy(resp.databuffer + offset, &ll, sizeof(int8_t));
+ offset += sizeof(int8_t);
}
/* Mode 5, 6, 7 */
- if ((req->options==5) || (req->options==6) || (req->options==7))
- {
- ts=context->trace_status;
- memcpy(resp.databuffer+offset,&ts,sizeof(int8_t));
- offset+=sizeof(int8_t);
+ if ((req->options == 5) || (req->options == 6) || (req->options == 7)) {
+ ts = context->trace_status;
+ memcpy(resp.databuffer + offset, &ts, sizeof(int8_t));
+ offset += sizeof(int8_t);
}
/* Mode 7 */
- if (req->options==7)
- {
- if (context->context_description)
- {
+ if (req->options == 7) {
+ if (context->context_description) {
len = strlen(context->context_description);
- memcpy(resp.databuffer+offset,&len,sizeof(uint16_t));
- offset+=sizeof(uint16_t);
- memcpy(resp.databuffer+offset,context->context_description,strlen(context->context_description));
- offset+=strlen(context->context_description);
+ memcpy(resp.databuffer + offset, &len, sizeof(uint16_t));
+ offset += sizeof(uint16_t);
+ memcpy(resp.databuffer + offset, context->context_description,
+ strlen(context->context_description));
+ offset += strlen(context->context_description);
}
- else
- {
+ else {
len = 0;
- memcpy(resp.databuffer+offset,&len,sizeof(uint16_t));
- offset+=sizeof(uint16_t);
+ memcpy(resp.databuffer + offset, &len, sizeof(uint16_t));
+ offset += sizeof(uint16_t);
}
}
-#if (DLT_DEBUG_GETLOGINFO==1)
- snprintf(str,DLT_DAEMON_TEXTBUFSIZE,"ll=%d ts=%d \n",(int32_t)ll,(int32_t)ts);
+#if (DLT_DEBUG_GETLOGINFO == 1)
+ snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "ll=%d ts=%d \n", (int32_t)ll, (int32_t)ts);
dlt_log(LOG_DEBUG, str);
#endif
}
-#if (DLT_DEBUG_GETLOGINFO==1)
- dlt_log(LOG_DEBUG,"\n");
+#if (DLT_DEBUG_GETLOGINFO == 1)
+ dlt_log(LOG_DEBUG, "\n");
#endif
}
/* Mode 7 */
- if (req->options==7)
- {
- if (application->application_description)
- {
+ if (req->options == 7) {
+ if (application->application_description) {
len = strlen(application->application_description);
- memcpy(resp.databuffer+offset,&len,sizeof(uint16_t));
- offset+=sizeof(uint16_t);
- memcpy(resp.databuffer+offset,application->application_description,strlen(application->application_description));
- offset+=strlen(application->application_description);
+ memcpy(resp.databuffer + offset, &len, sizeof(uint16_t));
+ offset += sizeof(uint16_t);
+ memcpy(resp.databuffer + offset, application->application_description,
+ strlen(application->application_description));
+ offset += strlen(application->application_description);
}
- else
- {
+ else {
len = 0;
- memcpy(resp.databuffer+offset,&len,sizeof(uint16_t));
- offset+=sizeof(uint16_t);
+ memcpy(resp.databuffer + offset, &len, sizeof(uint16_t));
+ offset += sizeof(uint16_t);
}
}
} /* if (application) */
+
} /* for (i=0;i<count_app_ids;i++) */
+
} /* if (count_app_ids!=0) */
- dlt_set_id((char*)(resp.databuffer+offset),DLT_DAEMON_REMO_STRING);
+ dlt_set_id((char *)(resp.databuffer + offset), DLT_DAEMON_REMO_STRING);
/* send message */
- dlt_daemon_client_send_control_message(sock,daemon,daemon_local,&resp,"","", verbose);
+ dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &resp, "", "", verbose);
/* free message */
- dlt_message_free(&resp,0);
+ dlt_message_free(&resp, 0);
}
-int dlt_daemon_control_message_buffer_overflow(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, unsigned int overflow_counter,char* apid, int verbose)
+int dlt_daemon_control_message_buffer_overflow(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ unsigned int overflow_counter,
+ char *apid,
+ int verbose)
{
- int ret;
+ int ret;
DltMessage msg;
- DltServiceMessageBufferOverflowResponse *resp;
+ DltServiceMessageBufferOverflowResponse *resp;
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon==0)
- {
+ if (daemon == 0)
return DLT_DAEMON_ERROR_UNKNOWN;
- }
/* initialise new message */
- if (dlt_message_init(&msg,0) == DLT_RETURN_ERROR)
- {
- dlt_daemon_control_service_response(sock, daemon,daemon_local, DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW, DLT_SERVICE_RESPONSE_ERROR, verbose);
- return DLT_DAEMON_ERROR_UNKNOWN;
+ if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR) {
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
+ return DLT_DAEMON_ERROR_UNKNOWN;
}
/* prepare payload of data */
msg.datasize = sizeof(DltServiceMessageBufferOverflowResponse);
- if (msg.databuffer && (msg.databuffersize < msg.datasize))
- {
+
+ if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
free(msg.databuffer);
- msg.databuffer=0;
+ msg.databuffer = 0;
}
- if (msg.databuffer == 0){
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
- msg.databuffersize = msg.datasize;
+
+ if (msg.databuffer == 0) {
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
+ msg.databuffersize = msg.datasize;
}
- if (msg.databuffer==0)
- {
+
+ if (msg.databuffer == 0)
return DLT_DAEMON_ERROR_UNKNOWN;
- }
- resp = (DltServiceMessageBufferOverflowResponse*) msg.databuffer;
+ resp = (DltServiceMessageBufferOverflowResponse *)msg.databuffer;
resp->service_id = DLT_SERVICE_ID_MESSAGE_BUFFER_OVERFLOW;
resp->status = DLT_SERVICE_RESPONSE_OK;
resp->overflow = DLT_MESSAGE_BUFFER_OVERFLOW;
- resp->overflow_counter = overflow_counter;
+ resp->overflow_counter = overflow_counter;
/* send message */
- if((ret=dlt_daemon_client_send_control_message(sock,daemon,daemon_local,&msg,apid,"", verbose)))
- {
- dlt_message_free(&msg,0);
- return ret;
+ if ((ret = dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, apid, "", verbose))) {
+ dlt_message_free(&msg, 0);
+ return ret;
}
/* free message */
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
return DLT_DAEMON_ERROR_OK;
}
-void dlt_daemon_control_service_response( int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, uint32_t service_id, int8_t status , int verbose)
+void dlt_daemon_control_service_response(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ uint32_t service_id,
+ int8_t status,
+ int verbose)
{
DltMessage msg;
DltServiceResponse *resp;
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon==0)
- {
+ if (daemon == 0)
return;
- }
/* initialise new message */
- if (dlt_message_init(&msg,0) == DLT_RETURN_ERROR)
- {
- return;
- }
+ if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+ return;
/* prepare payload of data */
msg.datasize = sizeof(DltServiceResponse);
- if (msg.databuffer && (msg.databuffersize < msg.datasize))
- {
+
+ if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
free(msg.databuffer);
- msg.databuffer=0;
+ msg.databuffer = 0;
}
- if (msg.databuffer == 0){
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
- msg.databuffersize = msg.datasize;
+
+ if (msg.databuffer == 0) {
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
+ msg.databuffersize = msg.datasize;
}
- if (msg.databuffer==0)
- {
+
+ if (msg.databuffer == 0)
return;
- }
- resp = (DltServiceResponse*) msg.databuffer;
+ resp = (DltServiceResponse *)msg.databuffer;
resp->service_id = service_id;
resp->status = status;
/* send message */
- dlt_daemon_client_send_control_message(sock,daemon,daemon_local,&msg,"","", verbose);
+ dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose);
/* free message */
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
}
-int dlt_daemon_control_message_unregister_context(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, char* apid, char* ctid, char* comid, int verbose)
+int dlt_daemon_control_message_unregister_context(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ char *apid,
+ char *ctid,
+ char *comid,
+ int verbose)
{
DltMessage msg;
DltServiceUnregisterContext *resp;
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon==0)
- {
+ if (daemon == 0)
return -1;
- }
/* initialise new message */
- if (dlt_message_init(&msg,0) == DLT_RETURN_ERROR)
- {
- return -1;
- }
+ if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+ return -1;
/* prepare payload of data */
msg.datasize = sizeof(DltServiceUnregisterContext);
- if (msg.databuffer && (msg.databuffersize < msg.datasize))
- {
+
+ if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
free(msg.databuffer);
- msg.databuffer=0;
+ msg.databuffer = 0;
}
- if (msg.databuffer == 0){
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
- msg.databuffersize = msg.datasize;
+
+ if (msg.databuffer == 0) {
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
+ msg.databuffersize = msg.datasize;
}
- if (msg.databuffer==0)
- {
+
+ if (msg.databuffer == 0)
return -1;
- }
- resp = (DltServiceUnregisterContext*) msg.databuffer;
+ resp = (DltServiceUnregisterContext *)msg.databuffer;
resp->service_id = DLT_SERVICE_ID_UNREGISTER_CONTEXT;
resp->status = DLT_SERVICE_RESPONSE_OK;
- dlt_set_id(resp->apid, apid);
- dlt_set_id(resp->ctid, ctid);
- dlt_set_id(resp->comid, comid);
+ dlt_set_id(resp->apid, apid);
+ dlt_set_id(resp->ctid, ctid);
+ dlt_set_id(resp->comid, comid);
/* send message */
- if(dlt_daemon_client_send_control_message(sock,daemon,daemon_local,&msg,"","", verbose))
- {
- dlt_message_free(&msg,0);
- return -1;
+ if (dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose)) {
+ dlt_message_free(&msg, 0);
+ return -1;
}
/* free message */
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
return 0;
}
-int dlt_daemon_control_message_connection_info(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, uint8_t state, char* comid, int verbose)
+int dlt_daemon_control_message_connection_info(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ uint8_t state,
+ char *comid,
+ int verbose)
{
DltMessage msg;
DltServiceConnectionInfo *resp;
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon==0)
- {
+ if (daemon == 0)
return -1;
- }
/* initialise new message */
- if (dlt_message_init(&msg,0) == DLT_RETURN_ERROR)
- {
- return -1;
- }
+ if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+ return -1;
/* prepare payload of data */
msg.datasize = sizeof(DltServiceConnectionInfo);
- if (msg.databuffer && (msg.databuffersize < msg.datasize))
- {
+
+ if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
free(msg.databuffer);
- msg.databuffer=0;
+ msg.databuffer = 0;
}
- if (msg.databuffer == 0){
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
- msg.databuffersize = msg.datasize;
+
+ if (msg.databuffer == 0) {
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
+ msg.databuffersize = msg.datasize;
}
- if (msg.databuffer==0)
- {
+
+ if (msg.databuffer == 0)
return -1;
- }
- resp = (DltServiceConnectionInfo*) msg.databuffer;
+ resp = (DltServiceConnectionInfo *)msg.databuffer;
resp->service_id = DLT_SERVICE_ID_CONNECTION_INFO;
resp->status = DLT_SERVICE_RESPONSE_OK;
resp->state = state;
dlt_set_id(resp->comid, comid);
/* send message */
- if(dlt_daemon_client_send_control_message(sock,daemon,daemon_local,&msg,"","", verbose))
- {
- dlt_message_free(&msg,0);
- return -1;
+ if (dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose)) {
+ dlt_message_free(&msg, 0);
+ return -1;
}
/* free message */
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
return 0;
}
@@ -1367,54 +1406,49 @@ int dlt_daemon_control_message_timezone(int sock, DltDaemon *daemon, DltDaemonLo
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon==0)
- {
+ if (daemon == 0)
return -1;
- }
/* initialise new message */
- if (dlt_message_init(&msg,0) == DLT_RETURN_ERROR)
- {
- return -1;
- }
+ if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+ return -1;
/* prepare payload of data */
msg.datasize = sizeof(DltServiceTimezone);
- if (msg.databuffer && (msg.databuffersize < msg.datasize))
- {
+
+ if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
free(msg.databuffer);
- msg.databuffer=0;
+ msg.databuffer = 0;
}
- if (msg.databuffer == 0){
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
- msg.databuffersize = msg.datasize;
+
+ if (msg.databuffer == 0) {
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
+ msg.databuffersize = msg.datasize;
}
- if (msg.databuffer==0)
- {
+
+ if (msg.databuffer == 0)
return -1;
- }
- resp = (DltServiceTimezone*) msg.databuffer;
+ resp = (DltServiceTimezone *)msg.databuffer;
resp->service_id = DLT_SERVICE_ID_TIMEZONE;
resp->status = DLT_SERVICE_RESPONSE_OK;
- time_t t = time(NULL);
- struct tm lt;
- localtime_r(&t, &lt);
+ time_t t = time(NULL);
+ struct tm lt;
+ localtime_r(&t, &lt);
#if !defined(__CYGWIN__)
- resp->timezone = (int32_t) lt.tm_gmtoff;
+ resp->timezone = (int32_t)lt.tm_gmtoff;
#endif
- resp->isdst = (uint8_t) lt.tm_isdst;
+ resp->isdst = (uint8_t)lt.tm_isdst;
/* send message */
- if(dlt_daemon_client_send_control_message(sock,daemon,daemon_local,&msg,"","", verbose))
- {
- dlt_message_free(&msg,0);
- return -1;
+ if (dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose)) {
+ dlt_message_free(&msg, 0);
+ return -1;
}
/* free message */
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
return 0;
}
@@ -1426,98 +1460,92 @@ int dlt_daemon_control_message_marker(int sock, DltDaemon *daemon, DltDaemonLoca
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon==0)
- {
+ if (daemon == 0)
return -1;
- }
/* initialise new message */
- if (dlt_message_init(&msg,0) == DLT_RETURN_ERROR)
- {
- return -1;
- }
+ if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
+ return -1;
/* prepare payload of data */
msg.datasize = sizeof(DltServiceMarker);
- if (msg.databuffer && (msg.databuffersize < msg.datasize))
- {
+
+ if (msg.databuffer && (msg.databuffersize < msg.datasize)) {
free(msg.databuffer);
- msg.databuffer=0;
+ msg.databuffer = 0;
}
- if (msg.databuffer == 0){
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
- msg.databuffersize = msg.datasize;
+
+ if (msg.databuffer == 0) {
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
+ msg.databuffersize = msg.datasize;
}
- if (msg.databuffer==0)
- {
+
+ if (msg.databuffer == 0)
return -1;
- }
- resp = (DltServiceMarker*) msg.databuffer;
+ resp = (DltServiceMarker *)msg.databuffer;
resp->service_id = DLT_SERVICE_ID_MARKER;
resp->status = DLT_SERVICE_RESPONSE_OK;
/* send message */
- if(dlt_daemon_client_send_control_message(sock,daemon,daemon_local,&msg,"","", verbose))
- {
- dlt_message_free(&msg,0);
- return -1;
+ if (dlt_daemon_client_send_control_message(sock, daemon, daemon_local, &msg, "", "", verbose)) {
+ dlt_message_free(&msg, 0);
+ return -1;
}
/* free message */
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
return 0;
}
-void dlt_daemon_control_callsw_cinjection(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose)
+void dlt_daemon_control_callsw_cinjection(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose)
{
- char apid[DLT_ID_SIZE],ctid[DLT_ID_SIZE];
- uint32_t id=0,id_tmp=0;
+ char apid[DLT_ID_SIZE], ctid[DLT_ID_SIZE];
+ uint32_t id = 0, id_tmp = 0;
uint8_t *ptr;
DltDaemonContext *context;
- int32_t data_length_inject=0;
- uint32_t data_length_inject_tmp=0;
+ int32_t data_length_inject = 0;
+ uint32_t data_length_inject_tmp = 0;
- int32_t datalength;
+ int32_t datalength;
- DltUserHeader userheader;
- DltUserControlMsgInjection usercontext;
- uint8_t *userbuffer;
+ DltUserHeader userheader;
+ DltUserControlMsgInjection usercontext;
+ uint8_t *userbuffer;
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
- {
return;
- }
datalength = msg->datasize;
ptr = msg->databuffer;
- DLT_MSG_READ_VALUE(id_tmp,ptr,datalength,uint32_t); /* Get service id */
- id=DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp);
+ DLT_MSG_READ_VALUE(id_tmp, ptr, datalength, uint32_t); /* Get service id */
+ id = DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp);
- if ((id>=DLT_DAEMON_INJECTION_MIN) && (id<=DLT_DAEMON_INJECTION_MAX))
- {
+ if ((id >= DLT_DAEMON_INJECTION_MIN) && (id <= DLT_DAEMON_INJECTION_MAX)) {
/* This a a real SW-C injection call */
- data_length_inject=0;
- data_length_inject_tmp=0;
+ data_length_inject = 0;
+ data_length_inject_tmp = 0;
- DLT_MSG_READ_VALUE(data_length_inject_tmp,ptr,datalength,uint32_t); /* Get data length */
- data_length_inject=DLT_ENDIAN_GET_32(msg->standardheader->htyp, data_length_inject_tmp);
+ DLT_MSG_READ_VALUE(data_length_inject_tmp, ptr, datalength, uint32_t); /* Get data length */
+ data_length_inject = DLT_ENDIAN_GET_32(msg->standardheader->htyp, data_length_inject_tmp);
/* Get context handle for apid, ctid (and seid) */
/* Warning: seid is ignored in this implementation! */
- if (DLT_IS_HTYP_UEH(msg->standardheader->htyp))
- {
+ if (DLT_IS_HTYP_UEH(msg->standardheader->htyp)) {
dlt_set_id(apid, msg->extendedheader->apid);
dlt_set_id(ctid, msg->extendedheader->ctid);
}
- else
- {
+ else {
/* No extended header, and therefore no apid and ctid available */
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
return;
}
@@ -1528,73 +1556,73 @@ void dlt_daemon_control_callsw_cinjection(int sock, DltDaemon *daemon, DltDaemon
daemon->ecuid,
verbose);
- if (context==0)
- {
- // dlt_log(LOG_INFO,"No context found!\n");
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ if (context == 0) {
+ /* dlt_log(LOG_INFO,"No context found!\n"); */
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
return;
}
/* Send user message to handle, specified in context */
- if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_INJECTION) < DLT_RETURN_OK)
- {
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
- return;
- }
-
- usercontext.log_level_pos = context->log_level_pos;
-
- if (data_length_inject > msg->databuffersize)
- {
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
- return;
- }
-
- userbuffer = malloc(data_length_inject);
-
- if (userbuffer==0)
- {
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
- return;
- }
-
- usercontext.data_length_inject = data_length_inject;
- usercontext.service_id = id;
-
- memcpy(userbuffer,ptr,data_length_inject); /* Copy received injection to send buffer */
-
- /* write to FIFO */
- DltReturnValue ret =
- dlt_user_log_out3(context->user_handle, &(userheader), sizeof(DltUserHeader),
- &(usercontext), sizeof(DltUserControlMsgInjection),
- userbuffer, data_length_inject);
- if (ret < DLT_RETURN_OK)
- {
- if (ret == DLT_RETURN_PIPE_ERROR)
- {
- /* Close connection */
- close(context->user_handle);
- context->user_handle=DLT_FD_INIT;
- }
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
- }
- else
- {
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
- }
-
- free(userbuffer);
- userbuffer=0;
+ if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_INJECTION) < DLT_RETURN_OK) {
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ return;
+ }
+
+ usercontext.log_level_pos = context->log_level_pos;
+
+ if (data_length_inject > msg->databuffersize) {
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ return;
+ }
+
+ userbuffer = malloc(data_length_inject);
+
+ if (userbuffer == 0) {
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ return;
+ }
+
+ usercontext.data_length_inject = data_length_inject;
+ usercontext.service_id = id;
+
+ memcpy(userbuffer, ptr, data_length_inject); /* Copy received injection to send buffer */
+
+ /* write to FIFO */
+ DltReturnValue ret =
+ dlt_user_log_out3(context->user_handle, &(userheader), sizeof(DltUserHeader),
+ &(usercontext), sizeof(DltUserControlMsgInjection),
+ userbuffer, data_length_inject);
+
+ if (ret < DLT_RETURN_OK) {
+ if (ret == DLT_RETURN_PIPE_ERROR) {
+ /* Close connection */
+ close(context->user_handle);
+ context->user_handle = DLT_FD_INIT;
+ }
+
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ }
+ else {
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+ }
+
+ free(userbuffer);
+ userbuffer = 0;
}
- else
- {
+ else {
/* Invalid ID */
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED, verbose);
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_NOT_SUPPORTED,
+ verbose);
}
}
-void dlt_daemon_send_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltDaemonContext *context,int8_t loglevel, int verbose)
+void dlt_daemon_send_log_level(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltDaemonContext *context,
+ int8_t loglevel,
+ int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
@@ -1605,17 +1633,14 @@ void dlt_daemon_send_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daem
context->log_level = loglevel; /* No endianess conversion necessary*/
if ((context->user_handle >= DLT_FD_MINIMUM) &&
- (dlt_daemon_user_send_log_level(daemon, context, verbose)==0))
- {
+ (dlt_daemon_user_send_log_level(daemon, context, verbose) == 0)) {
dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
}
- else
- {
+ else {
dlt_log(LOG_ERR, "Log level could not be sent!\n");
context->log_level = old_log_level;
dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
}
-
}
void dlt_daemon_find_multiple_context_and_send_log_level(int sock,
@@ -1631,102 +1656,116 @@ void dlt_daemon_find_multiple_context_and_send_log_level(int sock,
int count = 0;
DltDaemonContext *context = NULL;
- char src_str[DLT_ID_SIZE +1] = {0};
+ char src_str[DLT_ID_SIZE + 1] = { 0 };
int8_t ret = 0;
- DltDaemonRegisteredUsers* user_list = NULL;
+ DltDaemonRegisteredUsers *user_list = NULL;
- if (daemon == 0)
- {
+ if (daemon == 0) {
dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
return;
}
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return;
- }
- for (count = 0; count < user_list->num_contexts; count++)
- {
+ for (count = 0; count < user_list->num_contexts; count++) {
context = &(user_list->contexts[count]);
- if (context)
- {
+ if (context) {
if (app_flag == 1)
- {
strncpy(src_str, context->apid, DLT_ID_SIZE);
- }
else
- {
strncpy(src_str, context->ctid, DLT_ID_SIZE);
- }
+
ret = strncmp(src_str, str, len);
+
if (ret == 0)
- {
dlt_daemon_send_log_level(sock, daemon, daemon_local, context, loglevel, verbose);
- }
else if ((ret > 0) && (app_flag == 1))
- {
break;
- }
else
- {
continue;
- }
}
}
}
-void dlt_daemon_control_set_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose)
+void dlt_daemon_control_set_log_level(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
- char apid[DLT_ID_SIZE+1] = {0};
- char ctid[DLT_ID_SIZE+1] = {0};
+ char apid[DLT_ID_SIZE + 1] = { 0 };
+ char ctid[DLT_ID_SIZE + 1] = { 0 };
DltServiceSetLogLevel *req = NULL;
DltDaemonContext *context = NULL;
int8_t appid_length = 0;
int8_t ctxtid_length = 0;
if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
- {
return;
- }
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize, sizeof(DltServiceSetLogLevel)) < 0)
- {
return;
- }
- req = (DltServiceSetLogLevel*) (msg->databuffer);
+ req = (DltServiceSetLogLevel *)(msg->databuffer);
+
if (daemon_local->flags.enforceContextLLAndTS)
- {
req->log_level = getStatus(req->log_level, daemon_local->flags.contextLogLevel);
- }
dlt_set_id(apid, req->apid);
dlt_set_id(ctid, req->ctid);
appid_length = strlen(apid);
ctxtid_length = strlen(ctid);
- if ((appid_length != 0) && (apid[appid_length-1] == '*') && (ctid[0] == 0)) /*appid provided having '*' in it and ctid is null*/
- {
- dlt_daemon_find_multiple_context_and_send_log_level(sock, daemon, daemon_local, 1, apid, appid_length-1, req->log_level, verbose);
- }
- else if ((ctxtid_length != 0) && (ctid[ctxtid_length-1] == '*') && (apid[0] == 0)) /*ctid provided is having '*' in it and appid is null*/
- {
- dlt_daemon_find_multiple_context_and_send_log_level(sock, daemon, daemon_local, 0, ctid, ctxtid_length-1, req->log_level, verbose);
- }
- else if ((appid_length != 0) && (apid[appid_length-1] != '*') && (ctid[0] == 0)) /*only app id case*/
- {
- dlt_daemon_find_multiple_context_and_send_log_level(sock, daemon, daemon_local, 1, apid, DLT_ID_SIZE, req->log_level, verbose);
- }
- else if ((ctxtid_length != 0) && (ctid[ctxtid_length-1] != '*') && (apid[0] == 0)) /*only context id case*/
- {
- dlt_daemon_find_multiple_context_and_send_log_level(sock, daemon, daemon_local, 0, ctid, DLT_ID_SIZE, req->log_level, verbose);
- }
- else
- {
+
+ if ((appid_length != 0) && (apid[appid_length - 1] == '*') && (ctid[0] == 0)) { /*appid provided having '*' in it and ctid is null*/
+ dlt_daemon_find_multiple_context_and_send_log_level(sock,
+ daemon,
+ daemon_local,
+ 1,
+ apid,
+ appid_length - 1,
+ req->log_level,
+ verbose);
+ }
+ else if ((ctxtid_length != 0) && (ctid[ctxtid_length - 1] == '*') && (apid[0] == 0)) /*ctid provided is having '*' in it and appid is null*/
+ {
+ dlt_daemon_find_multiple_context_and_send_log_level(sock,
+ daemon,
+ daemon_local,
+ 0,
+ ctid,
+ ctxtid_length - 1,
+ req->log_level,
+ verbose);
+ }
+ else if ((appid_length != 0) && (apid[appid_length - 1] != '*') && (ctid[0] == 0)) /*only app id case*/
+ {
+ dlt_daemon_find_multiple_context_and_send_log_level(sock,
+ daemon,
+ daemon_local,
+ 1,
+ apid,
+ DLT_ID_SIZE,
+ req->log_level,
+ verbose);
+ }
+ else if ((ctxtid_length != 0) && (ctid[ctxtid_length - 1] != '*') && (apid[0] == 0)) /*only context id case*/
+ {
+ dlt_daemon_find_multiple_context_and_send_log_level(sock,
+ daemon,
+ daemon_local,
+ 0,
+ ctid,
+ DLT_ID_SIZE,
+ req->log_level,
+ verbose);
+ }
+ else {
context = dlt_daemon_context_find(daemon,
apid,
ctid,
@@ -1734,14 +1773,18 @@ void dlt_daemon_control_set_log_level(int sock, DltDaemon *daemon, DltDaemonLoca
verbose);
/* Set log level */
- if (context!=0)
- {
+ if (context != 0) {
dlt_daemon_send_log_level(sock, daemon, daemon_local, context, req->log_level, verbose);
}
- else
- {
- dlt_vlog(LOG_ERR, "Could not set log level: %d. Context [%.4s:%.4s] not found:", req->log_level, apid, ctid);
- dlt_daemon_control_service_response(sock, daemon, daemon_local, DLT_SERVICE_ID_SET_LOG_LEVEL, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ else {
+ dlt_vlog(LOG_ERR, "Could not set log level: %d. Context [%.4s:%.4s] not found:", req->log_level, apid,
+ ctid);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_SET_LOG_LEVEL,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
}
}
}
@@ -1763,12 +1806,10 @@ void dlt_daemon_send_trace_status(int sock,
context->trace_status = tracestatus; /* No endianess conversion necessary*/
if ((context->user_handle >= DLT_FD_MINIMUM) &&
- (dlt_daemon_user_send_log_level(daemon, context, verbose)==0))
- {
+ (dlt_daemon_user_send_log_level(daemon, context, verbose) == 0)) {
dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
}
- else
- {
+ else {
dlt_log(LOG_ERR, "Trace status could not be sent!\n");
context->trace_status = old_trace_status;
dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
@@ -1788,158 +1829,181 @@ void dlt_daemon_find_multiple_context_and_send_trace_status(int sock,
int count = 0;
DltDaemonContext *context = NULL;
- char src_str[DLT_ID_SIZE +1] = {0};
+ char src_str[DLT_ID_SIZE + 1] = { 0 };
int8_t ret = 0;
- DltDaemonRegisteredUsers* user_list = NULL;
+ DltDaemonRegisteredUsers *user_list = NULL;
- if (daemon == 0)
- {
+ if (daemon == 0) {
dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
return;
}
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return;
- }
- for (count = 0; count < user_list->num_contexts; count++)
- {
+ for (count = 0; count < user_list->num_contexts; count++) {
context = &(user_list->contexts[count]);
- if (context)
- {
+ if (context) {
if (app_flag == 1)
- {
strncpy(src_str, context->apid, DLT_ID_SIZE);
- }
else
- {
strncpy(src_str, context->ctid, DLT_ID_SIZE);
- }
+
ret = strncmp(src_str, str, len);
+
if (ret == 0)
- {
dlt_daemon_send_trace_status(sock, daemon, daemon_local, context, tracestatus, verbose);
- }
else if ((ret > 0) && (app_flag == 1))
- {
break;
- }
else
- {
continue;
- }
}
}
}
-void dlt_daemon_control_set_trace_status(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose)
+void dlt_daemon_control_set_trace_status(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
- char apid[DLT_ID_SIZE+1] = {0};
- char ctid[DLT_ID_SIZE+1] = {0};
+ char apid[DLT_ID_SIZE + 1] = { 0 };
+ char ctid[DLT_ID_SIZE + 1] = { 0 };
DltServiceSetLogLevel *req = NULL;
DltDaemonContext *context = NULL;
int8_t appid_length = 0;
int8_t ctxtid_length = 0;
if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
- {
return;
- }
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize, sizeof(DltServiceSetLogLevel)) < 0)
- {
return;
- }
- req = (DltServiceSetLogLevel*) (msg->databuffer);
+ req = (DltServiceSetLogLevel *)(msg->databuffer);
+
if (daemon_local->flags.enforceContextLLAndTS)
- {
req->log_level = getStatus(req->log_level, daemon_local->flags.contextTraceStatus);
- }
dlt_set_id(apid, req->apid);
dlt_set_id(ctid, req->ctid);
appid_length = strlen(apid);
ctxtid_length = strlen(ctid);
- if ((appid_length != 0) && (apid[appid_length-1] == '*') && (ctid[0] == 0)) /*appid provided having '*' in it and ctid is null*/
- {
- dlt_daemon_find_multiple_context_and_send_trace_status(sock, daemon, daemon_local, 1, apid, appid_length-1, req->log_level, verbose);
- }
- else if ((ctxtid_length != 0) && (ctid[ctxtid_length-1] == '*') && (apid[0] == 0)) /*ctid provided is having '*' in it and appid is null*/
- {
- dlt_daemon_find_multiple_context_and_send_trace_status(sock, daemon, daemon_local, 0, ctid, ctxtid_length-1, req->log_level, verbose);
- }
- else if ((appid_length != 0) && (apid[appid_length-1] != '*') && (ctid[0] == 0)) /*only app id case*/
- {
- dlt_daemon_find_multiple_context_and_send_trace_status(sock, daemon, daemon_local, 1, apid, DLT_ID_SIZE, req->log_level, verbose);
- }
- else if ((ctxtid_length != 0) && (ctid[ctxtid_length-1] != '*') && (apid[0] == 0)) /*only context id case*/
- {
- dlt_daemon_find_multiple_context_and_send_trace_status(sock, daemon, daemon_local, 0, ctid, DLT_ID_SIZE, req->log_level, verbose);
- }
- else
- {
- context=dlt_daemon_context_find(daemon, apid, ctid, daemon->ecuid, verbose);
+ if ((appid_length != 0) && (apid[appid_length - 1] == '*') && (ctid[0] == 0)) { /*appid provided having '*' in it and ctid is null*/
+ dlt_daemon_find_multiple_context_and_send_trace_status(sock,
+ daemon,
+ daemon_local,
+ 1,
+ apid,
+ appid_length - 1,
+ req->log_level,
+ verbose);
+ }
+ else if ((ctxtid_length != 0) && (ctid[ctxtid_length - 1] == '*') && (apid[0] == 0)) /*ctid provided is having '*' in it and appid is null*/
+
+ {
+ dlt_daemon_find_multiple_context_and_send_trace_status(sock,
+ daemon,
+ daemon_local,
+ 0,
+ ctid,
+ ctxtid_length - 1,
+ req->log_level,
+ verbose);
+ }
+ else if ((appid_length != 0) && (apid[appid_length - 1] != '*') && (ctid[0] == 0)) /*only app id case*/
+ {
+ dlt_daemon_find_multiple_context_and_send_trace_status(sock,
+ daemon,
+ daemon_local,
+ 1,
+ apid,
+ DLT_ID_SIZE,
+ req->log_level,
+ verbose);
+ }
+ else if ((ctxtid_length != 0) && (ctid[ctxtid_length - 1] != '*') && (apid[0] == 0)) /*only context id case*/
+ {
+ dlt_daemon_find_multiple_context_and_send_trace_status(sock,
+ daemon,
+ daemon_local,
+ 0,
+ ctid,
+ DLT_ID_SIZE,
+ req->log_level,
+ verbose);
+ }
+ else {
+ context = dlt_daemon_context_find(daemon, apid, ctid, daemon->ecuid, verbose);
/* Set trace status */
- if (context!=0)
- {
+ if (context != 0) {
dlt_daemon_send_trace_status(sock, daemon, daemon_local, context, req->log_level, verbose);
}
- else
- {
- dlt_vlog(LOG_ERR, "Could not set trace status: %d. Context [%.4s:%.4s] not found:", req->log_level, apid, ctid);
- dlt_daemon_control_service_response(sock, daemon, daemon_local, DLT_SERVICE_ID_SET_LOG_LEVEL, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ else {
+ dlt_vlog(LOG_ERR,
+ "Could not set trace status: %d. Context [%.4s:%.4s] not found:",
+ req->log_level,
+ apid,
+ ctid);
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_SET_LOG_LEVEL,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
}
}
}
-void dlt_daemon_control_set_default_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose)
+void dlt_daemon_control_set_default_log_level(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
DltServiceSetDefaultLogLevel *req;
- int32_t id=DLT_SERVICE_ID_SET_DEFAULT_LOG_LEVEL;
+ int32_t id = DLT_SERVICE_ID_SET_DEFAULT_LOG_LEVEL;
if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
- {
return;
- }
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize, sizeof(DltServiceSetDefaultLogLevel)) < 0)
- {
return;
- }
- req = (DltServiceSetDefaultLogLevel*) (msg->databuffer);
+ req = (DltServiceSetDefaultLogLevel *)(msg->databuffer);
/* No endianess conversion necessary */
if (/*(req->log_level>=0) &&*/
- (req->log_level<=DLT_LOG_VERBOSE))
- {
+ (req->log_level <= DLT_LOG_VERBOSE)) {
if (daemon_local->flags.enforceContextLLAndTS)
- daemon->default_log_level = getStatus(req->log_level, daemon_local->flags.contextLogLevel);
- else
- daemon->default_log_level = req->log_level; /* No endianess conversion necessary */
+ daemon->default_log_level = getStatus(req->log_level, daemon_local->flags.contextLogLevel);
+ else
+ daemon->default_log_level = req->log_level; /* No endianess conversion necessary */
/* Send Update to all contexts using the default log level */
dlt_daemon_user_send_default_update(daemon, verbose);
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
}
- else
- {
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ else {
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
}
}
-void dlt_daemon_control_set_all_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose)
+void dlt_daemon_control_set_all_log_level(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
@@ -1947,83 +2011,76 @@ void dlt_daemon_control_set_all_log_level(int sock, DltDaemon *daemon, DltDaemon
int32_t id = DLT_SERVICE_ID_SET_ALL_LOG_LEVEL;
int8_t loglevel = 0;
- if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
- {
+ if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL)) {
dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
return;
}
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize, sizeof(DltServiceSetDefaultLogLevel)) < 0)
- {
return;
- }
- req = (DltServiceSetDefaultLogLevel*) (msg->databuffer);
+ req = (DltServiceSetDefaultLogLevel *)(msg->databuffer);
/* No endianess conversion necessary */
- if ((req != NULL) && ((req->log_level <= DLT_LOG_VERBOSE) || (req->log_level == (uint8_t)DLT_LOG_DEFAULT)))
- {
+ if ((req != NULL) && ((req->log_level <= DLT_LOG_VERBOSE) || (req->log_level == (uint8_t)DLT_LOG_DEFAULT))) {
if (daemon_local->flags.enforceContextLLAndTS)
- {
loglevel = getStatus(req->log_level, daemon_local->flags.contextLogLevel);
- }
else
- {
loglevel = req->log_level; /* No endianess conversion necessary */
- }
/* Send Update to all contexts using the new log level */
dlt_daemon_user_send_all_log_level_update(daemon, loglevel, verbose);
dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
}
- else
- {
+ else {
dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
}
}
-void dlt_daemon_control_set_default_trace_status(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose)
+void dlt_daemon_control_set_default_trace_status(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
/* Payload of request message */
DltServiceSetDefaultLogLevel *req;
- int32_t id=DLT_SERVICE_ID_SET_DEFAULT_TRACE_STATUS;
+ int32_t id = DLT_SERVICE_ID_SET_DEFAULT_TRACE_STATUS;
if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
- {
return;
- }
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize, sizeof(DltServiceSetDefaultLogLevel)) < 0)
- {
return;
- }
- req = (DltServiceSetDefaultLogLevel*) (msg->databuffer);
+ req = (DltServiceSetDefaultLogLevel *)(msg->databuffer);
/* No endianess conversion necessary */
- if ((req->log_level==DLT_TRACE_STATUS_OFF) ||
- (req->log_level==DLT_TRACE_STATUS_ON))
- {
+ if ((req->log_level == DLT_TRACE_STATUS_OFF) ||
+ (req->log_level == DLT_TRACE_STATUS_ON)) {
if (daemon_local->flags.enforceContextLLAndTS)
- daemon->default_trace_status = getStatus(req->log_level, daemon_local->flags.contextTraceStatus);
- else
- daemon->default_trace_status = req->log_level; /* No endianess conversion necessary*/
+ daemon->default_trace_status = getStatus(req->log_level, daemon_local->flags.contextTraceStatus);
+ else
+ daemon->default_trace_status = req->log_level; /* No endianess conversion necessary*/
/* Send Update to all contexts using the default trace status */
dlt_daemon_user_send_default_update(daemon, verbose);
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
}
- else
- {
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ else {
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
}
}
-void dlt_daemon_control_set_all_trace_status(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose)
+void dlt_daemon_control_set_all_trace_status(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
@@ -2031,131 +2088,121 @@ void dlt_daemon_control_set_all_trace_status(int sock, DltDaemon *daemon, DltDae
int32_t id = DLT_SERVICE_ID_SET_ALL_TRACE_STATUS;
int8_t tracestatus = 0;
- if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
- {
+ if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL)) {
dlt_vlog(LOG_ERR, "%s: Invalid parameters\n", __func__);
return;
}
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize, sizeof(DltServiceSetDefaultLogLevel)) < 0)
- {
return;
- }
- req = (DltServiceSetDefaultLogLevel*) (msg->databuffer);
+ req = (DltServiceSetDefaultLogLevel *)(msg->databuffer);
/* No endianess conversion necessary */
- if ((req != NULL) && ((req->log_level <= DLT_TRACE_STATUS_ON) || (req->log_level == (uint8_t)DLT_TRACE_STATUS_DEFAULT)))
- {
+ if ((req != NULL) &&
+ ((req->log_level <= DLT_TRACE_STATUS_ON) || (req->log_level == (uint8_t)DLT_TRACE_STATUS_DEFAULT))) {
if (daemon_local->flags.enforceContextLLAndTS)
- {
tracestatus = getStatus(req->log_level, daemon_local->flags.contextTraceStatus);
- }
else
- {
tracestatus = req->log_level; /* No endianess conversion necessary */
- }
/* Send Update to all contexts using the new log level */
dlt_daemon_user_send_all_trace_status_update(daemon, tracestatus, verbose);
dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
}
- else
- {
+ else {
dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
}
}
-void dlt_daemon_control_set_timing_packets(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose)
+void dlt_daemon_control_set_timing_packets(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
DltServiceSetVerboseMode *req; /* request uses same struct as set verbose mode */
- int32_t id=DLT_SERVICE_ID_SET_TIMING_PACKETS;
+ int32_t id = DLT_SERVICE_ID_SET_TIMING_PACKETS;
if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL))
- {
return;
- }
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize, sizeof(DltServiceSetVerboseMode)) < 0)
- {
return;
- }
- req = (DltServiceSetVerboseMode*) (msg->databuffer);
- if ((req->new_status==0) || (req->new_status==1))
- {
+ req = (DltServiceSetVerboseMode *)(msg->databuffer);
+
+ if ((req->new_status == 0) || (req->new_status == 1)) {
daemon->timingpackets = req->new_status;
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose);
}
- else
- {
- dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
+ else {
+ dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose);
}
}
void dlt_daemon_control_message_time(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
{
- int ret;
+ int ret;
DltMessage msg;
int32_t len;
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon==0)
- {
+ if (daemon == 0)
return;
- }
/* initialise new message */
- if (dlt_message_init(&msg,0) == DLT_RETURN_ERROR)
- {
+ if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
return;
- }
/* send message */
/* prepare storage header */
- msg.storageheader = (DltStorageHeader*)msg.headerbuffer;
- dlt_set_storageheader(msg.storageheader,daemon->ecuid);
+ msg.storageheader = (DltStorageHeader *)msg.headerbuffer;
+ dlt_set_storageheader(msg.storageheader, daemon->ecuid);
/* prepare standard header */
- msg.standardheader = (DltStandardHeader*)(msg.headerbuffer + sizeof(DltStorageHeader));
- msg.standardheader->htyp = DLT_HTYP_WEID | DLT_HTYP_WTMS | DLT_HTYP_UEH | DLT_HTYP_PROTOCOL_VERSION1 ;
+ msg.standardheader = (DltStandardHeader *)(msg.headerbuffer + sizeof(DltStorageHeader));
+ msg.standardheader->htyp = DLT_HTYP_WEID | DLT_HTYP_WTMS | DLT_HTYP_UEH | DLT_HTYP_PROTOCOL_VERSION1;
-#if (BYTE_ORDER==BIG_ENDIAN)
- msg.standardheader->htyp = ( msg.standardheader->htyp | DLT_HTYP_MSBF);
+#if (BYTE_ORDER == BIG_ENDIAN)
+ msg.standardheader->htyp = (msg.standardheader->htyp | DLT_HTYP_MSBF);
#endif
msg.standardheader->mcnt = 0;
/* Set header extra parameters */
- dlt_set_id(msg.headerextra.ecu,daemon->ecuid);
+ dlt_set_id(msg.headerextra.ecu, daemon->ecuid);
msg.headerextra.tmsp = dlt_uptime();
dlt_message_set_extraparameters(&msg, verbose);
/* prepare extended header */
- msg.extendedheader = (DltExtendedHeader*)(msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp));
+ msg.extendedheader =
+ (DltExtendedHeader *)(msg.headerbuffer + sizeof(DltStorageHeader) + sizeof(DltStandardHeader) +
+ DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp));
msg.extendedheader->msin = DLT_MSIN_CONTROL_TIME;
msg.extendedheader->noar = 0; /* number of arguments */
- dlt_set_id(msg.extendedheader->apid,""); /* application id */
- dlt_set_id(msg.extendedheader->ctid,""); /* context id */
+ dlt_set_id(msg.extendedheader->apid, ""); /* application id */
+ dlt_set_id(msg.extendedheader->ctid, ""); /* context id */
/* prepare length information */
- msg.headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) + DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp);
+ msg.headersize = sizeof(DltStorageHeader) + sizeof(DltStandardHeader) + sizeof(DltExtendedHeader) +
+ DLT_STANDARD_HEADER_EXTRA_SIZE(msg.standardheader->htyp);
- len=msg.headersize - sizeof(DltStorageHeader) + msg.datasize;
- if (len>UINT16_MAX)
- {
- dlt_log(LOG_WARNING,"Huge control message discarded!\n");
+ len = msg.headersize - sizeof(DltStorageHeader) + msg.datasize;
+
+ if (len > UINT16_MAX) {
+ dlt_log(LOG_WARNING, "Huge control message discarded!\n");
/* free message */
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
return;
}
@@ -2163,14 +2210,14 @@ void dlt_daemon_control_message_time(int sock, DltDaemon *daemon, DltDaemonLocal
msg.standardheader->len = DLT_HTOBE_16(((uint16_t)len));
/* Send message */
- if((ret = dlt_daemon_client_send(sock,daemon,daemon_local,msg.headerbuffer,sizeof(DltStorageHeader),msg.headerbuffer+sizeof(DltStorageHeader),msg.headersize-sizeof(DltStorageHeader),
- msg.databuffer,msg.datasize,verbose)))
- {
-
- }
+ if ((ret =
+ dlt_daemon_client_send(sock, daemon, daemon_local, msg.headerbuffer, sizeof(DltStorageHeader),
+ msg.headerbuffer + sizeof(DltStorageHeader),
+ msg.headersize - sizeof(DltStorageHeader),
+ msg.databuffer, msg.datasize, verbose))) {}
/* free message */
- dlt_message_free(&msg,0);
+ dlt_message_free(&msg, 0);
}
int dlt_daemon_process_one_s_timer(DltDaemon *daemon,
@@ -2184,8 +2231,7 @@ int dlt_daemon_process_one_s_timer(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL))
- {
+ if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"%s: invalid parameters",
@@ -2196,36 +2242,30 @@ int dlt_daemon_process_one_s_timer(DltDaemon *daemon,
res = read(receiver->fd, &expir, sizeof(expir));
- if(res < 0)
- {
+ if (res < 0) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"%s: Fail to read timer (%s)\n", __func__, strerror(errno));
dlt_log(LOG_WARNING, str);
/* Activity received on timer_wd, but unable to read the fd:
- let's go on sending notification */
+ * let's go on sending notification */
}
- if((daemon->state == DLT_DAEMON_STATE_SEND_BUFFER) ||
- (daemon->state == DLT_DAEMON_STATE_BUFFER_FULL))
- {
+ if ((daemon->state == DLT_DAEMON_STATE_SEND_BUFFER) ||
+ (daemon->state == DLT_DAEMON_STATE_BUFFER_FULL)) {
if (dlt_daemon_send_ringbuffer_to_client(daemon,
daemon_local,
daemon_local->flags.vflag))
- {
dlt_log(LOG_DEBUG,
"Can't send contents of ring buffer to clients\n");
- }
}
- if((daemon->timingpackets) &&
- (daemon->state == DLT_DAEMON_STATE_SEND_DIRECT))
- {
+ if ((daemon->timingpackets) &&
+ (daemon->state == DLT_DAEMON_STATE_SEND_DIRECT))
dlt_daemon_control_message_time(DLT_DAEMON_SEND_TO_ALL,
daemon,
daemon_local,
daemon_local->flags.vflag);
- }
dlt_log(LOG_DEBUG, "Timer timingpacket\n");
@@ -2243,8 +2283,7 @@ int dlt_daemon_process_sixty_s_timer(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL))
- {
+ if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
snprintf(str,
DLT_DAEMON_TEXTBUFSIZE,
"%s: invalid parameters",
@@ -2255,32 +2294,28 @@ int dlt_daemon_process_sixty_s_timer(DltDaemon *daemon,
res = read(receiver->fd, &expir, sizeof(expir));
- if(res < 0)
- {
+ if (res < 0) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"%s: Fail to read timer (%s)\n", __func__, strerror(errno));
dlt_log(LOG_WARNING, str);
/* Activity received on timer_wd, but unable to read the fd:
- let's go on sending notification */
+ * let's go on sending notification */
}
- if(daemon_local->flags.sendECUSoftwareVersion > 0)
- {
+ if (daemon_local->flags.sendECUSoftwareVersion > 0)
dlt_daemon_control_get_software_version(DLT_DAEMON_SEND_TO_ALL,
daemon,
daemon_local,
daemon_local->flags.vflag);
- }
- if(daemon_local->flags.sendTimezone > 0)
- {
- // send timezone information
+ if (daemon_local->flags.sendTimezone > 0) {
+ /* send timezone information */
time_t t = time(NULL);
struct tm lt;
/*Added memset to avoid compiler warning for near initialization */
- memset((void*)&lt, 0, sizeof(lt));
+ memset((void *)&lt, 0, sizeof(lt));
localtime_r(&t, &lt);
dlt_daemon_control_message_timezone(DLT_DAEMON_SEND_TO_ALL,
@@ -2306,8 +2341,7 @@ int dlt_daemon_process_systemd_timer(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
- if((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL))
- {
+ if ((daemon_local == NULL) || (daemon == NULL) || (receiver == NULL)) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"%s: invalid parameters",
@@ -2318,21 +2352,18 @@ int dlt_daemon_process_systemd_timer(DltDaemon *daemon,
res = read(receiver->fd, &expir, sizeof(expir));
- if(res < 0)
- {
+ if (res < 0) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Failed to read timer_wd; %s\n",
strerror(errno));
dlt_log(LOG_WARNING, local_str);
/* Activity received on timer_wd, but unable to read the fd:
- let's go on sending notification */
+ * let's go on sending notification */
}
- if(sd_notify(0, "WATCHDOG=1") < 0)
- {
+ if (sd_notify(0, "WATCHDOG=1") < 0)
dlt_log(LOG_CRIT, "Could not reset systemd watchdog\n");
- }
dlt_log(LOG_DEBUG, "Timer watchdog\n");
@@ -2370,16 +2401,14 @@ void dlt_daemon_control_service_logstorage(int sock,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (msg == NULL) || (daemon_local == NULL))
- {
+ if ((daemon == NULL) || (msg == NULL) || (daemon_local == NULL)) {
dlt_vlog(LOG_ERR,
"%s: Invalid function parameters\n",
__func__);
- return ;
+ return;
}
- if ((daemon_local->flags.offlineLogstorageMaxDevices <= 0) || (msg->databuffer == NULL))
- {
+ if ((daemon_local->flags.offlineLogstorageMaxDevices <= 0) || (msg->databuffer == NULL)) {
dlt_daemon_control_service_response(sock,
daemon,
daemon_local,
@@ -2393,19 +2422,16 @@ void dlt_daemon_control_service_logstorage(int sock,
}
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize, sizeof(DltServiceOfflineLogstorage)) < 0)
- {
return;
- }
- req = (DltServiceOfflineLogstorage*) (msg->databuffer);
+ req = (DltServiceOfflineLogstorage *)(msg->databuffer);
- for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++)
- {
+ for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++) {
connection_type = daemon->storage_handle[i].connection_type;
+
/* Check if the requested device path is already used as log storage device */
if (strncmp(daemon->storage_handle[i].device_mount_point,
- req->mount_point, strlen(req->mount_point)) == 0)
- {
+ req->mount_point, strlen(req->mount_point)) == 0) {
device_index = i;
break;
}
@@ -2413,41 +2439,33 @@ void dlt_daemon_control_service_logstorage(int sock,
/* Get first available device index here */
if ((connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) &&
(device_index == -1))
- {
device_index = i;
- }
}
/* It might be possible to sync all caches of all devices */
if ((req->connection_type == DLT_OFFLINE_LOGSTORAGE_SYNC_CACHES) &&
- (strlen(req->mount_point) == 0))
- {
+ (strlen(req->mount_point) == 0)) {
/* It is expected to receive an empty mount point to sync all Logstorage
* devices in this case. */
}
- else
- {
- if (device_index == -1)
- {
- dlt_daemon_control_service_response(sock,
- daemon,
- daemon_local,
- DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
- DLT_SERVICE_RESPONSE_ERROR,
- verbose);
- dlt_log(LOG_WARNING, "MAX devices already in use \n");
- return;
- }
+ else if (device_index == -1) {
+ dlt_daemon_control_service_response(sock,
+ daemon,
+ daemon_local,
+ DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
+ DLT_SERVICE_RESPONSE_ERROR,
+ verbose);
+ dlt_log(LOG_WARNING, "MAX devices already in use \n");
+ return;
}
/* Check for device connection request from log storage ctrl app */
device = &daemon->storage_handle[device_index];
- if (req->connection_type == DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED)
- {
+
+ if (req->connection_type == DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) {
ret = dlt_logstorage_device_connected(device, req->mount_point);
- if (ret == 1)
- {
+ if (ret == 1) {
dlt_daemon_control_service_response(sock,
daemon,
daemon_local,
@@ -2482,15 +2500,15 @@ void dlt_daemon_control_service_logstorage(int sock,
}
/* Check for device disconnection request from log storage ctrl app */
- else if(req->connection_type == DLT_OFFLINE_LOGSTORAGE_DEVICE_DISCONNECTED)
+ else if (req->connection_type == DLT_OFFLINE_LOGSTORAGE_DEVICE_DISCONNECTED)
{
/* Check if log level of running application needs to be reset */
dlt_daemon_logstorage_reset_application_loglevel(
- daemon,
- daemon_local,
- device_index,
- daemon_local->flags.offlineLogstorageMaxDevices,
- verbose);
+ daemon,
+ daemon_local,
+ device_index,
+ daemon_local->flags.offlineLogstorageMaxDevices,
+ verbose);
dlt_logstorage_device_disconnected(&(daemon->storage_handle[device_index]),
DLT_LOGSTORAGE_SYNC_ON_DEVICE_DISCONNECT);
@@ -2504,54 +2522,45 @@ void dlt_daemon_control_service_logstorage(int sock,
}
/* Check for cache synchronization request from log storage ctrl app */
- else if(req->connection_type == DLT_OFFLINE_LOGSTORAGE_SYNC_CACHES)
+ else if (req->connection_type == DLT_OFFLINE_LOGSTORAGE_SYNC_CACHES)
{
int ret = 0;
- if (device_index == -1) /* sync all Logstorage devices */
- {
+
+ if (device_index == -1) { /* sync all Logstorage devices */
+
for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++)
- {
if (daemon->storage_handle[i].connection_type ==
DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED)
- {
ret = dlt_daemon_logstorage_sync_cache(
- daemon,
- daemon_local,
- daemon->storage_handle[i].device_mount_point,
- verbose);
- }
- }
+ daemon,
+ daemon_local,
+ daemon->storage_handle[i].device_mount_point,
+ verbose);
}
- else
- {
+ else {
/* trigger logstorage to sync caches */
ret = dlt_daemon_logstorage_sync_cache(daemon,
- daemon_local,
- req->mount_point,
- verbose);
+ daemon_local,
+ req->mount_point,
+ verbose);
}
if (ret == 0)
- {
dlt_daemon_control_service_response(sock,
daemon,
daemon_local,
DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
DLT_SERVICE_RESPONSE_OK,
verbose);
- }
else
- {
dlt_daemon_control_service_response(sock,
daemon,
daemon_local,
DLT_SERVICE_ID_OFFLINE_LOGSTORAGE,
DLT_SERVICE_RESPONSE_ERROR,
verbose);
- }
}
- else
- {
+ else {
dlt_daemon_control_service_response(sock,
daemon,
daemon_local,
@@ -2572,15 +2581,12 @@ void dlt_daemon_control_passive_node_connect(int sock,
DltServicePassiveNodeConnect *req;
uint32_t id = DLT_SERVICE_ID_PASSIVE_NODE_CONNECT;
- if (daemon == NULL || daemon_local == NULL || msg == NULL ||
- msg->databuffer == NULL)
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (msg == NULL) ||
+ (msg->databuffer == NULL))
return;
- }
/* return error, if gateway mode not enabled*/
- if (daemon_local->flags.gatewayMode == 0)
- {
+ if (daemon_local->flags.gatewayMode == 0) {
dlt_log(LOG_WARNING,
"Received passive node connection status request, "
"but GatewayMode is disabled\n");
@@ -2597,34 +2603,28 @@ void dlt_daemon_control_passive_node_connect(int sock,
}
if (DLT_CHECK_RCV_DATA_SIZE(msg->datasize, sizeof(DltServicePassiveNodeConnect)) < 0)
- {
return;
- }
- req = (DltServicePassiveNodeConnect *) msg->databuffer;
+ req = (DltServicePassiveNodeConnect *)msg->databuffer;
if (dlt_gateway_process_on_demand_request(&daemon_local->pGateway,
daemon_local,
req->node_id,
req->connection_status,
verbose) < 0)
- {
dlt_daemon_control_service_response(sock,
daemon,
daemon_local,
id,
DLT_SERVICE_RESPONSE_ERROR,
verbose);
- }
else
- {
dlt_daemon_control_service_response(sock,
daemon,
daemon_local,
id,
DLT_SERVICE_RESPONSE_OK,
verbose);
- }
}
void dlt_daemon_control_passive_node_connect_status(int sock,
@@ -2639,19 +2639,14 @@ void dlt_daemon_control_passive_node_connect_status(int sock,
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon == NULL || daemon_local == NULL)
- {
+ if ((daemon == NULL) || (daemon_local == NULL))
return;
- }
if (dlt_message_init(&msg, verbose) == -1)
- {
return;
- }
/* return error, if gateway mode not enabled*/
- if (daemon_local->flags.gatewayMode == 0)
- {
+ if (daemon_local->flags.gatewayMode == 0) {
dlt_log(LOG_WARNING,
"Received passive node connection status request, "
"but GatewayMode is disabled\n");
@@ -2669,39 +2664,37 @@ void dlt_daemon_control_passive_node_connect_status(int sock,
/* prepare payload of data */
msg.datasize = sizeof(DltServicePassiveNodeConnectionInfo);
+
if (msg.databuffer && (msg.databuffersize < msg.datasize))
- {
msg.databuffer = NULL;
- }
- if (msg.databuffer == NULL)
- {
- msg.databuffer = (uint8_t *) malloc(msg.datasize);
- if (msg.databuffer == NULL)
- {
+
+ if (msg.databuffer == NULL) {
+ msg.databuffer = (uint8_t *)malloc(msg.datasize);
+
+ if (msg.databuffer == NULL) {
dlt_log(LOG_CRIT, "Cannot allocate memory for message response\n");
return;
}
+
msg.databuffersize = msg.datasize;
}
- resp = (DltServicePassiveNodeConnectionInfo *) msg.databuffer;
+ resp = (DltServicePassiveNodeConnectionInfo *)msg.databuffer;
memset(resp, 0, msg.datasize);
resp->service_id = DLT_SERVICE_ID_PASSIVE_NODE_CONNECTION_STATUS;
resp->status = DLT_SERVICE_RESPONSE_OK;
resp->num_connections = daemon_local->pGateway.num_connections;
- for (i = 0; i < resp->num_connections; i++)
- {
- if ((i * DLT_ID_SIZE) > DLT_ENTRY_MAX)
- {
+ for (i = 0; i < resp->num_connections; i++) {
+ if ((i * DLT_ID_SIZE) > DLT_ENTRY_MAX) {
dlt_log(LOG_ERR,
"Maximal message size reached. Skip further information\n");
break;
}
con = &daemon_local->pGateway.connections[i];
- if (con == NULL)
- {
+
+ if (con == NULL) {
dlt_log(LOG_CRIT, "Passive node connection structure is NULL\n");
dlt_daemon_control_service_response(
sock,
diff --git a/src/daemon/dlt_daemon_client.h b/src/daemon/dlt_daemon_client.h
index b974b67..8406608 100644
--- a/src/daemon/dlt_daemon_client.h
+++ b/src/daemon/dlt_daemon_client.h
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt_daemon_client.h
-*/
+ */
/*******************************************************************************
@@ -89,7 +89,16 @@ int dlt_daemon_client_send_all(DltDaemon *daemon, DltDaemonLocal *daemon_local,
* @param verbose if set to true verbose information is printed out.
* @return unequal 0 if there is an error or buffer is full
*/
-int dlt_daemon_client_send(int sock,DltDaemon *daemon,DltDaemonLocal *daemon_local,void* storage_header,int storage_header_size,void* data1,int size1,void* data2,int size2,int verbose);
+int dlt_daemon_client_send(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ void *storage_header,
+ int storage_header_size,
+ void *data1,
+ int size1,
+ void *data2,
+ int size2,
+ int verbose);
/**
* Send out response message to dlt client
@@ -102,7 +111,13 @@ int dlt_daemon_client_send(int sock,DltDaemon *daemon,DltDaemonLocal *daemon_loc
* @param verbose if set to true verbose information is printed out.
* @return -1 if there is an error or buffer is full
*/
-int dlt_daemon_client_send_control_message(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, char* appid, char* contid, int verbose);
+int dlt_daemon_client_send_control_message(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ char *appid,
+ char *contid,
+ int verbose);
/**
* Process and generate response to received get log info control message
* @param sock connection handle used for sending response
@@ -111,7 +126,11 @@ int dlt_daemon_client_send_control_message(int sock, DltDaemon *daemon, DltDaemo
* @param msg pointer to received control message
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_get_log_info(int sock, DltDaemon *daemon,DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+void dlt_daemon_control_get_log_info(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Process and generate response to received get software version control message
* @param sock connection handle used for sending response
@@ -136,7 +155,12 @@ void dlt_daemon_control_get_default_log_level(int sock, DltDaemon *daemon, DltDa
* @param verbose if set to true verbose information is printed out.
* @return -1 if there is an error or buffer overflow, else 0
*/
-int dlt_daemon_control_message_buffer_overflow(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, unsigned int overflow_counter,char* apid, int verbose);
+int dlt_daemon_control_message_buffer_overflow(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ unsigned int overflow_counter,
+ char *apid,
+ int verbose);
/**
* Generate response to control message from dlt client
* @param sock connection handle used for sending response
@@ -146,7 +170,12 @@ int dlt_daemon_control_message_buffer_overflow(int sock, DltDaemon *daemon, DltD
* @param status status of response (e.g. ok, not supported, error)
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_service_response(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, uint32_t service_id, int8_t status, int verbose);
+void dlt_daemon_control_service_response(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ uint32_t service_id,
+ int8_t status,
+ int verbose);
/**
* Send control message unregister context (add on to AUTOSAR standard)
* @param sock connection handle used for sending response
@@ -157,7 +186,13 @@ void dlt_daemon_control_service_response(int sock, DltDaemon *daemon, DltDaemonL
* @param comid Communication id where apid is unregistered
* @param verbose if set to true verbose information is printed out.
*/
-int dlt_daemon_control_message_unregister_context(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, char* apid, char* ctid, char* comid, int verbose);
+int dlt_daemon_control_message_unregister_context(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ char *apid,
+ char *ctid,
+ char *comid,
+ int verbose);
/**
* Send control message connection info (add on to AUTOSAR standard)
* @param sock connection handle used for sending response
@@ -167,7 +202,12 @@ int dlt_daemon_control_message_unregister_context(int sock, DltDaemon *daemon, D
* @param comid Communication id where connection state changed
* @param verbose if set to true verbose information is printed out.
*/
-int dlt_daemon_control_message_connection_info(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, uint8_t state, char* comid, int verbose);
+int dlt_daemon_control_message_connection_info(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ uint8_t state,
+ char *comid,
+ int verbose);
/**
* Send control message timezone (add on to AUTOSAR standard)
* @param sock connection handle used for sending response
@@ -192,7 +232,11 @@ int dlt_daemon_control_message_marker(int sock, DltDaemon *daemon, DltDaemonLoca
* @param msg pointer to received control message
* @param verbose if set to true verbose information is printed out.
*/
-int dlt_daemon_client_process_control(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+int dlt_daemon_client_process_control(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Process and generate response to received sw injection control message
* @param sock connection handle used for sending response
@@ -201,7 +245,11 @@ int dlt_daemon_client_process_control(int sock, DltDaemon *daemon, DltDaemonLoca
* @param msg pointer to received sw injection control message
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_callsw_cinjection(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+void dlt_daemon_control_callsw_cinjection(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Process and generate response to received set log level control message
* @param sock connection handle used for sending response
@@ -210,7 +258,11 @@ void dlt_daemon_control_callsw_cinjection(int sock, DltDaemon *daemon, DltDaemon
* @param msg pointer to received control message
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_set_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+void dlt_daemon_control_set_log_level(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Process and generate response to received set trace status control message
* @param sock connection handle used for sending response
@@ -219,7 +271,11 @@ void dlt_daemon_control_set_log_level(int sock, DltDaemon *daemon, DltDaemonLoca
* @param msg pointer to received control message
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_set_trace_status(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+void dlt_daemon_control_set_trace_status(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Process and generate response to received set default log level control message
* @param sock connection handle used for sending response
@@ -228,7 +284,11 @@ void dlt_daemon_control_set_trace_status(int sock, DltDaemon *daemon, DltDaemonL
* @param msg pointer to received control message
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_set_default_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+void dlt_daemon_control_set_default_log_level(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Process and generate response to received set all log level control message
* @param sock connection handle used for sending response
@@ -237,7 +297,11 @@ void dlt_daemon_control_set_default_log_level(int sock, DltDaemon *daemon, DltDa
* @param msg pointer to received control message
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_set_all_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+void dlt_daemon_control_set_all_log_level(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Process and generate response to received set default trace status control message
@@ -247,7 +311,11 @@ void dlt_daemon_control_set_all_log_level(int sock, DltDaemon *daemon, DltDaemon
* @param msg pointer to received control message
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_set_default_trace_status(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+void dlt_daemon_control_set_default_trace_status(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Process and generate response to received set all trace status control message
* @param sock connection handle used for sending response
@@ -256,7 +324,11 @@ void dlt_daemon_control_set_default_trace_status(int sock, DltDaemon *daemon, Dl
* @param msg pointer to received control message
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_set_all_trace_status(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+void dlt_daemon_control_set_all_trace_status(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Process and generate response to set timing packets control message
* @param sock connection handle used for sending response
@@ -265,7 +337,11 @@ void dlt_daemon_control_set_all_trace_status(int sock, DltDaemon *daemon, DltDae
* @param msg pointer to received control message
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_set_timing_packets(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+void dlt_daemon_control_set_timing_packets(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Send time control message
* @param sock connection handle used for sending response
@@ -282,7 +358,11 @@ void dlt_daemon_control_message_time(int sock, DltDaemon *daemon, DltDaemonLocal
* @param msg pointer to received control message
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_service_logstorage(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose);
+void dlt_daemon_control_service_logstorage(int sock,
+ DltDaemon *daemon,
+ DltDaemonLocal *daemon_local,
+ DltMessage *msg,
+ int verbose);
/**
* Process and generate response to received passive node connect control
diff --git a/src/daemon/dlt_daemon_common.c b/src/daemon/dlt_daemon_common.c
index ce2de71..8508dfe 100644
--- a/src/daemon/dlt_daemon_common.c
+++ b/src/daemon/dlt_daemon_common.c
@@ -63,8 +63,8 @@
* $LastChangedRevision: 1670 $
* $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
* $LastChangedBy$
- Initials Date Comment
- aw 13.01.2010 initial
+ * Initials Date Comment
+ * aw 13.01.2010 initial
*/
#include <stdio.h>
@@ -94,37 +94,32 @@ sem_t dlt_daemon_mutex;
static int dlt_daemon_cmp_apid(const void *m1, const void *m2)
{
- if(m1 == NULL || m2 == NULL)
+ if ((m1 == NULL) || (m2 == NULL))
return -1;
- DltDaemonApplication *mi1 = (DltDaemonApplication *) m1;
- DltDaemonApplication *mi2 = (DltDaemonApplication *) m2;
+ DltDaemonApplication *mi1 = (DltDaemonApplication *)m1;
+ DltDaemonApplication *mi2 = (DltDaemonApplication *)m2;
return memcmp(mi1->apid, mi2->apid, DLT_ID_SIZE);
}
static int dlt_daemon_cmp_apid_ctid(const void *m1, const void *m2)
{
- if(m1 == NULL || m2 == NULL)
+ if ((m1 == NULL) || (m2 == NULL))
return -1;
int ret, cmp;
- DltDaemonContext *mi1 = (DltDaemonContext *) m1;
- DltDaemonContext *mi2 = (DltDaemonContext *) m2;
+ DltDaemonContext *mi1 = (DltDaemonContext *)m1;
+ DltDaemonContext *mi2 = (DltDaemonContext *)m2;
- cmp=memcmp(mi1->apid, mi2->apid, DLT_ID_SIZE);
- if (cmp<0)
- {
- ret=-1;
- }
- else if (cmp==0)
- {
- ret=memcmp(mi1->ctid, mi2->ctid, DLT_ID_SIZE);
- }
+ cmp = memcmp(mi1->apid, mi2->apid, DLT_ID_SIZE);
+
+ if (cmp < 0)
+ ret = -1;
+ else if (cmp == 0)
+ ret = memcmp(mi1->ctid, mi2->ctid, DLT_ID_SIZE);
else
- {
- ret=1;
- }
+ ret = 1;
return ret;
}
@@ -137,90 +132,89 @@ DltDaemonRegisteredUsers *dlt_daemon_find_users_list(DltDaemon *daemon,
int i = 0;
- if (daemon == NULL || ecu == NULL)
- {
+ if ((daemon == NULL) || (ecu == NULL)) {
dlt_vlog(LOG_ERR, "%s: Wrong parameters", __func__);
- return (DltDaemonRegisteredUsers *) NULL;
+ return (DltDaemonRegisteredUsers *)NULL;
}
for (i = 0; i < daemon->num_user_lists; i++)
- {
if (strncmp(ecu, daemon->user_list[i].ecu, DLT_ID_SIZE) == 0)
- {
return &daemon->user_list[i];
- }
- }
dlt_vlog(LOG_ERR, "Cannot find user list for ECU: %4s\n", ecu);
- return (DltDaemonRegisteredUsers *) NULL;
+ return (DltDaemonRegisteredUsers *)NULL;
}
-int dlt_daemon_load_runtime_configuration(DltDaemon *daemon,const char *runtime_directory, int verbose)
+int dlt_daemon_load_runtime_configuration(DltDaemon *daemon, const char *runtime_directory, int verbose)
{
int append_length = 0;
- if (daemon == NULL || runtime_directory == NULL)
- {
+ if ((daemon == NULL) || (runtime_directory == NULL))
return DLT_RETURN_ERROR;
- }
/* prepare filenames for configuration */
append_length = PATH_MAX - sizeof(DLT_RUNTIME_APPLICATION_CFG);
- if(runtime_directory[0])
- {
- strncpy(daemon->runtime_application_cfg,runtime_directory,append_length);
- daemon->runtime_application_cfg[append_length]=0;
+
+ if (runtime_directory[0]) {
+ strncpy(daemon->runtime_application_cfg, runtime_directory, append_length);
+ daemon->runtime_application_cfg[append_length] = 0;
}
- else
- {
- strncpy(daemon->runtime_application_cfg,DLT_RUNTIME_DEFAULT_DIRECTORY,append_length);
- daemon->runtime_application_cfg[append_length]=0;
+ else {
+ strncpy(daemon->runtime_application_cfg, DLT_RUNTIME_DEFAULT_DIRECTORY, append_length);
+ daemon->runtime_application_cfg[append_length] = 0;
}
- strcat(daemon->runtime_application_cfg,DLT_RUNTIME_APPLICATION_CFG); /* strcat uncritical here, because max length already checked */
+
+ strcat(daemon->runtime_application_cfg, DLT_RUNTIME_APPLICATION_CFG); /* strcat uncritical here, because max length already checked */
append_length = PATH_MAX - sizeof(DLT_RUNTIME_CONTEXT_CFG);
- if(runtime_directory[0])
- {
- strncpy(daemon->runtime_context_cfg,runtime_directory,append_length);
- daemon->runtime_context_cfg[append_length]=0;
+
+ if (runtime_directory[0]) {
+ strncpy(daemon->runtime_context_cfg, runtime_directory, append_length);
+ daemon->runtime_context_cfg[append_length] = 0;
}
- else
- {
- strncpy(daemon->runtime_context_cfg,DLT_RUNTIME_DEFAULT_DIRECTORY,append_length);
- daemon->runtime_context_cfg[append_length]=0;
+ else {
+ strncpy(daemon->runtime_context_cfg, DLT_RUNTIME_DEFAULT_DIRECTORY, append_length);
+ daemon->runtime_context_cfg[append_length] = 0;
}
- strcat(daemon->runtime_context_cfg,DLT_RUNTIME_CONTEXT_CFG); /* strcat uncritical here, because max length already checked */
+
+ strcat(daemon->runtime_context_cfg, DLT_RUNTIME_CONTEXT_CFG); /* strcat uncritical here, because max length already checked */
append_length = PATH_MAX - sizeof(DLT_RUNTIME_CONFIGURATION);
- if(runtime_directory[0])
- {
- strncpy(daemon->runtime_configuration,runtime_directory,append_length);
- daemon->runtime_configuration[append_length]=0;
+
+ if (runtime_directory[0]) {
+ strncpy(daemon->runtime_configuration, runtime_directory, append_length);
+ daemon->runtime_configuration[append_length] = 0;
}
- else
- {
- strncpy(daemon->runtime_configuration,DLT_RUNTIME_DEFAULT_DIRECTORY,append_length);
- daemon->runtime_configuration[append_length]=0;
+ else {
+ strncpy(daemon->runtime_configuration, DLT_RUNTIME_DEFAULT_DIRECTORY, append_length);
+ daemon->runtime_configuration[append_length] = 0;
}
- strcat(daemon->runtime_configuration,DLT_RUNTIME_CONFIGURATION); /* strcat uncritical here, because max length already checked */
+
+ strcat(daemon->runtime_configuration, DLT_RUNTIME_CONFIGURATION); /* strcat uncritical here, because max length already checked */
/* Check for runtime cfg, if it is loadable, load it! */
- if ((dlt_daemon_applications_load(daemon,daemon->runtime_application_cfg, verbose)==0) &&
- (dlt_daemon_contexts_load(daemon,daemon->runtime_context_cfg, verbose)==0))
- {
+ if ((dlt_daemon_applications_load(daemon, daemon->runtime_application_cfg, verbose) == 0) &&
+ (dlt_daemon_contexts_load(daemon, daemon->runtime_context_cfg, verbose) == 0))
daemon->runtime_context_cfg_loaded = 1;
- }
/* load configuration if available */
- dlt_daemon_configuration_load(daemon,daemon->runtime_configuration, verbose);
+ dlt_daemon_configuration_load(daemon, daemon->runtime_configuration, verbose);
return DLT_RETURN_OK;
}
-int dlt_daemon_init(DltDaemon *daemon,unsigned long RingbufferMinSize,unsigned long RingbufferMaxSize,unsigned long RingbufferStepSize,const char *runtime_directory,int InitialContextLogLevel, int InitialContextTraceStatus, int ForceLLTS, int verbose)
+int dlt_daemon_init(DltDaemon *daemon,
+ unsigned long RingbufferMinSize,
+ unsigned long RingbufferMaxSize,
+ unsigned long RingbufferStepSize,
+ const char *runtime_directory,
+ int InitialContextLogLevel,
+ int InitialContextTraceStatus,
+ int ForceLLTS,
+ int verbose)
{
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon == NULL || runtime_directory == NULL)
+ if ((daemon == NULL) || (runtime_directory == NULL))
return -1;
daemon->user_list = NULL;
@@ -243,15 +237,20 @@ int dlt_daemon_init(DltDaemon *daemon,unsigned long RingbufferMinSize,unsigned l
daemon->sendserialheader = 0;
daemon->timingpackets = 0;
- dlt_set_id(daemon->ecuid,"");
+ dlt_set_id(daemon->ecuid, "");
/* initialize ring buffer for client connection */
- snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE,"Ringbuffer configuration: %lu/%lu/%lu\n", RingbufferMinSize,RingbufferMaxSize,RingbufferStepSize );
+ snprintf(str,
+ DLT_DAEMON_COMMON_TEXTBUFSIZE,
+ "Ringbuffer configuration: %lu/%lu/%lu\n",
+ RingbufferMinSize,
+ RingbufferMaxSize,
+ RingbufferStepSize);
dlt_log(LOG_INFO, str);
- if (dlt_buffer_init_dynamic(&(daemon->client_ringbuffer), RingbufferMinSize,RingbufferMaxSize,RingbufferStepSize) == DLT_RETURN_ERROR)
- {
+
+ if (dlt_buffer_init_dynamic(&(daemon->client_ringbuffer), RingbufferMinSize, RingbufferMaxSize,
+ RingbufferStepSize) == DLT_RETURN_ERROR)
return -1;
- }
daemon->storage_handle = NULL;
return 0;
@@ -264,15 +263,14 @@ int dlt_daemon_free(DltDaemon *daemon, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon == NULL || daemon->user_list == NULL)
+ if ((daemon == NULL) || (daemon->user_list == NULL))
return -1;
/* free all registered user information */
- for (i = 0; i < daemon->num_user_lists; i++)
- {
+ for (i = 0; i < daemon->num_user_lists; i++) {
user_list = &daemon->user_list[i];
- if (user_list != NULL)
- {
+
+ if (user_list != NULL) {
/* ignore return values */
dlt_daemon_contexts_clear(daemon, user_list->ecu, verbose);
dlt_daemon_applications_clear(daemon, user_list->ecu, verbose);
@@ -280,10 +278,10 @@ int dlt_daemon_free(DltDaemon *daemon, int verbose)
}
free(daemon->user_list);
+
if (app_recv_buffer)
- {
free(app_recv_buffer);
- }
+
/* free ringbuffer */
dlt_buffer_free_dynamic(&(daemon->client_ringbuffer));
@@ -301,16 +299,13 @@ int dlt_daemon_init_user_information(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || ((gateway_mode == 1) && (gateway == NULL)))
- {
return DLT_RETURN_ERROR;
- }
- if (gateway_mode == 0)
- {
+ if (gateway_mode == 0) {
/* initialize application list */
daemon->user_list = calloc(nodes, sizeof(DltDaemonRegisteredUsers));
- if (daemon->user_list == NULL)
- {
+
+ if (daemon->user_list == NULL) {
dlt_log(LOG_ERR, "Allocating memory for user information");
return DLT_RETURN_ERROR;
}
@@ -318,14 +313,13 @@ int dlt_daemon_init_user_information(DltDaemon *daemon,
dlt_set_id(daemon->user_list[0].ecu, daemon->ecuid);
daemon->num_user_lists = 1;
}
- else /* gateway is active */
- {
+ else { /* gateway is active */
nodes += gateway->num_connections;
/* initialize application list */
daemon->user_list = calloc(nodes, sizeof(DltDaemonRegisteredUsers));
- if (daemon->user_list == NULL)
- {
+
+ if (daemon->user_list == NULL) {
dlt_log(LOG_ERR, "Allocating memory for user information");
return DLT_RETURN_ERROR;
}
@@ -334,9 +328,7 @@ int dlt_daemon_init_user_information(DltDaemon *daemon,
daemon->num_user_lists = nodes;
for (i = 1; i < nodes; i++)
- {
- dlt_set_id(daemon->user_list[i].ecu, gateway->connections[i-1].ecuid);
- }
+ dlt_set_id(daemon->user_list[i].ecu, gateway->connections[i - 1].ecuid);
}
return DLT_RETURN_OK;
@@ -348,25 +340,19 @@ int dlt_daemon_applications_invalidate_fd(DltDaemon *daemon,
int verbose)
{
int i;
- DltDaemonRegisteredUsers* user_list = NULL;
+ DltDaemonRegisteredUsers *user_list = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon == NULL || ecu == NULL)
- {
+ if ((daemon == NULL) || (ecu == NULL))
return DLT_RETURN_ERROR;
- }
user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
- if (user_list != NULL)
- {
- for (i=0; i<user_list->num_applications; i++)
- {
+
+ if (user_list != NULL) {
+ for (i = 0; i < user_list->num_applications; i++)
if (user_list->applications[i].user_handle == fd)
- {
user_list->applications[i].user_handle = DLT_FD_INIT;
- }
- }
return DLT_RETURN_OK;
}
@@ -382,29 +368,23 @@ int dlt_daemon_applications_clear(DltDaemon *daemon, char *ecu, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon->user_list == NULL) || (ecu == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+
if (user_list == NULL)
- {
return DLT_RETURN_ERROR;
- }
- for (i=0; i < user_list->num_applications; i++)
- {
- if (user_list->applications[i].application_description != NULL)
- {
+ for (i = 0; i < user_list->num_applications; i++)
+ if (user_list->applications[i].application_description != NULL) {
free(user_list->applications[i].application_description);
user_list->applications[i].application_description = NULL;
}
- }
+
+
if (user_list->applications != NULL)
- {
free(user_list->applications);
- }
user_list->applications = NULL;
user_list->num_applications = 0;
@@ -412,7 +392,7 @@ int dlt_daemon_applications_clear(DltDaemon *daemon, char *ecu, int verbose)
return 0;
}
-DltDaemonApplication* dlt_daemon_application_add(DltDaemon *daemon,
+DltDaemonApplication *dlt_daemon_application_add(DltDaemon *daemon,
char *apid,
pid_t pid,
char *description,
@@ -426,56 +406,49 @@ DltDaemonApplication* dlt_daemon_application_add(DltDaemon *daemon,
int dlt_user_handle;
DltDaemonRegisteredUsers *user_list = NULL;
#ifndef DLT_USE_UNIX_SOCKET_IPC
- (void) fd; /* To avoid compiler warning : unused variable */
+ (void)fd; /* To avoid compiler warning : unused variable */
char filename[DLT_DAEMON_COMMON_TEXTBUFSIZE];
#endif
- if ((daemon == NULL) || (apid == NULL) || (apid[0]=='\0') || (ecu == NULL))
- {
- return (DltDaemonApplication*) NULL;
- }
+ if ((daemon == NULL) || (apid == NULL) || (apid[0] == '\0') || (ecu == NULL))
+ return (DltDaemonApplication *)NULL;
user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+
if (user_list == NULL)
- {
- return (DltDaemonApplication*) NULL;
- }
+ return (DltDaemonApplication *)NULL;
+
+ if (user_list->applications == NULL) {
+ user_list->applications = (DltDaemonApplication *)
+ malloc(sizeof(DltDaemonApplication) * DLT_DAEMON_APPL_ALLOC_SIZE);
- if (user_list->applications == NULL)
- {
- user_list->applications = (DltDaemonApplication*)
- malloc(sizeof(DltDaemonApplication) * DLT_DAEMON_APPL_ALLOC_SIZE);
if (user_list->applications == NULL)
- {
- return (DltDaemonApplication*) NULL;
- }
+ return (DltDaemonApplication *)NULL;
}
- new_application=0;
+ new_application = 0;
/* Check if application [apid] is already available */
application = dlt_daemon_application_find(daemon, apid, ecu, verbose);
- if (application == NULL)
- {
+
+ if (application == NULL) {
user_list->num_applications += 1;
- if (user_list->num_applications != 0)
- {
- if ((user_list->num_applications % DLT_DAEMON_APPL_ALLOC_SIZE) == 0)
- {
+ if (user_list->num_applications != 0) {
+ if ((user_list->num_applications % DLT_DAEMON_APPL_ALLOC_SIZE) == 0) {
/* allocate memory in steps of DLT_DAEMON_APPL_ALLOC_SIZE, e.g. 100 */
old = user_list->applications;
- user_list->applications = (DltDaemonApplication*)
- malloc(sizeof(DltDaemonApplication) *
- ((user_list->num_applications / DLT_DAEMON_APPL_ALLOC_SIZE) + 1) *
- DLT_DAEMON_APPL_ALLOC_SIZE);
+ user_list->applications = (DltDaemonApplication *)
+ malloc(sizeof(DltDaemonApplication) *
+ ((user_list->num_applications / DLT_DAEMON_APPL_ALLOC_SIZE) + 1) *
+ DLT_DAEMON_APPL_ALLOC_SIZE);
- if (user_list->applications == NULL)
- {
+ if (user_list->applications == NULL) {
user_list->applications = old;
user_list->num_applications -= 1;
- return (DltDaemonApplication*) NULL;
+ return (DltDaemonApplication *)NULL;
}
+
memcpy(user_list->applications,
old,
sizeof(DltDaemonApplication) * user_list->num_applications);
@@ -485,7 +458,7 @@ DltDaemonApplication* dlt_daemon_application_add(DltDaemon *daemon,
application = &(user_list->applications[user_list->num_applications - 1]);
- dlt_set_id(application->apid,apid);
+ dlt_set_id(application->apid, apid);
application->pid = 0;
application->application_description = NULL;
application->num_contexts = 0;
@@ -493,7 +466,9 @@ DltDaemonApplication* dlt_daemon_application_add(DltDaemon *daemon,
new_application = 1;
- } else if ((pid != application->pid) && (application->pid != 0)) {
+ }
+ else if ((pid != application->pid) && (application->pid != 0))
+ {
dlt_vlog(LOG_WARNING,
"Duplicate registration of ApplicationID: '%.4s'; registering from PID %d, existing from PID %d\n",
@@ -503,53 +478,47 @@ DltDaemonApplication* dlt_daemon_application_add(DltDaemon *daemon,
}
/* Store application description and pid of application */
- if (application->application_description)
- {
+ if (application->application_description) {
free(application->application_description);
application->application_description = NULL;
}
- if (description != NULL)
- {
+ if (description != NULL) {
application->application_description = malloc(strlen(description) + 1);
- if (application->application_description)
- {
+
+ if (application->application_description) {
strncpy(application->application_description,
description,
strlen(description));
application->application_description[strlen(description)] = '\0';
}
- else
- {
+ else {
dlt_log(LOG_ERR, "Cannot allocate memory to store application description\n");
free(application);
- return (DltDaemonApplication*) NULL;
+ return (DltDaemonApplication *)NULL;
}
}
- if (application->user_handle != DLT_FD_INIT)
- {
- if (application->pid != pid)
- {
+ if (application->user_handle != DLT_FD_INIT) {
+ if (application->pid != pid) {
#ifndef DLT_USE_UNIX_SOCKET_IPC
- if (close(application->user_handle) < 0)
- {
- dlt_vlog(LOG_WARNING,
- "close() failed to %s/dltpipes/dlt%d, errno=%d (%s)!\n",
- dltFifoBaseDir,
- pid,
- errno,
- strerror(errno)); /* errno 2: ENOENT - No such file or directory */
- }
+
+ if (close(application->user_handle) < 0)
+ dlt_vlog(LOG_WARNING,
+ "close() failed to %s/dltpipes/dlt%d, errno=%d (%s)!\n",
+ dltFifoBaseDir,
+ pid,
+ errno,
+ strerror(errno)); /* errno 2: ENOENT - No such file or directory */
+
#endif
- application->user_handle = DLT_FD_INIT;
- application->pid = 0;
+ application->user_handle = DLT_FD_INIT;
+ application->pid = 0;
}
}
/* open user pipe only if it is not yet opened */
- if ((application->user_handle == DLT_FD_INIT) && (pid != 0))
- {
+ if ((application->user_handle == DLT_FD_INIT) && (pid != 0)) {
#ifdef DLT_USE_UNIX_SOCKET_IPC
dlt_user_handle = fd;
#else
@@ -559,15 +528,16 @@ DltDaemonApplication* dlt_daemon_application_add(DltDaemon *daemon,
dltFifoBaseDir,
pid);
- dlt_user_handle = open(filename, O_WRONLY|O_NONBLOCK);
- if (dlt_user_handle < 0)
- {
+ dlt_user_handle = open(filename, O_WRONLY | O_NONBLOCK);
+
+ if (dlt_user_handle < 0) {
int prio = (errno == ENOENT) ? LOG_INFO : LOG_WARNING;
dlt_vlog(prio, "open() failed to %s, errno=%d (%s)!\n", filename, errno, strerror(errno));
} /* if */
+
#endif
/* check if file descriptor was already used, and make it invalid if it
- * is reused. This prevents sending messages to wrong file descriptor */
+ * is reused. This prevents sending messages to wrong file descriptor */
dlt_daemon_applications_invalidate_fd(daemon, ecu, dlt_user_handle, verbose);
dlt_daemon_contexts_invalidate_fd(daemon, ecu, dlt_user_handle, verbose);
@@ -576,8 +546,7 @@ DltDaemonApplication* dlt_daemon_application_add(DltDaemon *daemon,
}
/* Sort */
- if (new_application)
- {
+ if (new_application) {
qsort(user_list->applications,
user_list->num_applications,
sizeof(DltDaemonApplication),
@@ -601,21 +570,16 @@ int dlt_daemon_application_del(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (application == NULL) || (ecu == NULL))
- {
return -1;
- }
user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+
if (user_list == NULL)
- {
return -1;
- }
- if (user_list->num_applications > 0)
- {
+ if (user_list->num_applications > 0) {
/* Check if user handle is open; if yes, close it */
- if (application->user_handle >= DLT_FD_MINIMUM)
- {
+ if (application->user_handle >= DLT_FD_MINIMUM) {
#ifndef DLT_USE_UNIX_SOCKET_IPC
close(application->user_handle);
#endif
@@ -623,8 +587,7 @@ int dlt_daemon_application_del(DltDaemon *daemon,
}
/* Free description of application to be deleted */
- if (application->application_description)
- {
+ if (application->application_description) {
free(application->application_description);
application->application_description = NULL;
}
@@ -633,11 +596,11 @@ int dlt_daemon_application_del(DltDaemon *daemon,
/* move all applications above pos to pos */
memmove(&(user_list->applications[pos]),
- &(user_list->applications[pos+1]),
+ &(user_list->applications[pos + 1]),
sizeof(DltDaemonApplication) * ((user_list->num_applications - 1) - pos));
/* Clear last application */
- memset(&(user_list->applications[user_list->num_applications-1]),
+ memset(&(user_list->applications[user_list->num_applications - 1]),
0,
sizeof(DltDaemonApplication));
@@ -647,43 +610,38 @@ int dlt_daemon_application_del(DltDaemon *daemon,
return 0;
}
-DltDaemonApplication* dlt_daemon_application_find(DltDaemon *daemon,
+DltDaemonApplication *dlt_daemon_application_find(DltDaemon *daemon,
char *apid,
char *ecu,
int verbose)
{
DltDaemonApplication application;
- DltDaemonRegisteredUsers* user_list = NULL;
+ DltDaemonRegisteredUsers *user_list = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon->user_list == NULL) || (apid == NULL) ||
- (apid[0]=='\0') || (ecu == NULL))
- {
- return (DltDaemonApplication*) NULL;
- }
+ (apid[0] == '\0') || (ecu == NULL))
+ return (DltDaemonApplication *)NULL;
user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
- if (user_list == NULL || (user_list->num_applications == 0))
- {
- return (DltDaemonApplication*) NULL;
- }
+
+ if ((user_list == NULL) || (user_list->num_applications == 0))
+ return (DltDaemonApplication *)NULL;
/* Check, if apid is smaller than smallest apid or greater than greatest apid */
if ((memcmp(apid, user_list->applications[0].apid, DLT_ID_SIZE) < 0) ||
(memcmp(apid,
user_list->applications[user_list->num_applications - 1].apid,
DLT_ID_SIZE) > 0))
- {
- return (DltDaemonApplication*) NULL;
- }
+ return (DltDaemonApplication *)NULL;
dlt_set_id(application.apid, apid);
- return (DltDaemonApplication*)bsearch(&application,
- user_list->applications,
- user_list->num_applications,
- sizeof(DltDaemonApplication),
- dlt_daemon_cmp_apid);
+ return (DltDaemonApplication *)bsearch(&application,
+ user_list->applications,
+ user_list->num_applications,
+ sizeof(DltDaemonApplication),
+ dlt_daemon_cmp_apid);
}
int dlt_daemon_applications_load(DltDaemon *daemon, const char *filename, int verbose)
@@ -696,13 +654,12 @@ int dlt_daemon_applications_load(DltDaemon *daemon, const char *filename, int ve
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (filename == NULL) || (filename[0]=='\0'))
+ if ((daemon == NULL) || (filename == NULL) || (filename[0] == '\0'))
return -1;
- fd=fopen(filename, "r");
+ fd = fopen(filename, "r");
- if (fd == NULL)
- {
+ if (fd == NULL) {
dlt_vlog(LOG_WARNING,
"%s: cannot open file %s: %s\n",
__func__,
@@ -712,19 +669,17 @@ int dlt_daemon_applications_load(DltDaemon *daemon, const char *filename, int ve
return -1;
}
- while (!feof(fd))
- {
+ while (!feof(fd)) {
/* Clear buf */
memset(buf, 0, sizeof(buf));
/* Get line */
ret = fgets(buf, sizeof(buf), fd);
- if (NULL == ret)
- {
+
+ if (NULL == ret) {
/* fgets always null pointer if the last byte of the file is a new line
* We need to check here if there was an error or was it feof.*/
- if (ferror(fd))
- {
+ if (ferror(fd)) {
dlt_vlog(LOG_WARNING,
"%s: fgets(buf,sizeof(buf),fd) returned NULL. %s\n",
__func__,
@@ -732,31 +687,29 @@ int dlt_daemon_applications_load(DltDaemon *daemon, const char *filename, int ve
fclose(fd);
return -1;
}
- else if(feof(fd))
+ else if (feof(fd))
{
fclose(fd);
return 0;
}
- else
- {
+ else {
dlt_vlog(LOG_WARNING,
- "%s: fgets(buf,sizeof(buf),fd) returned NULL. Unknown error.\n",
- __func__);
+ "%s: fgets(buf,sizeof(buf),fd) returned NULL. Unknown error.\n",
+ __func__);
fclose(fd);
return -1;
}
}
- if (strcmp(buf, "") != 0)
- {
+ if (strcmp(buf, "") != 0) {
/* Split line */
pb = strtok(buf, ":");
- if (pb != NULL)
- {
- dlt_set_id(apid,pb);
- pb = strtok(NULL,":");
- if (pb != NULL)
- {
+
+ if (pb != NULL) {
+ dlt_set_id(apid, pb);
+ pb = strtok(NULL, ":");
+
+ if (pb != NULL) {
/* pb contains now the description */
/* pid is unknown at loading time */
if (dlt_daemon_application_add(daemon,
@@ -765,8 +718,7 @@ int dlt_daemon_applications_load(DltDaemon *daemon, const char *filename, int ve
pb,
-1,
daemon->ecuid,
- verbose) == 0)
- {
+ verbose) == 0) {
dlt_vlog(LOG_WARNING,
"%s: dlt_daemon_application_add failed for %4s\n",
__func__,
@@ -778,6 +730,7 @@ int dlt_daemon_applications_load(DltDaemon *daemon, const char *filename, int ve
}
}
}
+
fclose(fd);
return 0;
@@ -788,50 +741,41 @@ int dlt_daemon_applications_save(DltDaemon *daemon, const char *filename, int ve
FILE *fd;
int i;
- char apid[DLT_ID_SIZE+1]; /* DLT_ID_SIZE+1, because the 0-termination is required here */
- DltDaemonRegisteredUsers* user_list = NULL;
+ char apid[DLT_ID_SIZE + 1]; /* DLT_ID_SIZE+1, because the 0-termination is required here */
+ DltDaemonRegisteredUsers *user_list = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (filename == NULL) || (filename[0]=='\0'))
- {
+ if ((daemon == NULL) || (filename == NULL) || (filename[0] == '\0'))
return -1;
- }
memset(apid, 0, sizeof(apid));
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return -1;
- }
- if ((user_list->applications != NULL) && (user_list->num_applications > 0))
- {
+ if ((user_list->applications != NULL) && (user_list->num_applications > 0)) {
fd = fopen(filename, "w");
- if (fd != NULL)
- {
- for (i = 0; i < user_list->num_applications; i++)
- {
+
+ if (fd != NULL) {
+ for (i = 0; i < user_list->num_applications; i++) {
dlt_set_id(apid, user_list->applications[i].apid);
if ((user_list->applications[i].application_description) &&
(user_list->applications[i].application_description[0] != '\0'))
- {
fprintf(fd,
"%s:%s:\n",
apid,
user_list->applications[i].application_description);
- }
else
- {
fprintf(fd, "%s::\n", apid);
- }
}
+
fclose(fd);
}
- else
- {
+ else {
dlt_vlog(LOG_ERR, "%s: open %s failed! No application information stored.\n",
__func__,
filename);
@@ -841,7 +785,7 @@ int dlt_daemon_applications_save(DltDaemon *daemon, const char *filename, int ve
return 0;
}
-DltDaemonContext* dlt_daemon_context_add(DltDaemon *daemon,
+DltDaemonContext *dlt_daemon_context_add(DltDaemon *daemon,
char *apid,
char *ctid,
int8_t log_level,
@@ -855,70 +799,60 @@ DltDaemonContext* dlt_daemon_context_add(DltDaemon *daemon,
DltDaemonApplication *application;
DltDaemonContext *context;
DltDaemonContext *old;
- int new_context=0;
- DltDaemonRegisteredUsers* user_list = NULL;
+ int new_context = 0;
+ DltDaemonRegisteredUsers *user_list = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (apid == NULL) || (apid[0]=='\0') ||
- (ctid == NULL) || (ctid[0]=='\0') || (ecu == NULL))
- {
- return (DltDaemonContext*) NULL;
- }
+ if ((daemon == NULL) || (apid == NULL) || (apid[0] == '\0') ||
+ (ctid == NULL) || (ctid[0] == '\0') || (ecu == NULL))
+ return (DltDaemonContext *)NULL;
- if ((log_level<DLT_LOG_DEFAULT) || (log_level>DLT_LOG_VERBOSE))
- {
- return (DltDaemonContext*) NULL;
- }
+ if ((log_level < DLT_LOG_DEFAULT) || (log_level > DLT_LOG_VERBOSE))
+ return (DltDaemonContext *)NULL;
- if ((trace_status<DLT_TRACE_STATUS_DEFAULT) || (trace_status>DLT_TRACE_STATUS_ON))
- {
- return (DltDaemonContext*) NULL;
- }
+ if ((trace_status < DLT_TRACE_STATUS_DEFAULT) || (trace_status > DLT_TRACE_STATUS_ON))
+ return (DltDaemonContext *)NULL;
user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+
if (user_list == NULL)
- {
- return (DltDaemonContext*) NULL;
- }
+ return (DltDaemonContext *)NULL;
+
+ if (user_list->contexts == NULL) {
+ user_list->contexts = (DltDaemonContext *)malloc(sizeof(DltDaemonContext) * DLT_DAEMON_CONTEXT_ALLOC_SIZE);
- if (user_list->contexts == NULL)
- {
- user_list->contexts = (DltDaemonContext*) malloc(sizeof(DltDaemonContext)*DLT_DAEMON_CONTEXT_ALLOC_SIZE);
if (user_list->contexts == NULL)
- {
- return (DltDaemonContext*) NULL;
- }
+ return (DltDaemonContext *)NULL;
}
/* Check if application [apid] is available */
application = dlt_daemon_application_find(daemon, apid, ecu, verbose);
+
if (application == NULL)
- {
- return (DltDaemonContext*) NULL;
- }
+ return (DltDaemonContext *)NULL;
/* Check if context [apid, ctid] is already available */
context = dlt_daemon_context_find(daemon, apid, ctid, ecu, verbose);
- if (context == NULL)
- {
+
+ if (context == NULL) {
user_list->num_contexts += 1;
- if (user_list->num_contexts != 0)
- {
- if ((user_list->num_contexts % DLT_DAEMON_CONTEXT_ALLOC_SIZE) == 0)
- {
+ if (user_list->num_contexts != 0) {
+ if ((user_list->num_contexts % DLT_DAEMON_CONTEXT_ALLOC_SIZE) == 0) {
/* allocate memory for context in steps of DLT_DAEMON_CONTEXT_ALLOC_SIZE, e.g 100 */
old = user_list->contexts;
- user_list->contexts = (DltDaemonContext*) malloc(sizeof(DltDaemonContext) *
- ((user_list->num_contexts / DLT_DAEMON_CONTEXT_ALLOC_SIZE) + 1) * DLT_DAEMON_CONTEXT_ALLOC_SIZE);
+ user_list->contexts = (DltDaemonContext *)malloc(sizeof(DltDaemonContext) *
+ ((user_list->num_contexts /
+ DLT_DAEMON_CONTEXT_ALLOC_SIZE) + 1) *
+ DLT_DAEMON_CONTEXT_ALLOC_SIZE);
- if (user_list->contexts == NULL)
- {
+ if (user_list->contexts == NULL) {
user_list->contexts = old;
user_list->num_contexts -= 1;
- return (DltDaemonContext*) NULL;
+ return (DltDaemonContext *)NULL;
}
+
memcpy(user_list->contexts,
old,
sizeof(DltDaemonContext) * user_list->num_contexts);
@@ -928,42 +862,35 @@ DltDaemonContext* dlt_daemon_context_add(DltDaemon *daemon,
context = &(user_list->contexts[user_list->num_contexts - 1]);
- dlt_set_id(context->apid,apid);
- dlt_set_id(context->ctid,ctid);
+ dlt_set_id(context->apid, apid);
+ dlt_set_id(context->ctid, ctid);
context->context_description = NULL;
application->num_contexts++;
- new_context =1;
+ new_context = 1;
}
/* Set context description */
- if (context->context_description)
- {
+ if (context->context_description) {
free(context->context_description);
context->context_description = NULL;
}
- if (description != NULL)
- {
- context->context_description = malloc(strlen(description)+1);
+ if (description != NULL) {
+ context->context_description = malloc(strlen(description) + 1);
- if (context->context_description)
- {
- strncpy(context->context_description,description,strlen(description));
- context->context_description[strlen(description)]='\0';
+ if (context->context_description) {
+ strncpy(context->context_description, description, strlen(description));
+ context->context_description[strlen(description)] = '\0';
}
}
- if ((strncmp(daemon->ecuid, ecu, DLT_ID_SIZE) == 0) && (daemon->force_ll_ts))
- {
+ if ((strncmp(daemon->ecuid, ecu, DLT_ID_SIZE) == 0) && (daemon->force_ll_ts)) {
if (log_level > daemon->default_log_level)
- {
log_level = daemon->default_log_level;
- }
+
if (trace_status > daemon->default_trace_status)
- {
trace_status = daemon->default_trace_status;
- }
dlt_vlog(LOG_NOTICE,
"Adapting ll_ts for context: %.4s:%.4s with %i %i\n",
@@ -974,11 +901,10 @@ DltDaemonContext* dlt_daemon_context_add(DltDaemon *daemon,
}
/* Store log level and trace status,
- if this is a new context, or
- if this is an old context and the runtime cfg was not loaded */
+ * if this is a new context, or
+ * if this is an old context and the runtime cfg was not loaded */
if ((new_context == 1) ||
- ((new_context == 0) && (daemon->runtime_context_cfg_loaded == 0)))
- {
+ ((new_context == 0) && (daemon->runtime_context_cfg_loaded == 0))) {
context->log_level = log_level;
context->trace_status = trace_status;
}
@@ -987,8 +913,7 @@ DltDaemonContext* dlt_daemon_context_add(DltDaemon *daemon,
context->user_handle = user_handle;
/* Sort */
- if (new_context)
- {
+ if (new_context) {
qsort(user_list->contexts,
user_list->num_contexts,
sizeof(DltDaemonContext),
@@ -1002,7 +927,7 @@ DltDaemonContext* dlt_daemon_context_add(DltDaemon *daemon,
}
int dlt_daemon_context_del(DltDaemon *daemon,
- DltDaemonContext* context,
+ DltDaemonContext *context,
char *ecu,
int verbose)
{
@@ -1013,28 +938,23 @@ int dlt_daemon_context_del(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (context == NULL) || (ecu == NULL))
- {
return -1;
- }
user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+
if (user_list == NULL)
- {
return -1;
- }
- if (user_list->num_contexts > 0)
- {
+ if (user_list->num_contexts > 0) {
application = dlt_daemon_application_find(daemon, context->apid, ecu, verbose);
/* Free description of context to be deleted */
- if (context->context_description)
- {
+ if (context->context_description) {
free(context->context_description);
context->context_description = NULL;
}
- pos = context-(user_list->contexts);
+ pos = context - (user_list->contexts);
/* move all contexts above pos to pos */
memmove(&(user_list->contexts[pos]),
@@ -1042,7 +962,7 @@ int dlt_daemon_context_del(DltDaemon *daemon,
sizeof(DltDaemonContext) * ((user_list->num_contexts - 1) - pos));
/* Clear last context */
- memset(&(user_list->contexts[user_list->num_contexts-1]),
+ memset(&(user_list->contexts[user_list->num_contexts - 1]),
0,
sizeof(DltDaemonContext));
@@ -1050,54 +970,47 @@ int dlt_daemon_context_del(DltDaemon *daemon,
/* Check if application [apid] is available */
if (application != NULL)
- {
application->num_contexts--;
- }
}
return 0;
}
-DltDaemonContext* dlt_daemon_context_find(DltDaemon *daemon,
+DltDaemonContext *dlt_daemon_context_find(DltDaemon *daemon,
char *apid,
char *ctid,
char *ecu,
int verbose)
{
DltDaemonContext context;
- DltDaemonRegisteredUsers* user_list = NULL;
+ DltDaemonRegisteredUsers *user_list = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (apid == NULL) || (apid[0]=='\0') ||
- (ctid == NULL) || (ctid[0]=='\0') || (ecu == NULL))
- {
- return (DltDaemonContext*) NULL;
- }
+ if ((daemon == NULL) || (apid == NULL) || (apid[0] == '\0') ||
+ (ctid == NULL) || (ctid[0] == '\0') || (ecu == NULL))
+ return (DltDaemonContext *)NULL;
user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
+
if ((user_list == NULL) || (user_list->num_contexts == 0))
- {
- return (DltDaemonContext*) NULL;
- }
+ return (DltDaemonContext *)NULL;
/* Check, if apid is smaller than smallest apid or greater than greatest apid */
if ((memcmp(apid, user_list->contexts[0].apid, DLT_ID_SIZE) < 0) ||
(memcmp(apid,
- user_list->contexts[user_list->num_contexts-1].apid,
+ user_list->contexts[user_list->num_contexts - 1].apid,
DLT_ID_SIZE) > 0))
- {
- return (DltDaemonContext*) NULL;
- }
+ return (DltDaemonContext *)NULL;
- dlt_set_id(context.apid,apid);
- dlt_set_id(context.ctid,ctid);
+ dlt_set_id(context.apid, apid);
+ dlt_set_id(context.ctid, ctid);
- return (DltDaemonContext*)bsearch(&context,
- user_list->contexts,
- user_list->num_contexts,
- sizeof(DltDaemonContext),
- dlt_daemon_cmp_apid_ctid);
+ return (DltDaemonContext *)bsearch(&context,
+ user_list->contexts,
+ user_list->num_contexts,
+ sizeof(DltDaemonContext),
+ dlt_daemon_cmp_apid_ctid);
}
int dlt_daemon_contexts_invalidate_fd(DltDaemon *daemon,
@@ -1106,25 +1019,19 @@ int dlt_daemon_contexts_invalidate_fd(DltDaemon *daemon,
int verbose)
{
int i;
- DltDaemonRegisteredUsers* user_list = NULL;
+ DltDaemonRegisteredUsers *user_list = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (ecu == NULL))
- {
return -1;
- }
user_list = dlt_daemon_find_users_list(daemon, ecu, verbose);
- if (user_list != NULL)
- {
- for (i=0; i<user_list->num_contexts; i++)
- {
+
+ if (user_list != NULL) {
+ for (i = 0; i < user_list->num_contexts; i++)
if (user_list->contexts[i].user_handle == fd)
- {
user_list->contexts[i].user_handle = DLT_FD_INIT;
- }
- }
return 0;
}
@@ -1139,36 +1046,29 @@ int dlt_daemon_contexts_clear(DltDaemon *daemon, char *ecu, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon == NULL || ecu == NULL)
- {
+ if ((daemon == NULL) || (ecu == NULL))
return DLT_RETURN_WRONG_PARAMETER;
- }
users = dlt_daemon_find_users_list(daemon, ecu, verbose);
+
if (users == NULL)
- {
return DLT_RETURN_ERROR;
- }
for (i = 0; i < users->num_contexts; i++)
- {
- if (users->contexts[i].context_description != NULL)
- {
+ if (users->contexts[i].context_description != NULL) {
free(users->contexts[i].context_description);
users->contexts[i].context_description = NULL;
}
- }
- if (users->contexts)
- {
+
+
+ if (users->contexts) {
free(users->contexts);
users->contexts = NULL;
}
for (i = 0; i < users->num_applications; i++)
- {
users->applications[i].num_contexts = 0;
- }
users->num_contexts = 0;
@@ -1186,15 +1086,12 @@ int dlt_daemon_contexts_load(DltDaemon *daemon, const char *filename, int verbos
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (filename == NULL) ||( filename[0]=='\0'))
- {
+ if ((daemon == NULL) || (filename == NULL) || (filename[0] == '\0'))
return -1;
- }
fd = fopen(filename, "r");
- if (fd == NULL)
- {
+ if (fd == NULL) {
dlt_vlog(LOG_WARNING,
"DLT runtime-context load, cannot open file %s: %s\n",
filename,
@@ -1203,19 +1100,17 @@ int dlt_daemon_contexts_load(DltDaemon *daemon, const char *filename, int verbos
return -1;
}
- while (!feof(fd))
- {
+ while (!feof(fd)) {
/* Clear buf */
memset(buf, 0, sizeof(buf));
/* Get line */
- ret = fgets(buf,sizeof(buf),fd);
- if (NULL == ret)
- {
+ ret = fgets(buf, sizeof(buf), fd);
+
+ if (NULL == ret) {
/* fgets always returns null pointer if the last byte of the file is a new line.
* We need to check here if there was an error or was it feof.*/
- if (ferror(fd))
- {
+ if (ferror(fd)) {
dlt_vlog(LOG_WARNING,
"%s fgets(buf,sizeof(buf),fd[%d]) returned NULL. %s\n",
__func__,
@@ -1224,13 +1119,12 @@ int dlt_daemon_contexts_load(DltDaemon *daemon, const char *filename, int verbos
fclose(fd);
return -1;
}
- else if(feof(fd))
+ else if (feof(fd))
{
fclose(fd);
return 0;
}
- else
- {
+ else {
dlt_vlog(LOG_WARNING,
"%s fgets(buf,sizeof(buf),fd[%d]) returned NULL. Unknown error.\n",
__func__,
@@ -1240,28 +1134,27 @@ int dlt_daemon_contexts_load(DltDaemon *daemon, const char *filename, int verbos
}
}
- if (strcmp(buf ,"") != 0)
- {
+ if (strcmp(buf, "") != 0) {
/* Split line */
pb = strtok(buf, ":");
- if (pb != NULL)
- {
+
+ if (pb != NULL) {
dlt_set_id(apid, pb);
pb = strtok(NULL, ":");
- if (pb != NULL)
- {
+
+ if (pb != NULL) {
dlt_set_id(ctid, pb);
pb = strtok(NULL, ":");
- if (pb != NULL)
- {
+
+ if (pb != NULL) {
sscanf(pb, "%d", &ll);
pb = strtok(NULL, ":");
- if (pb != NULL)
- {
+
+ if (pb != NULL) {
sscanf(pb, "%d", &ts);
- pb = strtok(NULL,":");
- if (pb != NULL)
- {
+ pb = strtok(NULL, ":");
+
+ if (pb != NULL) {
/* pb contains now the description */
/* log_level_pos, and user_handle are unknown at loading time */
@@ -1274,8 +1167,7 @@ int dlt_daemon_contexts_load(DltDaemon *daemon, const char *filename, int verbos
0,
pb,
daemon->ecuid,
- verbose) == NULL)
- {
+ verbose) == NULL) {
dlt_vlog(LOG_WARNING,
"%s dlt_daemon_context_add failed\n",
__func__);
@@ -1289,64 +1181,56 @@ int dlt_daemon_contexts_load(DltDaemon *daemon, const char *filename, int verbos
}
}
}
+
fclose(fd);
return 0;
}
-int dlt_daemon_contexts_save(DltDaemon *daemon,const char *filename, int verbose)
+int dlt_daemon_contexts_save(DltDaemon *daemon, const char *filename, int verbose)
{
FILE *fd;
int i;
- char apid[DLT_ID_SIZE+1], ctid[DLT_ID_SIZE+1]; /* DLT_ID_SIZE+1, because the 0-termination is required here */
- DltDaemonRegisteredUsers* user_list = NULL;
+ char apid[DLT_ID_SIZE + 1], ctid[DLT_ID_SIZE + 1]; /* DLT_ID_SIZE+1, because the 0-termination is required here */
+ DltDaemonRegisteredUsers *user_list = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (filename == NULL) || (filename[0]=='\0'))
- {
+ if ((daemon == NULL) || (filename == NULL) || (filename[0] == '\0'))
return -1;
- }
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return -1;
- }
memset(apid, 0, sizeof(apid));
memset(ctid, 0, sizeof(ctid));
- if ((user_list->contexts) && (user_list->num_contexts > 0))
- {
+ if ((user_list->contexts) && (user_list->num_contexts > 0)) {
fd = fopen(filename, "w");
- if (fd != NULL)
- {
- for (i = 0; i < user_list->num_contexts; i++)
- {
+
+ if (fd != NULL) {
+ for (i = 0; i < user_list->num_contexts; i++) {
dlt_set_id(apid, user_list->contexts[i].apid);
dlt_set_id(ctid, user_list->contexts[i].ctid);
if ((user_list->contexts[i].context_description) &&
(user_list->contexts[i].context_description[0] != '\0'))
- {
- fprintf(fd,"%s:%s:%d:%d:%s:\n",apid,ctid,
+ fprintf(fd, "%s:%s:%d:%d:%s:\n", apid, ctid,
(int)(user_list->contexts[i].log_level),
(int)(user_list->contexts[i].trace_status),
user_list->contexts[i].context_description);
- }
else
- {
- fprintf(fd,"%s:%s:%d:%d::\n",apid,ctid,
+ fprintf(fd, "%s:%s:%d:%d::\n", apid, ctid,
(int)(user_list->contexts[i].log_level),
(int)(user_list->contexts[i].trace_status));
- }
}
+
fclose(fd);
}
- else
- {
+ else {
dlt_vlog(LOG_ERR,
"%s: Cannot open %s. No context information stored\n",
__func__,
@@ -1366,11 +1250,11 @@ int dlt_daemon_configuration_save(DltDaemon *daemon, const char *filename, int v
if ((daemon == NULL) || (filename == NULL) || (filename[0] == '\0'))
return -1;
- fd=fopen(filename, "w");
- if (fd != NULL)
- {
- fprintf(fd,"# 0 = off, 1 = external, 2 = internal, 3 = both\n");
- fprintf(fd,"LoggingMode = %d\n",daemon->mode);
+ fd = fopen(filename, "w");
+
+ if (fd != NULL) {
+ fprintf(fd, "# 0 = off, 1 = external, 2 = internal, 3 = both\n");
+ fprintf(fd, "LoggingMode = %d\n", daemon->mode);
fclose(fd);
}
@@ -1380,10 +1264,10 @@ int dlt_daemon_configuration_save(DltDaemon *daemon, const char *filename, int v
int dlt_daemon_configuration_load(DltDaemon *daemon, const char *filename, int verbose)
{
- if(daemon == NULL || filename == NULL)
+ if ((daemon == NULL) || (filename == NULL))
return -1;
- FILE * pFile;
+ FILE *pFile;
char line[1024];
char token[1024];
char value[1024];
@@ -1391,65 +1275,55 @@ int dlt_daemon_configuration_load(DltDaemon *daemon, const char *filename, int v
PRINT_FUNCTION_VERBOSE(verbose);
- pFile = fopen (filename,"r");
+ pFile = fopen (filename, "r");
- if (pFile != NULL)
- {
- while(1)
- {
+ if (pFile != NULL) {
+ while (1) {
/* fetch line from configuration file */
- if ( fgets (line , 1024 , pFile) != NULL )
- {
- pch = strtok (line," =\r\n");
- token[0]=0;
- value[0]=0;
+ if (fgets (line, 1024, pFile) != NULL) {
+ pch = strtok (line, " =\r\n");
+ token[0] = 0;
+ value[0] = 0;
- while (pch != NULL)
- {
- if(strcmp(pch,"#")==0)
+ while (pch != NULL) {
+ if (strcmp(pch, "#") == 0)
break;
- if(token[0]==0)
- {
- strncpy(token,pch,sizeof(token)-1);
- token[sizeof(token)-1]=0;
+ if (token[0] == 0) {
+ strncpy(token, pch, sizeof(token) - 1);
+ token[sizeof(token) - 1] = 0;
}
- else
- {
- strncpy(value,pch,sizeof(value)-1);
- value[sizeof(value)-1]=0;
+ else {
+ strncpy(value, pch, sizeof(value) - 1);
+ value[sizeof(value) - 1] = 0;
break;
}
pch = strtok (NULL, " =\r\n");
- }
-
- if(token[0] && value[0])
- {
- /* parse arguments here */
- if(strcmp(token, "LoggingMode") == 0)
- {
- daemon->mode = atoi(value);
- snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE,"Runtime Option: %s=%d\n",token,daemon->mode);
- dlt_log(LOG_INFO, str);
- }
- else
- {
- snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE,"Unknown option: %s=%s\n",token,value);
- dlt_log(LOG_WARNING, str);
- }
+ }
+
+ if (token[0] && value[0]) {
+ /* parse arguments here */
+ if (strcmp(token, "LoggingMode") == 0) {
+ daemon->mode = atoi(value);
+ snprintf(str, DLT_DAEMON_COMMON_TEXTBUFSIZE, "Runtime Option: %s=%d\n", token, daemon->mode);
+ dlt_log(LOG_INFO, str);
+ }
+ else {
+ snprintf(str, DLT_DAEMON_COMMON_TEXTBUFSIZE, "Unknown option: %s=%s\n", token, value);
+ dlt_log(LOG_WARNING, str);
}
+ }
}
- else
- {
+ else {
break;
}
}
+
fclose (pFile);
}
- else
- {
- dlt_vlog(LOG_INFO, "Cannot open configuration file: %s\n",filename);
+ else {
+ dlt_vlog(LOG_INFO, "Cannot open configuration file: %s\n", filename);
}
return 0;
@@ -1463,28 +1337,25 @@ int dlt_daemon_user_send_log_level(DltDaemon *daemon, DltDaemonContext *context,
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (context == NULL))
- {
+ if ((daemon == NULL) || (context == NULL)) {
dlt_vlog(LOG_ERR, "NULL parameter in %s", __func__);
return -1;
}
- if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_LOG_LEVEL) < DLT_RETURN_OK)
- {
+ if (dlt_user_set_userheader(&userheader, DLT_USER_MESSAGE_LOG_LEVEL) < DLT_RETURN_OK) {
dlt_vlog(LOG_ERR, "Failed to set userheader in %s", __func__);
return -1;
}
- if(context->storage_log_level != DLT_LOG_DEFAULT)
- {
- usercontext.log_level = context->log_level > context->storage_log_level ? context->log_level:context->storage_log_level;
- }
+ if (context->storage_log_level != DLT_LOG_DEFAULT)
+ usercontext.log_level = context->log_level >
+ context->storage_log_level ? context->log_level : context->storage_log_level;
else /* Storage log level is not updated (is DEFAULT) then no device is yet connected so ignore */
- {
- usercontext.log_level = ((context->log_level == DLT_LOG_DEFAULT)?daemon->default_log_level:context->log_level);
- }
+ usercontext.log_level =
+ ((context->log_level == DLT_LOG_DEFAULT) ? daemon->default_log_level : context->log_level);
- usercontext.trace_status = ((context->trace_status == DLT_TRACE_STATUS_DEFAULT)?daemon->default_trace_status:context->trace_status);
+ usercontext.trace_status =
+ ((context->trace_status == DLT_TRACE_STATUS_DEFAULT) ? daemon->default_trace_status : context->trace_status);
usercontext.log_level_pos = context->log_level_pos;
@@ -1499,17 +1370,15 @@ int dlt_daemon_user_send_log_level(DltDaemon *daemon, DltDaemonContext *context,
/* log to FIFO */
errno = 0;
ret = dlt_user_log_out2(context->user_handle,
- &(userheader), sizeof(DltUserHeader),
- &(usercontext), sizeof(DltUserControlMsgLogLevel));
+ &(userheader), sizeof(DltUserHeader),
+ &(usercontext), sizeof(DltUserControlMsgLogLevel));
- if (ret < DLT_RETURN_OK)
- {
+ if (ret < DLT_RETURN_OK) {
dlt_vlog(LOG_ERR, "Failed to send data to application in %s: %s",
__func__,
errno != 0 ? strerror(errno) : "Unknown error");
- if (errno == EPIPE)
- {
+ if (errno == EPIPE) {
#ifndef DLT_USE_UNIX_SOCKET_IPC
/* Close connection */
close(context->user_handle);
@@ -1518,7 +1387,7 @@ int dlt_daemon_user_send_log_level(DltDaemon *daemon, DltDaemonContext *context,
}
}
- return ((ret == DLT_RETURN_OK) ? DLT_RETURN_OK : DLT_RETURN_ERROR);
+ return (ret == DLT_RETURN_OK) ? DLT_RETURN_OK : DLT_RETURN_ERROR;
}
int dlt_daemon_user_send_log_state(DltDaemon *daemon, DltDaemonApplication *app, int verbose)
@@ -1539,56 +1408,56 @@ int dlt_daemon_user_send_log_state(DltDaemon *daemon, DltDaemonApplication *app,
/* log to FIFO */
ret = dlt_user_log_out2(app->user_handle,
- &(userheader), sizeof(DltUserHeader),
- &(logstate), sizeof(DltUserControlMsgLogState));
+ &(userheader), sizeof(DltUserHeader),
+ &(logstate), sizeof(DltUserControlMsgLogState));
- if (ret < DLT_RETURN_OK)
- {
- if (errno==EPIPE)
- {
+ if (ret < DLT_RETURN_OK) {
+ if (errno == EPIPE) {
#ifndef DLT_USE_UNIX_SOCKET_IPC
/* Close connection */
close(app->user_handle);
#endif
- app->user_handle=DLT_FD_INIT;
+ app->user_handle = DLT_FD_INIT;
}
}
- return ((ret == DLT_RETURN_OK) ? DLT_RETURN_OK : DLT_RETURN_ERROR);
+ return (ret == DLT_RETURN_OK) ? DLT_RETURN_OK : DLT_RETURN_ERROR;
}
-void dlt_daemon_control_reset_to_factory_default(DltDaemon *daemon,const char *filename, const char *filename1, int InitialContextLogLevel, int InitialContextTraceStatus, int InitialEnforceLlTsStatus, int verbose)
+void dlt_daemon_control_reset_to_factory_default(DltDaemon *daemon,
+ const char *filename,
+ const char *filename1,
+ int InitialContextLogLevel,
+ int InitialContextTraceStatus,
+ int InitialEnforceLlTsStatus,
+ int verbose)
{
FILE *fd;
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (filename == NULL) || (filename1 == NULL))
- {
+ if ((daemon == NULL) || (filename == NULL) || (filename1 == NULL)) {
dlt_log(LOG_WARNING, "Wrong parameter: Null pointer\n");
return;
}
- if ((filename[0] == '\0') || (filename1[0] == '\0'))
- {
+ if ((filename[0] == '\0') || (filename1[0] == '\0')) {
dlt_log(LOG_WARNING, "Wrong parameter: Empty string\n");
return;
}
/* Check for runtime cfg file and delete it, if available */
- fd=fopen(filename, "r");
+ fd = fopen(filename, "r");
- if (fd != NULL)
- {
+ if (fd != NULL) {
/* Close and delete file */
fclose(fd);
unlink(filename);
}
- fd=fopen(filename1, "r");
+ fd = fopen(filename1, "r");
- if (fd != NULL)
- {
+ if (fd != NULL) {
/* Close and delete file */
fclose(fd);
unlink(filename1);
@@ -1599,7 +1468,7 @@ void dlt_daemon_control_reset_to_factory_default(DltDaemon *daemon,const char *f
daemon->force_ll_ts = InitialEnforceLlTsStatus;
/* Reset all other things (log level, trace status, etc.
- to default values */
+ * to default values */
/* Inform user libraries about changed default log level/trace status */
dlt_daemon_user_send_default_update(daemon, verbose);
@@ -1613,35 +1482,27 @@ void dlt_daemon_user_send_default_update(DltDaemon *daemon, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon == NULL)
- {
+ if (daemon == NULL) {
dlt_log(LOG_WARNING, "Wrong parameter: Null pointer\n");
return;
}
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return;
- }
- for (count = 0; count < user_list->num_contexts; count ++)
- {
+ for (count = 0; count < user_list->num_contexts; count++) {
context = &(user_list->contexts[count]);
- if (context != NULL)
- {
+ if (context != NULL) {
if ((context->log_level == DLT_LOG_DEFAULT) ||
- (context->trace_status == DLT_TRACE_STATUS_DEFAULT))
- {
- if (context->user_handle >= DLT_FD_MINIMUM)
- {
+ (context->trace_status == DLT_TRACE_STATUS_DEFAULT)) {
+ if (context->user_handle >= DLT_FD_MINIMUM) {
if (dlt_daemon_user_send_log_level(daemon,
context,
verbose) == -1)
- {
dlt_vlog(LOG_WARNING, "Cannot update default of %.4s:%.4s\n", context->apid, context->ctid);
- }
}
}
}
@@ -1657,30 +1518,28 @@ void dlt_daemon_user_send_all_log_level_update(DltDaemon *daemon, int8_t log_lev
PRINT_FUNCTION_VERBOSE(verbose);
if (daemon == NULL)
- {
return;
- }
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return;
- }
- for (count = 0; count < user_list->num_contexts; count++)
- {
+ for (count = 0; count < user_list->num_contexts; count++) {
context = &(user_list->contexts[count]);
- if (context)
- {
- if (context->user_handle >= DLT_FD_MINIMUM)
- {
+
+ if (context) {
+ if (context->user_handle >= DLT_FD_MINIMUM) {
context->log_level = log_level;
+
if (dlt_daemon_user_send_log_level(daemon,
context,
verbose) == -1)
- {
- dlt_vlog(LOG_WARNING, "Cannot send log level %.4s:%.4s -> %i\n", context->apid, context->ctid, context->log_level);
- }
+ dlt_vlog(LOG_WARNING,
+ "Cannot send log level %.4s:%.4s -> %i\n",
+ context->apid,
+ context->ctid,
+ context->log_level);
}
}
}
@@ -1695,29 +1554,28 @@ void dlt_daemon_user_send_all_trace_status_update(DltDaemon *daemon, int8_t trac
PRINT_FUNCTION_VERBOSE(verbose);
if (daemon == NULL)
- {
return;
- }
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return;
- }
+
dlt_vlog(LOG_NOTICE, "All trace status is updated -> %i\n", trace_status);
- for (count = 0; count < user_list->num_contexts; count++)
- {
+ for (count = 0; count < user_list->num_contexts; count++) {
context = &(user_list->contexts[count]);
- if (context)
- {
- if (context->user_handle >= DLT_FD_MINIMUM)
- {
+
+ if (context) {
+ if (context->user_handle >= DLT_FD_MINIMUM) {
context->trace_status = trace_status;
+
if (dlt_daemon_user_send_log_level(daemon, context, verbose) == -1)
- {
- dlt_vlog(LOG_WARNING, "Cannot send trace status %.4s:%.4s -> %i\n", context->apid, context->ctid, context->trace_status);
- }
+ dlt_vlog(LOG_WARNING,
+ "Cannot send trace status %.4s:%.4s -> %i\n",
+ context->apid,
+ context->ctid,
+ context->trace_status);
}
}
}
@@ -1731,30 +1589,23 @@ void dlt_daemon_user_send_all_log_state(DltDaemon *daemon, int verbose)
PRINT_FUNCTION_VERBOSE(verbose);
- if (daemon == NULL)
- {
+ if (daemon == NULL) {
dlt_log(LOG_WARNING, "Wrong parameter: Null pointer\n");
return;
}
user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+
if (user_list == NULL)
- {
return;
- }
- for (count = 0; count < user_list->num_applications; count ++)
- {
+ for (count = 0; count < user_list->num_applications; count++) {
app = &(user_list->applications[count]);
- if (app != NULL)
- {
- if (app->user_handle >= DLT_FD_MINIMUM)
- {
+ if (app != NULL) {
+ if (app->user_handle >= DLT_FD_MINIMUM) {
if (dlt_daemon_user_send_log_state(daemon, app, verbose) == -1)
- {
- dlt_vlog(LOG_WARNING, "Cannot send log state to Apid: %.4s, PID: %d\n",app->apid, app->pid);
- }
+ dlt_vlog(LOG_WARNING, "Cannot send log state to Apid: %.4s, PID: %d\n", app->apid, app->pid);
}
}
}
@@ -1762,28 +1613,26 @@ void dlt_daemon_user_send_all_log_state(DltDaemon *daemon, int verbose)
void dlt_daemon_change_state(DltDaemon *daemon, DltDaemonState newState)
{
- switch(newState)
- {
- case DLT_DAEMON_STATE_INIT:
- dlt_log(LOG_INFO,"Switched to init state.\n");
- daemon->state = DLT_DAEMON_STATE_INIT;
- break;
- case DLT_DAEMON_STATE_BUFFER:
- dlt_log(LOG_INFO,"Switched to buffer state for socket connections.\n");
- daemon->state = DLT_DAEMON_STATE_BUFFER;
- break;
- case DLT_DAEMON_STATE_BUFFER_FULL:
- dlt_log(LOG_INFO,"Switched to buffer full state.\n");
- daemon->state = DLT_DAEMON_STATE_BUFFER_FULL;
- break;
- case DLT_DAEMON_STATE_SEND_BUFFER:
- dlt_log(LOG_INFO,"Switched to send buffer state for socket connections.\n");
- daemon->state = DLT_DAEMON_STATE_SEND_BUFFER;
- break;
- case DLT_DAEMON_STATE_SEND_DIRECT:
- dlt_log(LOG_INFO,"Switched to send direct state.\n");
- daemon->state = DLT_DAEMON_STATE_SEND_DIRECT;
- break;
+ switch (newState) {
+ case DLT_DAEMON_STATE_INIT:
+ dlt_log(LOG_INFO, "Switched to init state.\n");
+ daemon->state = DLT_DAEMON_STATE_INIT;
+ break;
+ case DLT_DAEMON_STATE_BUFFER:
+ dlt_log(LOG_INFO, "Switched to buffer state for socket connections.\n");
+ daemon->state = DLT_DAEMON_STATE_BUFFER;
+ break;
+ case DLT_DAEMON_STATE_BUFFER_FULL:
+ dlt_log(LOG_INFO, "Switched to buffer full state.\n");
+ daemon->state = DLT_DAEMON_STATE_BUFFER_FULL;
+ break;
+ case DLT_DAEMON_STATE_SEND_BUFFER:
+ dlt_log(LOG_INFO, "Switched to send buffer state for socket connections.\n");
+ daemon->state = DLT_DAEMON_STATE_SEND_BUFFER;
+ break;
+ case DLT_DAEMON_STATE_SEND_DIRECT:
+ dlt_log(LOG_INFO, "Switched to send direct state.\n");
+ daemon->state = DLT_DAEMON_STATE_SEND_DIRECT;
+ break;
}
-
}
diff --git a/src/daemon/dlt_daemon_common.h b/src/daemon/dlt_daemon_common.h
index 4110a72..112cb92 100644
--- a/src/daemon/dlt_daemon_common.h
+++ b/src/daemon/dlt_daemon_common.h
@@ -64,41 +64,41 @@
* $LastChangedRevision: 1670 $
* $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
* $LastChangedBy$
- Initials Date Comment
- aw 15.02.2010 initial
+ * Initials Date Comment
+ * aw 15.02.2010 initial
*/
#ifndef DLT_DAEMON_COMMON_H
-#define DLT_DAEMON_COMMON_H
+# define DLT_DAEMON_COMMON_H
/**
- \defgroup daemonapi DLT Daemon API
- \addtogroup daemonapi
- \{
-*/
+ * \defgroup daemonapi DLT Daemon API
+ * \addtogroup daemonapi
+ \{
+ */
-#include <limits.h>
-#include <semaphore.h>
-#include "dlt_common.h"
-#include "dlt_user.h"
-#include "dlt_offline_logstorage.h"
-#include "dlt_gateway_types.h"
+# include <limits.h>
+# include <semaphore.h>
+# include "dlt_common.h"
+# include "dlt_user.h"
+# include "dlt_offline_logstorage.h"
+# include "dlt_gateway_types.h"
-#ifdef __cplusplus
+# ifdef __cplusplus
extern "C" {
-#endif
+# endif
-#define DLT_DAEMON_RINGBUFFER_MIN_SIZE 500000 /**< Ring buffer size for storing log messages while no client is connected */
-#define DLT_DAEMON_RINGBUFFER_MAX_SIZE 10000000 /**< Ring buffer size for storing log messages while no client is connected */
-#define DLT_DAEMON_RINGBUFFER_STEP_SIZE 500000 /**< Ring buffer size for storing log messages while no client is connected */
+# define DLT_DAEMON_RINGBUFFER_MIN_SIZE 500000/**< Ring buffer size for storing log messages while no client is connected */
+# define DLT_DAEMON_RINGBUFFER_MAX_SIZE 10000000/**< Ring buffer size for storing log messages while no client is connected */
+# define DLT_DAEMON_RINGBUFFER_STEP_SIZE 500000/**< Ring buffer size for storing log messages while no client is connected */
-#define DLT_DAEMON_SEND_TO_ALL -3 /**< Constant value to identify the command "send to all" */
-#define DLT_DAEMON_SEND_FORCE -4 /**< Constant value to identify the command "send force to all" */
+# define DLT_DAEMON_SEND_TO_ALL -3/**< Constant value to identify the command "send to all" */
+# define DLT_DAEMON_SEND_FORCE -4/**< Constant value to identify the command "send force to all" */
/* Use a semaphore or mutex from your OS to prevent concurrent access to the DLT buffer. */
-#define DLT_DAEMON_SEM_LOCK() { sem_wait(&dlt_daemon_mutex); }
-#define DLT_DAEMON_SEM_FREE() { sem_post(&dlt_daemon_mutex); }
+# define DLT_DAEMON_SEM_LOCK() { sem_wait(&dlt_daemon_mutex); }
+# define DLT_DAEMON_SEM_FREE() { sem_post(&dlt_daemon_mutex); }
extern sem_t dlt_daemon_mutex;
/**
@@ -106,11 +106,11 @@ extern sem_t dlt_daemon_mutex;
*/
typedef enum
{
- DLT_DAEMON_STATE_INIT = 0, /**< Initial state */
- DLT_DAEMON_STATE_BUFFER = 1, /**< logging is buffered until external logger is connected or internal logging is activated */
- DLT_DAEMON_STATE_BUFFER_FULL = 2, /**< then internal buffer is full, wait for connect from client */
- DLT_DAEMON_STATE_SEND_BUFFER = 3, /**< external logger is connected, but buffer is still not empty or external logger queue is full */
- DLT_DAEMON_STATE_SEND_DIRECT = 4 /**< External logger is connected or internal logging is active, and buffer is empty */
+ DLT_DAEMON_STATE_INIT = 0, /**< Initial state */
+ DLT_DAEMON_STATE_BUFFER = 1, /**< logging is buffered until external logger is connected or internal logging is activated */
+ DLT_DAEMON_STATE_BUFFER_FULL = 2, /**< then internal buffer is full, wait for connect from client */
+ DLT_DAEMON_STATE_SEND_BUFFER = 3, /**< external logger is connected, but buffer is still not empty or external logger queue is full */
+ DLT_DAEMON_STATE_SEND_DIRECT = 4 /**< External logger is connected or internal logging is active, and buffer is empty */
} DltDaemonState;
/**
@@ -118,7 +118,7 @@ typedef enum
*/
typedef struct
{
- char apid[DLT_ID_SIZE]; /**< application id */
+ char apid[DLT_ID_SIZE]; /**< application id */
pid_t pid; /**< process id of user application */
int user_handle; /**< connection handle for connection to user application */
char *application_description; /**< context description */
@@ -192,14 +192,22 @@ typedef struct
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_init(DltDaemon *daemon,unsigned long RingbufferMinSize,unsigned long RingbufferMaxSize,unsigned long RingbufferStepSize,const char *runtime_directory,int InitialContextLogLevel, int InitialContextTraceStatus, int ForceLLTS, int verbose);
+int dlt_daemon_init(DltDaemon *daemon,
+ unsigned long RingbufferMinSize,
+ unsigned long RingbufferMaxSize,
+ unsigned long RingbufferStepSize,
+ const char *runtime_directory,
+ int InitialContextLogLevel,
+ int InitialContextTraceStatus,
+ int ForceLLTS,
+ int verbose);
/**
* De-Initialise the dlt daemon structure
* @param daemon pointer to dlt daemon structure
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_free(DltDaemon *daemon,int verbose);
+int dlt_daemon_free(DltDaemon *daemon, int verbose);
/**
* Initialize data structures to store information about applications running on same
* or passive node.
@@ -245,7 +253,7 @@ int dlt_daemon_load_runtime_configuration(DltDaemon *daemon,
* @param verbose if set to true verbose information is printed out.
* @return Pointer to added context, null pointer on error
*/
-DltDaemonApplication* dlt_daemon_application_add(DltDaemon *daemon,
+DltDaemonApplication *dlt_daemon_application_add(DltDaemon *daemon,
char *apid,
pid_t pid,
char *description,
@@ -272,7 +280,7 @@ int dlt_daemon_application_del(DltDaemon *daemon,
* @param verbose if set to true verbose information is printed out.
* @return Pointer to application, null pointer on error or not found
*/
-DltDaemonApplication* dlt_daemon_application_find(DltDaemon *daemon,
+DltDaemonApplication *dlt_daemon_application_find(DltDaemon *daemon,
char *apid,
char *ecu,
int verbose);
@@ -283,7 +291,7 @@ DltDaemonApplication* dlt_daemon_application_find(DltDaemon *daemon,
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_applications_load(DltDaemon *daemon,const char *filename, int verbose);
+int dlt_daemon_applications_load(DltDaemon *daemon, const char *filename, int verbose);
/**
* Save applications from internal context management to file
* @param daemon pointer to dlt daemon structure
@@ -291,7 +299,7 @@ int dlt_daemon_applications_load(DltDaemon *daemon,const char *filename, int ver
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_applications_save(DltDaemon *daemon,const char *filename, int verbose);
+int dlt_daemon_applications_save(DltDaemon *daemon, const char *filename, int verbose);
/**
* Invalidate all applications fd, if fd is reused
* @param daemon pointer to dlt daemon structure
@@ -311,7 +319,7 @@ int dlt_daemon_applications_invalidate_fd(DltDaemon *daemon,
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_applications_clear(DltDaemon *daemon,char *ecu, int verbose);
+int dlt_daemon_applications_clear(DltDaemon *daemon, char *ecu, int verbose);
/**
* Add (new) context to internal context management
@@ -327,7 +335,7 @@ int dlt_daemon_applications_clear(DltDaemon *daemon,char *ecu, int verbose);
* @param verbose if set to true verbose information is printed out.
* @return Pointer to added context, null pointer on error
*/
-DltDaemonContext* dlt_daemon_context_add(DltDaemon *daemon,
+DltDaemonContext *dlt_daemon_context_add(DltDaemon *daemon,
char *apid,
char *ctid,
int8_t log_level,
@@ -346,7 +354,7 @@ DltDaemonContext* dlt_daemon_context_add(DltDaemon *daemon,
* @return negative value if there was an error
*/
int dlt_daemon_context_del(DltDaemon *daemon,
- DltDaemonContext* context,
+ DltDaemonContext *context,
char *ecu,
int verbose);
/**
@@ -358,7 +366,7 @@ int dlt_daemon_context_del(DltDaemon *daemon,
* @param verbose if set to true verbose information is printed out.
* @return Pointer to context, null pointer on error or not found
*/
-DltDaemonContext* dlt_daemon_context_find(DltDaemon *daemon,
+DltDaemonContext *dlt_daemon_context_find(DltDaemon *daemon,
char *apid,
char *ctid,
char *ecu,
@@ -390,7 +398,7 @@ int dlt_daemon_contexts_clear(DltDaemon *daemon, char *ecu, int verbose);
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_contexts_load(DltDaemon *daemon,const char *filename, int verbose);
+int dlt_daemon_contexts_load(DltDaemon *daemon, const char *filename, int verbose);
/**
* Save contexts from internal context management to file
* @param daemon pointer to dlt daemon structure
@@ -398,7 +406,7 @@ int dlt_daemon_contexts_load(DltDaemon *daemon,const char *filename, int verbose
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_contexts_save(DltDaemon *daemon,const char *filename, int verbose);
+int dlt_daemon_contexts_save(DltDaemon *daemon, const char *filename, int verbose);
/**
* Load persistant configuration
* @param daemon pointer to dlt daemon structure
@@ -406,7 +414,7 @@ int dlt_daemon_contexts_save(DltDaemon *daemon,const char *filename, int verbose
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_configuration_load(DltDaemon *daemon,const char *filename, int verbose);
+int dlt_daemon_configuration_load(DltDaemon *daemon, const char *filename, int verbose);
/**
* Save configuration persistantly
* @param daemon pointer to dlt daemon structure
@@ -414,7 +422,7 @@ int dlt_daemon_configuration_load(DltDaemon *daemon,const char *filename, int ve
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_configuration_save(DltDaemon *daemon,const char *filename, int verbose);
+int dlt_daemon_configuration_save(DltDaemon *daemon, const char *filename, int verbose);
/**
@@ -424,7 +432,7 @@ int dlt_daemon_configuration_save(DltDaemon *daemon,const char *filename, int ve
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_user_send_log_level(DltDaemon *daemon,DltDaemonContext *context, int verbose);
+int dlt_daemon_user_send_log_level(DltDaemon *daemon, DltDaemonContext *context, int verbose);
/**
* Send user message DLT_USER_MESSAGE_LOG_STATE to user application
@@ -433,7 +441,7 @@ int dlt_daemon_user_send_log_level(DltDaemon *daemon,DltDaemonContext *context,
* @param verbose if set to true verbose information is printed out.
* @return negative value if there was an error
*/
-int dlt_daemon_user_send_log_state(DltDaemon *daemon,DltDaemonApplication *app,int verbose);
+int dlt_daemon_user_send_log_state(DltDaemon *daemon, DltDaemonApplication *app, int verbose);
/**
* Send user messages to all user applications using default context, or trace status
@@ -477,7 +485,13 @@ void dlt_daemon_user_send_all_log_state(DltDaemon *daemon, int verbose);
* @param ForceLLTS force default log-level
* @param verbose if set to true verbose information is printed out.
*/
-void dlt_daemon_control_reset_to_factory_default(DltDaemon *daemon,const char *filename, const char *filename1, int InitialContextLogLevel, int InitialContextTraceStatus, int InitialEnforceLlTsStatus, int verbose);
+void dlt_daemon_control_reset_to_factory_default(DltDaemon *daemon,
+ const char *filename,
+ const char *filename1,
+ int InitialContextLogLevel,
+ int InitialContextTraceStatus,
+ int InitialEnforceLlTsStatus,
+ int verbose);
/**
* Change the logging state of dlt daemon
@@ -486,12 +500,12 @@ void dlt_daemon_control_reset_to_factory_default(DltDaemon *daemon,const char *f
*/
void dlt_daemon_change_state(DltDaemon *daemon, DltDaemonState newState);
-#ifdef __cplusplus
+# ifdef __cplusplus
}
-#endif
+# endif
/**
- \}
-*/
+ \}
+ */
#endif /* DLT_DAEMON_COMMON_H */
diff --git a/src/daemon/dlt_daemon_common_cfg.h b/src/daemon/dlt_daemon_common_cfg.h
index 468ed41..31d2f8b 100644
--- a/src/daemon/dlt_daemon_common_cfg.h
+++ b/src/daemon/dlt_daemon_common_cfg.h
@@ -22,7 +22,7 @@
* License MPL-2.0: Mozilla Public License version 2.0 http://mozilla.org/MPL/2.0/.
*
* \file dlt_daemon_common_cfg.h
-*/
+ */
@@ -86,30 +86,30 @@
/* Default Path for control socket */
#define DLT_DAEMON_DEFAULT_CTRL_SOCK_PATH DLT_RUNTIME_DEFAULT_DIRECTORY \
- "/dlt-ctrl.sock"
+ "/dlt-ctrl.sock"
#ifdef DLT_USE_UNIX_SOCKET_IPC
-#define DLT_DAEMON_DEFAULT_APP_SOCK_PATH DLT_RUNTIME_DEFAULT_DIRECTORY \
- "/dlt-app.sock"
+# define DLT_DAEMON_DEFAULT_APP_SOCK_PATH DLT_RUNTIME_DEFAULT_DIRECTORY \
+ "/dlt-app.sock"
#endif
/* Size of text buffer */
#define DLT_DAEMON_COMMON_TEXTBUFSIZE 255
/* Application ID used when the dlt daemon creates a control message */
-#define DLT_DAEMON_CTRL_APID "DA1"
+#define DLT_DAEMON_CTRL_APID "DA1"
/* Context ID used when the dlt daemon creates a control message */
-#define DLT_DAEMON_CTRL_CTID "DC1"
+#define DLT_DAEMON_CTRL_CTID "DC1"
/* Number of entries to be allocated at one in application table,
- when no more entries are available */
+ * when no more entries are available */
#define DLT_DAEMON_APPL_ALLOC_SIZE 500
/* Number of entries to be allocated at one in context table,
- when no more entries are available */
+ * when no more entries are available */
#define DLT_DAEMON_CONTEXT_ALLOC_SIZE 1000
/* Debug get log info function,
- set to 1 to enable, 0 to disable debugging */
+ * set to 1 to enable, 0 to disable debugging */
#define DLT_DEBUG_GETLOGINFO 0
/************************/
diff --git a/src/daemon/dlt_daemon_connection.c b/src/daemon/dlt_daemon_connection.c
index c9e7be7..669a7b1 100644
--- a/src/daemon/dlt_daemon_connection.c
+++ b/src/daemon/dlt_daemon_connection.c
@@ -67,36 +67,33 @@ extern char *app_recv_buffer;
* errno is appropriately set.
*/
DLT_STATIC int dlt_connection_send(DltConnection *conn,
- void *msg,
- size_t msg_size)
+ void *msg,
+ size_t msg_size)
{
DltConnectionType type = DLT_CONNECTION_TYPE_MAX;
int bytes_sent = 0;
int ret = 0;
if ((conn != NULL) && (conn->receiver != NULL))
- {
type = conn->type;
- }
- switch (type)
- {
- case DLT_CONNECTION_CLIENT_MSG_SERIAL:
- if (write(conn->receiver->fd, msg, msg_size) > 0)
- {
- return DLT_DAEMON_ERROR_OK;
- }
- return DLT_DAEMON_ERROR_UNKNOWN;
-
- case DLT_CONNECTION_CLIENT_MSG_TCP:
- ret = dlt_daemon_socket_sendreliable(conn->receiver->fd,
- msg,
- msg_size,
- &bytes_sent);
- conn->receiver->bytes_sent += bytes_sent;
- return ret;
- default:
- return DLT_DAEMON_ERROR_UNKNOWN;
+ switch (type) {
+ case DLT_CONNECTION_CLIENT_MSG_SERIAL:
+
+ if (write(conn->receiver->fd, msg, msg_size) > 0)
+ return DLT_DAEMON_ERROR_OK;
+
+ return DLT_DAEMON_ERROR_UNKNOWN;
+
+ case DLT_CONNECTION_CLIENT_MSG_TCP:
+ ret = dlt_daemon_socket_sendreliable(conn->receiver->fd,
+ msg,
+ msg_size,
+ &bytes_sent);
+ conn->receiver->bytes_sent += bytes_sent;
+ return ret;
+ default:
+ return DLT_DAEMON_ERROR_UNKNOWN;
}
}
@@ -115,35 +112,27 @@ DLT_STATIC int dlt_connection_send(DltConnection *conn,
* @return DLT_DAEMON_ERROR_OK on success, -1 otherwise. errno is properly set.
*/
int dlt_connection_send_multiple(DltConnection *con,
- void *data1,
- int size1,
- void *data2,
- int size2,
- int sendserialheader)
+ void *data1,
+ int size1,
+ void *data2,
+ int size2,
+ int sendserialheader)
{
int ret = 0;
if (con == NULL)
- {
return DLT_DAEMON_ERROR_UNKNOWN;
- }
if (sendserialheader)
- {
ret = dlt_connection_send(con,
- (void *)dltSerialHeader,
- sizeof(dltSerialHeader));
- }
+ (void *)dltSerialHeader,
+ sizeof(dltSerialHeader));
if ((data1 != NULL) && (ret == DLT_RETURN_OK))
- {
ret = dlt_connection_send(con, data1, size1);
- }
if ((data2 != NULL) && (ret == DLT_RETURN_OK))
- {
ret = dlt_connection_send(con, data2, size2);
- }
return ret;
}
@@ -163,9 +152,7 @@ int dlt_connection_send_multiple(DltConnection *con,
DltConnection *dlt_connection_get_next(DltConnection *current, int type_mask)
{
while (current && !((1 << current->type) & type_mask))
- {
current = current->next;
- }
return current;
}
@@ -175,8 +162,7 @@ DLT_STATIC void dlt_connection_destroy_receiver(DltConnection *con)
if (!con)
return;
- switch (con->type)
- {
+ switch (con->type) {
case DLT_CONNECTION_GATEWAY:
/* We rely on the gateway for clean-up */
break;
@@ -186,7 +172,7 @@ DLT_STATIC void dlt_connection_destroy_receiver(DltConnection *con)
con->receiver = NULL;
break;
default:
- (void) dlt_receiver_free(con->receiver);
+ (void)dlt_receiver_free(con->receiver);
free(con->receiver);
con->receiver = NULL;
break;
@@ -208,13 +194,12 @@ DLT_STATIC void dlt_connection_destroy_receiver(DltConnection *con)
* @return DltReceiver structure or NULL if none corresponds to the type.
*/
DLT_STATIC DltReceiver *dlt_connection_get_receiver(DltDaemonLocal *daemon_local,
- DltConnectionType type,
- int fd)
+ DltConnectionType type,
+ int fd)
{
DltReceiver *ret = NULL;
- switch (type)
- {
+ switch (type) {
case DLT_CONNECTION_CONTROL_CONNECT:
/* FALL THROUGH */
case DLT_CONNECTION_CONTROL_MSG:
@@ -223,26 +208,29 @@ DLT_STATIC DltReceiver *dlt_connection_get_receiver(DltDaemonLocal *daemon_local
/* FALL THROUGH */
case DLT_CONNECTION_CLIENT_MSG_TCP:
ret = calloc(1, sizeof(DltReceiver));
- if (ret) {
+
+ if (ret)
dlt_receiver_init(ret, fd, DLT_DAEMON_RCVBUFSIZESOCK);
- }
+
break;
case DLT_CONNECTION_CLIENT_MSG_SERIAL:
ret = calloc(1, sizeof(DltReceiver));
- if (ret) {
+
+ if (ret)
dlt_receiver_init(ret, fd, DLT_DAEMON_RCVBUFSIZESERIAL);
- }
+
break;
case DLT_CONNECTION_APP_MSG:
ret = calloc(1, sizeof(DltReceiver));
- if (ret)
- {
+
+ if (ret) {
#ifdef DLT_USE_UNIX_SOCKET_IPC
dlt_receiver_init_unix_socket(ret, fd, &app_recv_buffer);
#else
dlt_receiver_init(ret, fd, DLT_RECEIVE_BUFSIZE);
#endif
}
+
break;
case DLT_CONNECTION_APP_CONNECT:
/* FALL THROUGH */
@@ -256,9 +244,10 @@ DLT_STATIC DltReceiver *dlt_connection_get_receiver(DltDaemonLocal *daemon_local
/* FALL THROUGH */
case DLT_CONNECTION_GATEWAY_TIMER:
ret = calloc(1, sizeof(DltReceiver));
- if (ret) {
+
+ if (ret)
dlt_receiver_init(ret, fd, DLT_DAEMON_RCVBUFSIZE);
- }
+
break;
case DLT_CONNECTION_GATEWAY:
/* We rely on the gateway for init */
@@ -288,12 +277,9 @@ void *dlt_connection_get_callback(DltConnection *con)
DltConnectionType type = DLT_CONNECTION_TYPE_MAX;
if (con)
- {
type = con->type;
- }
- switch (type)
- {
+ switch (type) {
case DLT_CONNECTION_CLIENT_CONNECT:
ret = dlt_daemon_process_client_connect;
break;
@@ -377,32 +363,28 @@ void dlt_connection_destroy(DltConnection *to_destroy)
* @return 0 On success, -1 otherwise.
*/
int dlt_connection_create(DltDaemonLocal *daemon_local,
- DltEventHandler *evh,
- int fd,
- int mask,
- DltConnectionType type)
+ DltEventHandler *evh,
+ int fd,
+ int mask,
+ DltConnectionType type)
{
DltConnection *temp = NULL;
- if (fd < 0) {
+ if (fd < 0)
/* Nothing to do */
return 0;
- }
if (dlt_event_handler_find_connection(evh, fd) != NULL)
- {
/* No need for the same client to be registered twice
* for the same event.
* TODO: If another mask can be expected,
* we need it to update the poll event here.
*/
return 0;
- }
temp = (DltConnection *)malloc(sizeof(DltConnection));
- if (temp == NULL)
- {
+ if (temp == NULL) {
dlt_log(LOG_CRIT, "Allocation of client handle failed\n");
return -1;
}
@@ -410,6 +392,7 @@ int dlt_connection_create(DltDaemonLocal *daemon_local,
memset(temp, 0, sizeof(DltConnection));
temp->receiver = dlt_connection_get_receiver(daemon_local, type, fd);
+
if (!temp->receiver) {
char local_str[DLT_DAEMON_TEXTBUFSIZE];
snprintf(local_str,
@@ -424,11 +407,10 @@ int dlt_connection_create(DltDaemonLocal *daemon_local,
/* We are single threaded no need for protection. */
temp->id = connectionId++;
+
if (!temp->id)
- {
/* Skipping 0 */
temp->id = connectionId++;
- }
temp->type = type;
temp->status = ACTIVE;
diff --git a/src/daemon/dlt_daemon_connection.h b/src/daemon/dlt_daemon_connection.h
index 00759c6..e46c05c 100644
--- a/src/daemon/dlt_daemon_connection.h
+++ b/src/daemon/dlt_daemon_connection.h
@@ -40,24 +40,24 @@ DltConnection *dlt_connection_get_next(DltConnection *, int);
int dlt_connection_create_remaining(DltDaemonLocal *);
int dlt_connection_create(DltDaemonLocal *,
- DltEventHandler *,
- int,
- int,
- DltConnectionType);
+ DltEventHandler *,
+ int,
+ int,
+ DltConnectionType);
void dlt_connection_destroy(DltConnection *);
void *dlt_connection_get_callback(DltConnection *);
#ifdef DLT_UNIT_TESTS
int dlt_connection_send(DltConnection *conn,
- void *msg,
- size_t msg_size);
+ void *msg,
+ size_t msg_size);
void dlt_connection_destroy_receiver(DltConnection *con);
DltReceiver *dlt_connection_get_receiver(DltDaemonLocal *daemon_local,
- DltConnectionType type,
- int fd);
+ DltConnectionType type,
+ int fd);
#endif
#endif /* DLT_DAEMON_CONNECTION_H */
diff --git a/src/daemon/dlt_daemon_event_handler.c b/src/daemon/dlt_daemon_event_handler.c
index 029e938..895a896 100644
--- a/src/daemon/dlt_daemon_event_handler.c
+++ b/src/daemon/dlt_daemon_event_handler.c
@@ -81,22 +81,17 @@ int dlt_daemon_prepare_event_handling(DltEventHandler *ev)
int i = 0;
if (ev == NULL)
- {
return DLT_RETURN_ERROR;
- }
ev->pfd = calloc(DLT_EV_BASE_FD, sizeof(struct pollfd));
- if (ev->pfd == NULL)
- {
+ if (ev->pfd == NULL) {
dlt_log(LOG_CRIT, "Creation of poll instance failed!\n");
return -1;
}
for (i = 0; i < DLT_EV_BASE_FD; i++)
- {
init_poll_fd(&ev->pfd[i]);
- }
ev->nfds = 0;
ev->max_nfds = DLT_EV_BASE_FD;
@@ -115,14 +110,12 @@ int dlt_daemon_prepare_event_handling(DltEventHandler *ev)
*/
static void dlt_event_handler_enable_fd(DltEventHandler *ev, int fd, int mask)
{
- if (ev->max_nfds <= ev->nfds)
- {
+ if (ev->max_nfds <= ev->nfds) {
int i = ev->nfds;
int max = 2 * ev->max_nfds;
struct pollfd *tmp = realloc(ev->pfd, max * sizeof(*ev->pfd));
- if (!tmp)
- {
+ if (!tmp) {
dlt_log(LOG_CRIT,
"Unable to register new fd for the event handler.\n");
return;
@@ -132,9 +125,7 @@ static void dlt_event_handler_enable_fd(DltEventHandler *ev, int fd, int mask)
ev->max_nfds = max;
for (; i < max; i++)
- {
init_poll_fd(&ev->pfd[i]);
- }
}
ev->pfd[ev->nfds].fd = fd;
@@ -156,29 +147,23 @@ static void dlt_event_handler_disable_fd(DltEventHandler *ev, int fd)
unsigned int j = 0;
unsigned int nfds = ev->nfds;
- for (; i < nfds; i++, j++)
- {
- if (ev->pfd[i].fd == fd)
- {
+ for (; i < nfds; i++, j++) {
+ if (ev->pfd[i].fd == fd) {
init_poll_fd(&ev->pfd[i]);
j++;
ev->nfds--;
}
if (i == j)
- {
continue;
- }
/* Compressing the table */
- if (i < ev->nfds)
- {
+ if (i < ev->nfds) {
ev->pfd[i].fd = ev->pfd[j].fd;
ev->pfd[i].events = ev->pfd[j].events;
ev->pfd[i].revents = ev->pfd[j].revents;
}
- else
- {
+ else {
init_poll_fd(&ev->pfd[i]);
}
}
@@ -205,82 +190,65 @@ int dlt_daemon_handle_event(DltEventHandler *pEvent,
char str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
int (*callback)(DltDaemon *, DltDaemonLocal *, DltReceiver *, int) = NULL;
- if ((pEvent == NULL) || (daemon == NULL) || (daemon_local == NULL))
- {
+ if ((pEvent == NULL) || (daemon == NULL) || (daemon_local == NULL))
return DLT_RETURN_ERROR;
- }
ret = poll(pEvent->pfd, pEvent->nfds, DLT_EV_TIMEOUT_MSEC);
- if (ret <= 0)
- {
+ if (ret <= 0) {
/* We are not interested in EINTR has it comes
* either from timeout or signal.
*/
if (errno == EINTR)
- {
ret = 0;
- }
if (ret < 0)
- {
dlt_vlog(LOG_CRIT, "poll() failed: %s\n", strerror(errno));
- }
return ret;
}
- for (i = 0 ; i < pEvent->nfds ; i++)
- {
+ for (i = 0; i < pEvent->nfds; i++) {
int fd = 0;
DltConnection *con = NULL;
DltConnectionType type = DLT_CONNECTION_TYPE_MAX;
if (pEvent->pfd[i].revents == 0)
- {
continue;
- }
con = dlt_event_handler_find_connection(pEvent, pEvent->pfd[i].fd);
- if (con && con->receiver)
- {
+ if (con && con->receiver) {
type = con->type;
fd = con->receiver->fd;
}
- else /* connection might have been destroyed in the meanwhile */
- {
+ else { /* connection might have been destroyed in the meanwhile */
dlt_event_handler_disable_fd(pEvent, pEvent->pfd[i].fd);
continue;
}
/* First of all handle error events */
- if (pEvent->pfd[i].revents & DLT_EV_MASK_REJECTED)
- {
+ if (pEvent->pfd[i].revents & DLT_EV_MASK_REJECTED) {
/* An error occurred, we need to clean-up the concerned event
*/
if (type == DLT_CONNECTION_CLIENT_MSG_TCP)
- {
/* To transition to BUFFER state if this is final TCP client connection,
* call dedicated function. this function also calls
* dlt_event_handler_unregister_connection() inside the function.
*/
dlt_daemon_close_socket(fd, daemon, daemon_local, 0);
- }
else
- {
dlt_event_handler_unregister_connection(pEvent,
daemon_local,
fd);
- }
+
continue;
}
/* Get the function to be used to handle the event */
callback = dlt_connection_get_callback(con);
- if (!callback)
- {
+ if (!callback) {
snprintf(str,
DLT_DAEMON_TEXTBUFSIZE,
"Unable to find function for %d handle type.\n",
@@ -293,16 +261,16 @@ int dlt_daemon_handle_event(DltEventHandler *pEvent,
if (callback(daemon,
daemon_local,
con->receiver,
- daemon_local->flags.vflag) == -1)
- {
+ daemon_local->flags.vflag) == -1) {
snprintf(str,
DLT_DAEMON_TEXTBUFSIZE,
"Processing from %d handle type failed!\n",
- type );
+ type);
dlt_log(LOG_CRIT, str);
return -1;
}
}
+
return 0;
}
@@ -318,15 +286,13 @@ int dlt_daemon_handle_event(DltEventHandler *pEvent,
* @return The found connection pointer, NULL otherwise.
*/
DltConnection *dlt_event_handler_find_connection(DltEventHandler *ev,
- int fd)
+ int fd)
{
DltConnection *temp = ev->connections;
while ((temp != NULL) && (temp->receiver->fd != fd))
- {
temp = temp->next;
- }
return temp;
}
@@ -342,25 +308,21 @@ DltConnection *dlt_event_handler_find_connection(DltEventHandler *ev,
* @return 0 on success, -1 if the connection is not found.
*/
DLT_STATIC int dlt_daemon_remove_connection(DltEventHandler *ev,
- DltConnection *to_remove)
+ DltConnection *to_remove)
{
- if (ev == NULL || to_remove == NULL)
- {
+ if ((ev == NULL) || (to_remove == NULL))
return DLT_RETURN_ERROR;
- }
DltConnection *curr = ev->connections;
DltConnection *prev = curr;
/* Find the address where to_remove value is registered */
- while (curr && (curr != to_remove))
- {
+ while (curr && (curr != to_remove)) {
prev = curr;
curr = curr->next;
}
- if (!curr)
- {
+ if (!curr) {
/* Must not be possible as we check for existence before */
dlt_log(LOG_CRIT, "Connection not found for removal.\n");
return -1;
@@ -369,8 +331,7 @@ DLT_STATIC int dlt_daemon_remove_connection(DltEventHandler *ev,
{
ev->connections = curr->next;
}
- else
- {
+ else {
prev->next = curr->next;
}
@@ -391,21 +352,15 @@ void dlt_event_handler_cleanup_connections(DltEventHandler *ev)
unsigned int i = 0;
if (ev == NULL)
- {
/* Nothing to do. */
return;
- }
while (ev->connections != NULL)
- {
/* We don really care on failure */
(void)dlt_daemon_remove_connection(ev, ev->connections);
- }
for (i = 0; i < ev->nfds; i++)
- {
init_poll_fd(&ev->pfd[i]);
- }
free(ev->pfd);
}
@@ -418,15 +373,14 @@ void dlt_event_handler_cleanup_connections(DltEventHandler *ev)
* @param connection The connection to be added.
*/
DLT_STATIC void dlt_daemon_add_connection(DltEventHandler *ev,
- DltConnection *connection)
+ DltConnection *connection)
{
DltConnection **temp = &ev->connections;
while (*temp != NULL)
- {
temp = &(*temp)->next;
- }
+
*temp = connection;
}
@@ -449,23 +403,21 @@ int dlt_connection_check_activate(DltEventHandler *evhdl,
{
char local_str[DLT_DAEMON_TEXTBUFSIZE] = { '\0' };
- if (!evhdl || !con || !con->receiver)
- {
+ if (!evhdl || !con || !con->receiver) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"%s: wrong parameters (%p %p).\n",
__func__,
evhdl,
con);
- dlt_log(LOG_ERR, local_str);
- return -1;
+ dlt_log(LOG_ERR, local_str);
+ return -1;
}
- switch (con->status)
- {
+ switch (con->status) {
case ACTIVE:
- if (activation_type == DEACTIVATE)
- {
+
+ if (activation_type == DEACTIVATE) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Deactivate connection type: %d\n",
@@ -473,17 +425,17 @@ int dlt_connection_check_activate(DltEventHandler *evhdl,
dlt_log(LOG_INFO, local_str);
dlt_event_handler_disable_fd(evhdl, con->receiver->fd);
-
+
if (con->type == DLT_CONNECTION_CLIENT_CONNECT)
- {
con->receiver->fd = -1;
- }
+
con->status = INACTIVE;
}
+
break;
case INACTIVE:
- if (activation_type == ACTIVATE)
- {
+
+ if (activation_type == ACTIVATE) {
snprintf(local_str,
DLT_DAEMON_TEXTBUFSIZE,
"Activate connection type: %d\n",
@@ -496,14 +448,15 @@ int dlt_connection_check_activate(DltEventHandler *evhdl,
con->status = ACTIVE;
}
+
break;
default:
- snprintf(local_str,
- DLT_DAEMON_TEXTBUFSIZE,
- "Unknown connection status: %d\n",
- con->status);
- dlt_log(LOG_ERR, local_str);
- return -1;
+ snprintf(local_str,
+ DLT_DAEMON_TEXTBUFSIZE,
+ "Unknown connection status: %d\n",
+ con->status);
+ dlt_log(LOG_ERR, local_str);
+ return -1;
}
return 0;
@@ -530,8 +483,7 @@ int dlt_event_handler_register_connection(DltEventHandler *evhdl,
DltConnection *connection,
int mask)
{
- if (!evhdl || !connection || !connection->receiver)
- {
+ if (!evhdl || !connection || !connection->receiver) {
dlt_log(LOG_ERR, "Wrong parameters when registering connection.\n");
return -1;
}
@@ -540,9 +492,7 @@ int dlt_event_handler_register_connection(DltEventHandler *evhdl,
if ((connection->type == DLT_CONNECTION_CLIENT_MSG_TCP) ||
(connection->type == DLT_CONNECTION_CLIENT_MSG_SERIAL))
- {
daemon_local->client_connections++;
- }
/* On creation the connection is not active by default */
connection->status = INACTIVE;
@@ -573,29 +523,24 @@ int dlt_event_handler_unregister_connection(DltEventHandler *evhdl,
DltDaemonLocal *daemon_local,
int fd)
{
- if (evhdl == NULL || daemon_local == NULL)
- {
+ if ((evhdl == NULL) || (daemon_local == NULL))
return DLT_RETURN_ERROR;
- }
/* Look for the pointer in the client list.
* There shall be only one event handler with the same fd.
*/
DltConnection *temp = dlt_event_handler_find_connection(evhdl, fd);
- if (!temp)
- {
+ if (!temp) {
dlt_log(LOG_ERR, "Connection not found for unregistration.\n");
return -1;
}
if ((temp->type == DLT_CONNECTION_CLIENT_MSG_TCP) ||
- (temp->type == DLT_CONNECTION_CLIENT_MSG_SERIAL))
- {
+ (temp->type == DLT_CONNECTION_CLIENT_MSG_SERIAL)) {
daemon_local->client_connections--;
- if (daemon_local->client_connections < 0)
- {
+ if (daemon_local->client_connections < 0) {
daemon_local->client_connections = 0;
dlt_log(LOG_CRIT, "Unregistering more client than registered!\n");
}
@@ -604,9 +549,7 @@ int dlt_event_handler_unregister_connection(DltEventHandler *evhdl,
if (dlt_connection_check_activate(evhdl,
temp,
DEACTIVATE) < 0)
- {
dlt_log(LOG_ERR, "Unable to unregister event.\n");
- }
/* Cannot fail as far as dlt_daemon_find_connection succeed */
return dlt_daemon_remove_connection(evhdl, temp);
diff --git a/src/daemon/dlt_daemon_event_handler.h b/src/daemon/dlt_daemon_event_handler.h
index 280bfd7..53639c4 100644
--- a/src/daemon/dlt_daemon_event_handler.h
+++ b/src/daemon/dlt_daemon_event_handler.h
@@ -42,27 +42,27 @@ int dlt_daemon_handle_event(DltEventHandler *, DltDaemon *, DltDaemonLocal *);
DltConnection *dlt_event_handler_find_connection_by_id(DltEventHandler *,
DltConnectionId);
DltConnection *dlt_event_handler_find_connection(DltEventHandler *,
- int);
+ int);
void dlt_event_handler_cleanup_connections(DltEventHandler *);
int dlt_event_handler_register_connection(DltEventHandler *,
- DltDaemonLocal *,
- DltConnection *,
- int);
+ DltDaemonLocal *,
+ DltConnection *,
+ int);
int dlt_event_handler_unregister_connection(DltEventHandler *,
- DltDaemonLocal *,
- int);
+ DltDaemonLocal *,
+ int);
int dlt_connection_check_activate(DltEventHandler *,
DltConnection *,
int);
-#ifdef DLT_UNIT_TESTS
+# ifdef DLT_UNIT_TESTS
int dlt_daemon_remove_connection(DltEventHandler *ev,
- DltConnection *to_remove);
+ DltConnection *to_remove);
void dlt_daemon_add_connection(DltEventHandler *ev,
- DltConnection *connection);
-#endif
+ DltConnection *connection);
+# endif
#endif /* DLT_DAEMON_EVENT_HANDLER_H */
diff --git a/src/daemon/dlt_daemon_event_handler_types.h b/src/daemon/dlt_daemon_event_handler_types.h
index 99a1217..16e0a98 100644
--- a/src/daemon/dlt_daemon_event_handler_types.h
+++ b/src/daemon/dlt_daemon_event_handler_types.h
@@ -32,7 +32,7 @@
#include "dlt_daemon_connection_types.h"
#ifndef DLT_DAEMON_EVENT_HANDLER_TYPES_H
-#define DLT_DAEMON_EVENT_HANDLER_TYPES_H
+# define DLT_DAEMON_EVENT_HANDLER_TYPES_H
/* FIXME: Remove the need for DltDaemonLocal everywhere in the code
* These typedefs are needed by DltDaemonLocal which is
@@ -43,9 +43,9 @@
typedef enum {
DLT_TIMER_PACKET = 0,
DLT_TIMER_ECU,
-#ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
+# ifdef DLT_SYSTEMD_WATCHDOG_ENABLE
DLT_TIMER_SYSTEMD,
-#endif
+# endif
DLT_TIMER_GATEWAY,
DLT_TIMER_UNKNOWN
} DltTimers;
diff --git a/src/daemon/dlt_daemon_offline_logstorage.c b/src/daemon/dlt_daemon_offline_logstorage.c
index 86d4b5e..8ec7016 100644
--- a/src/daemon/dlt_daemon_offline_logstorage.c
+++ b/src/daemon/dlt_daemon_offline_logstorage.c
@@ -43,15 +43,13 @@
* @return 0 on success -1 on error
*/
DLT_STATIC DltReturnValue dlt_logstorage_split_ecuid(char *key,
- int len,
- char *ecuid,
- char *appid,
- char *ctxid)
+ int len,
+ char *ecuid,
+ char *appid,
+ char *ctxid)
{
if ((len > (DLT_ID_SIZE + 2)) || (len < 2))
- {
return DLT_RETURN_ERROR;
- }
strncpy(ecuid, key, (len - 2));
strncpy(appid, ".*", 2);
@@ -72,14 +70,12 @@ DLT_STATIC DltReturnValue dlt_logstorage_split_ecuid(char *key,
* @return 0 on success -1 on error
*/
DLT_STATIC DltReturnValue dlt_logstorage_split_ctid(char *key,
- int len,
- char *appid,
- char *ctxid)
+ int len,
+ char *appid,
+ char *ctxid)
{
- if ((len > (DLT_ID_SIZE + 2)) || (len < 1) )
- {
+ if ((len > (DLT_ID_SIZE + 2)) || (len < 1))
return DLT_RETURN_ERROR;
- }
strncpy(ctxid, (key + 2), (len - 1));
strncpy(appid, ".*", 2);
@@ -99,14 +95,12 @@ DLT_STATIC DltReturnValue dlt_logstorage_split_ctid(char *key,
* @return 0 on success -1 on error
*/
DLT_STATIC DltReturnValue dlt_logstorage_split_apid(char *key,
- int len,
- char *appid,
- char *ctxid)
+ int len,
+ char *appid,
+ char *ctxid)
{
if ((len > (DLT_ID_SIZE + 2)) || (len < 2))
- {
return DLT_RETURN_ERROR;
- }
strncpy(appid, key + 1, (len - 2));
strncpy(ctxid, ".*", 2);
@@ -126,37 +120,29 @@ DLT_STATIC DltReturnValue dlt_logstorage_split_apid(char *key,
* @return 0 on success -1 on error
*/
DLT_STATIC DltReturnValue dlt_logstorage_split_apid_ctid(char *key,
- int len,
- char *appid,
- char *ctxid)
+ int len,
+ char *appid,
+ char *ctxid)
{
char *tok = NULL;
if (len > DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN)
- {
return DLT_RETURN_ERROR;
- }
/* copy appid and ctxid */
tok = strtok(key, ":");
+
if (tok != NULL)
- {
strncpy(appid, tok, DLT_ID_SIZE);
- }
else
- {
return DLT_RETURN_ERROR;
- }
tok = strtok(NULL, ":");
+
if (tok != NULL)
- {
strncpy(ctxid, tok, DLT_ID_SIZE);
- }
else
- {
return DLT_RETURN_ERROR;
- }
return DLT_RETURN_OK;
}
@@ -174,39 +160,31 @@ DLT_STATIC DltReturnValue dlt_logstorage_split_apid_ctid(char *key,
* @return 0 on success -1 on error
*/
DLT_STATIC DltReturnValue dlt_logstorage_split_ecuid_apid(char *key,
- int len,
- char *ecuid,
- char *appid,
- char *ctxid)
+ int len,
+ char *ecuid,
+ char *appid,
+ char *ctxid)
{
char *tok = NULL;
if (len > DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN)
- {
return DLT_RETURN_ERROR;
- }
/* copy appid and ctxid */
tok = strtok(key, ":");
+
if (tok != NULL)
- {
strncpy(ecuid, tok, DLT_ID_SIZE);
- }
else
- {
return DLT_RETURN_ERROR;
- }
tok = strtok(NULL, ":");
if (tok != NULL)
- {
strncpy(appid, tok, DLT_ID_SIZE);
- }
else
- {
return DLT_RETURN_ERROR;
- }
+
strncpy(ctxid, ".*", 2);
return DLT_RETURN_OK;
@@ -224,38 +202,34 @@ DLT_STATIC DltReturnValue dlt_logstorage_split_ecuid_apid(char *key,
* @return None
*/
DLT_STATIC DltReturnValue dlt_logstorage_split_multi(char *key,
- int len,
- char *ecuid,
- char *appid,
- char *ctxid)
+ int len,
+ char *ecuid,
+ char *appid,
+ char *ctxid)
{
char *tok = NULL;
if (len > DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN)
- {
return DLT_RETURN_ERROR;
- }
tok = strtok(key, ":");
+
if (tok == NULL)
- {
return DLT_RETURN_ERROR;
- }
len = strlen(tok);
- if (key[len + 1] == ':')
- {
+
+ if (key[len + 1] == ':') {
strncpy(ecuid, tok, DLT_ID_SIZE);
tok = strtok(NULL, ":");
+
if (tok != NULL)
- {
strncpy(ctxid, tok, DLT_ID_SIZE);
- }
+
strncpy(appid, ".*", 2);
}
- else
- {
+ else {
strncpy(ecuid, tok, DLT_ID_SIZE);
tok = strtok(NULL, ":");
strncpy(appid, tok, DLT_ID_SIZE);
@@ -285,49 +259,33 @@ DLT_STATIC DltReturnValue dlt_logstorage_split_key(char *key, char *appid, char
char *sep = NULL;
if ((key == NULL) || (appid == NULL) || (ctxid == NULL) || (ecuid == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
len = strlen(key);
sep = strchr (key, ':');
if (sep == NULL)
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
/* key is ecuid only ecuid::*/
if ((key[len - 1] == ':') && (key[len - 2] == ':'))
- {
return dlt_logstorage_split_ecuid(key, len, ecuid, appid, ctxid);
- }
/* key is context id only ::apid*/
else if ((key[0] == ':') && (key[1] == ':'))
- {
return dlt_logstorage_split_ctid(key, len, appid, ctxid);
- }
/* key is application id only :apid: */
- else if ((key[0] == ':') && key[len - 1] == ':')
- {
+ else if ((key[0] == ':') && (key[len - 1] == ':'))
return dlt_logstorage_split_apid(key, len, appid, ctxid);
- }
/* key is :apid:ctid */
- else if ((key[0] == ':') && key[len - 1] != ':')
- {
+ else if ((key[0] == ':') && (key[len - 1] != ':'))
return dlt_logstorage_split_apid_ctid(key, len, appid, ctxid);
- }
/* key is ecuid:apid: */
- else if ((key[0] != ':') && key[len - 1] == ':')
- {
- return dlt_logstorage_split_ecuid_apid(key, len, ecuid, appid, ctxid);
- }
+ else if ((key[0] != ':') && (key[len - 1] == ':'))
+ return dlt_logstorage_split_ecuid_apid(key, len, ecuid, appid, ctxid);
/* key is either ecuid::ctid or ecuid:apid:ctid */
else
- {
return dlt_logstorage_split_multi(key, len, ecuid, appid, ctxid);
- }
}
/**
@@ -341,30 +299,28 @@ DLT_STATIC DltReturnValue dlt_logstorage_split_key(char *key, char *appid, char
* @param verbose verbosity flag
*/
DLT_STATIC DltReturnValue dlt_daemon_logstorage_update_passive_node_context(
- DltDaemonLocal *daemon_local,
- char *apid,
- char *ctid,
- char *ecuid,
- int loglevel,
- int verbose)
+ DltDaemonLocal *daemon_local,
+ char *apid,
+ char *ctid,
+ char *ecuid,
+ int loglevel,
+ int verbose)
{
- DltServiceSetLogLevel req = {0};
- DltPassiveControlMessage ctrl = {0};
+ DltServiceSetLogLevel req = { 0 };
+ DltPassiveControlMessage ctrl = { 0 };
DltGatewayConnection *con = NULL;
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon_local == NULL) || (apid == NULL) || (ctid == NULL) || (ecuid == NULL) ||
- (loglevel > DLT_LOG_VERBOSE) || (loglevel < DLT_LOG_DEFAULT))
- {
+ (loglevel > DLT_LOG_VERBOSE) || (loglevel < DLT_LOG_DEFAULT)) {
dlt_vlog(LOG_ERR, "%s: Wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
con = dlt_gateway_get_connection(&daemon_local->pGateway, ecuid, verbose);
- if (con == NULL)
- {
+ if (con == NULL) {
dlt_vlog(LOG_ERR,
"Failed to fond connection to passive node %s\n",
ecuid);
@@ -379,8 +335,7 @@ DLT_STATIC DltReturnValue dlt_daemon_logstorage_update_passive_node_context(
req.log_level = loglevel;
- if (dlt_gateway_send_control_message(con, &ctrl, (void *) &req, verbose) != 0)
- {
+ if (dlt_gateway_send_control_message(con, &ctrl, (void *)&req, verbose) != 0) {
dlt_vlog(LOG_ERR,
"Failed to forward SET_LOG_LEVEL message to passive node %s\n",
ecuid);
@@ -406,58 +361,49 @@ DLT_STATIC DltReturnValue dlt_daemon_logstorage_update_passive_node_context(
* @return 0 on success, -1 on error
*/
DLT_STATIC DltReturnValue dlt_daemon_logstorage_send_log_level(DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- DltDaemonContext *context,
- char *ecuid,
- int loglevel,
- int verbose)
+ DltDaemonLocal *daemon_local,
+ DltDaemonContext *context,
+ char *ecuid,
+ int loglevel,
+ int verbose)
{
int old_log_level = -1;
int ll = DLT_LOG_DEFAULT;
if ((daemon == NULL) || (daemon_local == NULL) || (ecuid == NULL) ||
- (context == NULL) || (loglevel > DLT_LOG_VERBOSE) || (loglevel < DLT_LOG_DEFAULT))
- {
+ (context == NULL) || (loglevel > DLT_LOG_VERBOSE) || (loglevel < DLT_LOG_DEFAULT)) {
dlt_vlog(LOG_ERR, "%s: Wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
-
- if (strncmp(ecuid, daemon->ecuid, DLT_ID_SIZE) == 0)
- {
+ if (strncmp(ecuid, daemon->ecuid, DLT_ID_SIZE) == 0) {
old_log_level = context->storage_log_level;
context->storage_log_level = DLT_OFFLINE_LOGSTORAGE_MAX(loglevel,
- context->storage_log_level);
+ context->storage_log_level);
- if (context->storage_log_level > old_log_level)
- {
- if (dlt_daemon_user_send_log_level(daemon, context, verbose) == -1)
- {
+ if (context->storage_log_level > old_log_level) {
+ if (dlt_daemon_user_send_log_level(daemon, context, verbose) == -1) {
dlt_log(LOG_ERR, "Unable to update log level\n");
return DLT_RETURN_ERROR;
}
}
-
}
- else
- {
+ else {
old_log_level = context->log_level;
ll = DLT_OFFLINE_LOGSTORAGE_MAX(loglevel, context->log_level);
if (ll > old_log_level)
- {
return dlt_daemon_logstorage_update_passive_node_context(daemon_local,
context->apid,
context->ctid,
ecuid,
ll,
verbose);
- }
-
}
+
return DLT_RETURN_OK;
}
@@ -476,45 +422,40 @@ DLT_STATIC DltReturnValue dlt_daemon_logstorage_send_log_level(DltDaemon *daemon
* @return 0 on success, -1 on error
*/
DLT_STATIC DltReturnValue dlt_daemon_logstorage_reset_log_level(DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- DltDaemonContext *context,
- char *ecuid,
- int loglevel,
- int verbose)
+ DltDaemonLocal *daemon_local,
+ DltDaemonContext *context,
+ char *ecuid,
+ int loglevel,
+ int verbose)
{
if ((daemon == NULL) || (daemon_local == NULL) || (ecuid == NULL) ||
- (context == NULL) || (loglevel > DLT_LOG_VERBOSE) || (loglevel < DLT_LOG_DEFAULT))
- {
+ (context == NULL) || (loglevel > DLT_LOG_VERBOSE) || (loglevel < DLT_LOG_DEFAULT)) {
dlt_vlog(LOG_ERR, "%s: Wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
-
/* Set storage level to -1, to clear log levels */
context->storage_log_level = DLT_LOG_DEFAULT;
- if (loglevel == DLT_DAEMON_LOGSTORAGE_RESET_SEND_LOGLEVEL)
- {
- if (strncmp(ecuid, daemon->ecuid, DLT_ID_SIZE) == 0)
- {
+ if (loglevel == DLT_DAEMON_LOGSTORAGE_RESET_SEND_LOGLEVEL) {
+ if (strncmp(ecuid, daemon->ecuid, DLT_ID_SIZE) == 0) {
if (dlt_daemon_user_send_log_level(daemon,
context,
- verbose) == DLT_RETURN_ERROR)
- {
+ verbose) == DLT_RETURN_ERROR) {
dlt_log(LOG_ERR, "Unable to update log level\n");
return DLT_RETURN_ERROR;
}
}
- else /* forward set log level to passive node */
- {
+ else { /* forward set log level to passive node */
return dlt_daemon_logstorage_update_passive_node_context(daemon_local,
- context->apid,
- context->ctid,
- ecuid,
- DLT_LOG_DEFAULT,
- verbose);
+ context->apid,
+ context->ctid,
+ ecuid,
+ DLT_LOG_DEFAULT,
+ verbose);
}
}
+
return DLT_RETURN_OK;
}
@@ -531,12 +472,12 @@ DLT_STATIC DltReturnValue dlt_daemon_logstorage_reset_log_level(DltDaemon *daemo
* @return 0 on success, -1 on error
*/
DLT_STATIC DltReturnValue dlt_daemon_logstorage_force_reset_level(DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- char *apid,
- char *ctxid,
- char *ecuid,
- int loglevel,
- int verbose)
+ DltDaemonLocal *daemon_local,
+ char *apid,
+ char *ctxid,
+ char *ecuid,
+ int loglevel,
+ int verbose)
{
int ll = DLT_LOG_DEFAULT;
int num = 0;
@@ -544,37 +485,29 @@ DLT_STATIC DltReturnValue dlt_daemon_logstorage_force_reset_level(DltDaemon *dae
DltLogStorageFilterConfig *config[DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS] = { 0 };
if ((daemon == NULL) || (daemon_local == NULL) || (ecuid == NULL) ||
- (apid == NULL) || (ctxid == NULL) || (loglevel > DLT_LOG_VERBOSE) || (loglevel < DLT_LOG_DEFAULT))
- {
+ (apid == NULL) || (ctxid == NULL) || (loglevel > DLT_LOG_VERBOSE) || (loglevel < DLT_LOG_DEFAULT)) {
dlt_vlog(LOG_ERR, "%s: Wrong parameter\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
- for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++)
- {
+ for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++) {
num = dlt_logstorage_get_config(&(daemon->storage_handle[i]), config, apid, ctxid, ecuid);
+
if (num > 0)
- {
break; /* found config */
- }
}
- if ((num == 0) || (config[0] == NULL ))
- {
+ if ((num == 0) || (config[0] == NULL)) {
dlt_vlog(LOG_ERR,
- "%s: No information about APID: %s, CTID: %s, ECU: %s in Logstorage configuration\n",
- __func__, apid, ctxid, ecuid);
+ "%s: No information about APID: %s, CTID: %s, ECU: %s in Logstorage configuration\n",
+ __func__, apid, ctxid, ecuid);
return DLT_RETURN_ERROR;
}
if (loglevel == DLT_DAEMON_LOGSTORAGE_RESET_SEND_LOGLEVEL)
- {
ll = config[0]->reset_log_level;
- }
else
- {
ll = config[0]->log_level;
- }
return dlt_daemon_logstorage_update_passive_node_context(daemon_local, apid,
ctxid, ecuid, ll, verbose);
@@ -601,64 +534,53 @@ DLT_STATIC DltReturnValue dlt_daemon_logstorage_force_reset_level(DltDaemon *dae
* @return 0 on success, -1 on error
*/
DltReturnValue dlt_logstorage_update_all_contexts(DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- char *id,
- int curr_log_level,
- int cmp_flag,
- char *ecuid,
- int verbose)
+ DltDaemonLocal *daemon_local,
+ char *id,
+ int curr_log_level,
+ int cmp_flag,
+ char *ecuid,
+ int verbose)
{
- DltDaemonRegisteredUsers* user_list = NULL;
+ DltDaemonRegisteredUsers *user_list = NULL;
int i = 0;
- char tmp_id[DLT_ID_SIZE + 1] = {'\0'};
+ char tmp_id[DLT_ID_SIZE + 1] = { '\0' };
- if ((daemon == NULL) || (daemon_local == NULL) ||(id == NULL) ||
+ if ((daemon == NULL) || (daemon_local == NULL) || (id == NULL) ||
(ecuid == NULL) || (cmp_flag < DLT_DAEMON_LOGSTORAGE_CMP_APID) ||
- (cmp_flag > DLT_DAEMON_LOGSTORAGE_CMP_CTID))
- {
+ (cmp_flag > DLT_DAEMON_LOGSTORAGE_CMP_CTID)) {
dlt_vlog(LOG_ERR, "Wrong parameter in function %s\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
user_list = dlt_daemon_find_users_list(daemon, ecuid, verbose);
+
if (user_list == NULL)
- {
return DLT_RETURN_ERROR;
- }
- for (i = 0; i < user_list->num_contexts; i++)
- {
+ for (i = 0; i < user_list->num_contexts; i++) {
if (cmp_flag == 1)
- {
dlt_set_id(tmp_id, user_list->contexts[i].apid);
- }
else
- {
dlt_set_id(tmp_id, user_list->contexts[i].ctid);
- }
- if (strncmp(id, tmp_id, DLT_ID_SIZE) == 0)
- {
+ if (strncmp(id, tmp_id, DLT_ID_SIZE) == 0) {
if (curr_log_level > 0)
- {
dlt_daemon_logstorage_send_log_level(daemon,
daemon_local,
&user_list->contexts[i],
ecuid,
curr_log_level,
verbose);
- }
else /* The request is to reset log levels */
- {
dlt_daemon_logstorage_reset_log_level(daemon,
daemon_local,
&user_list->contexts[i],
ecuid,
curr_log_level,
verbose);
- }
}
}
+
return DLT_RETURN_OK;
}
@@ -680,50 +602,43 @@ DltReturnValue dlt_logstorage_update_all_contexts(DltDaemon *daemon,
* @return 0 on success, -1 on error
*/
DltReturnValue dlt_logstorage_update_context(DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- char *apid,
- char *ctxid,
- char *ecuid,
- int curr_log_level,
- int verbose)
+ DltDaemonLocal *daemon_local,
+ char *apid,
+ char *ctxid,
+ char *ecuid,
+ int curr_log_level,
+ int verbose)
{
DltDaemonContext *context = NULL;
- if ((daemon == NULL) || (daemon_local == NULL) ||(apid == NULL)
- || (ctxid == NULL) || (ecuid == NULL))
- {
+ if ((daemon == NULL) || (daemon_local == NULL) || (apid == NULL)
+ || (ctxid == NULL) || (ecuid == NULL)) {
dlt_vlog(LOG_ERR, "Wrong parameter in function %s\n", __func__);
return DLT_RETURN_WRONG_PARAMETER;
}
context = dlt_daemon_context_find(daemon, apid, ctxid, ecuid, verbose);
- if (context != NULL)
- {
+
+ if (context != NULL) {
if (curr_log_level > 0)
- {
return dlt_daemon_logstorage_send_log_level(daemon,
daemon_local,
context,
ecuid,
curr_log_level,
verbose);
- }
else /* The request is to reset log levels */
- {
return dlt_daemon_logstorage_reset_log_level(daemon,
daemon_local,
context,
ecuid,
curr_log_level,
verbose);
- }
}
- else
- {
- if (strncmp(ecuid, daemon->ecuid, DLT_ID_SIZE) != 0)
- {
- // we intentionally have no data provided by passive node.
- // We blindly send the log level or reset log level
+ else {
+ if (strncmp(ecuid, daemon->ecuid, DLT_ID_SIZE) != 0) {
+ /* we intentionally have no data provided by passive node. */
+ /* We blindly send the log level or reset log level */
return dlt_daemon_logstorage_force_reset_level(daemon,
daemon_local,
apid,
@@ -732,14 +647,13 @@ DltReturnValue dlt_logstorage_update_context(DltDaemon *daemon,
curr_log_level,
verbose);
}
- else
- {
+ else {
dlt_vlog(LOG_WARNING,
- "%s: No information about APID: %s, CTID: %s, ECU: %s\n",
- __func__,
- apid,
- ctxid,
- ecuid);
+ "%s: No information about APID: %s, CTID: %s, ECU: %s\n",
+ __func__,
+ apid,
+ ctxid,
+ ecuid);
return DLT_RETURN_ERROR;
}
@@ -760,38 +674,32 @@ DltReturnValue dlt_logstorage_update_context(DltDaemon *daemon,
* @return 0 on success, -1 on error
*/
DltReturnValue dlt_logstorage_update_context_loglevel(DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- char *key,
- int curr_log_level,
- int verbose)
+ DltDaemonLocal *daemon_local,
+ char *key,
+ int curr_log_level,
+ int verbose)
{
int cmp_flag = 0;
- char appid[DLT_ID_SIZE + 1] = {'\0'};
- char ctxid[DLT_ID_SIZE + 1] = {'\0'};
- char ecuid[DLT_ID_SIZE + 1] = {'\0'};
+ char appid[DLT_ID_SIZE + 1] = { '\0' };
+ char ctxid[DLT_ID_SIZE + 1] = { '\0' };
+ char ecuid[DLT_ID_SIZE + 1] = { '\0' };
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL) || (key == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- if (dlt_logstorage_split_key(key, appid, ctxid, ecuid) != 0)
- {
+ if (dlt_logstorage_split_key(key, appid, ctxid, ecuid) != 0) {
dlt_log(LOG_ERR,
"Error while updating application log levels (split key)\n");
return DLT_RETURN_ERROR;
}
if (ecuid[0] == '\0') /* ECU id was not specified in filter configuration */
- {
dlt_set_id(ecuid, daemon->ecuid);
- }
/* wildcard for context id, find all contexts of given application id */
- if (strcmp(ctxid, ".*") == 0)
- {
+ if (strcmp(ctxid, ".*") == 0) {
cmp_flag = DLT_DAEMON_LOGSTORAGE_CMP_APID;
if (dlt_logstorage_update_all_contexts(daemon,
@@ -801,9 +709,7 @@ DltReturnValue dlt_logstorage_update_context_loglevel(DltDaemon *daemon,
cmp_flag,
ecuid,
verbose) != 0)
- {
return DLT_RETURN_ERROR;
- }
}
/* wildcard for application id, find all contexts with context id */
else if (strcmp(appid, ".*") == 0)
@@ -817,9 +723,7 @@ DltReturnValue dlt_logstorage_update_context_loglevel(DltDaemon *daemon,
cmp_flag,
ecuid,
verbose) != 0)
- {
return DLT_RETURN_ERROR;
- }
}
/* In case of given application id, context id pair, call available context
* find function */
@@ -861,15 +765,14 @@ void dlt_daemon_logstorage_reset_application_loglevel(DltDaemon *daemon,
DltLogStorage *handle = NULL;
DltLogStorageFilterList **tmp = NULL;
int i = 0;
- char key[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = {'\0'};
+ char key[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = { '\0' };
int num_device_configured = 0;
unsigned int status;
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL) ||
- (daemon->storage_handle == NULL) || (dev_num < 0))
- {
+ (daemon->storage_handle == NULL) || (dev_num < 0)) {
dlt_vlog(LOG_ERR,
"Invalid function parameters used for %s\n",
__func__);
@@ -880,26 +783,21 @@ void dlt_daemon_logstorage_reset_application_loglevel(DltDaemon *daemon,
if ((handle->connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) ||
(handle->config_status != DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE))
- {
return;
- }
/* First, check number of devices configured */
- for (i = 0; i < max_device; i++)
- {
+ for (i = 0; i < max_device; i++) {
status = daemon->storage_handle[i].config_status;
if (status == DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE)
- {
num_device_configured++;
- }
}
/* for all filters (keys) check if application context are already running
* and log level need to be reset*/
tmp = &(handle->config_list);
- while (*(tmp) != NULL)
- {
+
+ while (*(tmp) != NULL) {
memset(key, 0, sizeof(key));
strncpy(key,
@@ -907,7 +805,6 @@ void dlt_daemon_logstorage_reset_application_loglevel(DltDaemon *daemon,
DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN);
if (num_device_configured == 1)
- {
/* Reset context log level and send to application */
dlt_logstorage_update_context_loglevel(
daemon,
@@ -915,36 +812,30 @@ void dlt_daemon_logstorage_reset_application_loglevel(DltDaemon *daemon,
key,
DLT_DAEMON_LOGSTORAGE_RESET_SEND_LOGLEVEL,
verbose);
- }
else /* Reset context log level do not send to application as other
- devices can have same configuration */
- {
+ * devices can have same configuration */
dlt_logstorage_update_context_loglevel(
daemon,
daemon_local,
key,
DLT_DAEMON_LOGSTORAGE_RESET_LOGLEVEL,
verbose);
- }
+
tmp = &(*tmp)->next;
}
/* Re-run update log level for all other configured devices */
- for (i = 0; i < max_device; i++)
- {
+ for (i = 0; i < max_device; i++) {
status = daemon->storage_handle[i].config_status;
+
if (i == dev_num)
- {
continue;
- }
if (status == DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE)
- {
dlt_daemon_logstorage_update_application_loglevel(daemon,
daemon_local,
i,
verbose);
- }
}
return;
@@ -970,12 +861,11 @@ void dlt_daemon_logstorage_update_application_loglevel(DltDaemon *daemon,
{
DltLogStorage *handle = NULL;
DltLogStorageFilterList **tmp = NULL;
- char key[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = {'\0'};
+ char key[DLT_OFFLINE_LOGSTORAGE_MAX_KEY_LEN + 1] = { '\0' };
PRINT_FUNCTION_VERBOSE(verbose);
- if ((daemon == NULL) || (dev_num < 0))
- {
+ if ((daemon == NULL) || (dev_num < 0)) {
dlt_vlog(LOG_ERR,
"Invalid function parameters used for %s\n",
__func__);
@@ -986,15 +876,13 @@ void dlt_daemon_logstorage_update_application_loglevel(DltDaemon *daemon,
if ((handle->connection_type != DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) ||
(handle->config_status != DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE))
- {
return;
- }
/* for all filters (keys) check if application or context already running
* and log level need to be updated*/
tmp = &(handle->config_list);
- while (*(tmp) != NULL)
- {
+
+ while (*(tmp) != NULL) {
int log_level = -1;
memset(key, 0, sizeof(key));
@@ -1006,8 +894,7 @@ void dlt_daemon_logstorage_update_application_loglevel(DltDaemon *daemon,
/* Obtain storage configuration data */
log_level = dlt_logstorage_get_loglevel_by_key(handle, key);
- if (log_level < 0)
- {
+ if (log_level < 0) {
dlt_log(LOG_ERR, "Failed to get log level by key \n");
return;
}
@@ -1041,7 +928,7 @@ int dlt_daemon_logstorage_get_loglevel(DltDaemon *daemon,
char *apid,
char *ctid)
{
- DltLogStorageFilterConfig *config[DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS] = {0};
+ DltLogStorageFilterConfig *config[DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS] = { 0 };
int i = 0;
int j = 0;
int8_t storage_loglevel = -1;
@@ -1049,48 +936,39 @@ int dlt_daemon_logstorage_get_loglevel(DltDaemon *daemon,
int num_config = 0;
if ((daemon == NULL) || (max_device == 0) || (apid == NULL) || (ctid == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
for (i = 0; i < max_device; i++)
- {
if (daemon->storage_handle[i].config_status ==
- DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE)
- {
+ DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE) {
num_config = dlt_logstorage_get_config(&(daemon->storage_handle[i]),
- config,
- apid,
- ctid,
- daemon->ecuid);
+ config,
+ apid,
+ ctid,
+ daemon->ecuid);
- if (num_config == 0)
- {
+ if (num_config == 0) {
dlt_log(LOG_DEBUG, "No valid filter configuration found\n");
continue;
}
- for (j = 0; j < DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS; j++)
- {
+ for (j = 0; j < DLT_OFFLINE_LOGSTORAGE_MAX_POSSIBLE_CONFIGS; j++) {
if (config[j] == NULL)
- {
continue;
- }
/* If logstorage configuration do not contain file name,
* then it is non verbose control filter, so return level as in this filter */
- if (config[j]->file_name == NULL)
- {
+ if (config[j]->file_name == NULL) {
storage_loglevel = config[j]->log_level;
break;
}
+
configured_loglevel = config[j]->log_level;
storage_loglevel = DLT_OFFLINE_LOGSTORAGE_MAX(
- configured_loglevel,
- storage_loglevel);
+ configured_loglevel,
+ storage_loglevel);
}
}
- }
return storage_loglevel;
}
@@ -1125,10 +1003,9 @@ void dlt_daemon_logstorage_write(DltDaemon *daemon,
if ((daemon == NULL) || (user_config == NULL) ||
(user_config->offlineLogstorageMaxDevices <= 0) || (data1 == NULL) ||
- (data2 == NULL) || (data3 == NULL))
- {
+ (data2 == NULL) || (data3 == NULL)) {
dlt_vlog(LOG_DEBUG,
- "%s: message type is not LOG. Skip storing.\n",
+ "%s: message type is not LOG. Skip storing.\n",
__func__);
return;
/* Log Level changed callback */
@@ -1142,10 +1019,8 @@ void dlt_daemon_logstorage_write(DltDaemon *daemon,
user_config->offlineLogstorageMaxCounterIdx;
for (i = 0; i < user_config->offlineLogstorageMaxDevices; i++)
- {
if (daemon->storage_handle[i].config_status ==
- DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE)
- {
+ DLT_OFFLINE_LOGSTORAGE_CONFIG_DONE) {
if (dlt_logstorage_write(&(daemon->storage_handle[i]),
&file_config,
data1,
@@ -1153,8 +1028,7 @@ void dlt_daemon_logstorage_write(DltDaemon *daemon,
data2,
size2,
data3,
- size3) != 0)
- {
+ size3) != 0) {
dlt_log(LOG_ERR,
"dlt_daemon_logstorage_write: failed. "
"Disable storage device\n");
@@ -1165,7 +1039,6 @@ void dlt_daemon_logstorage_write(DltDaemon *daemon,
DLT_LOGSTORAGE_SYNC_ON_DEVICE_DISCONNECT);
}
}
- }
}
/**
@@ -1189,16 +1062,13 @@ int dlt_daemon_logstorage_setup_internal_storage(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
if ((path == NULL) || (daemon == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
/* connect internal storage device */
/* Device index always used as 0 as it is setup on DLT daemon startup */
ret = dlt_logstorage_device_connected(&(daemon->storage_handle[0]), path);
- if (ret != 0)
- {
+ if (ret != 0) {
dlt_vlog(LOG_ERR, "%s: Device connect failed\n", __func__);
return DLT_RETURN_ERROR;
}
@@ -1227,21 +1097,15 @@ int dlt_daemon_logstorage_cleanup(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++)
- {
/* call disconnect on all currently connected devices */
if (daemon->storage_handle[i].connection_type ==
DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED)
- {
dlt_logstorage_device_disconnected(
&daemon->storage_handle[i],
DLT_LOGSTORAGE_SYNC_ON_DAEMON_EXIT);
- }
- }
return 0;
}
@@ -1257,57 +1121,48 @@ int dlt_daemon_logstorage_sync_cache(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL) || (mnt_point == NULL))
- {
return DLT_RETURN_WRONG_PARAMETER;
- }
- if (strlen(mnt_point) > 0) /* mount point is given */
- {
+ if (strlen(mnt_point) > 0) { /* mount point is given */
handle = dlt_daemon_logstorage_get_device(daemon,
daemon_local,
mnt_point,
verbose);
- if (handle == NULL)
- {
+
+ if (handle == NULL) {
return DLT_RETURN_ERROR;
}
- else
- {
+ else {
handle->uconfig.logfile_counteridxlen =
- daemon_local->flags.offlineLogstorageMaxCounterIdx;
+ daemon_local->flags.offlineLogstorageMaxCounterIdx;
handle->uconfig.logfile_delimiter =
- daemon_local->flags.offlineLogstorageDelimiter;
+ daemon_local->flags.offlineLogstorageDelimiter;
handle->uconfig.logfile_maxcounter =
- daemon_local->flags.offlineLogstorageMaxCounter;
+ daemon_local->flags.offlineLogstorageMaxCounter;
handle->uconfig.logfile_timestamp =
- daemon_local->flags.offlineLogstorageTimestamp;
+ daemon_local->flags.offlineLogstorageTimestamp;
+
if (dlt_logstorage_sync_caches(handle) != 0)
- {
return DLT_RETURN_ERROR;
- }
}
}
- else /* sync caches for all connected logstorage devices */
- {
+ else { /* sync caches for all connected logstorage devices */
+
for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++)
- {
if (daemon->storage_handle[i].connection_type ==
- DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED)
- {
+ DLT_OFFLINE_LOGSTORAGE_DEVICE_CONNECTED) {
daemon->storage_handle[i].uconfig.logfile_counteridxlen =
- daemon_local->flags.offlineLogstorageMaxCounterIdx;
+ daemon_local->flags.offlineLogstorageMaxCounterIdx;
daemon->storage_handle[i].uconfig.logfile_delimiter =
- daemon_local->flags.offlineLogstorageDelimiter;
+ daemon_local->flags.offlineLogstorageDelimiter;
daemon->storage_handle[i].uconfig.logfile_maxcounter =
- daemon_local->flags.offlineLogstorageMaxCounter;
+ daemon_local->flags.offlineLogstorageMaxCounter;
daemon->storage_handle[i].uconfig.logfile_timestamp =
- daemon_local->flags.offlineLogstorageTimestamp;
+ daemon_local->flags.offlineLogstorageTimestamp;
+
if (dlt_logstorage_sync_caches(&daemon->storage_handle[i]) != 0)
- {
return DLT_RETURN_ERROR;
- }
}
- }
}
return 0;
@@ -1326,24 +1181,20 @@ DltLogStorage *dlt_daemon_logstorage_get_device(DltDaemon *daemon,
PRINT_FUNCTION_VERBOSE(verbose);
if ((daemon == NULL) || (daemon_local == NULL) || (mnt_point == NULL))
- {
return NULL;
- }
len1 = strlen(mnt_point);
- for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++)
- {
+ for (i = 0; i < daemon_local->flags.offlineLogstorageMaxDevices; i++) {
len2 = strlen(daemon->storage_handle[i].device_mount_point);
/* Check if the requested device path is already used as log storage
* device. Check for strlen first, to avoid comparison errors when
* final '/' is given or not */
len = len1 > len2 ? len2 : len1;
+
if (strncmp(daemon->storage_handle[i].device_mount_point, mnt_point, len) == 0)
- {
return &daemon->storage_handle[i];
- }
}
return NULL;
diff --git a/src/daemon/dlt_daemon_offline_logstorage_internal.h b/src/daemon/dlt_daemon_offline_logstorage_internal.h
index cf5c593..4ad22c3 100644
--- a/src/daemon/dlt_daemon_offline_logstorage_internal.h
+++ b/src/daemon/dlt_daemon_offline_logstorage_internal.h
@@ -72,9 +72,9 @@ DltReturnValue dlt_logstorage_update_context(DltDaemon *daemon,
int verbose);
DltReturnValue dlt_logstorage_update_context_loglevel(DltDaemon *daemon,
- DltDaemonLocal *daemon_local,
- char *key,
- int curr_log_level,
- int verbose);
+ DltDaemonLocal *daemon_local,
+ char *key,
+ int curr_log_level,
+ int verbose);
#endif
diff --git a/src/daemon/dlt_daemon_serial.c b/src/daemon/dlt_daemon_serial.c
index cafcf80..58c2a67 100644
--- a/src/daemon/dlt_daemon_serial.c
+++ b/src/daemon/dlt_daemon_serial.c
@@ -70,28 +70,24 @@
#include "dlt_daemon_serial.h"
-int dlt_daemon_serial_send(int sock,void* data1,int size1,void* data2,int size2,char serialheader)
+int dlt_daemon_serial_send(int sock, void *data1, int size1, void *data2, int size2, char serialheader)
{
/* Optional: Send serial header, if requested */
if (serialheader)
- {
- if ( 0 > write(sock, dltSerialHeader,sizeof(dltSerialHeader)) )
+ if (0 > write(sock, dltSerialHeader, sizeof(dltSerialHeader)))
return DLT_DAEMON_ERROR_SEND_FAILED;
- }
-
/* Send data */
- if(data1 && size1>0)
- {
- if (0 > write(sock, data1,size1))
+
+ if (data1 && (size1 > 0))
+ if (0 > write(sock, data1, size1))
return DLT_DAEMON_ERROR_SEND_FAILED;
- }
- if(data2 && size2>0)
- {
- if (0 > write(sock, data2,size2))
- return DLT_DAEMON_ERROR_SEND_FAILED;
- }
+
+
+ if (data2 && (size2 > 0))
+ if (0 > write(sock, data2, size2))
+ return DLT_DAEMON_ERROR_SEND_FAILED;
return DLT_DAEMON_ERROR_OK;
}
diff --git a/src/daemon/dlt_daemon_serial.h b/src/daemon/dlt_daemon_serial.h
index d5ffb0a..fb540bf 100644
--- a/src/daemon/dlt_daemon_serial.h
+++ b/src/daemon/dlt_daemon_serial.h
@@ -62,6 +62,6 @@
#include "dlt_common.h"
#include "dlt_user.h"
-int dlt_daemon_serial_send(int sock,void* data1,int size1,void* data2,int size2,char serialheader);
+int dlt_daemon_serial_send(int sock, void *data1, int size1, void *data2, int size2, char serialheader);
#endif /* DLT_DAEMON_SERIAL_H */
diff --git a/src/daemon/dlt_daemon_socket.c b/src/daemon/dlt_daemon_socket.c
index f51d803..5a45195 100644
--- a/src/daemon/dlt_daemon_socket.c
+++ b/src/daemon/dlt_daemon_socket.c
@@ -45,12 +45,12 @@
#include <net/if.h>
#ifdef linux
-#include <sys/timerfd.h>
+# include <sys/timerfd.h>
#endif
#include <sys/stat.h>
#include <sys/time.h>
#if defined(linux) && defined(__NR_statx)
-#include <linux/stat.h>
+# include <linux/stat.h>
#endif
#include "dlt_types.h"
@@ -72,20 +72,21 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort)
memset(&hints, 0, sizeof hints);
#ifdef DLT_USE_IPv6
- hints.ai_family = AF_INET6; // force IPv6 - will still work with IPv4
+ hints.ai_family = AF_INET6; /* force IPv6 - will still work with IPv4 */
#else
hints.ai_family = AF_INET;
#endif
hints.ai_socktype = SOCK_STREAM;
- hints.ai_flags = AI_PASSIVE; // use my IP address
+ hints.ai_flags = AI_PASSIVE; /* use my IP address */
snprintf(portnumbuffer, 32, "%d", servPort);
+
if ((rv = getaddrinfo(NULL, portnumbuffer, &hints, &servinfo)) != 0) {
dlt_vlog(LOG_WARNING, "getaddrinfo error %d: %s\n", rv, gai_strerror(rv));
return -1;
}
- for(p = servinfo; p != NULL; p = p->ai_next) {
+ for (p = servinfo; p != NULL; p = p->ai_next) {
if ((*sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) {
const int lastErrno = errno;
dlt_vlog(LOG_WARNING, "dlt_daemon_socket_open: socket() error %d: %s\n", lastErrno, strerror(lastErrno));
@@ -96,15 +97,17 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort)
__FUNCTION__, p->ai_family, p->ai_socktype, p->ai_protocol);
dlt_log(LOG_INFO, str);
- if (setsockopt(*sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1)
- {
+ if (setsockopt(*sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) {
const int lastErrno = errno;
- dlt_vlog(LOG_WARNING, "dlt_daemon_socket_open: Setsockopt error %d in dlt_daemon_local_connection_init: %s\n", lastErrno, strerror(lastErrno));
+ dlt_vlog(LOG_WARNING,
+ "dlt_daemon_socket_open: Setsockopt error %d in dlt_daemon_local_connection_init: %s\n",
+ lastErrno,
+ strerror(lastErrno));
continue;
}
if (bind(*sock, p->ai_addr, p->ai_addrlen) == -1) {
- const int lastErrno = errno; //close() may set errno too
+ const int lastErrno = errno; /*close() may set errno too */
close(*sock);
dlt_vlog(LOG_WARNING, "dlt_daemon_socket_open: bind() error %d: %s\n", lastErrno, strerror(lastErrno));
continue;
@@ -123,18 +126,21 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort)
snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "%s: Listening on port: %u\n", __FUNCTION__, servPort);
dlt_log(LOG_INFO, str);
- // get socket buffer size
- snprintf(str, DLT_DAEMON_TEXTBUFSIZE, "dlt_daemon_socket_open: Socket send queue size: %d\n", dlt_daemon_socket_get_send_qeue_max_size(*sock));
+ /* get socket buffer size */
+ snprintf(str,
+ DLT_DAEMON_TEXTBUFSIZE,
+ "dlt_daemon_socket_open: Socket send queue size: %d\n",
+ dlt_daemon_socket_get_send_qeue_max_size(*sock));
dlt_log(LOG_INFO, str);
- if (listen(*sock, 3) < 0)
- {
+ if (listen(*sock, 3) < 0) {
const int lastErrno = errno;
- dlt_vlog(LOG_WARNING, "dlt_daemon_socket_open: listen() failed with error %d: %s\n", lastErrno, strerror(lastErrno));
+ dlt_vlog(LOG_WARNING, "dlt_daemon_socket_open: listen() failed with error %d: %s\n", lastErrno,
+ strerror(lastErrno));
return -1;
}
- return 0; // OK
+ return 0; /* OK */
}
int dlt_daemon_socket_close(int sock)
@@ -144,36 +150,32 @@ int dlt_daemon_socket_close(int sock)
return 0;
}
-int dlt_daemon_socket_send(int sock,void* data1,int size1,void* data2,int size2,char serialheader)
+int dlt_daemon_socket_send(int sock, void *data1, int size1, void *data2, int size2, char serialheader)
{
int ret = DLT_RETURN_OK;
int bytes_sent = 0;
-
+
/* Optional: Send serial header, if requested */
- if (serialheader)
- {
+ if (serialheader) {
ret = dlt_daemon_socket_sendreliable(sock,
- (void *) dltSerialHeader,
+ (void *)dltSerialHeader,
sizeof(dltSerialHeader),
&bytes_sent);
+
if (ret != DLT_RETURN_OK)
return ret;
}
/* Send data */
- if ((data1 != NULL) && (size1 > 0))
- {
+ if ((data1 != NULL) && (size1 > 0)) {
ret = dlt_daemon_socket_sendreliable(sock, data1, size1, &bytes_sent);
+
if (ret != DLT_RETURN_OK)
- {
return ret;
- }
}
if ((data2 != NULL) && (size2 > 0))
- {
ret = dlt_daemon_socket_sendreliable(sock, data2, size2, &bytes_sent);
- }
return ret;
}
@@ -187,23 +189,21 @@ int dlt_daemon_socket_get_send_qeue_max_size(int sock)
return n;
}
-int dlt_daemon_socket_sendreliable(int sock, void* data_buffer, int message_size, int* bytes_sent)
+int dlt_daemon_socket_sendreliable(int sock, void *data_buffer, int message_size, int *bytes_sent)
{
int data_sent = 0;
- while (data_sent < message_size)
- {
+ while (data_sent < message_size) {
ssize_t ret = send(sock, data_buffer + data_sent, message_size - data_sent, 0);
- if (ret < 0)
- {
+
+ if (ret < 0) {
dlt_vlog(LOG_WARNING,
"dlt_daemon_socket_sendreliable: socket send failed [errno: %d]!\n",
errno);
*bytes_sent = data_sent;
return DLT_DAEMON_ERROR_SEND_FAILED;
}
- else
- {
+ else {
data_sent += ret;
}
}
diff --git a/src/daemon/dlt_daemon_socket.h b/src/daemon/dlt_daemon_socket.h
index 3765c70..7276b2d 100644
--- a/src/daemon/dlt_daemon_socket.h
+++ b/src/daemon/dlt_daemon_socket.h
@@ -67,7 +67,7 @@ int dlt_daemon_socket_close(int sock);
int dlt_daemon_socket_get_send_qeue_max_size(int sock);
-int dlt_daemon_socket_send(int sock, void* data1, int size1, void* data2, int size2, char serialheader);
+int dlt_daemon_socket_send(int sock, void *data1, int size1, void *data2, int size2, char serialheader);
/**
* @brief dlt_daemon_socket_sendreliable - sends data to socket with additional checks and resending functionality - trying to be reliable
@@ -76,6 +76,6 @@ int dlt_daemon_socket_send(int sock, void* data1, int size1, void* data2, int si
* @param message_size
* @return on sucess: DLT_DAEMON_ERROR_OK, on error: DLT_DAEMON_ERROR_SEND_FAILED
*/
-int dlt_daemon_socket_sendreliable(int sock, void* data_buffer, int message_size, int* bytes_sent);
+int dlt_daemon_socket_sendreliable(int sock, void *data_buffer, int message_size, int *bytes_sent);
#endif /* DLT_DAEMON_SOCKET_H */
diff --git a/src/daemon/dlt_daemon_unix_socket.c b/src/daemon/dlt_daemon_unix_socket.c
index 0ed92ad..743035a 100644
--- a/src/daemon/dlt_daemon_unix_socket.c
+++ b/src/daemon/dlt_daemon_unix_socket.c
@@ -47,14 +47,12 @@ int dlt_daemon_unix_socket_open(int *sock, char *sock_path, int type, int mask)
struct sockaddr_un addr;
int old_mask;
- if (sock == NULL || sock_path == NULL)
- {
+ if ((sock == NULL) || (sock_path == NULL)) {
dlt_log(LOG_ERR, "dlt_daemon_unix_socket_open: arguments invalid");
return -1;
}
- if ((*sock = socket(AF_UNIX, type, 0)) == -1)
- {
+ if ((*sock = socket(AF_UNIX, type, 0)) == -1) {
dlt_log(LOG_WARNING, "unix socket: socket() error");
return -1;
}
@@ -68,14 +66,12 @@ int dlt_daemon_unix_socket_open(int *sock, char *sock_path, int type, int mask)
/* set appropriate access permissions */
old_mask = umask(mask);
- if (bind(*sock, (struct sockaddr *) &addr, sizeof(addr)) == -1)
- {
+ if (bind(*sock, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
dlt_log(LOG_WARNING, "unix socket: bind() error");
return -1;
}
- if (listen(*sock, 1) == -1)
- {
+ if (listen(*sock, 1) == -1) {
dlt_log(LOG_WARNING, "unix socket: listen error");
return -1;
}
@@ -90,8 +86,7 @@ int dlt_daemon_unix_socket_close(int sock)
{
int ret = close(sock);
- if (ret != 0)
- {
+ if (ret != 0) {
sprintf(err_string, "unix socket close failed: %s", strerror(errno));
dlt_log(LOG_WARNING, err_string);
}