Merge branch 'master' into develop
[profile/ivi/dlt-daemon.git] / src / daemon / dlt-daemon.h
1 /*\r
2  * Dlt- Diagnostic Log and Trace daemon\r
3  * @licence app begin@
4  *
5  * Copyright (C) 2011, BMW AG - Alexander Wenzel <alexander.wenzel@bmw.de>
6  * 
7  * This program is free software; you can redistribute it and/or modify it under the terms of the 
8  * GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
9  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even 
10  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General 
11  * Public License, version 2.1, for more details.
12  * 
13  * You should have received a copy of the GNU Lesser General Public License, version 2.1, along 
14  * with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
15  * 
16  * Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may 
17  * also be applicable to programs even in cases in which the program is not a library in the technical sense.
18  * 
19  * Linking DLT statically or dynamically with other modules is making a combined work based on DLT. You may 
20  * license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to 
21  * license your linked modules under the GNU Lesser General Public License, version 2.1, you 
22  * may use the program under the following exception.
23  * 
24  * As a special exception, the copyright holders of DLT give you permission to combine DLT 
25  * with software programs or libraries that are released under any license unless such a combination is not
26  * permitted by the license of such a software program or library. You may copy and distribute such a 
27  * system following the terms of the GNU Lesser General Public License, version 2.1, including this
28  * special exception, for DLT and the licenses of the other code concerned.
29  * 
30  * Note that people who make modified versions of DLT are not obligated to grant this special exception 
31  * for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, 
32  * version 2.1, gives permission to release a modified version without this exception; this exception 
33  * also makes it possible to release a modified version which carries forward this exception.
34  *
35  * @licence end@\r
36  */\r
37 \r
38 \r
39 /*******************************************************************************\r
40 **                                                                            **\r
41 **  SRC-MODULE: dlt-daemon.h                                                  **\r
42 **                                                                            **\r
43 **  TARGET    : linux                                                         **\r
44 **                                                                            **\r
45 **  PROJECT   : DLT                                                           **\r
46 **                                                                            **\r
47 **  AUTHOR    : Alexander Wenzel Alexander.AW.Wenzel@bmw.de                   **\r
48 **              Markus Klein                                                  **\r
49 **                                                                            **\r
50 **  PURPOSE   :                                                               **\r
51 **                                                                            **\r
52 **  REMARKS   :                                                               **\r
53 **                                                                            **\r
54 **  PLATFORM DEPENDANT [yes/no]: yes                                          **\r
55 **                                                                            **\r
56 **  TO BE CHANGED BY USER [yes/no]: no                                        **\r
57 **                                                                            **\r
58 *******************************************************************************/\r
59 \r
60 /*******************************************************************************\r
61 **                      Author Identity                                       **\r
62 ********************************************************************************\r
63 **                                                                            **\r
64 ** Initials     Name                       Company                            **\r
65 ** --------     -------------------------  ---------------------------------- **\r
66 **  aw          Alexander Wenzel           BMW                                **\r
67 **  mk          Markus Klein               Fraunhofer ESK                     **\r
68 *******************************************************************************/\r
69 \r
70 /*******************************************************************************\r
71 **                      Author Identity                                       **\r
72 ********************************************************************************\r
73 **                                                                            **\r
74 ** Initials     Name                       Company                            **\r
75 ** --------     -------------------------  ---------------------------------- **\r
76 **  aw          Alexander Wenzel           BMW                                **\r
77 **  mk          Markus Klein               Fraunhofer ESK                     **\r
78 *******************************************************************************/\r
79 \r
80 #ifndef DLT_DAEMON_H\r
81 #define DLT_DAEMON_H\r
82 \r
83 #include "dlt_daemon_common.h"\r
84 #include "dlt_user_shared.h"\r
85 #include "dlt_user_shared_cfg.h"\r
86 \r
87 #include <dlt_offline_trace.h>\r
88 \r
89 /**\r
90  * The flags of a dlt daemon.\r
91  */\r
92 typedef struct\r
93 {\r
94     int aflag;      /**< (Boolean) Print DLT messages; payload as ASCII */\r
95     int sflag;      /**< (Boolean) Print DLT messages; payload as hex */\r
96     int xflag;      /**< (Boolean) Print DLT messages; only headers */\r
97     int vflag;      /**< (Boolean) Verbose mode */\r
98     int dflag;      /**< (Boolean) Daemonize */\r
99     int lflag;      /**< (Boolean) Send DLT messages with serial header */\r
100     int rflag;      /**< (Boolean) Send automatic get log info response during context registration */\r
101     int mflag;      /**< (Boolean) Sync to serial header on serial connection */\r
102     int nflag;      /**< (Boolean) Sync to serial header on all TCP connections */\r
103     char evalue[256];   /**< (String: ECU ID) Set ECU ID (Default: ECU1) */\r
104     char bvalue[256];   /**< (String: Baudrate) Serial device baudrate (Default: 115200) */\r
105     char yvalue[256];   /**< (String: Devicename) Additional support for serial device */\r
106     char ivalue[256];   /**< (String: Directory) Directory where to store the persistant configuration (Default: /tmp) */\r
107     char cvalue[256];   /**< (String: Directory) Filename of DLT configuration file (Default: /etc/dlt.conf) */\r
108     int  sharedMemorySize;         /**< (int) Size of shared memory (Default: 100000) */\r
109     int  sendMessageTime;          /**< (Boolean) Send periodic Message Time if client is connected (Default: 0) */\r
110     char offlineTraceDirectory[256]; /**< (String: Directory) Store DLT messages to local directory (Default: /etc/dlt.conf) */\r
111     int  offlineTraceFileSize;  /**< (int) Maximum size in bytes of one trace file (Default: 1000000) */\r
112     int  offlineTraceMaxSize;   /**< (int) Maximum size of all trace files (Default: 4000000) */\r
113 } DltDaemonFlags;\r
114 \r
115 /**\r
116  * The global parameters of a dlt daemon.\r
117  */\r
118 typedef struct\r
119 {\r
120     DltDaemonFlags flags;     /**< flags of the daemon */\r
121     int fp;               /**< handle for own fifo */\r
122     int sock;             /**< handle for tcp connection to client */\r
123     int fdserial;         /**< handle for serial connection */\r
124     int fdmax;            /**< highest number of used handles */\r
125     fd_set master;            /**< master set of handles */\r
126     fd_set read_fds;          /**< read set of handles */\r
127     DltFile file;             /**< struct for file access */\r
128     //int ohandle;          /**< handle to output file */\r
129     DltMessage msg;           /**< one dlt message */\r
130     DltReceiver receiver;     /**< receiver for fifo connection */\r
131     DltReceiver receiverSock; /**< receiver for socket connection */\r
132     DltReceiver receiverSerial; /**< receiver for serial connection */\r
133     int client_connections;    /**< counter for nr. of client connections */\r
134     size_t baudrate;          /**< Baudrate of serial connection */\r
135     DltShm dlt_shm;                             /**< Shared memory handling */\r
136     DltOfflineTrace offlineTrace; /**< Offline trace handling */\r
137 } DltDaemonLocal;\r
138 \r
139 typedef struct\r
140 {\r
141     int timer_fd;\r
142     unsigned long long wakeups_missed;\r
143 } DltDaemonPeriodicData;\r
144 \r
145 typedef struct\r
146 {\r
147     DltDaemon *daemon;\r
148     DltDaemonLocal *daemon_local;\r
149 } DltDaemonTimingPacketThreadData;\r
150 \r
151 /* Function prototypes */\r
152 void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
153 int dlt_daemon_local_init_p1(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
154 int dlt_daemon_local_init_p2(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
155 int dlt_daemon_local_connection_init(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
156 \r
157 void dlt_daemon_daemonize(int verbose);\r
158 void dlt_daemon_signal_handler(int sig);\r
159 \r
160 int dlt_daemon_process_client_connect(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
161 int dlt_daemon_process_client_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
162 int dlt_daemon_process_client_messages_serial(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
163 int dlt_daemon_process_user_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
164 \r
165 int dlt_daemon_process_user_message_overflow(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
166 int dlt_daemon_process_user_message_register_application(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
167 int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
168 int dlt_daemon_process_user_message_register_context(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
169 int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
170 int dlt_daemon_process_user_message_log(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
171 int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
172 int dlt_daemon_process_user_message_log_mode(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
173 \r
174 void dlt_daemon_timingpacket_thread(void *ptr);\r
175 int dlt_daemon_make_periodic (unsigned int period, DltDaemonPeriodicData *info, int verbose);\r
176 void dlt_daemon_wait_period(DltDaemonPeriodicData *info, int verbose);\r
177 \r
178 #endif /* DLT_DAEMON_H */\r
179 \r