automotive-dlt
dlt-daemon.h
Go to the documentation of this file.
1 /*
2  * @licence app begin@
3  * SPDX license identifier: MPL-2.0
4  *
5  * Copyright (C) 2011-2015, BMW AG
6  *
7  * This file is part of GENIVI Project DLT - Diagnostic Log and Trace.
8  *
9  * This Source Code Form is subject to the terms of the
10  * Mozilla Public License (MPL), v. 2.0.
11  * If a copy of the MPL was not distributed with this file,
12  * You can obtain one at http://mozilla.org/MPL/2.0/.
13  *
14  * For further information see http://www.genivi.org/.
15  * @licence end@
16  */
17 
28 /*******************************************************************************
29 ** **
30 ** SRC-MODULE: dlt-daemon.h **
31 ** **
32 ** TARGET : linux **
33 ** **
34 ** PROJECT : DLT **
35 ** **
36 ** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de **
37 ** Markus Klein **
38 ** **
39 ** PURPOSE : **
40 ** **
41 ** REMARKS : **
42 ** **
43 ** PLATFORM DEPENDANT [yes/no]: yes **
44 ** **
45 ** TO BE CHANGED BY USER [yes/no]: no **
46 ** **
47 *******************************************************************************/
48 
49 /*******************************************************************************
50 ** Author Identity **
51 ********************************************************************************
52 ** **
53 ** Initials Name Company **
54 ** -------- ------------------------- ---------------------------------- **
55 ** aw Alexander Wenzel BMW **
56 ** mk Markus Klein Fraunhofer ESK **
57 *******************************************************************************/
58 
59 /*******************************************************************************
60 ** Author Identity **
61 ********************************************************************************
62 ** **
63 ** Initials Name Company **
64 ** -------- ------------------------- ---------------------------------- **
65 ** aw Alexander Wenzel BMW **
66 ** mk Markus Klein Fraunhofer ESK **
67 *******************************************************************************/
68 
69 #ifndef DLT_DAEMON_H
70 #define DLT_DAEMON_H
71 
72 #include <limits.h> /* for NAME_MAX */
73 
74 #include "dlt_daemon_common.h"
75 #include "dlt_user_shared.h"
76 #include "dlt_user_shared_cfg.h"
78 #include "dlt_gateway_types.h"
79 #include <dlt_offline_trace.h>
80 #include <sys/time.h>
81 
82 #define DLT_DAEMON_FLAG_MAX 256
83 
87 typedef struct
88 {
89  int aflag;
90  int sflag;
91  int xflag;
92  int vflag;
93  int dflag;
94  int lflag;
95  int rflag;
96  int mflag;
97  int nflag;
98  char evalue[NAME_MAX + 1];
99  char bvalue[NAME_MAX + 1];
100  char yvalue[NAME_MAX + 1];
101  char ivalue[NAME_MAX + 1];
102  char cvalue[NAME_MAX + 1];
105  char offlineTraceDirectory[DLT_DAEMON_FLAG_MAX];
111  char loggingFilename[DLT_DAEMON_FLAG_MAX];
113  char pathToECUSoftwareVersion[DLT_DAEMON_FLAG_MAX];
116  char offlineLogstorageDirPath[DLT_MOUNT_PATH_MAX];
122  char userPipesDir[NAME_MAX + 1];
123  char daemonFifoName[NAME_MAX + 1];
124  unsigned int port;
125  char ctrlSockPath[DLT_DAEMON_FLAG_MAX];
127  char gatewayConfigFile[DLT_DAEMON_FLAG_MAX];
136 typedef struct
137 {
144  size_t baudrate;
145 #ifdef DLT_SHM_ENABLE
146  DltShm dlt_shm;
147 #endif
150  unsigned long RingbufferMinSize;
151  unsigned long RingbufferMaxSize;
152  unsigned long RingbufferStepSize;
153  unsigned long daemonFifoSize;
155 
156 typedef struct
157 {
158  int timer_fd;
159  unsigned long long wakeups_missed;
161 
162 typedef struct
163 {
167 
169 
170 #define DLT_DAEMON_ERROR_OK 0
171 #define DLT_DAEMON_ERROR_UNKNOWN -1
172 #define DLT_DAEMON_ERROR_BUFFER_FULL -2
173 #define DLT_DAEMON_ERROR_SEND_FAILED -3
174 #define DLT_DAEMON_ERROR_WRITE_FAILED -4
175 
176 /* Function prototypes */
177 void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
178 int dlt_daemon_local_init_p1(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
179 int dlt_daemon_local_init_p2(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
180 int dlt_daemon_local_connection_init(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
181 int dlt_daemon_local_ecu_version_init(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
182 
183 void dlt_daemon_daemonize(int verbose);
184 void dlt_daemon_signal_handler(int sig);
185 int dlt_daemon_process_client_connect(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
186 int dlt_daemon_process_client_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *revc, int verbose);
187 int dlt_daemon_process_client_messages_serial(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
188 int dlt_daemon_process_user_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
189 int dlt_daemon_process_one_s_timer(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
190 int dlt_daemon_process_sixty_s_timer(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
191 int dlt_daemon_process_systemd_timer(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
192 
193 int dlt_daemon_process_control_connect(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
194 int dlt_daemon_process_control_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose);
195 
196 typedef int (*dlt_daemon_process_user_message_func)(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
197 
198 int dlt_daemon_process_user_message_overflow(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
199 int dlt_daemon_send_message_overflow(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
202 int dlt_daemon_process_user_message_register_context(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
203 int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
204 int dlt_daemon_process_user_message_log(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
205 #ifdef DLT_SHM_ENABLE
206 int dlt_daemon_process_user_message_log_shm(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
207 #endif
208 int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
209 int dlt_daemon_process_user_message_marker(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose);
210 
211 int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
212 void dlt_daemon_timingpacket_thread(void *ptr);
213 void dlt_daemon_ecu_version_thread(void *ptr);
214 #if defined(DLT_SYSTEMD_WATCHDOG_ENABLE)
215  void dlt_daemon_systemd_watchdog_thread(void *ptr);
216 #endif
217 
218 int create_timer_fd(DltDaemonLocal *daemon_local, int period_sec, int starts_in, DltTimers timer);
219 
220 int dlt_daemon_close_socket(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
221 
222 #endif /* DLT_DAEMON_H */
223 
int create_timer_fd(DltDaemonLocal *daemon_local, int period_sec, int starts_in, DltTimers timer)
Definition: dlt-daemon.c:3142
int dlt_daemon_process_user_message_overflow(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose)
Definition: dlt-daemon.c:2035
int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose)
Definition: dlt-daemon.c:2436
int dlt_daemon_process_user_message_log(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose)
Definition: dlt-daemon.c:2618
int dlt_daemon_local_ecu_version_init(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
Definition: dlt-daemon.c:1128
unsigned long RingbufferMaxSize
Definition: dlt-daemon.h:151
#define DLT_DAEMON_FLAG_MAX
Definition: dlt-daemon.h:82
int client_connections
Definition: dlt-daemon.h:143
int dlt_daemon_process_control_connect(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose)
Definition: dlt-daemon.c:1761
DltDaemonLocal * daemon_local
Definition: dlt-daemon.h:165
int sharedMemorySize
Definition: dlt-daemon.h:103
int dlt_daemon_process_one_s_timer(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose)
int contextTraceStatus
Definition: dlt-daemon.h:130
int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose)
Definition: dlt-daemon.c:2537
DltDaemonTimingPacketThreadData DltDaemonECUVersionThreadData
Definition: dlt-daemon.h:168
unsigned int port
Definition: dlt-daemon.h:124
size_t baudrate
Definition: dlt-daemon.h:144
int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
Definition: dlt-daemon.c:3061
unsigned long daemonFifoSize
Definition: dlt-daemon.h:153
Definition: dlt_shm.h:78
unsigned int offlineLogstorageMaxCounterIdx
Definition: dlt-daemon.h:120
char offlineLogstorageDelimiter
Definition: dlt-daemon.h:118
int dlt_daemon_process_sixty_s_timer(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose)
DltFile file
Definition: dlt-daemon.h:139
int dlt_daemon_process_client_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *revc, int verbose)
Definition: dlt-daemon.c:1593
int dlt_daemon_process_user_message_marker(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose)
Definition: dlt-daemon.c:3027
int sendECUSoftwareVersion
Definition: dlt-daemon.h:112
int dlt_daemon_local_init_p2(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
Definition: dlt-daemon.c:823
int dlt_daemon_send_message_overflow(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
Definition: dlt-daemon.c:2083
DltDaemonFlags flags
Definition: dlt-daemon.h:138
void dlt_daemon_signal_handler(int sig)
Definition: dlt-daemon.c:1252
DltEventHandler pEvent
Definition: dlt-daemon.h:140
DltOfflineTrace offlineTrace
Definition: dlt-daemon.h:148
#define DLT_MOUNT_PATH_MAX
Definition: dlt_common.h:332
unsigned long long wakeups_missed
Definition: dlt-daemon.h:159
int dlt_daemon_close_socket(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
Definition: dlt-daemon.c:3222
unsigned long RingbufferStepSize
Definition: dlt-daemon.h:152
void dlt_daemon_ecu_version_thread(void *ptr)
int dlt_daemon_process_systemd_timer(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose)
int(* dlt_daemon_process_user_message_func)(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose)
Definition: dlt-daemon.h:196
int dlt_daemon_process_user_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose)
Definition: dlt-daemon.c:1948
int dlt_daemon_process_client_messages_serial(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose)
Definition: dlt-daemon.c:1681
int offlineLogstorageTimestamp
Definition: dlt-daemon.h:117
int enforceContextLLAndTS
Definition: dlt-daemon.h:131
int offlineTraceFileSize
Definition: dlt-daemon.h:106
int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose)
Definition: dlt-daemon.c:2916
int offlineTraceMaxSize
Definition: dlt-daemon.h:107
int dlt_daemon_process_control_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose)
Definition: dlt-daemon.c:1817
int autoResponseGetLogInfoOption
Definition: dlt-daemon.h:128
DltGateway pGateway
Definition: dlt-daemon.h:141
int offlineLogstorageMaxDevices
Definition: dlt-daemon.h:115
int dlt_daemon_process_user_message_register_application(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose)
Definition: dlt-daemon.c:2103
int offlineTraceFilenameTimestampBased
Definition: dlt-daemon.h:108
int dlt_daemon_process_user_message_register_context(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *rec, int verbose)
Definition: dlt-daemon.c:2213
unsigned int offlineLogstorageMaxCounter
Definition: dlt-daemon.h:119
unsigned int offlineLogstorageCacheSize
Definition: dlt-daemon.h:121
int dlt_daemon_process_client_connect(DltDaemon *daemon, DltDaemonLocal *daemon_local, DltReceiver *recv, int verbose)
Definition: dlt-daemon.c:1477
void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
Definition: dlt-daemon.c:1200
void dlt_daemon_daemonize(int verbose)
Definition: dlt-daemon.c:1288
int dlt_daemon_local_init_p1(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
Definition: dlt-daemon.c:748
DltMessage msg
Definition: dlt-daemon.h:142
int dlt_daemon_local_connection_init(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose)
Definition: dlt-daemon.c:1067
void dlt_daemon_timingpacket_thread(void *ptr)
unsigned long RingbufferMinSize
Definition: dlt-daemon.h:150