Init of dlt daemon
[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 /**\r
88  * The flags of a dlt daemon.\r
89  */\r
90 typedef struct\r
91 {\r
92     int aflag;      /**< (Boolean) Print DLT messages; payload as ASCII */\r
93     int sflag;      /**< (Boolean) Print DLT messages; payload as hex */\r
94     int xflag;      /**< (Boolean) Print DLT messages; only headers */\r
95     int vflag;      /**< (Boolean) Verbose mode */\r
96     int dflag;      /**< (Boolean) Daemonize */\r
97     int lflag;      /**< (Boolean) Send DLT messages with serial header */\r
98     int rflag;      /**< (Boolean) Send automatic get log info response during context registration */\r
99     int mflag;      /**< (Boolean) Sync to serial header on serial connection */\r
100     int nflag;      /**< (Boolean) Sync to serial header on all TCP connections */\r
101     char *ovalue;   /**< (String: Filename) Store DLT messages to local log file */\r
102     char *fvalue;   /**< (String: Filename) Enable filtering of messages */\r
103     char *evalue;   /**< (String: ECU ID) Set ECU ID (Default: ECU1) */\r
104     char *bvalue;   /**< (String: Baudrate) Serial device baudrate (Default: 115200) */\r
105     char *yvalue;   /**< (String: Devicename) Additional support for serial device */\r
106     char *uvalue;   /**< (String: Ringbuffer) Size of the ringbuffer in bytes (Default: 10024) */\r
107 } DltDaemonFlags;\r
108 \r
109 /**\r
110  * The global parameters of a dlt daemon.\r
111  */\r
112 typedef struct\r
113 {\r
114     DltDaemonFlags flags;     /**< flags of the daemon */\r
115     int fp;               /**< handle for own fifo */\r
116     int sock;             /**< handle for tcp connection to client */\r
117     int fdserial;         /**< handle for serial connection */\r
118     int fdmax;            /**< highest number of used handles */\r
119     fd_set master;            /**< master set of handles */\r
120     fd_set read_fds;          /**< read set of handles */\r
121     DltFile file;             /**< struct for file access */\r
122     DltFilter filter;         /**< struct for filter access */\r
123     int ohandle;          /**< handle to output file */\r
124     DltMessage msg;           /**< one dlt message */\r
125     DltReceiver receiver;     /**< receiver for fifo connection */\r
126     DltReceiver receiverSock; /**< receiver for socket connection */\r
127     DltReceiver receiverSerial; /**< receiver for serial connection */\r
128     int client_connections;    /**< counter for nr. of client connections */\r
129     size_t baudrate;          /**< Baudrate of serial connection */\r
130     size_t ringbufferSize;    /**< Size of the ringbuffer */\r
131 } DltDaemonLocal;\r
132 \r
133 typedef struct\r
134 {\r
135     int timer_fd;\r
136     unsigned long long wakeups_missed;\r
137 } DltDaemonPeriodicData;\r
138 \r
139 typedef struct\r
140 {\r
141     DltDaemon *daemon;\r
142     DltDaemonLocal *daemon_local;\r
143 } DltDaemonTimingPacketThreadData;\r
144 \r
145 /* Function prototypes */\r
146 void dlt_daemon_local_cleanup(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
147 int dlt_daemon_local_init_p1(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
148 int dlt_daemon_local_init_p2(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
149 int dlt_daemon_local_connection_init(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
150 \r
151 void dlt_daemon_daemonize(int verbose);\r
152 void dlt_daemon_signal_handler(int sig);\r
153 \r
154 int dlt_daemon_process_client_connect(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
155 int dlt_daemon_process_client_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
156 int dlt_daemon_process_client_messages_serial(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
157 int dlt_daemon_process_user_messages(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
158 \r
159 int dlt_daemon_process_user_message_overflow(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
160 int dlt_daemon_process_user_message_register_application(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
161 int dlt_daemon_process_user_message_unregister_application(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
162 int dlt_daemon_process_user_message_register_context(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
163 int dlt_daemon_process_user_message_unregister_context(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
164 int dlt_daemon_process_user_message_log(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
165 int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
166 int dlt_daemon_send_ringbuffer_to_client(DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);\r
167 \r
168 void dlt_daemon_timingpacket_thread(void *ptr);\r
169 int dlt_daemon_make_periodic (unsigned int period, DltDaemonPeriodicData *info, int verbose);\r
170 void dlt_daemon_wait_period(DltDaemonPeriodicData *info, int verbose);\r
171 \r
172 #endif /* DLT_DAEMON_H */\r
173 \r