GDLT-38, Update license in internal headers.
[profile/ivi/dlt-daemon.git] / src / shared / dlt_user_shared.h
1 /**\r
2  * @licence app begin@\r
3  * Copyright (C) 2012  BMW AG\r
4  *\r
5  * This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps.\r
6  *\r
7  * Contributions are licensed to the GENIVI Alliance under one or more\r
8  * Contribution License Agreements.\r
9  *\r
10  * \copyright\r
11  * This Source Code Form is subject to the terms of the\r
12  * Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed with\r
13  * this file, You can obtain one at http://mozilla.org/MPL/2.0/.\r
14  *\r
15  *\r
16  * \author Alexander Wenzel <alexander.wenzel@bmw.de> BMW 2011-2012\r
17  *\r
18  * \file <FILE>\r
19  * For further information see http://www.genivi.org/.\r
20  * @licence end@\r
21  */\r
22 \r
23 \r
24 \r
25 /*******************************************************************************\r
26 **                                                                            **\r
27 **  SRC-MODULE: dlt_user_shared.h                                             **\r
28 **                                                                            **\r
29 **  TARGET    : linux                                                         **\r
30 **                                                                            **\r
31 **  PROJECT   : DLT                                                           **\r
32 **                                                                            **\r
33 **  AUTHOR    : Alexander Wenzel Alexander.AW.Wenzel@bmw.de                   **\r
34 **              Markus Klein                                                  **\r
35 **                                                                            **\r
36 **  PURPOSE   :                                                               **\r
37 **                                                                            **\r
38 **  REMARKS   :                                                               **\r
39 **                                                                            **\r
40 **  PLATFORM DEPENDANT [yes/no]: yes                                          **\r
41 **                                                                            **\r
42 **  TO BE CHANGED BY USER [yes/no]: no                                        **\r
43 **                                                                            **\r
44 *******************************************************************************/\r
45 \r
46 /*******************************************************************************\r
47 **                      Author Identity                                       **\r
48 ********************************************************************************\r
49 **                                                                            **\r
50 ** Initials     Name                       Company                            **\r
51 ** --------     -------------------------  ---------------------------------- **\r
52 **  aw          Alexander Wenzel           BMW                                **\r
53 **  mk          Markus Klein               Fraunhofer ESK                     **\r
54 *******************************************************************************/\r
55 \r
56 /*******************************************************************************\r
57 **                      Author Identity                                       **\r
58 ********************************************************************************\r
59 **                                                                            **\r
60 ** Initials     Name                       Company                            **\r
61 ** --------     -------------------------  ---------------------------------- **\r
62 **  aw          Alexander Wenzel           BMW                                **\r
63 **  mk          Markus Klein               Fraunhofer ESK                     **\r
64 *******************************************************************************/\r
65 \r
66 #ifndef DLT_USER_SHARED_H\r
67 #define DLT_USER_SHARED_H\r
68
69 #include "dlt_types.h"\r
70 #include "dlt_user.h"\r
71 \r
72 #include <sys/types.h>\r
73
74 /**\r
75  * This are the return values for the functions dlt_user_log_out2() and dlt_user_log_out3()\r
76  */
77 typedef enum
78 {
79         DLT_RETURN_PIPE_FULL  = -3,
80         DLT_RETURN_PIPE_ERROR = -2,
81         DLT_RETURN_ERROR      = -1,
82         DLT_RETURN_OK         =  0
83 } DltReturnValue;
84 \r
85 /**\r
86  * This is the header of each message to be exchanged between application and daemon.\r
87  */\r
88 typedef struct\r
89 {\r
90         char pattern[DLT_ID_SIZE];      /**< This pattern should be DUH0x01 */\r
91         uint32_t message;               /**< messsage info */\r
92 } PACKED DltUserHeader;\r
93 \r
94 /**\r
95  * This is the internal message content to exchange control msg register app information between application and daemon.\r
96  */\r
97 typedef struct\r
98 {\r
99         char apid[DLT_ID_SIZE];          /**< application id */\r
100         pid_t pid;                       /**< process id of user application */\r
101     uint32_t description_length;     /**< length of description */\r
102 } PACKED DltUserControlMsgRegisterApplication;\r
103 \r
104 /**\r
105  * This is the internal message content to exchange control msg unregister app information between application and daemon.\r
106  */\r
107 typedef struct\r
108 {\r
109         char apid[DLT_ID_SIZE];         /**< application id */\r
110     pid_t pid;                      /**< process id of user application */\r
111 } PACKED DltUserControlMsgUnregisterApplication;\r
112 \r
113 /**\r
114  * This is the internal message content to exchange control msg register information between application and daemon.\r
115  */\r
116 typedef struct\r
117 {\r
118         char apid[DLT_ID_SIZE];          /**< application id */\r
119         char ctid[DLT_ID_SIZE];          /**< context id */\r
120         int32_t log_level_pos;           /**< offset in management structure on user-application side */\r
121         int8_t log_level;                /**< log level */\r
122         int8_t trace_status;             /**< trace status */\r
123         pid_t pid;                       /**< process id of user application */\r
124     uint32_t description_length;     /**< length of description */\r
125 } PACKED DltUserControlMsgRegisterContext;\r
126 \r
127 /**\r
128  * This is the internal message content to exchange control msg unregister information between application and daemon.\r
129  */\r
130 typedef struct\r
131 {\r
132         char apid[DLT_ID_SIZE];         /**< application id */\r
133         char ctid[DLT_ID_SIZE];         /**< context id */\r
134         pid_t pid;                      /**< process id of user application */\r
135 } PACKED DltUserControlMsgUnregisterContext;\r
136 \r
137 /**\r
138  * This is the internal message content to exchange control msg log level information between application and daemon.\r
139  */\r
140 typedef struct\r
141 {\r
142         uint8_t log_level;             /**< log level */\r
143         uint8_t trace_status;          /**< trace status */\r
144         int32_t log_level_pos;          /**< offset in management structure on user-application side */\r
145 } PACKED DltUserControlMsgLogLevel;\r
146 \r
147 /**\r
148  * This is the internal message content to exchange control msg injection information between application and daemon.\r
149  */\r
150 typedef struct\r
151 {\r
152         int32_t log_level_pos;          /**< offset in management structure on user-application side */\r
153         uint32_t service_id;            /**< service id of injection */\r
154     uint32_t data_length_inject;    /**< length of injection message data field */\r
155 } PACKED DltUserControlMsgInjection;\r
156 \r
157 /**\r
158  * This is the internal message content to exchange information about application log level and trace stats between\r
159  * application and daemon.\r
160  */\r
161 typedef struct\r
162 {\r
163     char apid[DLT_ID_SIZE];        /**< application id */\r
164         uint8_t log_level;             /**< log level */\r
165         uint8_t trace_status;          /**< trace status */\r
166 } PACKED DltUserControlMsgAppLogLevelTraceStatus;\r
167 \r
168 /**\r
169  * This is the internal message content to set the logging mode: off, external, internal, both.\r
170  */\r
171 typedef struct\r
172 {\r
173         int8_t log_mode;          /**< the mode to be used for logging: off, external, internal, both */\r
174 } PACKED DltUserControlMsgLogMode;\r
175 \r
176 /**\r
177  * This is the internal message content to get the logging state: 0 = off, 1 = external client connected.\r
178  */\r
179 typedef struct\r
180 {\r
181         int8_t log_state;          /**< the state to be used for logging state: 0 = off, 1 = external client connected */\r
182 } PACKED DltUserControlMsgLogState;\r
183 \r
184 /**************************************************************************************************\r
185 * The folowing functions are used shared between the user lib and the daemon implementation\r
186 **************************************************************************************************/\r
187 \r
188 /**\r
189  * Set user header marker and store message type in user header\r
190  * @param userheader pointer to the userheader\r
191  * @param mtype user message type of internal message\r
192  * @return negative value if there was an error {
193                         return -1;
194                     }\r
195  */\r
196 int dlt_user_set_userheader(DltUserHeader *userheader, uint32_t mtype);\r
197 \r
198 /**\r
199  * Check if user header contains its marker\r
200  * @param userheader pointer to the userheader\r
201  * @return 0 no, 1 yes, negative value if there was an error\r
202  */\r
203 int dlt_user_check_userheader(DltUserHeader *userheader);\r
204 \r
205 /**\r
206  * Atomic write to file descriptor, using vector of 2 elements\r
207  * @param handle file descriptor\r
208  * @param ptr1 generic pointer to first segment of data to be written\r
209  * @param len1 length of first segment of data to be written\r
210  * @param ptr2 generic pointer to second segment of data to be written\r
211  * @param len2 length of second segment of data to be written\r
212  * @return Value from DltReturnValue enum\r
213  */\r
214 DltReturnValue dlt_user_log_out2(int handle, void *ptr1, size_t len1, void* ptr2, size_t len2);\r
215 \r
216 /**\r
217  * Atomic write to file descriptor, using vector of 3 elements\r
218  * @param handle file descriptor\r
219  * @param ptr1 generic pointer to first segment of data to be written\r
220  * @param len1 length of first segment of data to be written\r
221  * @param ptr2 generic pointer to second segment of data to be written\r
222  * @param len2 length of second segment of data to be written\r
223  * @param ptr3 generic pointer to third segment of data to be written\r
224  * @param len3 length of third segment of data to be written\r
225  * @return Value from DltReturnValue enum\r
226  */\r
227 DltReturnValue dlt_user_log_out3(int handle, void *ptr1, size_t len1, void* ptr2, size_t len2, void *ptr3, size_t len3);\r
228 \r
229 #endif /* DLT_USER_SHARED_H */\r