blob: f949aeab16d5882e0e74f29839462a5bf3185365 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
/**
* @licence app begin@
* Copyright (C) 2012 BMW AG
*
* This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps.
*
* Contributions are licensed to the GENIVI Alliance under one or more
* Contribution License Agreements.
*
* \copyright
* This Source Code Form is subject to the terms of the
* Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
* this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*
* \author Lassi Marttala <lassi.lm.marttala@partner.bmw.de> BMW 2012
*
* \file dlt-system.c
* For further information see http://www.genivi.org/.
* @licence end@
*/
/*******************************************************************************
** **
** SRC-MODULE: dlt-system.h **
** **
** TARGET : linux **
** **
** PROJECT : DLT **
** **
** AUTHOR : Lassi Marttala <lassi.lm.marttala@partner.bmw.de> **
** **
** PURPOSE : **
** **
** REMARKS : **
** **
** PLATFORM DEPENDANT [yes/no]: yes **
** **
** TO BE CHANGED BY USER [yes/no]: no **
** **
*******************************************************************************/
/*******************************************************************************
** Author Identity **
********************************************************************************
** **
** Initials Name Company **
** -------- ------------------------- ---------------------------------- **
** lm Lassi Marttala BMW **
*******************************************************************************/
#ifndef DLT_SYSTEM_H_
#define DLT_SYSTEM_H_
// DLT related includes.
#include "dlt.h"
#include "dlt_common.h"
// Constants
#define DEFAULT_CONF_FILE "/etc/dlt-system.conf"
#define DLT_SYSTEM_LOG_FILE_MAX 32
#define DLT_SYSTEM_LOG_DIRS_MAX 32
#define DLT_SYSTEM_LOG_PROCESSES_MAX 32
#define DLT_SYSTEM_MODE_OFF 0
#define DLT_SYSTEM_MODE_STARTUP 1
#define DLT_SYSTEM_MODE_REGULAR 2
#define MAX_LINE 1024
#define MAX_THREADS 8
// Macros
#define MALLOC_ASSERT(x) if(x == NULL) {\
fprintf(stderr, "Out of memory\n");\
abort();}
/**
* Configuration structures.
* Please see dlt-system.conf for explanation of all the options.
*/
// Command line options
typedef struct {
char *ConfigurationFileName;
int Daemonize;
} DltSystemCliOptions;
// Configuration file options
typedef struct {
int Enable;
char *ContextId;
int Port;
} SyslogOptions;
typedef struct {
int Enable;
char *ContextId;
int TimeStartup;
int TimeDelay;
int TimeoutBetweenLogs;
char *TempDir;
// Variable number of file transfer dirs
int Count;
int Compression[DLT_SYSTEM_LOG_DIRS_MAX];
int CompressionLevel[DLT_SYSTEM_LOG_DIRS_MAX];
char *Directory[DLT_SYSTEM_LOG_DIRS_MAX];
} FiletransferOptions;
typedef struct {
int Enable;
// Variable number of files to transfer
int Count;
char *ContextId[DLT_SYSTEM_LOG_FILE_MAX];
char *Filename[DLT_SYSTEM_LOG_FILE_MAX];
int Mode[DLT_SYSTEM_LOG_FILE_MAX];
int TimeDelay[DLT_SYSTEM_LOG_FILE_MAX];
} LogFileOptions;
typedef struct {
int Enable;
char *ContextId;
// Variable number of processes
int Count;
char *Name[DLT_SYSTEM_LOG_PROCESSES_MAX];
char *Filename[DLT_SYSTEM_LOG_PROCESSES_MAX];
int Mode[DLT_SYSTEM_LOG_PROCESSES_MAX];
int TimeDelay[DLT_SYSTEM_LOG_PROCESSES_MAX];
} LogProcessOptions;
typedef struct {
char *ApplicationId;
SyslogOptions Syslog;
FiletransferOptions Filetransfer;
LogFileOptions LogFile;
LogProcessOptions LogProcesses;
} DltSystemConfiguration;
typedef struct {
pthread_t threads[MAX_THREADS];
int count;
int shutdown;
} DltSystemThreads;
/**
* Forward declarations for the whole application
*/
// In dlt-system-options.c
int read_command_line(DltSystemCliOptions *options, int argc, char *argv[]);
int read_configuration_file(DltSystemConfiguration *config, char *file_name);
// In dlt-process-handling.c
int daemonize();
void start_threads(DltSystemConfiguration *config);
void join_threads();
void dlt_system_signal_handler(int sig);
void register_with_dlt(DltSystemConfiguration *config);
// Thread initiators:
void init_shell();
void start_syslog();
void start_filetransfer(DltSystemConfiguration *conf);
void start_logfile(DltSystemConfiguration *conf);
void start_logprocess(DltSystemConfiguration *conf);
#if defined(DLT_SYSTEMD_WATCHDOG_ENABLE)
void start_systemd_watchdog(DltSystemConfiguration *conf);
#endif
#endif /* DLT_SYSTEM_H_ */
|