automotive-dlt
dlt-system.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 
27 /*******************************************************************************
28 ** **
29 ** SRC-MODULE: dlt-system.h **
30 ** **
31 ** TARGET : linux **
32 ** **
33 ** PROJECT : DLT **
34 ** **
35 ** AUTHOR : Lassi Marttala <lassi.lm.marttala@partner.bmw.de> **
36 ** **
37 ** PURPOSE : **
38 ** **
39 ** REMARKS : **
40 ** **
41 ** PLATFORM DEPENDANT [yes/no]: yes **
42 ** **
43 ** TO BE CHANGED BY USER [yes/no]: no **
44 ** **
45 *******************************************************************************/
46 
47 /*******************************************************************************
48 ** Author Identity **
49 ********************************************************************************
50 ** **
51 ** Initials Name Company **
52 ** -------- ------------------------- ---------------------------------- **
53 ** lm Lassi Marttala BMW **
54 *******************************************************************************/
55 
56 #ifndef DLT_SYSTEM_H_
57 #define DLT_SYSTEM_H_
58 
59 // DLT related includes.
60 #include "dlt.h"
61 #include "dlt_common.h"
62 
63 // Constants
64 #define DEFAULT_CONF_FILE ( CONFIGURATION_FILES_DIR "/dlt-system.conf")
65 #define DLT_SYSTEM_LOG_FILE_MAX 32
66 #define DLT_SYSTEM_LOG_DIRS_MAX 32
67 #define DLT_SYSTEM_LOG_PROCESSES_MAX 32
68 
69 #define DLT_SYSTEM_MODE_OFF 0
70 #define DLT_SYSTEM_MODE_STARTUP 1
71 #define DLT_SYSTEM_MODE_REGULAR 2
72 
73 #define MAX_LINE 1024
74 
75 #define MAX_THREADS 8
76 
77 // Macros
78 #define MALLOC_ASSERT(x) if(x == NULL) {\
79  fprintf(stderr, "Out of memory\n");\
80  abort();}
81 
87 // Command line options
88 typedef struct {
90  int Daemonize;
92 
93 // Configuration shell options
94 typedef struct {
95  int Enable;
96 } ShellOptions;
97 
98 // Configuration syslog options
99 typedef struct {
100  int Enable;
101  char *ContextId;
102  int Port;
103 } SyslogOptions;
104 
105 // Configuration journal options
106 typedef struct {
107  int Enable;
108  char *ContextId;
110  int Follow;
113 
114 typedef struct {
115  int Enable;
116  char *ContextId;
120  char *TempDir;
121 
122  // Variable number of file transfer dirs
123  int Count;
124  int Compression[DLT_SYSTEM_LOG_DIRS_MAX];
125  int CompressionLevel[DLT_SYSTEM_LOG_DIRS_MAX];
126  char *Directory[DLT_SYSTEM_LOG_DIRS_MAX];
128 
129 typedef struct {
130  int Enable;
131 
132  // Variable number of files to transfer
133  int Count;
134  char *ContextId[DLT_SYSTEM_LOG_FILE_MAX];
135  char *Filename[DLT_SYSTEM_LOG_FILE_MAX];
137  int TimeDelay[DLT_SYSTEM_LOG_FILE_MAX];
139 
140 typedef struct {
141  int Enable;
142  char *ContextId;
143 
144  // Variable number of processes
145  int Count;
151 
152 typedef struct {
161 
162 typedef struct {
163  pthread_t threads[MAX_THREADS];
164  int count;
165  int shutdown;
167 
172 // In dlt-system-options.c
173 int read_command_line(DltSystemCliOptions *options, int argc, char *argv[]);
175 
176 // In dlt-process-handling.c
177 int daemonize();
179 void join_threads();
180 void dlt_system_signal_handler(int sig);
182 
183 // Thread initiators:
184 void init_shell();
185 void start_syslog();
189 
190 #if defined(DLT_SYSTEMD_WATCHDOG_ENABLE)
191 void start_systemd_watchdog(DltSystemConfiguration *conf);
192 #endif
193 
194 #if defined(DLT_SYSTEMD_JOURNAL_ENABLE)
195 void start_systemd_journal(DltSystemConfiguration *conf);
196 #endif
197 
198 #endif /* DLT_SYSTEM_H_ */
void join_threads()
int daemonize()
DltKpiConfig config
Definition: dlt-kpi.c:37
void start_filetransfer(DltSystemConfiguration *conf)
SyslogOptions Syslog
Definition: dlt-system.h:155
#define DLT_SYSTEM_LOG_PROCESSES_MAX
Definition: dlt-system.h:67
char * ContextId
Definition: dlt-system.h:108
void start_logfile(DltSystemConfiguration *conf)
#define DLT_SYSTEM_LOG_DIRS_MAX
Definition: dlt-system.h:66
int read_configuration_file(DltSystemConfiguration *config, char *file_name)
ShellOptions Shell
Definition: dlt-system.h:154
FiletransferOptions Filetransfer
Definition: dlt-system.h:157
#define MAX_THREADS
Definition: dlt-system.h:75
LogFileOptions LogFile
Definition: dlt-system.h:158
JournalOptions Journal
Definition: dlt-system.h:156
void start_syslog()
void register_with_dlt(DltSystemConfiguration *config)
char * ContextId
Definition: dlt-system.h:101
void init_shell()
DltSystemThreads threads
void start_threads(DltSystemConfiguration *config)
void start_logprocess(DltSystemConfiguration *conf)
char * ConfigurationFileName
Definition: dlt-system.h:89
int read_command_line(DltSystemCliOptions *options, int argc, char *argv[])
LogProcessOptions LogProcesses
Definition: dlt-system.h:159
void dlt_system_signal_handler(int sig)
#define DLT_SYSTEM_LOG_FILE_MAX
Definition: dlt-system.h:65