summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ejdestig <martin.ejdestig@volvocars.com>2020-12-14 01:43:52 +0100
committerGitHub <noreply@github.com>2020-12-14 09:43:52 +0900
commit8f5e3dc0f3134ea2fdaffd13a16464b1a2f2ecd4 (patch)
treecd371956f6098d4d7e9e0937a929e87e5e5f0f71
parent329ba78deb40558df30aa8731928c9887197d30b (diff)
downloadDLT-daemon-8f5e3dc0f3134ea2fdaffd13a16464b1a2f2ecd4.tar.gz
Add support for logging with VSOCK (#255)
For more information about VSOCK, see "man vsock" ( https://man7.org/linux/man-pages/man7/vsock.7.html ). Makes it possible for processes in a virtual machine to log directly in DLT running on host without setting up a network connection between guest and host. It is also probably more efficient. Have not done any performance measurements (not main reason for patch), but no forwarding is required as when running DLT in a multi-node setup. When building dlt-daemon for host, WITH_DLT_DAEMON_VSOCK_IPC should be enabled for daemon to listen on incoming VSOCK requests. Local communication method between applications and daemon is still determined with DLT_IPC. When building for guest, WITH_DLT_LIB_VSOCK_IPC should be enabled and DLT_IPC will be ignored, which will make libdlt open a VSOCK socket to the deamon for logging messages. VSOCK can be tested without a virtual machine. Since VMADDR_CID_HOST is used by libdlt when connecting, see vsock man page, clients can be run on host to test VSOCK communication. Some modifications has been done to be able to handle logging through FIFO pipe and socket in the same build of dlt-daemon: - dlt_receiver_init/free_unix_socket() is renamed to dlt_receiver_init/free_global_buffer() and used for FIFO as well. Also fixes memory leak since dlt_receiver_free_unix_socket() was used regardless of whether DLT_USE_UNIX_SOCKET was defined or not. - Pass type to dlt_receiver_init() instead of dlt_receiver_receive(). And remove preprocessor conditionals for handling DLT_CONNECTION_APP_MSG in dlt_daemon_process_user_messages(). Also fixes wrong enum type being passed to dlt_receiver_receive() in dlt_client.c (DltClient::mode was used as a DltReceiverType enum but it is a DltClientMode enum). - Add a flag to DltDaemonApplication to indicate whether file descriptor is "owned" by the DltDaemonApplication or not. When dlt_daemon_application_add() is called due to message received on a socket, fd is passed as an argument (app does not own fd). For FIFO, a per application FIFO is opened (app owns the fd). Also fixes so that user handle is reset for both application and all its contexts when resetting any. Prevents fd from being used by accident after it has been closed. dlt_mkdir_recursive() is moved to src/daemon since it is only used in the daemon. Minimizes use of DLT_USE_UNIX_SOCKET_IPC. Other bugfixes: - Call DLT_SEM_FREE() if setting socket to O_NONBLOCK fails in src/lib/dlt_user.c:dlt_initialize_socket_connection(). - Close socket if dlt_receiver_init() fails in src/lib/dlt_user.c:dlt_initialize_socket_connection(). Signed-off-by: Martin Ejdestig <martin.ejdestig@volvocars.com>
-rw-r--r--Android.bp3
-rw-r--r--CMakeLists.txt23
-rw-r--r--README.md3
-rw-r--r--doc/dlt_design_specification.md29
-rw-r--r--include/dlt/dlt_common.h24
-rw-r--r--include/dlt/dlt_types.h2
-rw-r--r--include/dlt/dlt_user.h.in2
-rw-r--r--src/daemon/dlt-daemon.c159
-rw-r--r--src/daemon/dlt-daemon.h6
-rw-r--r--src/daemon/dlt_daemon_common.c118
-rw-r--r--src/daemon/dlt_daemon_common.h1
-rw-r--r--src/daemon/dlt_daemon_common_cfg.h2
-rw-r--r--src/daemon/dlt_daemon_connection.c32
-rw-r--r--src/examples/dlt-example-multicast-clientmsg-view.c4
-rw-r--r--src/gateway/dlt_gateway.c2
-rw-r--r--src/lib/dlt_client.c14
-rw-r--r--src/lib/dlt_user.c162
-rw-r--r--src/shared/dlt_common.c58
-rw-r--r--tests/gtest_dlt_daemon_offline_log.cpp8
19 files changed, 428 insertions, 224 deletions
diff --git a/Android.bp b/Android.bp
index df5b598..996ae85 100644
--- a/Android.bp
+++ b/Android.bp
@@ -26,7 +26,8 @@ cc_defaults {
"dlt_user_header"],
cflags: [
- "-DDLT_USE_UNIX_SOCKET_IPC",
+ "-DDLT_DAEMON_USE_UNIX_SOCKET_IPC",
+ "-DDLT_LIB_USE_UNIX_SOCKET_IPC",
"-DCONFIGURATION_FILES_DIR=\"/vendor/etc\"",
"-DDLT_USER_IPC_PATH=\"/data/local/tmp\"",
] + [
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ee37382..5b0462d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -77,6 +77,10 @@ option(WITH_DLT_KPI "Set to ON to build src/kpi binaries"
option(WITH_DLT_FATAL_LOG_TRAP "Set to ON to enable DLT_LOG_FATAL trap(trigger segv inside dlt-user library)" OFF)
option(WITH_UDP_CONNECTION "Set to ON to enable dlt UDP multicast SUPPORT" OFF)
+option(WITH_DLT_DAEMON_VSOCK_IPC "Set to ON to enable VSOCK support in daemon" OFF)
+option(WITH_DLT_LIB_VSOCK_IPC "Set to ON to enable VSOCK support in library (DLT_IPC is not used in library)" OFF)
+set(DLT_VSOCK_PORT "13490" CACHE STRING "VSOCK port number for logging traffic.")
+
# RPM settings
set(GENIVI_RPM_RELEASE "1") # ${DLT_REVISION}")
set(LICENSE "Mozilla Public License Version 2.0")
@@ -111,8 +115,20 @@ include_directories(
add_definitions(-D_GNU_SOURCE)
-if(DLT_IPC STREQUAL "UNIX_SOCKET")
- add_definitions(-DDLT_USE_UNIX_SOCKET_IPC)
+if(NOT DLT_IPC STREQUAL "UNIX_SOCKET" AND NOT DLT_IPC STREQUAL "FIFO")
+ message(FATAL_ERROR "${DLT_IPC} is not a valid value for DLT_IPC")
+endif()
+add_definitions(-DDLT_DAEMON_USE_${DLT_IPC}_IPC)
+if(WITH_DLT_DAEMON_VSOCK_IPC)
+ add_definitions(-DDLT_DAEMON_VSOCK_IPC_ENABLE)
+endif()
+if(NOT WITH_DLT_LIB_VSOCK_IPC)
+ add_definitions(-DDLT_LIB_USE_${DLT_IPC}_IPC)
+else()
+ add_definitions(-DDLT_LIB_USE_VSOCK_IPC)
+endif()
+if(WITH_DLT_DAEMON_VSOCK_IPC OR WITH_DLT_LIB_VSOCK_IPC)
+ add_definitions(-DDLT_VSOCK_PORT=${DLT_VSOCK_PORT})
endif()
if(NOT DLT_USER_IPC_PATH)
@@ -269,6 +285,9 @@ message(STATUS "CMAKE_HOST_SYSTEM_PROCESSOR = ${CMAKE_HOST_SYSTEM_PROCESSOR}")
message(STATUS "CMAKE_SYSTEM_PROCESSOR = ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS "WITH_DLT_LOGSTORAGE_CTRL_UDEV = ${WITH_DLT_LOGSTORAGE_CTRL_UDEV}")
message(STATUS "DLT_IPC = ${DLT_IPC}(Path: ${DLT_USER_IPC_PATH})")
+message(STATUS "WITH_DLT_DAEMON_VSOCK_IPC = ${WITH_DLT_DAEMON_VSOCK_IPC}")
+message(STATUS "WITH_DLT_LIB_VSOCK_IPC = ${WITH_DLT_LIB_VSOCK_IPC}")
+message(STATUS "DLT_VSOCK_PORT = ${DLT_VSOCK_PORT}")
message(STATUS "WITH_UDP_CONNECTION = ${WITH_UDP_CONNECTION}")
message(STATUS "WITH_DLT_QNX_SYSTEM = ${WITH_DLT_QNX_SYSTEM})")
message(STATUS "Change a value with: cmake -D<Variable>=<Value>")
diff --git a/README.md b/README.md
index e70f787..93a6b14 100644
--- a/README.md
+++ b/README.md
@@ -64,6 +64,9 @@ WITH\_CHECK\_CONFIG\_FILE | OFF | Set to ON to create a confi
CMAKE\_INSTALL\_PREFIX | /usr/local
CMAKE\_BUILD\_TYPE | RelWithDebInfo
WITH\_UDP\_CONNECTION | ON | Set to ON to enable dlt UDP multicast SUPPORT
+WITH\_DLT\_DAEMON\_VSOCK\_IPC | OFF | Set to ON for VSOCK support in daemon.
+WITH\_DLT\_LIB\_VSOCK\_IPC | OFF | Set to ON for VSOCK support in libdlt (DLT_IPC is overridden in libdlt).
+DLT\_VSOCK\_PORT | 13490 | Port to use for VSOCK communication.
#### Command Line Tool Options
diff --git a/doc/dlt_design_specification.md b/doc/dlt_design_specification.md
index 4642e31..5731cec 100644
--- a/doc/dlt_design_specification.md
+++ b/doc/dlt_design_specification.md
@@ -61,8 +61,8 @@ applications using the DLT user library.
The DLT daemon is a standalone application which is running as the center of
management and this is implemented as a single-thread process. The DLT daemon
communicates with the DLT clients over TCP/IP connections or over a serial line
-with the applications using the DLT user library over named pipes (FIFOs) or
-UNIX_SOCKET based on compile time configuration.
+with the applications using the DLT user library over named pipes (FIFOs),
+UNIX sockets or VSOCK sockets based on compile time configuration.
The message format is specified in the DLT AUTOSAR Standard. More details
concerning the exchanged user messages and their content can be found in
@@ -94,6 +94,8 @@ mode, it uses the syslog daemon for log messages of the DLT daemon application.
- Open DLT output file, if specified
- After phase 1, the daemon initializes the connection handling:
- Delete, create and open its own named FIFO /tmp/dlt or UNIX_SOCKET
+ - If VSOCK support is enabled in the daemon, open, bind and listen to VSOCK
+ socket for incoming application connections.
- Open, bind and listen to TCP socket for incoming connections
- Setup and open serial device, if specified
- Then the daemon enters initialization phase 2:
@@ -126,8 +128,8 @@ and possibly on the serial device, via poll() call.
- Create a new TCP connection
- If the newly created connection is the first TCP connection, send all log
messages already stored in ring buffer to DLT client.
- - Event from incoming named pipe (FIFO) or Unix socket (from DLT user library
- to DLT daemon):
+ - Event from incoming named pipe (FIFO) or UNIX socket and, if enabled, VSOCK
+ socket (from DLT user library to DLT daemon):
- Use dlt receiver to read data
- As long as there are DLT messages available in received data, the handle
user messages type can be found at src/shared/dlt_user_shared_cfg.h
@@ -213,8 +215,8 @@ contains one entry for each context:
- Setup signal handler and atexit handler
- Ignore all pipe signals
- Create and open own named pipe (with the name /tmp/dlt<PID>, where <PID> is the
-process id of the application using the DLT user library) or Unix socket IPC to
-the DLT daemon
+process id of the application using the DLT user library) or UNIX/VSOCK socket IPC
+to the DLT daemon
- Open local file for storage, if specified
- Initialize receiver object
- Start housekeeper thread for receiving messages
@@ -345,7 +347,8 @@ steps are executed:
### Communication between DLT daemon and DLT user library
The communication mechanism (IPC) used between DLT daemon and DLT user library
-are named pipes (FIFOs or UNIX_SOCKETS, based on compile time configuration).
+are named pipes (FIFOs), UNIX sockets or VSOCK sockets, based on compile time
+configuration).
During the startup of the DLT daemon, the DLT daemon creates and opens the IPC
(FIFOs or UNIX_SOCKET) on the configured path called /tmp/dlt. If a DLT user
@@ -379,6 +382,16 @@ itself with the same PID, which is impossible. To solve this problem, the
UNIX_SOCKETS based communication is used. The UNIX_SOCKETS IPC is also supported
in the Non-linux platforms (eg: QNX).
+If the daemon is built with VSOCK socket support, it can also receive log
+messages from processes running in virtual machines. The communication mechanism
+between the daemon and the DLT user library on the host is still FIFOs or UNIX
+sockets. But the DLT user library for the system running in the virtual machine
+can be built to use VSOCK sockets for sending log messages to the daemon. See
+"man vsock" for more information about VSOCK sockets. This is an alternative to
+using a [multinode](dlt_multinode.md) setup for receiving DLT log messages from
+processes in a virtualized environment. No passive daemon(s) are required and it
+works without having a network configured between the guest and the host.
+
### Place of message creation
The following table shows, where the certain types of DLT messages are created.
@@ -746,7 +759,7 @@ The shared directory contains the following files:
| --------- | ----------- |
| dlt_common.c | Common helper functions, such as: Print functions for DLT messages, Functions for handling DLT Ids, Filter functions, DLT message handling functions, Functions for handling DLT files, DLT receiver functions, Log handling, Ringbuffer functions, Setting and checking of storage header |
| dlt_common_cfg.h | Compile time configuration for dlt_common.c |
-| dlt_user_shared.c | Shared functions, required by the DLT daemon and the DLT user library, such as: Setting and checking the user header, Sending DLT messages over named pipes (FIFOs) or UNIX_SOCKET |
+| dlt_user_shared.c | Shared functions, required by the DLT daemon and the DLT user library, such as: Setting and checking the user header, Sending DLT messages over named pipes (FIFOs) or UNIX/VSOCK sockets |
| dlt_user_shared.h | Header file for dlt_user_shared.c |
| dlt_user_shared_cfg.h | Compile time configuration for dlt_user_shared.c |
diff --git a/include/dlt/dlt_common.h b/include/dlt/dlt_common.h
index 9bbd544..71b9c10 100644
--- a/include/dlt/dlt_common.h
+++ b/include/dlt/dlt_common.h
@@ -423,7 +423,7 @@ extern const char dltSerialHeader[DLT_ID_SIZE];
*/
extern char dltSerialHeaderChar[DLT_ID_SIZE];
-#ifndef DLT_USE_UNIX_SOCKET_IPC
+#if defined DLT_DAEMON_USE_FIFO_IPC || defined DLT_LIB_USE_FIFO_IPC
/**
* The common base-path of the dlt-daemon-fifo and application-generated fifos
*/
@@ -779,6 +779,7 @@ typedef struct
char *buf; /**< pointer to position within receiver buffer */
char *backup_buf; /** pointer to the buffer with partial messages if any **/
int fd; /**< connection handle */
+ DltReceiverType type; /**< type of connection handle */
int32_t buffersize; /**< size of receiver buffer */
struct sockaddr_in addr; /**< socket address information */
} DltReceiver;
@@ -1157,7 +1158,7 @@ DltReturnValue dlt_file_free(DltFile *file, int verbose);
* @param filename the filename
*/
void dlt_log_set_filename(const char *filename);
-#ifndef DLT_USE_UNIX_SOCKET_IPC
+#if defined DLT_DAEMON_USE_FIFO_IPC || defined DLT_LIB_USE_FIFO_IPC
/**
* Set FIFO base direction
* @param pipe_dir the pipe direction
@@ -1211,10 +1212,11 @@ void dlt_log_free(void);
* Initialising a dlt receiver structure
* @param receiver pointer to dlt receiver structure
* @param _fd handle to file/socket/fifo, fram which the data should be received
+ * @param type specify whether received data is from socket or file/fifo
* @param _buffersize size of data buffer for storing the received data
* @return negative value if there was an error
*/
-DltReturnValue dlt_receiver_init(DltReceiver *receiver, int _fd, int _buffersize);
+DltReturnValue dlt_receiver_init(DltReceiver *receiver, int _fd, DltReceiverType type, int _buffersize);
/**
* De-Initialize a dlt receiver structure
* @param receiver pointer to dlt receiver structure
@@ -1225,23 +1227,23 @@ DltReturnValue dlt_receiver_free(DltReceiver *receiver);
* Initialising a dlt receiver structure
* @param receiver pointer to dlt receiver structure
* @param fd handle to file/socket/fifo, fram which the data should be received
+ * @param type specify whether received data is from socket or file/fifo
* @param buffer data buffer for storing the received data
* @return negative value if there was an error and zero if success
*/
-DltReturnValue dlt_receiver_init_unix_socket(DltReceiver *receiver, int fd, char **buffer);
+DltReturnValue dlt_receiver_init_global_buffer(DltReceiver *receiver, int fd, DltReceiverType type, char **buffer);
/**
* De-Initialize a dlt receiver structure
* @param receiver pointer to dlt receiver structure
* @return negative value if there was an error and zero if success
*/
-DltReturnValue dlt_receiver_free_unix_socket(DltReceiver *receiver);
+DltReturnValue dlt_receiver_free_global_buffer(DltReceiver *receiver);
/**
* Receive data from socket or file/fifo using the dlt receiver structure
* @param receiver pointer to dlt receiver structure
- * @param from_src specify whether received data is from socket or file/fifo
* @return number of received bytes or negative value if there was an error
*/
-int dlt_receiver_receive(DltReceiver *receiver, DltReceiverType from_src);
+int dlt_receiver_receive(DltReceiver *receiver);
/**
* Remove a specific size of bytes from the received data
* @param receiver pointer to dlt receiver structure
@@ -1616,14 +1618,6 @@ void dlt_getloginfo_conv_ascii_to_id(char *rp, int *rp_count, char *wp, int len)
*/
void dlt_hex_ascii_to_binary(const char *ptr, uint8_t *binary, int *size);
-# ifndef DLT_USE_UNIX_SOCKET_IPC
-/**
- * Create the specified path, recursive if necessary
- * behaves like calling mkdir -p \<dir\> on the console
- */
-int dlt_mkdir_recursive(const char *dir);
-# endif
-
# ifdef __cplusplus
}
# endif
diff --git a/include/dlt/dlt_types.h b/include/dlt/dlt_types.h
index 0047233..9943e31 100644
--- a/include/dlt/dlt_types.h
+++ b/include/dlt/dlt_types.h
@@ -176,7 +176,7 @@ typedef enum
typedef float float32_t;
typedef double float64_t;
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#if defined DLT_LIB_USE_UNIX_SOCKET_IPC || defined DLT_LIB_USE_VSOCK_IPC
/**
* Definition Library connection state
*/
diff --git a/include/dlt/dlt_user.h.in b/include/dlt/dlt_user.h.in
index e4b6569..473575b 100644
--- a/include/dlt/dlt_user.h.in
+++ b/include/dlt/dlt_user.h.in
@@ -253,7 +253,7 @@ typedef struct
int corrupt_message_size;
int16_t corrupt_message_size_size;
# endif
-# ifdef DLT_USE_UNIX_SOCKET_IPC
+# if defined DLT_LIB_USE_UNIX_SOCKET_IPC || defined DLT_LIB_USE_VSOCK_IPC
DltUserConnectionState connection_state;
# endif
uint16_t log_buf_len; /**< length of message buffer, by default: DLT_USER_BUF_MAX_SIZE */
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c
index cd6e5d9..d4a5e90 100644
--- a/src/daemon/dlt-daemon.c
+++ b/src/daemon/dlt-daemon.c
@@ -50,6 +50,15 @@
# include <linux/stat.h>
#endif
+#ifdef DLT_DAEMON_VSOCK_IPC_ENABLE
+# ifdef linux
+# include <linux/vm_sockets.h>
+# endif
+# ifdef __QNX__
+# include <vm_sockets.h>
+# endif
+#endif
+
#include "dlt_types.h"
#include "dlt-daemon.h"
#include "dlt-daemon_cfg.h"
@@ -106,7 +115,7 @@ void usage()
printf(" -h Usage\n");
printf(" -c filename DLT daemon configuration file (Default: " CONFIGURATION_FILES_DIR "/dlt.conf)\n");
-#ifndef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_FIFO_IPC
printf(" -t directory Directory for local fifo and user-pipes (Default: /tmp)\n");
printf(" (Applications wanting to connect to a daemon using a\n");
printf(" custom directory need to be started with the environment \n");
@@ -143,7 +152,7 @@ int option_handling(DltDaemonLocal *daemon_local, int argc, char *argv[])
/* default values */
daemon_local->flags.port = DLT_DAEMON_TCP_PORT;
-#ifndef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_FIFO_IPC
dlt_log_set_fifo_basedir(DLT_USER_IPC_PATH);
#endif
@@ -171,7 +180,7 @@ int option_handling(DltDaemonLocal *daemon_local, int argc, char *argv[])
strncpy(daemon_local->flags.cvalue, optarg, NAME_MAX);
break;
}
-#ifndef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_FIFO_IPC
case 't':
{
dlt_log_set_fifo_basedir(optarg);
@@ -224,7 +233,7 @@ int option_handling(DltDaemonLocal *daemon_local, int argc, char *argv[])
/* switch() */
-#ifndef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_FIFO_IPC
snprintf(daemon_local->flags.userPipesDir, DLT_PATH_MAX,
"%s/dltpipes", dltFifoBaseDir);
snprintf(daemon_local->flags.daemonFifoName, DLT_PATH_MAX,
@@ -263,11 +272,11 @@ int option_file_parser(DltDaemonLocal *daemon_local)
daemon_local->flags.loggingMode = DLT_LOG_TO_CONSOLE;
daemon_local->flags.loggingLevel = LOG_INFO;
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_UNIX_SOCKET_IPC
n = snprintf(daemon_local->flags.loggingFilename,
sizeof(daemon_local->flags.loggingFilename),
"%s/dlt.log", DLT_USER_IPC_PATH);
-#else
+#else /* DLT_DAEMON_USE_FIFO_IPC */
n = snprintf(daemon_local->flags.loggingFilename,
sizeof(daemon_local->flags.loggingFilename),
"%s/dlt.log", dltFifoBaseDir);
@@ -298,14 +307,14 @@ int option_file_parser(DltDaemonLocal *daemon_local)
strncpy(daemon_local->flags.ctrlSockPath,
DLT_DAEMON_DEFAULT_CTRL_SOCK_PATH,
sizeof(daemon_local->flags.ctrlSockPath) - 1);
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_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);
-#else
+#else /* DLT_DAEMON_USE_FIFO_IPC */
memset(daemon_local->flags.daemonFifoGroup, 0, sizeof(daemon_local->flags.daemonFifoGroup));
#endif
daemon_local->flags.gatewayMode = 0;
@@ -626,7 +635,7 @@ int option_file_parser(DltDaemonLocal *daemon_local)
}
}
-#ifndef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_FIFO_IPC
else if (strcmp(token, "DaemonFifoGroup") == 0)
{
strncpy(daemon_local->flags.daemonFifoGroup, value, NAME_MAX);
@@ -728,7 +737,43 @@ int option_file_parser(DltDaemonLocal *daemon_local)
return 0;
}
-#ifndef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_FIFO_IPC
+static int dlt_mkdir_recursive(const char *dir)
+{
+ int ret = 0;
+ char tmp[PATH_MAX + 1];
+ char *p = NULL;
+ char *end = NULL;
+ size_t len;
+
+ strncpy(tmp, dir, PATH_MAX);
+ len = strlen(tmp);
+
+ if (tmp[len - 1] == '/')
+ tmp[len - 1] = 0;
+
+ end = tmp + len;
+
+ for (p = tmp + 1; ((*p) && (ret == 0)) || ((ret == -1 && errno == EEXIST) && (p != end)); p++)
+ if (*p == '/') {
+ *p = 0;
+ ret = mkdir(tmp, S_IRWXU);
+ *p = '/';
+ }
+
+
+
+ if ((ret == 0) || ((ret == -1) && (errno == EEXIST)))
+ ret = mkdir(tmp, S_IRWXU);
+
+ if ((ret == -1) && (errno == EEXIST))
+ ret = 0;
+
+ return ret;
+}
+#endif
+
+#ifdef DLT_DAEMON_USE_FIFO_IPC
static DltReturnValue dlt_daemon_create_pipes_dir(char *dir)
{
int ret = DLT_RETURN_OK;
@@ -811,7 +856,7 @@ int main(int argc, char *argv[])
PRINT_FUNCTION_VERBOSE(daemon_local.flags.vflag);
-#ifndef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_FIFO_IPC
/* Make sure the parent user directory is created */
if (dlt_mkdir_recursive(dltFifoBaseDir) != 0) {
@@ -979,7 +1024,7 @@ int dlt_daemon_local_init_p1(DltDaemon *daemon, DltDaemonLocal *daemon_local, in
#endif
-#ifndef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_FIFO_IPC
if (dlt_daemon_create_pipes_dir(daemon_local->flags.userPipesDir) == DLT_RETURN_ERROR)
return DLT_RETURN_ERROR;
@@ -1174,7 +1219,7 @@ static int dlt_daemon_init_serial(DltDaemonLocal *daemon_local)
DLT_CONNECTION_CLIENT_MSG_SERIAL);
}
-#ifndef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_FIFO_IPC
static int dlt_daemon_init_fifo(DltDaemonLocal *daemon_local)
{
int ret;
@@ -1254,6 +1299,43 @@ static int dlt_daemon_init_fifo(DltDaemonLocal *daemon_local)
}
#endif
+#ifdef DLT_DAEMON_VSOCK_IPC_ENABLE
+static int dlt_daemon_init_vsock(DltDaemonLocal *daemon_local)
+{
+ int fd;
+ struct sockaddr_vm addr;
+
+ fd = socket(AF_VSOCK, SOCK_STREAM, 0);
+ if (fd == -1) {
+ dlt_vlog(LOG_ERR, "Failed to create VSOCK socket: %s\n", strerror(errno));
+ return -1;
+ }
+
+ memset(&addr, 0, sizeof(addr));
+ addr.svm_family = AF_VSOCK;
+ addr.svm_port = DLT_VSOCK_PORT;
+ addr.svm_cid = VMADDR_CID_ANY;
+
+ if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) != 0) {
+ dlt_vlog(LOG_ERR, "Failed to bind VSOCK socket: %s\n", strerror(errno));
+ close(fd);
+ return -1;
+ }
+
+ if (listen(fd, 1) != 0) {
+ dlt_vlog(LOG_ERR, "Failed to listen on VSOCK socket: %s\n", strerror(errno));
+ close(fd);
+ return -1;
+ }
+
+ return dlt_connection_create(daemon_local,
+ &daemon_local->pEvent,
+ fd,
+ POLLIN,
+ DLT_CONNECTION_APP_CONNECT);
+}
+#endif
+
int dlt_daemon_local_connection_init(DltDaemon *daemon,
DltDaemonLocal *daemon_local,
int verbose)
@@ -1269,7 +1351,7 @@ int dlt_daemon_local_connection_init(DltDaemon *daemon,
return -1;
}
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_UNIX_SOCKET_IPC
/* 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;
@@ -1292,7 +1374,7 @@ int dlt_daemon_local_connection_init(DltDaemon *daemon,
return DLT_RETURN_ERROR;
}
-#else
+#else /* DLT_DAEMON_USE_FIFO_IPC */
if (dlt_daemon_init_fifo(daemon_local)) {
dlt_log(LOG_ERR, "Unable to initialize fifo.\n");
@@ -1301,6 +1383,13 @@ int dlt_daemon_local_connection_init(DltDaemon *daemon,
#endif
+#ifdef DLT_DAEMON_VSOCK_IPC_ENABLE
+ if (dlt_daemon_init_vsock(daemon_local) != 0) {
+ dlt_log(LOG_ERR, "Unable to initialize app VSOCK socket.\n");
+ return DLT_RETURN_ERROR;
+ }
+#endif
+
/* create and open socket to receive incoming connections from client */
daemon_local->client_connections = 0;
@@ -1484,10 +1573,10 @@ void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, i
/* Ignore result */
dlt_file_free(&(daemon_local->file), daemon_local->flags.vflag);
-#ifndef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_FIFO_IPC
/* Try to delete existing pipe, ignore result of unlink() */
unlink(daemon_local->flags.daemonFifoName);
-#else
+#else /* DLT_DAEMON_USE_UNIX_SOCKET_IPC */
/* Try to delete existing pipe, ignore result of unlink() */
unlink(daemon_local->flags.appSockPath);
#endif
@@ -1520,7 +1609,7 @@ void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, i
void dlt_daemon_exit_trigger()
{
-#ifndef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_FIFO_IPC
char tmp[DLT_PATH_MAX] = { 0 };
ssize_t n;
@@ -1832,7 +1921,7 @@ int dlt_daemon_process_client_messages(DltDaemon *daemon,
return -1;
}
- must_close_socket = dlt_receiver_receive(receiver, DLT_RECEIVE_SOCKET);
+ must_close_socket = dlt_receiver_receive(receiver);
if (must_close_socket < 0) {
dlt_daemon_close_socket(receiver->fd,
@@ -1908,7 +1997,7 @@ int dlt_daemon_process_client_messages_serial(DltDaemon *daemon,
return -1;
}
- if (dlt_receiver_receive(receiver, DLT_RECEIVE_FD) <= 0) {
+ if (dlt_receiver_receive(receiver) <= 0) {
dlt_log(LOG_WARNING,
"dlt_receiver_receive_fd() for messages from serial interface "
"failed!\n");
@@ -2010,15 +2099,13 @@ int dlt_daemon_process_control_connect(
return 0;
}
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#if defined DLT_DAEMON_USE_UNIX_SOCKET_IPC || defined DLT_DAEMON_VSOCK_IPC_ENABLE
int dlt_daemon_process_app_connect(
DltDaemon *daemon,
DltDaemonLocal *daemon_local,
DltReceiver *receiver,
int verbose)
{
- socklen_t app_size;
- struct sockaddr_un app;
int in_sock = -1;
PRINT_FUNCTION_VERBOSE(verbose);
@@ -2030,10 +2117,9 @@ int dlt_daemon_process_app_connect(
return DLT_RETURN_WRONG_PARAMETER;
}
- /* event from UNIX server socket, new connection */
- app_size = sizeof(app);
+ /* event from server socket, new connection */
- if ((in_sock = accept(receiver->fd, (struct sockaddr *)&app, &app_size)) < 0) {
+ if ((in_sock = accept(receiver->fd, NULL, NULL)) < 0) {
dlt_vlog(LOG_ERR, "accept() on UNIX socket %d failed: %s\n", receiver->fd, strerror(errno));
return -1;
}
@@ -2077,7 +2163,7 @@ int dlt_daemon_process_control_messages(
return -1;
}
- if (dlt_receiver_receive(receiver, DLT_RECEIVE_SOCKET) <= 0) {
+ if (dlt_receiver_receive(receiver) <= 0) {
dlt_daemon_close_socket(receiver->fd,
daemon,
daemon_local,
@@ -2189,28 +2275,21 @@ int dlt_daemon_process_user_messages(DltDaemon *daemon,
return -1;
}
-#ifdef DLT_USE_UNIX_SOCKET_IPC
- recv = dlt_receiver_receive(receiver, DLT_RECEIVE_SOCKET);
+ recv = dlt_receiver_receive(receiver);
- if (recv <= 0) {
+ if (recv <= 0 && receiver->type == DLT_RECEIVE_SOCKET) {
dlt_daemon_close_socket(receiver->fd,
daemon,
daemon_local,
verbose);
return 0;
}
-
-#else
- recv = dlt_receiver_receive(receiver, DLT_RECEIVE_FD);
-
- if (recv < 0) {
+ else 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) {
dlt_daemon_process_user_message_func func = NULL;
@@ -2327,6 +2406,7 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
char description[DLT_DAEMON_DESCSIZE + 1] = { '\0' };
DltUserControlMsgRegisterApplication userapp;
char *origin;
+ int fd = -1;
PRINT_FUNCTION_VERBOSE(verbose);
@@ -2386,11 +2466,14 @@ int dlt_daemon_process_user_message_register_application(DltDaemon *daemon,
if (old_application != NULL)
old_pid = old_application->pid;
+ if (rec->type == DLT_RECEIVE_SOCKET)
+ fd = rec->fd; /* For sockets, an app specific fd has already been created with accept(). */
+
application = dlt_daemon_application_add(daemon,
userapp.apid,
userapp.pid,
description,
- rec->fd,
+ fd,
daemon->ecuid,
verbose);
diff --git a/src/daemon/dlt-daemon.h b/src/daemon/dlt-daemon.h
index 31598bb..4095cf3 100644
--- a/src/daemon/dlt-daemon.h
+++ b/src/daemon/dlt-daemon.h
@@ -117,9 +117,9 @@ typedef struct
unsigned int offlineLogstorageMaxCounter; /**< (int) Maximum offline logstorage file counter index until wraparound */
unsigned int offlineLogstorageMaxCounterIdx; /**< (int) String len of offlineLogstorageMaxCounter*/
unsigned int offlineLogstorageCacheSize; /**< Max cache size offline logstorage cache */
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_UNIX_SOCKET_IPC
char appSockPath[DLT_DAEMON_FLAG_MAX]; /**< Path to User socket */
-#else
+#else /* DLT_DAEMON_USE_FIFO_IPC */
char userPipesDir[DLT_PATH_MAX]; /**< (String: Directory) directory where dltpipes reside (Default: /tmp/dltpipes) */
char daemonFifoName[DLT_PATH_MAX]; /**< (String: Filename) name of local fifo (Default: /tmp/dlt) */
char daemonFifoGroup[DLT_PATH_MAX]; /**< (String: Group name) Owner group of local fifo (Default: Primary Group) */
@@ -209,7 +209,7 @@ int dlt_daemon_process_sixty_s_timer(DltDaemon *daemon, DltDaemonLocal *daemon_l
int dlt_daemon_process_systemd_timer(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
int dlt_daemon_process_control_connect(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#if defined DLT_DAEMON_USE_UNIX_SOCKET_IPC || defined DLT_DAEMON_VSOCK_IPC_ENABLE
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,
diff --git a/src/daemon/dlt_daemon_common.c b/src/daemon/dlt_daemon_common.c
index f628cd5..4349753 100644
--- a/src/daemon/dlt_daemon_common.c
+++ b/src/daemon/dlt_daemon_common.c
@@ -65,6 +65,7 @@
* aw 13.01.2010 initial
*/
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -384,6 +385,33 @@ int dlt_daemon_applications_clear(DltDaemon *daemon, char *ecu, int verbose)
return 0;
}
+static void dlt_daemon_application_reset_user_handle(DltDaemon *daemon,
+ DltDaemonApplication *application,
+ int verbose)
+{
+ DltDaemonRegisteredUsers *user_list;
+ DltDaemonContext *context;
+ int i;
+
+ if (application->user_handle == DLT_FD_INIT)
+ return;
+
+ user_list = dlt_daemon_find_users_list(daemon, daemon->ecuid, verbose);
+ if (user_list != NULL) {
+ for (i = 0; i < user_list->num_contexts; i++) {
+ context = &user_list->contexts[i];
+ if (context->user_handle == application->user_handle)
+ context->user_handle = DLT_FD_INIT;
+ }
+ }
+
+ if (application->owns_user_handle)
+ close(application->user_handle);
+
+ application->user_handle = DLT_FD_INIT;
+ application->owns_user_handle = false;
+}
+
DltDaemonApplication *dlt_daemon_application_add(DltDaemon *daemon,
char *apid,
pid_t pid,
@@ -396,8 +424,9 @@ DltDaemonApplication *dlt_daemon_application_add(DltDaemon *daemon,
DltDaemonApplication *old;
int new_application;
int dlt_user_handle;
+ bool owns_user_handle;
DltDaemonRegisteredUsers *user_list = NULL;
-#ifndef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_FIFO_IPC
(void)fd; /* To avoid compiler warning : unused variable */
char filename[DLT_DAEMON_COMMON_TEXTBUFSIZE];
#endif
@@ -455,6 +484,7 @@ DltDaemonApplication *dlt_daemon_application_add(DltDaemon *daemon,
application->application_description = NULL;
application->num_contexts = 0;
application->user_handle = DLT_FD_INIT;
+ application->owns_user_handle = false;
new_application = 1;
@@ -487,42 +517,39 @@ DltDaemonApplication *dlt_daemon_application_add(DltDaemon *daemon,
}
}
- 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 */
-
-#endif
- application->user_handle = DLT_FD_INIT;
- application->pid = 0;
- }
+ if (application->pid != pid) {
+ dlt_daemon_application_reset_user_handle(daemon, application, verbose);
+ application->pid = 0;
}
/* open user pipe only if it is not yet opened */
if ((application->user_handle == DLT_FD_INIT) && (pid != 0)) {
-#ifdef DLT_USE_UNIX_SOCKET_IPC
- dlt_user_handle = fd;
-#else
- snprintf(filename,
- DLT_DAEMON_COMMON_TEXTBUFSIZE,
- "%s/dltpipes/dlt%d",
- dltFifoBaseDir,
- pid);
-
- 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 */
+ dlt_user_handle = DLT_FD_INIT;
+ owns_user_handle = false;
+#if defined DLT_DAEMON_USE_UNIX_SOCKET_IPC || defined DLT_DAEMON_VSOCK_IPC_ENABLE
+ if (fd >= DLT_FD_MINIMUM) {
+ dlt_user_handle = fd;
+ owns_user_handle = false;
+ }
+#endif
+#ifdef DLT_DAEMON_USE_FIFO_IPC
+ if (dlt_user_handle < DLT_FD_MINIMUM) {
+ snprintf(filename,
+ DLT_DAEMON_COMMON_TEXTBUFSIZE,
+ "%s/dltpipes/dlt%d",
+ dltFifoBaseDir,
+ pid);
+
+ 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));
+ } else {
+ owns_user_handle = true;
+ }
+ }
#endif
/* check if file descriptor was already used, and make it invalid if it
* is reused. This prevents sending messages to wrong file descriptor */
@@ -530,6 +557,7 @@ DltDaemonApplication *dlt_daemon_application_add(DltDaemon *daemon,
dlt_daemon_contexts_invalidate_fd(daemon, ecu, dlt_user_handle, verbose);
application->user_handle = dlt_user_handle;
+ application->owns_user_handle = owns_user_handle;
application->pid = pid;
}
@@ -566,13 +594,7 @@ int dlt_daemon_application_del(DltDaemon *daemon,
return -1;
if (user_list->num_applications > 0) {
- /* Check if user handle is open; if yes, close it */
- if (application->user_handle >= DLT_FD_MINIMUM) {
-#ifndef DLT_USE_UNIX_SOCKET_IPC
- close(application->user_handle);
-#endif
- application->user_handle = DLT_FD_INIT;
- }
+ dlt_daemon_application_reset_user_handle(daemon, application, verbose);
/* Free description of application to be deleted */
if (application->application_description) {
@@ -1325,6 +1347,7 @@ int dlt_daemon_user_send_log_level(DltDaemon *daemon, DltDaemonContext *context,
DltUserHeader userheader;
DltUserControlMsgLogLevel usercontext;
DltReturnValue ret;
+ DltDaemonApplication *app;
PRINT_FUNCTION_VERBOSE(verbose);
@@ -1370,11 +1393,9 @@ int dlt_daemon_user_send_log_level(DltDaemon *daemon, DltDaemonContext *context,
errno != 0 ? strerror(errno) : "Unknown error");
if (errno == EPIPE) {
-#ifndef DLT_USE_UNIX_SOCKET_IPC
- /* Close connection */
- close(context->user_handle);
-#endif
- context->user_handle = DLT_FD_INIT;
+ app = dlt_daemon_application_find(daemon, context->apid, daemon->ecuid, verbose);
+ if (app != NULL)
+ dlt_daemon_application_reset_user_handle(daemon, app, verbose);
}
}
@@ -1403,13 +1424,8 @@ int dlt_daemon_user_send_log_state(DltDaemon *daemon, DltDaemonApplication *app,
&(logstate), sizeof(DltUserControlMsgLogState));
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;
- }
+ if (errno == EPIPE)
+ dlt_daemon_application_reset_user_handle(daemon, app, verbose);
}
return (ret == DLT_RETURN_OK) ? DLT_RETURN_OK : DLT_RETURN_ERROR;
diff --git a/src/daemon/dlt_daemon_common.h b/src/daemon/dlt_daemon_common.h
index 5e1bb1b..c6a4594 100644
--- a/src/daemon/dlt_daemon_common.h
+++ b/src/daemon/dlt_daemon_common.h
@@ -133,6 +133,7 @@ typedef struct
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 */
+ bool owns_user_handle; /**< user_handle should be closed when reset */
char *application_description; /**< context description */
int num_contexts; /**< number of contexts for this application */
} DltDaemonApplication;
diff --git a/src/daemon/dlt_daemon_common_cfg.h b/src/daemon/dlt_daemon_common_cfg.h
index 926befd..8fbd9b0 100644
--- a/src/daemon/dlt_daemon_common_cfg.h
+++ b/src/daemon/dlt_daemon_common_cfg.h
@@ -86,7 +86,7 @@
#define DLT_DAEMON_DEFAULT_CTRL_SOCK_PATH DLT_RUNTIME_DEFAULT_DIRECTORY \
"/dlt-ctrl.sock"
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_UNIX_SOCKET_IPC
# define DLT_DAEMON_DEFAULT_APP_SOCK_PATH DLT_RUNTIME_DEFAULT_DIRECTORY \
"/dlt-app.sock"
#endif
diff --git a/src/daemon/dlt_daemon_connection.c b/src/daemon/dlt_daemon_connection.c
index 43a202b..a438c03 100644
--- a/src/daemon/dlt_daemon_connection.c
+++ b/src/daemon/dlt_daemon_connection.c
@@ -33,6 +33,7 @@
#include <sys/socket.h>
#include <syslog.h>
+#include <sys/stat.h>
#include <sys/types.h>
#include "dlt_daemon_connection_types.h"
@@ -162,7 +163,7 @@ DLT_STATIC void dlt_connection_destroy_receiver(DltConnection *con)
/* We rely on the gateway for clean-up */
break;
case DLT_CONNECTION_APP_MSG:
- dlt_receiver_free_unix_socket(con->receiver);
+ dlt_receiver_free_global_buffer(con->receiver);
free(con->receiver);
con->receiver = NULL;
break;
@@ -193,6 +194,8 @@ DLT_STATIC DltReceiver *dlt_connection_get_receiver(DltDaemonLocal *daemon_local
int fd)
{
DltReceiver *ret = NULL;
+ DltReceiverType receiver_type = DLT_RECEIVE_FD;
+ struct stat statbuf;
switch (type) {
case DLT_CONNECTION_CONTROL_CONNECT:
@@ -205,29 +208,34 @@ DLT_STATIC DltReceiver *dlt_connection_get_receiver(DltDaemonLocal *daemon_local
ret = calloc(1, sizeof(DltReceiver));
if (ret)
- dlt_receiver_init(ret, fd, DLT_DAEMON_RCVBUFSIZESOCK);
+ dlt_receiver_init(ret, fd, DLT_RECEIVE_SOCKET, DLT_DAEMON_RCVBUFSIZESOCK);
break;
case DLT_CONNECTION_CLIENT_MSG_SERIAL:
ret = calloc(1, sizeof(DltReceiver));
if (ret)
- dlt_receiver_init(ret, fd, DLT_DAEMON_RCVBUFSIZESERIAL);
+ dlt_receiver_init(ret, fd, DLT_RECEIVE_FD, DLT_DAEMON_RCVBUFSIZESERIAL);
break;
case DLT_CONNECTION_APP_MSG:
ret = calloc(1, sizeof(DltReceiver));
- 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
+ receiver_type = DLT_RECEIVE_FD;
+
+ if (fstat(fd, &statbuf) == 0) {
+ if (S_ISSOCK(statbuf.st_mode))
+ receiver_type = DLT_RECEIVE_SOCKET;
+ } else {
+ dlt_vlog(LOG_WARNING,
+ "Failed to determine receive type for DLT_CONNECTION_APP_MSG, using \"FD\"\n");
}
+ if (ret)
+ dlt_receiver_init_global_buffer(ret, fd, receiver_type, &app_recv_buffer);
+
break;
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#if defined DLT_DAEMON_USE_UNIX_SOCKET_IPC || defined DLT_DAEMON_VSOCK_IPC_ENABLE
case DLT_CONNECTION_APP_CONNECT:
/* FALL THROUGH */
#endif
@@ -243,7 +251,7 @@ DLT_STATIC DltReceiver *dlt_connection_get_receiver(DltDaemonLocal *daemon_local
ret = calloc(1, sizeof(DltReceiver));
if (ret)
- dlt_receiver_init(ret, fd, DLT_DAEMON_RCVBUFSIZE);
+ dlt_receiver_init(ret, fd, DLT_RECEIVE_FD, DLT_DAEMON_RCVBUFSIZE);
break;
case DLT_CONNECTION_GATEWAY:
@@ -286,7 +294,7 @@ void *dlt_connection_get_callback(DltConnection *con)
case DLT_CONNECTION_CLIENT_MSG_SERIAL:
ret = dlt_daemon_process_client_messages_serial;
break;
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#if defined DLT_DAEMON_USE_UNIX_SOCKET_IPC || defined DLT_DAEMON_VSOCK_IPC_ENABLE
case DLT_CONNECTION_APP_CONNECT:
ret = dlt_daemon_process_app_connect;
break;
diff --git a/src/examples/dlt-example-multicast-clientmsg-view.c b/src/examples/dlt-example-multicast-clientmsg-view.c
index c9bd743..f68473c 100644
--- a/src/examples/dlt-example-multicast-clientmsg-view.c
+++ b/src/examples/dlt-example-multicast-clientmsg-view.c
@@ -164,7 +164,9 @@ int main()
if (dlt_message_init(&msg, 0) == DLT_RETURN_ERROR)
return DLT_RETURN_ERROR;
- if (dlt_receiver_init(&(clientinfo.receiver), clientinfo.fd,
+ if (dlt_receiver_init(&(clientinfo.receiver),
+ clientinfo.fd,
+ DLT_RECEIVE_UDP_SOCKET,
DLT_RECEIVE_BUFSIZE) != DLT_RETURN_OK)
return DLT_RETURN_ERROR;
diff --git a/src/gateway/dlt_gateway.c b/src/gateway/dlt_gateway.c
index 9c6578f..9d0041d 100644
--- a/src/gateway/dlt_gateway.c
+++ b/src/gateway/dlt_gateway.c
@@ -1321,7 +1321,7 @@ DltReturnValue dlt_gateway_process_passive_node_messages(DltDaemon *daemon,
}
/* nearly copy and paste of dlt_client_main_loop function */
- if (dlt_receiver_receive(receiver, DLT_RECEIVE_SOCKET) <= 0) {
+ if (dlt_receiver_receive(receiver) <= 0) {
/* No more data to be received */
if (dlt_message_free(&msg, verbose) < 0) {
dlt_log(LOG_ERR, "Cannot free DLT message\n");
diff --git a/src/lib/dlt_client.c b/src/lib/dlt_client.c
index ad7a66b..736fd70 100644
--- a/src/lib/dlt_client.c
+++ b/src/lib/dlt_client.c
@@ -166,6 +166,8 @@ DltReturnValue dlt_client_connect(DltClient *client, int verbose)
struct sockaddr_un addr;
int rv;
struct ip_mreq mreq;
+ DltReceiverType receiver_type = DLT_RECEIVE_FD;
+
memset(&hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_STREAM;
@@ -206,6 +208,8 @@ DltReturnValue dlt_client_connect(DltClient *client, int verbose)
if (verbose)
printf("Connected to DLT daemon (%s)\n", client->servIP);
+ receiver_type = DLT_RECEIVE_SOCKET;
+
break;
case DLT_CLIENT_MODE_SERIAL:
/* open serial connection */
@@ -242,6 +246,8 @@ DltReturnValue dlt_client_connect(DltClient *client, int verbose)
if (verbose)
printf("Connected to %s\n", client->serialDevice);
+ receiver_type = DLT_RECEIVE_FD;
+
break;
case DLT_CLIENT_MODE_UNIX:
@@ -267,6 +273,8 @@ DltReturnValue dlt_client_connect(DltClient *client, int verbose)
return DLT_RETURN_ERROR;
}
+ receiver_type = DLT_RECEIVE_SOCKET;
+
break;
case DLT_CLIENT_MODE_UDP_MULTICAST:
@@ -319,6 +327,8 @@ DltReturnValue dlt_client_connect(DltClient *client, int verbose)
return DLT_RETURN_ERROR;
}
+ receiver_type = DLT_RECEIVE_UDP_SOCKET;
+
break;
default:
@@ -328,7 +338,7 @@ DltReturnValue dlt_client_connect(DltClient *client, int verbose)
return DLT_RETURN_ERROR;
}
- if (dlt_receiver_init(&(client->receiver), client->sock, DLT_RECEIVE_BUFSIZE) != DLT_RETURN_OK) {
+ if (dlt_receiver_init(&(client->receiver), client->sock, receiver_type, DLT_RECEIVE_BUFSIZE) != DLT_RETURN_OK) {
fprintf(stderr, "ERROR initializing receiver\n");
return DLT_RETURN_ERROR;
}
@@ -389,7 +399,7 @@ DltReturnValue dlt_client_main_loop(DltClient *client, void *data, int verbose)
while (1) {
/* wait for data from socket or serial connection */
- ret = dlt_receiver_receive(&(client->receiver), client->mode);
+ ret = dlt_receiver_receive(&(client->receiver));
if (ret <= 0) {
/* No more data to be received */
diff --git a/src/lib/dlt_user.c b/src/lib/dlt_user.c
index ae076ca..ccebd4f 100644
--- a/src/lib/dlt_user.c
+++ b/src/lib/dlt_user.c
@@ -54,10 +54,21 @@
#include <unistd.h>
#include <stdbool.h>
-#ifdef DLT_USE_UNIX_SOCKET_IPC
-# include <sys/un.h>
+
+#if defined DLT_LIB_USE_UNIX_SOCKET_IPC || defined DLT_LIB_USE_VSOCK_IPC
# include <sys/socket.h>
#endif
+#ifdef DLT_LIB_USE_UNIX_SOCKET_IPC
+# include <sys/un.h>
+#endif
+#ifdef DLT_LIB_USE_VSOCK_IPC
+# ifdef linux
+# include <linux/vm_sockets.h>
+# endif
+# ifdef __QNX__
+# include <vm_sockets.h>
+# endif
+#endif
#include "dlt_user.h"
#include "dlt_common.h"
@@ -81,7 +92,7 @@ static DltUser dlt_user;
static bool dlt_user_initialised = false;
static int dlt_user_freeing = 0;
-#ifndef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_LIB_USE_FIFO_IPC
static char dlt_user_dir[DLT_PATH_MAX];
static char dlt_daemon_fifo[DLT_PATH_MAX];
#endif
@@ -209,13 +220,33 @@ DltReturnValue dlt_user_check_library_version(const char *user_major_version, co
return DLT_RETURN_OK;
}
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#if defined DLT_LIB_USE_UNIX_SOCKET_IPC || defined DLT_LIB_USE_VSOCK_IPC
+static DltReturnValue dlt_socket_set_nonblock_and_linger(int sockfd)
+{
+ int status;
+ struct linger l_opt;
+
+ status = fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFL, 0) | O_NONBLOCK);
+ if (status == -1) {
+ dlt_log(LOG_INFO, "Socket cannot be changed to NON BLOCK\n");
+ return DLT_RETURN_ERROR;
+ }
+
+ l_opt.l_onoff = 1;
+ l_opt.l_linger = 10;
+
+ if (setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &l_opt, sizeof l_opt) < 0)
+ dlt_log(LOG_WARNING, "Failed to set socket linger option\n");
+
+ return DLT_RETURN_OK;
+}
+#endif
+
+#ifdef DLT_LIB_USE_UNIX_SOCKET_IPC
static DltReturnValue dlt_initialize_socket_connection(void)
{
struct sockaddr_un remote;
- int status = 0;
char dltSockBaseDir[DLT_IPC_PATH_MAX];
- struct linger l_opt;
DLT_SEM_LOCK();
int sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
@@ -226,22 +257,12 @@ static DltReturnValue dlt_initialize_socket_connection(void)
return DLT_RETURN_ERROR;
}
- status = fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFL, 0) | O_NONBLOCK);
-
- if (status == -1) {
- dlt_vlog(LOG_INFO,
- "Socket %s/dlt cannot be changed to NON BLOCK\n",
- DLT_USER_IPC_PATH);
+ if (dlt_socket_set_nonblock_and_linger(sockfd) != DLT_RETURN_OK) {
+ close(sockfd);
+ DLT_SEM_FREE();
return DLT_RETURN_ERROR;
}
- /* Set SO_LINGER opt for the new client socket. */
- l_opt.l_onoff = 1;
- l_opt.l_linger = 10;
-
- if (setsockopt(sockfd, SOL_SOCKET, SO_LINGER, &l_opt, sizeof l_opt) < 0)
- dlt_log(LOG_WARNING, "Failed to set linger option\n");
-
remote.sun_family = AF_UNIX;
snprintf(dltSockBaseDir, DLT_IPC_PATH_MAX, "%s/dlt", DLT_USER_IPC_PATH);
strncpy(remote.sun_path, dltSockBaseDir, sizeof(remote.sun_path));
@@ -268,8 +289,10 @@ static DltReturnValue dlt_initialize_socket_connection(void)
if (dlt_receiver_init(&(dlt_user.receiver),
sockfd,
+ DLT_RECEIVE_SOCKET,
DLT_USER_RCVBUF_MAX_SIZE) == DLT_RETURN_ERROR) {
dlt_user_initialised = false;
+ close(sockfd);
DLT_SEM_FREE();
return DLT_RETURN_ERROR;
}
@@ -279,7 +302,62 @@ static DltReturnValue dlt_initialize_socket_connection(void)
return DLT_RETURN_OK;
}
-#else /* setup fifo*/
+#elif defined DLT_LIB_USE_VSOCK_IPC
+static DltReturnValue dlt_initialize_vsock_connection()
+{
+ struct sockaddr_vm remote;
+
+ DLT_SEM_LOCK();
+ int sockfd = socket(AF_VSOCK, SOCK_STREAM, 0);
+
+ if (sockfd == DLT_FD_INIT) {
+ dlt_log(LOG_CRIT, "Failed to create VSOCK socket\n");
+ DLT_SEM_FREE();
+ return DLT_RETURN_ERROR;
+ }
+
+ memset(&remote, 0, sizeof(remote));
+ remote.svm_family = AF_VSOCK;
+ remote.svm_port = DLT_VSOCK_PORT;
+ remote.svm_cid = VMADDR_CID_HOST;
+
+ if (connect(sockfd, (struct sockaddr *)&remote, sizeof(remote)) == -1) {
+ if (dlt_user.connection_state != DLT_USER_RETRY_CONNECT) {
+ dlt_vlog(LOG_INFO, "VSOCK socket cannot be opened. Retrying later...\n");
+ dlt_user.connection_state = DLT_USER_RETRY_CONNECT;
+ }
+
+ close(sockfd);
+ dlt_user.dlt_log_handle = -1;
+ }
+ else {
+ /* Set to non-blocking after connect() to avoid EINPROGRESS. DltUserConntextionState
+ needs "connecting" state if connect() should be non-blocking. */
+ if (dlt_socket_set_nonblock_and_linger(sockfd) != DLT_RETURN_OK) {
+ close(sockfd);
+ DLT_SEM_FREE();
+ return DLT_RETURN_ERROR;
+ }
+
+ dlt_user.dlt_log_handle = sockfd;
+ dlt_user.connection_state = DLT_USER_CONNECTED;
+
+ if (dlt_receiver_init(&(dlt_user.receiver),
+ sockfd,
+ DLT_RECEIVE_SOCKET,
+ DLT_USER_RCVBUF_MAX_SIZE) == DLT_RETURN_ERROR) {
+ dlt_user_initialised = false;
+ close(sockfd);
+ DLT_SEM_FREE();
+ return DLT_RETURN_ERROR;
+ }
+ }
+
+ DLT_SEM_FREE();
+
+ return DLT_RETURN_OK;
+}
+#else /* DLT_LIB_USE_FIFO_IPC */
static DltReturnValue dlt_initialize_fifo_connection(void)
{
char filename[DLT_PATH_MAX];
@@ -383,7 +461,7 @@ DltReturnValue dlt_init(void)
#endif
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_LIB_USE_UNIX_SOCKET_IPC
if (dlt_initialize_socket_connection() != DLT_RETURN_OK)
/* We could connect to the pipe, but not to the socket, which is normally */
@@ -391,12 +469,19 @@ DltReturnValue dlt_init(void)
/* in case application is started before daemon, it is expected behaviour */
return DLT_RETURN_ERROR;
-#else /* FIFO connection */
+#elif defined DLT_LIB_USE_VSOCK_IPC
+
+ if (dlt_initialize_vsock_connection() != DLT_RETURN_OK)
+ return DLT_RETURN_ERROR;
+
+#else /* DLT_LIB_USE_FIFO_IPC */
if (dlt_initialize_fifo_connection() != DLT_RETURN_OK)
return DLT_RETURN_ERROR;
- if (dlt_receiver_init(&(dlt_user.receiver), dlt_user.dlt_user_handle,
+ if (dlt_receiver_init(&(dlt_user.receiver),
+ dlt_user.dlt_user_handle,
+ DLT_RECEIVE_FD,
DLT_USER_RCVBUF_MAX_SIZE) == DLT_RETURN_ERROR) {
dlt_user_initialised = false;
return DLT_RETURN_ERROR;
@@ -821,7 +906,7 @@ DltReturnValue dlt_free(void)
{
uint32_t i;
int ret = 0;
-#ifndef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_LIB_USE_FIFO_IPC
char filename[DLT_PATH_MAX];
#endif
@@ -841,7 +926,7 @@ DltReturnValue dlt_free(void)
dlt_stop_threads();
-#ifndef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_LIB_USE_FIFO_IPC
if (dlt_user.dlt_user_handle != DLT_FD_INIT) {
close(dlt_user.dlt_user_handle);
@@ -859,7 +944,7 @@ DltReturnValue dlt_free(void)
if (dlt_user.dlt_log_handle != -1) {
/* close log file/output fifo to daemon */
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#if defined DLT_LIB_USE_UNIX_SOCKET_IPC || defined DLT_LIB_USE_VSOCK_IPC
ret = shutdown(dlt_user.dlt_log_handle, SHUT_WR);
if (ret < 0) {
@@ -3752,7 +3837,7 @@ DltReturnValue dlt_user_log_send_log(DltContextData *log, int mtype)
/* handle not open or pipe error */
close(dlt_user.dlt_log_handle);
dlt_user.dlt_log_handle = -1;
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#if defined DLT_LIB_USE_UNIX_SOCKET_IPC || defined DLT_LIB_USE_VSOCK_IPC
dlt_user.connection_state = DLT_USER_RETRY_CONNECT;
#endif
@@ -4126,7 +4211,6 @@ DltReturnValue dlt_user_log_check_user_message(void)
uint32_t i;
int fd;
- DltReceiverType from_src_type = DLT_RECEIVE_FD;
struct pollfd nfd[1];
DltUserHeader *userheader;
@@ -4150,20 +4234,18 @@ DltReturnValue dlt_user_log_check_user_message(void)
delayed_log_level_changed_callback.log_level_changed_callback = 0;
delayed_injection_callback.data = 0;
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#if defined DLT_LIB_USE_UNIX_SOCKET_IPC || defined DLT_LIB_USE_VSOCK_IPC
fd = dlt_user.dlt_log_handle;
- from_src_type = DLT_RECEIVE_SOCKET;
-#else
+#else /* DLT_LIB_USE_FIFO_IPC */
fd = dlt_user.dlt_user_handle;
- from_src_type = DLT_RECEIVE_FD;
#endif
nfd[0].events = POLLIN;
nfd[0].fd = fd;
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#if defined DLT_LIB_USE_UNIX_SOCKET_IPC || defined DLT_LIB_USE_VSOCK_IPC
if (fd != DLT_FD_INIT) {
ret = poll(nfd, 1, -1);
-#else
+#else /* DLT_LIB_USE_FIFO_IPC */
if (fd != DLT_FD_INIT && dlt_user.dlt_log_handle > 0) {
ret = poll(nfd, 1, DLT_USER_RECEIVE_NDELAY);
#endif
@@ -4173,7 +4255,7 @@ DltReturnValue dlt_user_log_check_user_message(void)
return DLT_RETURN_ERROR;
}
- if (dlt_receiver_receive(receiver, from_src_type) <= 0)
+ if (dlt_receiver_receive(receiver) <= 0)
/* No new message available */
return DLT_RETURN_OK;
@@ -4502,7 +4584,7 @@ void dlt_user_log_reattach_to_daemon(void)
if (dlt_user.dlt_log_handle < 0) {
dlt_user.dlt_log_handle = DLT_FD_INIT;
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_LIB_USE_UNIX_SOCKET_IPC
/* try to open connection to dlt daemon */
dlt_initialize_socket_connection();
@@ -4510,7 +4592,13 @@ void dlt_user_log_reattach_to_daemon(void)
/* return if not connected */
return;
-#else
+#elif defined DLT_LIB_USE_VSOCK_IPC
+ dlt_initialize_vsock_connection();
+
+ if (dlt_user.connection_state != DLT_USER_CONNECTED)
+ return;
+
+#else /* DLT_LIB_USE_FIFO_IPC */
/* try to open pipe to dlt daemon */
int fd = open(dlt_daemon_fifo, O_WRONLY | O_NONBLOCK);
diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c
index 615665c..d545fe0 100644
--- a/src/shared/dlt_common.c
+++ b/src/shared/dlt_common.c
@@ -66,7 +66,7 @@
const char dltSerialHeader[DLT_ID_SIZE] = { 'D', 'L', 'S', 1 };
char dltSerialHeaderChar[DLT_ID_SIZE] = { 'D', 'L', 'S', 1 };
-#ifndef DLT_USE_UNIX_SOCKET_IPC
+#if defined DLT_DAEMON_USE_FIFO_IPC || defined DLT_LIB_USE_FIFO_IPC
char dltFifoBaseDir[DLT_PATH_MAX] = "/tmp";
#endif
@@ -1736,7 +1736,7 @@ void dlt_log_set_filename(const char *filename)
logging_filename[NAME_MAX] = 0;
}
-#ifndef DLT_USE_UNIX_SOCKET_IPC
+#if defined DLT_DAEMON_USE_FIFO_IPC || defined DLT_LIB_USE_FIFO_IPC
void dlt_log_set_fifo_basedir(const char *pipe_dir)
{
strncpy(dltFifoBaseDir, pipe_dir, DLT_PATH_MAX);
@@ -1921,12 +1921,13 @@ DltReturnValue dlt_vnlog(int prio, size_t size, const char *format, ...)
return DLT_RETURN_OK;
}
-DltReturnValue dlt_receiver_init(DltReceiver *receiver, int fd, int buffersize)
+DltReturnValue dlt_receiver_init(DltReceiver *receiver, int fd, DltReceiverType type, int buffersize)
{
if (NULL == receiver)
return DLT_RETURN_WRONG_PARAMETER;
receiver->fd = fd;
+ receiver->type = type;
/** Reuse the receiver buffer if it exists and the buffer size
* is not changed. If not, free the old one and allocate a new buffer.
@@ -1957,7 +1958,7 @@ DltReturnValue dlt_receiver_init(DltReceiver *receiver, int fd, int buffersize)
return DLT_RETURN_OK;
}
-DltReturnValue dlt_receiver_init_unix_socket(DltReceiver *receiver, int fd, char **buffer)
+DltReturnValue dlt_receiver_init_global_buffer(DltReceiver *receiver, int fd, DltReceiverType type, char **buffer)
{
if (receiver == NULL)
return DLT_RETURN_WRONG_PARAMETER;
@@ -1977,6 +1978,7 @@ DltReturnValue dlt_receiver_init_unix_socket(DltReceiver *receiver, int fd, char
receiver->totalBytesRcvd = 0;
receiver->buffersize = DLT_RECEIVE_BUFSIZE;
receiver->fd = fd;
+ receiver->type = type;
receiver->buffer = *buffer;
receiver->backup_buf = NULL;
receiver->buf = receiver->buffer;
@@ -2003,7 +2005,7 @@ DltReturnValue dlt_receiver_free(DltReceiver *receiver)
return DLT_RETURN_OK;
}
-DltReturnValue dlt_receiver_free_unix_socket(DltReceiver *receiver)
+DltReturnValue dlt_receiver_free_global_buffer(DltReceiver *receiver)
{
if (receiver == NULL)
@@ -2019,7 +2021,7 @@ DltReturnValue dlt_receiver_free_unix_socket(DltReceiver *receiver)
return DLT_RETURN_OK;
}
-int dlt_receiver_receive(DltReceiver *receiver, DltReceiverType from_src)
+int dlt_receiver_receive(DltReceiver *receiver)
{
socklen_t addrlen;
@@ -2038,19 +2040,19 @@ int dlt_receiver_receive(DltReceiver *receiver, DltReceiverType from_src)
receiver->backup_buf = NULL;
}
- if (from_src == DLT_RECEIVE_SOCKET)
+ if (receiver->type == DLT_RECEIVE_SOCKET)
/* wait for data from socket */
receiver->bytesRcvd = recv(receiver->fd,
receiver->buf + receiver->lastBytesRcvd,
receiver->buffersize - receiver->lastBytesRcvd,
0);
- else if (from_src == DLT_RECEIVE_FD)
+ else if (receiver->type == DLT_RECEIVE_FD)
/* wait for data from fd */
receiver->bytesRcvd = read(receiver->fd,
receiver->buf + receiver->lastBytesRcvd,
receiver->buffersize - receiver->lastBytesRcvd);
- else {
+ else { /* receiver->type == DLT_RECEIVE_UDP_SOCKET */
/* wait for data from UDP socket */
addrlen = sizeof(receiver->addr);
receiver->bytesRcvd = recvfrom(receiver->fd,
@@ -3834,7 +3836,7 @@ void dlt_check_envvar()
dlt_log_init(mode);
}
-#ifndef DLT_USE_UNIX_SOCKET_IPC
+#if defined DLT_DAEMON_USE_FIFO_IPC || defined DLT_LIB_USE_FIFO_IPC
char *env_pipe_dir = getenv("DLT_PIPE_DIR");
if (env_pipe_dir != NULL)
@@ -3993,42 +3995,6 @@ void dlt_hex_ascii_to_binary(const char *ptr, uint8_t *binary, int *size)
}
}
-#ifndef DLT_USE_UNIX_SOCKET_IPC
-int dlt_mkdir_recursive(const char *dir)
-{
- int ret = 0;
- char tmp[PATH_MAX + 1];
- char *p = NULL;
- char *end = NULL;
- size_t len;
-
- strncpy(tmp, dir, PATH_MAX);
- len = strlen(tmp);
-
- if (tmp[len - 1] == '/')
- tmp[len - 1] = 0;
-
- end = tmp + len;
-
- for (p = tmp + 1; ((*p) && (ret == 0)) || ((ret == -1 && errno == EEXIST) && (p != end)); p++)
- if (*p == '/') {
- *p = 0;
- ret = mkdir(tmp, S_IRWXU);
- *p = '/';
- }
-
-
-
- if ((ret == 0) || ((ret == -1) && (errno == EEXIST)))
- ret = mkdir(tmp, S_IRWXU);
-
- if ((ret == -1) && (errno == EEXIST))
- ret = 0;
-
- return ret;
-}
-#endif
-
DltReturnValue dlt_file_quick_parsing(DltFile *file, const char *filename,
int type, int verbose)
{
diff --git a/tests/gtest_dlt_daemon_offline_log.cpp b/tests/gtest_dlt_daemon_offline_log.cpp
index 0bd4d5e..be6404c 100644
--- a/tests/gtest_dlt_daemon_offline_log.cpp
+++ b/tests/gtest_dlt_daemon_offline_log.cpp
@@ -1649,7 +1649,7 @@ TEST(t_dlt_logstorage_sync_msg_cache, null)
int connectServer(void)
{
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_UNIX_SOCKET_IPC
int sockfd, portno;
struct sockaddr_in serv_addr;
struct hostent *server;
@@ -1668,7 +1668,7 @@ int connectServer(void)
close(sockfd);
return -1;
}
-#else
+#else /* DLT_DAEMON_USE_FIFO_IPC */
char filename[1024];
int sockfd;
snprintf(filename, 1024, "/tmp/dltpipes/dlt%d", getpid());
@@ -1687,7 +1687,7 @@ int connectServer(void)
int main(int argc, char **argv)
{
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_UNIX_SOCKET_IPC
pid_t cpid;
cpid = fork();
@@ -1758,7 +1758,7 @@ int main(int argc, char **argv)
::testing::FLAGS_gtest_break_on_failure = false;
/* ::testing::FLAGS_gtest_filter = "t_dlt_event_handler_register_connection*"; */
return RUN_ALL_TESTS();
-#ifdef DLT_USE_UNIX_SOCKET_IPC
+#ifdef DLT_DAEMON_USE_UNIX_SOCKET_IPC
}
#endif