203763a29905dd0300bf4ac46b91fed1ccfed3e7
[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.aw.wenzel@bmw.de> BMW 2011-2012\r
17  *\r
18  * \file dlt_user_shared.h\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 {\r
79         DLT_RETURN_BUFFER_FULL  = -4,
80         DLT_RETURN_PIPE_FULL    = -3,
81         DLT_RETURN_PIPE_ERROR   = -2,
82         DLT_RETURN_ERROR                = -1,
83         DLT_RETURN_OK                   =  0
84 } DltReturnValue;
85 \r
86 /**\r
87  * This is the header of each message to be exchanged between application and daemon.\r
88  */\r
89 typedef struct\r
90 {\r
91         char pattern[DLT_ID_SIZE];      /**< This pattern should be DUH0x01 */\r
92         uint32_t message;               /**< messsage info */\r
93 } PACKED DltUserHeader;\r
94 \r
95 /**\r
96  * This is the internal message content to exchange control msg register app information between application and daemon.\r
97  */\r
98 typedef struct\r
99 {\r
100         char apid[DLT_ID_SIZE];          /**< application id */\r
101         pid_t pid;                       /**< process id of user application */\r
102     uint32_t description_length;     /**< length of description */\r
103 } PACKED DltUserControlMsgRegisterApplication;\r
104 \r
105 /**\r
106  * This is the internal message content to exchange control msg unregister app information between application and daemon.\r
107  */\r
108 typedef struct\r
109 {\r
110         char apid[DLT_ID_SIZE];         /**< application id */\r
111     pid_t pid;                      /**< process id of user application */\r
112 } PACKED DltUserControlMsgUnregisterApplication;\r
113 \r
114 /**\r
115  * This is the internal message content to exchange control msg register information between application and daemon.\r
116  */\r
117 typedef struct\r
118 {\r
119         char apid[DLT_ID_SIZE];          /**< application id */\r
120         char ctid[DLT_ID_SIZE];          /**< context id */\r
121         int32_t log_level_pos;           /**< offset in management structure on user-application side */\r
122         int8_t log_level;                /**< log level */\r
123         int8_t trace_status;             /**< trace status */\r
124         pid_t pid;                       /**< process id of user application */\r
125     uint32_t description_length;     /**< length of description */\r
126 } PACKED DltUserControlMsgRegisterContext;\r
127 \r
128 /**\r
129  * This is the internal message content to exchange control msg unregister information between application and daemon.\r
130  */\r
131 typedef struct\r
132 {\r
133         char apid[DLT_ID_SIZE];         /**< application id */\r
134         char ctid[DLT_ID_SIZE];         /**< context id */\r
135         pid_t pid;                      /**< process id of user application */\r
136 } PACKED DltUserControlMsgUnregisterContext;\r
137 \r
138 /**\r
139  * This is the internal message content to exchange control msg log level information between application and daemon.\r
140  */\r
141 typedef struct\r
142 {\r
143         uint8_t log_level;             /**< log level */\r
144         uint8_t trace_status;          /**< trace status */\r
145         int32_t log_level_pos;          /**< offset in management structure on user-application side */\r
146 } PACKED DltUserControlMsgLogLevel;\r
147 \r
148 /**\r
149  * This is the internal message content to exchange control msg injection information between application and daemon.\r
150  */\r
151 typedef struct\r
152 {\r
153         int32_t log_level_pos;          /**< offset in management structure on user-application side */\r
154         uint32_t service_id;            /**< service id of injection */\r
155     uint32_t data_length_inject;    /**< length of injection message data field */\r
156 } PACKED DltUserControlMsgInjection;\r
157 \r
158 /**\r
159  * This is the internal message content to exchange information about application log level and trace stats between\r
160  * application and daemon.\r
161  */\r
162 typedef struct\r
163 {\r
164     char apid[DLT_ID_SIZE];        /**< application id */\r
165         uint8_t log_level;             /**< log level */\r
166         uint8_t trace_status;          /**< trace status */\r
167 } PACKED DltUserControlMsgAppLogLevelTraceStatus;\r
168 \r
169 /**\r
170  * This is the internal message content to set the logging mode: off, external, internal, both.\r
171  */\r
172 typedef struct\r
173 {\r
174         int8_t log_mode;          /**< the mode to be used for logging: off, external, internal, both */\r
175 } PACKED DltUserControlMsgLogMode;\r
176 \r
177 /**\r
178  * This is the internal message content to get the logging state: 0 = off, 1 = external client connected.\r
179  */\r
180 typedef struct\r
181 {\r
182         int8_t log_state;          /**< the state to be used for logging state: 0 = off, 1 = external client connected */\r
183 } PACKED DltUserControlMsgLogState;\r
184 \r
185 /**************************************************************************************************\r
186 * The folowing functions are used shared between the user lib and the daemon implementation\r
187 **************************************************************************************************/\r
188 \r
189 /**\r
190  * Set user header marker and store message type in user header\r
191  * @param userheader pointer to the userheader\r
192  * @param mtype user message type of internal message\r
193  * @return negative value if there was an error {
194                         return -1;
195                     }\r
196  */\r
197 int dlt_user_set_userheader(DltUserHeader *userheader, uint32_t mtype);\r
198 \r
199 /**\r
200  * Check if user header contains its marker\r
201  * @param userheader pointer to the userheader\r
202  * @return 0 no, 1 yes, negative value if there was an error\r
203  */\r
204 int dlt_user_check_userheader(DltUserHeader *userheader);\r
205 \r
206 /**\r
207  * Atomic write to file descriptor, using vector of 2 elements\r
208  * @param handle file descriptor\r
209  * @param ptr1 generic pointer to first segment of data to be written\r
210  * @param len1 length of first segment of data to be written\r
211  * @param ptr2 generic pointer to second segment of data to be written\r
212  * @param len2 length of second segment of data to be written\r
213  * @return Value from DltReturnValue enum\r
214  */\r
215 DltReturnValue dlt_user_log_out2(int handle, void *ptr1, size_t len1, void* ptr2, size_t len2);\r
216 \r
217 /**\r
218  * Atomic write to file descriptor, using vector of 3 elements\r
219  * @param handle file descriptor\r
220  * @param ptr1 generic pointer to first segment of data to be written\r
221  * @param len1 length of first segment of data to be written\r
222  * @param ptr2 generic pointer to second segment of data to be written\r
223  * @param len2 length of second segment of data to be written\r
224  * @param ptr3 generic pointer to third segment of data to be written\r
225  * @param len3 length of third segment of data to be written\r
226  * @return Value from DltReturnValue enum\r
227  */\r
228 DltReturnValue dlt_user_log_out3(int handle, void *ptr1, size_t len1, void* ptr2, size_t len2, void *ptr3, size_t len3);\r
229 \r
230 #endif /* DLT_USER_SHARED_H */\r