diff options
Diffstat (limited to 'src/daemon')
-rw-r--r-- | src/daemon/dlt_daemon_common_cfg.h | 2 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_event_handler.h | 6 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_event_handler_types.h | 6 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_offline_logstorage.h | 8 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_serial.c | 27 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_serial.h | 7 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_socket.c | 62 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_socket.h | 7 |
8 files changed, 81 insertions, 44 deletions
diff --git a/src/daemon/dlt_daemon_common_cfg.h b/src/daemon/dlt_daemon_common_cfg.h index 8fbd9b0..77c6ca6 100644 --- a/src/daemon/dlt_daemon_common_cfg.h +++ b/src/daemon/dlt_daemon_common_cfg.h @@ -87,7 +87,7 @@ "/dlt-ctrl.sock" #ifdef DLT_DAEMON_USE_UNIX_SOCKET_IPC -# define DLT_DAEMON_DEFAULT_APP_SOCK_PATH DLT_RUNTIME_DEFAULT_DIRECTORY \ +#define DLT_DAEMON_DEFAULT_APP_SOCK_PATH DLT_RUNTIME_DEFAULT_DIRECTORY \ "/dlt-app.sock" #endif diff --git a/src/daemon/dlt_daemon_event_handler.h b/src/daemon/dlt_daemon_event_handler.h index bd550d3..62ef89b 100644 --- a/src/daemon/dlt_daemon_event_handler.h +++ b/src/daemon/dlt_daemon_event_handler.h @@ -32,7 +32,7 @@ #include "dlt-daemon.h" #ifndef DLT_DAEMON_EVENT_HANDLER_H -# define DLT_DAEMON_EVENT_HANDLER_H +#define DLT_DAEMON_EVENT_HANDLER_H int dlt_daemon_prepare_event_handling(DltEventHandler *); int dlt_daemon_handle_event(DltEventHandler *, DltDaemon *, DltDaemonLocal *); @@ -56,11 +56,11 @@ int dlt_event_handler_unregister_connection(DltEventHandler *, 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); void dlt_daemon_add_connection(DltEventHandler *ev, DltConnection *connection); -# endif +#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 0b16d08..a879d4d 100644 --- a/src/daemon/dlt_daemon_event_handler_types.h +++ b/src/daemon/dlt_daemon_event_handler_types.h @@ -30,7 +30,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 @@ -41,9 +41,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.h b/src/daemon/dlt_daemon_offline_logstorage.h index 956b09d..cd7803d 100644 --- a/src/daemon/dlt_daemon_offline_logstorage.h +++ b/src/daemon/dlt_daemon_offline_logstorage.h @@ -59,10 +59,10 @@ #define DLT_DAEMON_LOGSTORAGE_RESET_SEND_LOGLEVEL 0 typedef enum { - DLT_DAEMON_LOGSTORAGE_CMP_MIN = 0, - DLT_DAEMON_LOGSTORAGE_CMP_APID = 1, - DLT_DAEMON_LOGSTORAGE_CMP_CTID = 2, - DLT_DAEMON_LOGSTORAGE_CMP_ECID = 3, + DLT_DAEMON_LOGSTORAGE_CMP_MIN = 0, + DLT_DAEMON_LOGSTORAGE_CMP_APID = 1, + DLT_DAEMON_LOGSTORAGE_CMP_CTID = 2, + DLT_DAEMON_LOGSTORAGE_CMP_ECID = 3, DLT_DAEMON_LOGSTORAGE_CMP_MAX, } DltCompareFlags; diff --git a/src/daemon/dlt_daemon_serial.c b/src/daemon/dlt_daemon_serial.c index 36b7990..272a3dc 100644 --- a/src/daemon/dlt_daemon_serial.c +++ b/src/daemon/dlt_daemon_serial.c @@ -66,24 +66,33 @@ #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 (serialheader) { + 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)) + 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 fe49bff..08fdfac 100644 --- a/src/daemon/dlt_daemon_serial.h +++ b/src/daemon/dlt_daemon_serial.h @@ -60,6 +60,11 @@ #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 9db48b9..803b821 100644 --- a/src/daemon/dlt_daemon_socket.c +++ b/src/daemon/dlt_daemon_socket.c @@ -41,11 +41,11 @@ #include <sys/ioctl.h> #ifdef linux -# include <sys/timerfd.h> +#include <sys/timerfd.h> #endif #include <sys/time.h> #if defined(linux) && defined(__NR_statx) -# include <linux/stat.h> +#include <linux/stat.h> #endif #include "dlt_types.h" @@ -66,7 +66,8 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort, char *ip) /* create socket */ if ((*sock = socket(AF_INET6, SOCK_STREAM, 0)) == -1) { lastErrno = errno; - dlt_vlog(LOG_ERR, "dlt_daemon_socket_open: socket() error %d: %s\n", lastErrno, strerror(lastErrno)); + dlt_vlog(LOG_ERR, "dlt_daemon_socket_open: socket() error %d: %s\n", lastErrno, + strerror(lastErrno)); return -1; } @@ -74,7 +75,8 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort, char *ip) if ((*sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { lastErrno = errno; - dlt_vlog(LOG_ERR, "dlt_daemon_socket_open: socket() error %d: %s\n", lastErrno, strerror(lastErrno)); + dlt_vlog(LOG_ERR, "dlt_daemon_socket_open: socket() error %d: %s\n", lastErrno, + strerror(lastErrno)); return -1; } @@ -85,10 +87,11 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort, char *ip) /* setsockpt SO_REUSEADDR */ if (setsockopt(*sock, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) { lastErrno = errno; - dlt_vlog(LOG_ERR, - "dlt_daemon_socket_open: Setsockopt error %d in dlt_daemon_local_connection_init: %s\n", - lastErrno, - strerror(lastErrno)); + dlt_vlog( + LOG_ERR, + "dlt_daemon_socket_open: Setsockopt error %d in dlt_daemon_local_connection_init: %s\n", + lastErrno, + strerror(lastErrno)); return -1; } @@ -98,10 +101,13 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort, char *ip) memset(&forced_addr, 0, sizeof(forced_addr)); forced_addr.sin6_family = AF_INET6; forced_addr.sin6_port = htons(servPort); - if (0 == strcmp(ip, "0.0.0.0")) + + if (0 == strcmp(ip, "0.0.0.0")) { forced_addr.sin6_addr = in6addr_any; - else + } else { ret_inet_pton = inet_pton(AF_INET6, ip, &forced_addr.sin6_addr); + } + #else struct sockaddr_in forced_addr; memset(&forced_addr, 0, sizeof(forced_addr)); @@ -113,18 +119,20 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort, char *ip) /* inet_pton returns 1 on success */ if (ret_inet_pton != 1) { lastErrno = errno; - dlt_vlog(LOG_WARNING, - "dlt_daemon_socket_open: inet_pton() error %d: %s. Cannot convert IP address: %s\n", - lastErrno, - strerror(lastErrno), - ip); + dlt_vlog( + LOG_WARNING, + "dlt_daemon_socket_open: inet_pton() error %d: %s. Cannot convert IP address: %s\n", + lastErrno, + strerror(lastErrno), + ip); return -1; } if (bind(*sock, (struct sockaddr *)&forced_addr, sizeof(forced_addr)) == -1) { 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)); + dlt_vlog(LOG_WARNING, "dlt_daemon_socket_open: bind() error %d: %s\n", lastErrno, + strerror(lastErrno)); return -1; } @@ -137,7 +145,9 @@ int dlt_daemon_socket_open(int *sock, unsigned int servPort, char *ip) if (listen(*sock, 3) < 0) { lastErrno = errno; - dlt_vlog(LOG_WARNING, "dlt_daemon_socket_open: listen() failed with error %d: %s\n", lastErrno, + dlt_vlog(LOG_WARNING, + "dlt_daemon_socket_open: listen() failed with error %d: %s\n", + lastErrno, strerror(lastErrno)); return -1; } @@ -152,7 +162,12 @@ 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; @@ -162,20 +177,23 @@ int dlt_daemon_socket_send(int sock, void *data1, int size1, void *data2, int si (void *)dltSerialHeader, sizeof(dltSerialHeader)); - if (ret != DLT_RETURN_OK) + if (ret != DLT_RETURN_OK) { return ret; + } } /* Send data */ if ((data1 != NULL) && (size1 > 0)) { ret = dlt_daemon_socket_sendreliable(sock, data1, size1); - if (ret != DLT_RETURN_OK) + if (ret != DLT_RETURN_OK) { return ret; + } } - if ((data2 != NULL) && (size2 > 0)) + if ((data2 != NULL) && (size2 > 0)) { ret = dlt_daemon_socket_sendreliable(sock, data2, size2); + } return ret; } @@ -195,7 +213,7 @@ int dlt_daemon_socket_sendreliable(int sock, void *data_buffer, int message_size while (data_sent < message_size) { ssize_t ret = send(sock, - (uint8_t*)data_buffer + data_sent, + (uint8_t *)data_buffer + data_sent, message_size - data_sent, 0); diff --git a/src/daemon/dlt_daemon_socket.h b/src/daemon/dlt_daemon_socket.h index a180529..c2cced6 100644 --- a/src/daemon/dlt_daemon_socket.h +++ b/src/daemon/dlt_daemon_socket.h @@ -65,7 +65,12 @@ 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 |