be04e6898eb689fd4dfaecd810dc09041470cffb
[profile/ivi/dlt-daemon.git] / include / dlt / dlt_common.h
1 /**
2  * @licence app begin@
3  * Copyright (C) 2012  BMW AG
4  *
5  * This file is part of GENIVI Project Dlt - Diagnostic Log and Trace console apps.
6  *
7  * Contributions are licensed to the GENIVI Alliance under one or more
8  * Contribution License Agreements.
9  *
10  * \copyright
11  * This Source Code Form is subject to the terms of the
12  * Mozilla Public License, v. 2.0. If a  copy of the MPL was not distributed with
13  * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
14  *
15  *
16  * \author Alexander Wenzel <alexander.aw.wenzel@bmw.de> BMW 2011-2012
17  *
18  * \file dlt_common.h
19  * For further information see http://www.genivi.org/.
20  * @licence end@
21  */
22
23 /*******************************************************************************
24 **                                                                            **
25 **  SRC-MODULE: dlt_common.h                                                  **
26 **                                                                            **
27 **  TARGET    : linux                                                         **
28 **                                                                            **
29 **  PROJECT   : DLT                                                           **
30 **                                                                            **
31 **  AUTHOR    : Alexander Wenzel Alexander.AW.Wenzel@bmw.de                   **
32 **              Markus Klein                                                  **
33 **                                                                            **
34 **  PURPOSE   :                                                               **
35 **                                                                            **
36 **  REMARKS   :                                                               **
37 **                                                                            **
38 **  PLATFORM DEPENDANT [yes/no]: yes                                          **
39 **                                                                            **
40 **  TO BE CHANGED BY USER [yes/no]: no                                        **
41 **                                                                            **
42 *******************************************************************************/
43
44 /*******************************************************************************
45 **                      Author Identity                                       **
46 ********************************************************************************
47 **                                                                            **
48 ** Initials     Name                       Company                            **
49 ** --------     -------------------------  ---------------------------------- **
50 **  aw          Alexander Wenzel           BMW                                **
51 **  mk          Markus Klein               Fraunhofer ESK                     **
52 *******************************************************************************/
53
54 /*******************************************************************************
55 **                      Revision Control History                              **
56 *******************************************************************************/
57
58 /*
59  * $LastChangedRevision: 1670 $
60  * $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
61  * $LastChangedBy$
62  Initials    Date         Comment
63  aw          13.01.2010   initial
64  */
65 #ifndef DLT_COMMON_H
66 #define DLT_COMMON_H
67
68 /**
69   \defgroup commonapi DLT Common API
70   \addtogroup commonapi
71   \{
72 */
73
74 #include <stdio.h>
75
76 #if !defined(_MSC_VER)
77 #include <unistd.h>
78 #include <time.h>
79 #endif
80
81 #if !defined (__WIN32__) && !defined(_MSC_VER)
82 #include <termios.h>
83 #endif
84
85 #include "dlt_types.h"
86 #include "dlt_protocol.h"
87
88 #if !defined (PACKED)
89 #define PACKED __attribute__((aligned(1),packed))
90 #endif
91
92 #if defined (__MSDOS__) || defined (_MSC_VER)
93 /* set instead /Zp8 flag in Visual C++ configuration */
94 #undef PACKED
95 #define PACKED
96 #endif
97
98 /*
99  * Macros to swap the byte order.
100  */
101 #define DLT_SWAP_64(value) ((((uint64_t)DLT_SWAP_32((value)&0xffffffffull))<<32) | (DLT_SWAP_32((value)>>32)))
102
103 #define DLT_SWAP_16(value) ((((value) >> 8)&0xff) | (((value) << 8)&0xff00))
104 #define DLT_SWAP_32(value) ((((value) >> 24)&0xff) | (((value) << 8)&0xff0000) | (((value) >> 8)&0xff00) | (((value) << 24)&0xff000000))
105
106 /* Set Big Endian and Little Endian to a initial value, if not defined */
107 #if !defined __USE_BSD
108 #ifndef LITTLE_ENDIAN
109 #define LITTLE_ENDIAN 1234
110 #endif
111
112 #ifndef BIG_ENDIAN
113 #define BIG_ENDIAN    4321
114 #endif
115 #endif /* __USE_BSD */
116
117 /* If byte order is not defined, default to little endian */
118 #if !defined __USE_BSD
119 #ifndef BYTE_ORDER
120 #define BYTE_ORDER LITTLE_ENDIAN
121 #endif
122 #endif /* __USE_BSD */
123
124 /* Check for byte-order */
125 #if (BYTE_ORDER==BIG_ENDIAN)
126 /* #warning "Big Endian Architecture!" */
127 #define DLT_HTOBE_16(x) ((x))
128 #define DLT_HTOLE_16(x) DLT_SWAP_16((x))
129 #define DLT_BETOH_16(x) ((x))
130 #define DLT_LETOH_16(x) DLT_SWAP_16((x))
131
132 #define DLT_HTOBE_32(x) ((x))
133 #define DLT_HTOLE_32(x) DLT_SWAP_32((x))
134 #define DLT_BETOH_32(x) ((x))
135 #define DLT_LETOH_32(x) DLT_SWAP_32((x))
136
137 #define DLT_HTOBE_64(x) ((x))
138 #define DLT_HTOLE_64(x) DLT_SWAP_64((x))
139 #define DLT_BETOH_64(x) ((x))
140 #define DLT_LETOH_64(x) DLT_SWAP_64((x))
141 #else
142 /* #warning "Litte Endian Architecture!" */
143 #define DLT_HTOBE_16(x) DLT_SWAP_16((x))
144 #define DLT_HTOLE_16(x) ((x))
145 #define DLT_BETOH_16(x) DLT_SWAP_16((x))
146 #define DLT_LETOH_16(x) ((x))
147
148 #define DLT_HTOBE_32(x) DLT_SWAP_32((x))
149 #define DLT_HTOLE_32(x) ((x))
150 #define DLT_BETOH_32(x) DLT_SWAP_32((x))
151 #define DLT_LETOH_32(x) ((x))
152
153 #define DLT_HTOBE_64(x) DLT_SWAP_64((x))
154 #define DLT_HTOLE_64(x) ((x))
155 #define DLT_BETOH_64(x) DLT_SWAP_64((x))
156 #define DLT_LETOH_64(x) ((x))
157 #endif
158
159 #define DLT_ENDIAN_GET_16(htyp,x) ((((htyp) & DLT_HTYP_MSBF)>0)?DLT_BETOH_16(x):DLT_LETOH_16(x))
160 #define DLT_ENDIAN_GET_32(htyp,x) ((((htyp) & DLT_HTYP_MSBF)>0)?DLT_BETOH_32(x):DLT_LETOH_32(x))
161 #define DLT_ENDIAN_GET_64(htyp,x) ((((htyp) & DLT_HTYP_MSBF)>0)?DLT_BETOH_64(x):DLT_LETOH_64(x))
162
163 #if defined (__WIN32__) || defined (_MSC_VER)
164 #define LOG_EMERG       0
165 #define LOG_ALERT       1
166 #define LOG_CRIT        2
167 #define LOG_ERR         3
168 #define LOG_WARNING     4
169 #define LOG_NOTICE      5
170 #define LOG_INFO        6
171 #define LOG_DEBUG       7
172
173 #define LOG_PID         0x01
174 #define LOG_DAEMON      (3<<3)
175 #endif
176
177 enum {
178     DLT_LOG_TO_CONSOLE=0,
179     DLT_LOG_TO_SYSLOG=1,
180     DLT_LOG_TO_FILE=2,
181     DLT_LOG_DROPPED=3
182 };
183
184 /**
185  * The standard TCP Port used for DLT daemon
186  */
187 #define DLT_DAEMON_TCP_PORT 3490
188
189
190 /* Initi value for file descritpor */
191 #define DLT_FD_INIT -1
192
193 /* Minimum value for a file descriptor except the POSIX Standards: stdin=0, stdout=1, stderr=2 */
194 #define DLT_FD_MINIMUM 3
195
196 /**
197  * The size of a DLT ID
198  */
199 #define DLT_ID_SIZE 4
200
201 #define DLT_SIZE_WEID DLT_ID_SIZE
202 #define DLT_SIZE_WSID (sizeof(uint32_t))
203 #define DLT_SIZE_WTMS (sizeof(uint32_t))
204
205 /**
206  * Get the size of extra header parameters, depends on htyp.
207  */
208 #define DLT_STANDARD_HEADER_EXTRA_SIZE(htyp) ( (DLT_IS_HTYP_WEID(htyp) ? DLT_SIZE_WEID : 0) + (DLT_IS_HTYP_WSID(htyp) ? DLT_SIZE_WSID : 0) + (DLT_IS_HTYP_WTMS(htyp) ? DLT_SIZE_WTMS : 0) )
209
210
211 #if defined (__MSDOS__) || defined (_MSC_VER)
212 #define __func__ __FUNCTION__
213 #endif
214
215 #define PRINT_FUNCTION_VERBOSE(_verbose)  \
216 { \
217         static char _strbuf[255]; \
218     \
219     if(_verbose) \
220     { \
221                 snprintf(_strbuf, 255, "%s()\n",__func__); \
222                 dlt_log(LOG_INFO, _strbuf); \
223     } \
224 }
225
226 #ifndef NULL
227 #define NULL (char*)0
228 #endif
229
230 #define DLT_MSG_IS_CONTROL(MSG)          ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
231                                           (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_CONTROL))
232
233 #define DLT_MSG_IS_CONTROL_REQUEST(MSG)  ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
234                                           (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_CONTROL) && \
235                                           (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin)==DLT_CONTROL_REQUEST))
236
237 #define DLT_MSG_IS_CONTROL_RESPONSE(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
238                                           (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_CONTROL) && \
239                                           (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin)==DLT_CONTROL_RESPONSE))
240
241 #define DLT_MSG_IS_CONTROL_TIME(MSG)     ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
242                                           (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_CONTROL) && \
243                                           (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin)==DLT_CONTROL_TIME))
244
245 #define DLT_MSG_IS_NW_TRACE(MSG)         ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
246                                                                               (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_NW_TRACE))
247
248 #define DLT_MSG_IS_TRACE_MOST(MSG)       ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \
249                                                                               (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_NW_TRACE) && \
250                                                                               (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin)==DLT_NW_TRACE_MOST))
251
252 #define DLT_MSG_IS_NONVERBOSE(MSG)       (!(DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) || \
253                                           ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && (!(DLT_IS_MSIN_VERB((MSG)->extendedheader->msin)))))
254
255 /*
256
257  * Definitions of DLT message buffer overflow
258  */
259 #define DLT_MESSAGE_BUFFER_NO_OVERFLOW     0x00 /**< Buffer overflow has not occured */
260 #define DLT_MESSAGE_BUFFER_OVERFLOW        0x01 /**< Buffer overflow has occured */
261
262 /*
263  * Definition of DLT output variants
264  */
265 #define DLT_OUTPUT_HEX              1
266 #define DLT_OUTPUT_ASCII            2
267 #define DLT_OUTPUT_MIXED_FOR_PLAIN  3
268 #define DLT_OUTPUT_MIXED_FOR_HTML   4
269 #define DLT_OUTPUT_ASCII_LIMITED    5
270
271 #define DLT_FILTER_MAX 30 /**< Maximum number of filters */
272
273 #define DLT_MSG_READ_VALUE(dst,src,length,type) \
274     { \
275     if((length<0) || ((length)<((int32_t)sizeof(type)))) \
276         { length = -1; } \
277     else \
278         { dst = *((type*)src);src+=sizeof(type);length-=sizeof(type); } \
279     }
280
281 #define DLT_MSG_READ_ID(dst,src,length) \
282     { \
283     if((length<0) || ((length)<DLT_ID_SIZE)) \
284         { length = -1; } \
285     else \
286         { memcpy(dst,src,DLT_ID_SIZE);src+=DLT_ID_SIZE;length-=DLT_ID_SIZE; } \
287     }
288
289 #define DLT_MSG_READ_STRING(dst,src,maxlength,length) \
290     { \
291     if(((maxlength)<0) || ((length)<0) || ((maxlength)<(length))) \
292         { maxlength = -1; } \
293     else \
294         { memcpy(dst,src,length);dlt_clean_string(dst,length);dst[length]=0; \
295           src+=length;maxlength-=length; } \
296     }
297
298 #define DLT_MSG_READ_NULL(src,maxlength,length) \
299     { \
300     if(((maxlength)<0) || ((length)<0) || ((maxlength)<(length))) \
301         { length = -1; } \
302     else \
303         { src+=length;maxlength-=length; } \
304     }
305
306 #define DLT_HEADER_SHOW_NONE       0x0000
307 #define DLT_HEADER_SHOW_TIME       0x0001
308 #define DLT_HEADER_SHOW_TMSTP      0x0002
309 #define DLT_HEADER_SHOW_MSGCNT     0x0004
310 #define DLT_HEADER_SHOW_ECUID      0x0008
311 #define DLT_HEADER_SHOW_APID       0x0010
312 #define DLT_HEADER_SHOW_CTID       0x0020
313 #define DLT_HEADER_SHOW_MSGTYPE    0x0040
314 #define DLT_HEADER_SHOW_MSGSUBTYPE 0x0080
315 #define DLT_HEADER_SHOW_VNVSTATUS  0x0100
316 #define DLT_HEADER_SHOW_NOARG      0x0200
317 #define DLT_HEADER_SHOW_ALL        0xFFFF
318
319 /**
320  * The definition of the serial header containing the characters "DLS" + 0x01.
321  */
322 extern const char dltSerialHeader[DLT_ID_SIZE];
323
324 /**
325  * The definition of the serial header containing the characters "DLS" + 0x01 as char.
326  */
327 extern char dltSerialHeaderChar[DLT_ID_SIZE];
328
329 /**
330
331  * The type of a DLT ID (context id, application id, etc.)
332  */
333 typedef char ID4[DLT_ID_SIZE];
334
335 /**
336  * The structure of the DLT file storage header. This header is used before each stored DLT message.
337  */
338 typedef struct
339 {
340     char pattern[DLT_ID_SIZE];          /**< This pattern should be DLT0x01 */
341     uint32_t seconds;                               /**< seconds since 1.1.1970 */
342     int32_t microseconds;                       /**< Microseconds */
343     char ecu[DLT_ID_SIZE];                      /**< The ECU id is added, if it is not already in the DLT message itself */
344 } PACKED DltStorageHeader;
345
346 /**
347  * The structure of the DLT standard header. This header is used in each DLT message.
348  */
349 typedef struct
350 {
351     uint8_t htyp;           /**< This parameter contains several informations, see definitions below */
352     uint8_t mcnt;           /**< The message counter is increased with each sent DLT message */
353     uint16_t len;           /**< Length of the complete message, without storage header */
354 } PACKED DltStandardHeader;
355
356 /**
357  * The structure of the DLT extra header parameters. Each parameter is sent only if enabled in htyp.
358  */
359 typedef struct
360 {
361     char ecu[DLT_ID_SIZE];       /**< ECU id */
362     uint32_t seid;     /**< Session number */
363     uint32_t tmsp;     /**< Timestamp since system start in 0.1 milliseconds */
364 } PACKED DltStandardHeaderExtra;
365
366 /**
367  * The structure of the DLT extended header. This header is only sent if enabled in htyp parameter.
368  */
369 typedef struct
370 {
371     uint8_t msin;          /**< messsage info */
372     uint8_t noar;          /**< number of arguments */
373     char apid[DLT_ID_SIZE];          /**< application id */
374     char ctid[DLT_ID_SIZE];          /**< context id */
375 } PACKED DltExtendedHeader;
376
377 /**
378  * The structure to organise the DLT messages.
379  * This structure is used by the corresponding functions.
380  */
381 typedef struct sDltMessage
382 {
383     /* flags */
384     int8_t found_serialheader;
385
386     /* offsets */
387     int32_t resync_offset;
388
389     /* size parameters */
390     int32_t headersize;    /**< size of complete header including storage header */
391     int32_t datasize;      /**< size of complete payload */
392
393     /* buffer for current loaded message */
394     uint8_t headerbuffer[sizeof(DltStorageHeader)+
395                          sizeof(DltStandardHeader)+sizeof(DltStandardHeaderExtra)+sizeof(DltExtendedHeader)]; /**< buffer for loading complete header */
396     uint8_t *databuffer;         /**< buffer for loading payload */
397         int32_t databuffersize;
398
399     /* header values of current loaded message */
400     DltStorageHeader       *storageheader;  /**< pointer to storage header of current loaded header */
401     DltStandardHeader      *standardheader; /**< pointer to standard header of current loaded header */
402     DltStandardHeaderExtra headerextra;     /**< extra parameters of current loaded header */
403     DltExtendedHeader      *extendedheader; /**< pointer to extended of current loaded header */
404 } DltMessage;
405
406 /**
407  * The structure of the DLT Service Get Log Info.
408  */
409 typedef struct
410 {
411     uint32_t service_id;            /**< service ID */
412     uint8_t options;                /**< type of request */
413     char apid[DLT_ID_SIZE];                   /**< application id */
414     char ctid[DLT_ID_SIZE];                   /**< context id */
415     char com[DLT_ID_SIZE];                    /**< communication interface */
416 } PACKED DltServiceGetLogInfoRequest;
417
418 /**
419  * The structure of the DLT Service Set Log Level.
420  */
421 typedef struct
422 {
423
424     uint32_t service_id;            /**< service ID */
425     char apid[DLT_ID_SIZE];                   /**< application id */
426     char ctid[DLT_ID_SIZE];                   /**< context id */
427     uint8_t log_level;              /**< log level to be set */
428     char com[DLT_ID_SIZE];                    /**< communication interface */
429 } PACKED DltServiceSetLogLevel;
430
431 /**
432  * The structure of the DLT Service Set Default Log Level.
433  */
434 typedef struct
435 {
436     uint32_t service_id;            /**< service ID */
437     uint8_t log_level;              /**< default log level to be set */
438     char com[DLT_ID_SIZE];                    /**< communication interface */
439 } PACKED DltServiceSetDefaultLogLevel;
440
441 /**
442  * The structure of the DLT Service Set Verbose Mode
443  */
444 typedef struct
445 {
446     uint32_t service_id;            /**< service ID */
447     uint8_t new_status;             /**< new status to be set */
448 } PACKED DltServiceSetVerboseMode;
449
450 /**
451  * The structure of the DLT Service Set Communication Interface Status
452  */
453 typedef struct
454 {
455     uint32_t service_id;            /**< service ID */
456     char com[DLT_ID_SIZE];                    /**< communication interface */
457     uint8_t new_status;             /**< new status to be set */
458 } PACKED DltServiceSetCommunicationInterfaceStatus;
459
460 /**
461  * The structure of the DLT Service Set Communication Maximum Bandwidth
462  */
463 typedef struct
464 {
465     uint32_t service_id;            /**< service ID */
466     char com[DLT_ID_SIZE];                    /**< communication interface */
467     uint32_t max_bandwidth;         /**< maximum bandwith */
468 } PACKED DltServiceSetCommunicationMaximumBandwidth;
469
470 typedef struct
471 {
472     uint32_t service_id;            /**< service ID */
473     uint8_t status;                 /**< reponse status */
474 } PACKED DltServiceResponse;
475
476 typedef struct
477 {
478     uint32_t service_id;            /**< service ID */
479     uint8_t status;                 /**< reponse status */
480     uint8_t log_level;              /**< log level */
481 } PACKED DltServiceGetDefaultLogLevelResponse;
482
483 typedef struct
484 {
485     uint32_t service_id;            /**< service ID */
486     uint8_t status;                 /**< reponse status */
487     uint8_t overflow;               /**< overflow status */
488     uint32_t overflow_counter;      /**< overflow counter */
489 } PACKED DltServiceMessageBufferOverflowResponse;
490
491 typedef struct
492 {
493     uint32_t service_id;            /**< service ID */
494     uint8_t  status;                /**< reponse status */
495     uint32_t length;                /**< length of following payload */
496     /*char [] payload;*/
497 } PACKED DltServiceGetSoftwareVersionResponse;
498
499 /**
500  * The structure of the DLT Service Unregister Context.
501  */
502 typedef struct
503 {
504     uint32_t service_id;            /**< service ID */
505     uint8_t status;                 /**< reponse status */
506     char apid[DLT_ID_SIZE];         /**< application id */
507     char ctid[DLT_ID_SIZE];         /**< context id */
508     char comid[DLT_ID_SIZE];        /**< communication interface */
509 } PACKED DltServiceUnregisterContext;
510
511 /**
512  * The structure of the DLT Service Connection Info
513  */
514 typedef struct
515 {
516     uint32_t service_id;            /**< service ID */
517     uint8_t status;                 /**< reponse status */
518     uint8_t state;                  /**< new state */
519     char comid[DLT_ID_SIZE];        /**< communication interface */
520 } PACKED DltServiceConnectionInfo;
521
522 /**
523  * The structure of the DLT Service Timezone
524  */
525 typedef struct
526 {
527     uint32_t service_id;            /**< service ID */
528     uint8_t status;                 /**< reponse status */
529     int32_t timezone;               /**< Timezone in seconds */
530     uint8_t isdst;                  /**< Is daylight saving time */
531 } PACKED DltServiceTimezone;
532
533 /**
534  * Structure to store filter parameters.
535  * ID are maximal four characters. Unused values are filled with zeros.
536  * If every value as filter is valid, the id should be empty by having only zero values.
537  */
538 typedef struct
539 {
540     char apid[DLT_FILTER_MAX][DLT_ID_SIZE]; /**< application id */
541     char ctid[DLT_FILTER_MAX][DLT_ID_SIZE]; /**< context id */
542     int  counter;                           /**< number of filters */
543 } DltFilter;
544
545 /**
546  * The structure to organise the access to DLT files.
547  * This structure is used by the corresponding functions.
548  */
549 typedef struct sDltFile
550 {
551     /* file handle and index for fast access */
552     FILE *handle;      /**< file handle of opened DLT file */
553     long *index;       /**< file positions of all DLT messages for fast access to file, only filtered messages */
554
555     /* size parameters */
556     int32_t counter;       /**< number of messages in DLT file with filter */
557     int32_t counter_total; /**< number of messages in DLT file without filter */
558     int32_t position;      /**< current index to message parsed in DLT file starting at 0 */
559     long file_length;  /**< length of the file */
560     long file_position; /**< current position in the file */
561
562     /* error counters */
563     int32_t error_messages; /**< number of incomplete DLT messages found during file parsing */
564
565     /* filter parameters */
566     DltFilter *filter;  /**< pointer to filter list. Zero if no filter is set. */
567     int32_t filter_counter; /**< number of filter set */
568
569     /* current loaded message */
570     DltMessage msg;     /**< pointer to message */
571
572 } DltFile;
573
574 /**
575  * The structure is used to organise the receiving of data
576  * including buffer handling.
577  * This structure is used by the corresponding functions.
578  */
579 typedef struct
580 {
581     int32_t lastBytesRcvd;    /**< bytes received in last receive call */
582     int32_t bytesRcvd;        /**< received bytes */
583     int32_t totalBytesRcvd;   /**< total number of received bytes */
584     char *buffer;         /**< pointer to receiver buffer */
585     char *buf;            /**< pointer to position within receiver buffer */
586     int fd;               /**< connection handle */
587     int32_t buffersize;       /**< size of receiver buffer */
588 } DltReceiver;
589
590 typedef struct
591 {
592         unsigned char* shm;     /* pointer to beginning of shared memory */
593         int size;       /* size of data area in shared memory */
594         unsigned char* mem;     /* pointer to data area in shared memory */     
595         
596     uint32_t    min_size;  /**< Minimum size of buffer */
597     uint32_t    max_size;  /**< Maximum size of buffer */
598     uint32_t    step_size; /**< Step size of buffer */
599 } DltBuffer;
600
601 typedef struct
602 {
603         int write;
604         int read;
605         int count;      
606 } DltBufferHead;
607
608 #define DLT_BUFFER_HEAD         "SHM"
609
610 typedef struct
611 {
612         char head[4];
613         unsigned char status;
614         int size;       
615 } DltBufferBlockHead;
616
617 #define DLT_MESSAGE_ERROR_OK                    0
618 #define DLT_MESSAGE_ERROR_UNKNOWN               -1
619 #define DLT_MESSAGE_ERROR_SIZE          -2
620 #define DLT_MESSAGE_ERROR_CONTENT       -3
621
622 #ifdef __cplusplus
623 extern "C"
624 {
625 #endif
626
627     /**
628      * Helper function to print a byte array in hex.
629      * @param ptr pointer to the byte array.
630      * @param size number of bytes to be printed.
631      */
632     void dlt_print_hex(uint8_t *ptr,int size);
633     /**
634      * Helper function to print a byte array in hex into a string.
635      * @param text pointer to a ASCII string, in which the text is written
636      * @param textlength maximal size of text buffer
637      * @param ptr pointer to the byte array.
638      * @param size number of bytes to be printed.
639      * @return negative value if there was an error
640      */
641     int dlt_print_hex_string(char *text,int textlength,uint8_t *ptr,int size);
642     /**
643      * Helper function to print a byte array in hex and ascii into a string.
644      * @param text pointer to a ASCII string, in which the text is written
645      * @param textlength maximal size of text buffer
646      * @param ptr pointer to the byte array.
647      * @param size number of bytes to be printed.
648      * @param html output is html? 0 - false, 1 - true
649      * @return negative value if there was an error
650      */
651     int dlt_print_mixed_string(char *text,int textlength,uint8_t *ptr,int size,int html);
652     /**
653      * Helper function to print a byte array in ascii into a string.
654      * @param text pointer to a ASCII string, in which the text is written
655      * @param textlength maximal size of text buffer
656      * @param ptr pointer to the byte array.
657      * @param size number of bytes to be printed.
658      * @return negative value if there was an error
659      */
660     int dlt_print_char_string(char **text,int textlength,uint8_t *ptr,int size);
661
662     /**
663      * Helper function to print an id.
664      * @param text pointer to ASCII string where to write the id
665      * @param id four byte char array as used in DLT mesages as IDs.
666      */
667     void dlt_print_id(char *text,const char *id);
668
669     /**
670      * Helper function to set an ID parameter.
671      * @param id four byte char array as used in DLT mesages as IDs.
672      * @param text string to be copied into char array.
673      */
674     void dlt_set_id(char *id,const char *text);
675
676     /**
677      * Helper function to remove not nice to print characters, e.g. NULL or carage return.
678      * @param text pointer to string to be cleaned.
679      * @param length length of string excluding terminating zero.
680      */
681     void dlt_clean_string(char *text,int length);
682
683     /**
684      * Initialise the filter list.
685      * This function must be called before using further dlt filter.
686      * @param filter pointer to structure of organising DLT filter
687      * @param verbose if set to true verbose information is printed out.
688      * @return negative value if there was an error
689      */
690     int dlt_filter_init(DltFilter *filter,int verbose);
691     /**
692      * Free the used memory by the organising structure of filter.
693      * @param filter pointer to structure of organising DLT filter
694      * @param verbose if set to true verbose information is printed out.
695      * @return negative value if there was an error
696      */
697     int dlt_filter_free(DltFilter *filter,int verbose);
698     /**
699      * Load filter list from file.
700      * @param filter pointer to structure of organising DLT filter
701      * @param filename filename to load filters from
702      * @param verbose if set to true verbose information is printed out.
703      * @return negative value if there was an error
704      */
705     int dlt_filter_load(DltFilter *filter,const char *filename,int verbose);
706     /**
707      * Save filter list to file.
708      * @param filter pointer to structure of organising DLT filter
709      * @param filename filename to load filters from
710      * @param verbose if set to true verbose information is printed out.
711      * @return negative value if there was an error
712      */
713     int dlt_filter_save(DltFilter *filter,const char *filename,int verbose);
714     /**
715      * Find index of filter in filter list
716      * @param filter pointer to structure of organising DLT filter
717      * @param apid application id to be found in filter list
718      * @param ctid context id to be found in filter list
719      * @param verbose if set to true verbose information is printed out.
720      * @return negative value if there was an error (or not found), else return index of filter
721      */
722     int dlt_filter_find(DltFilter *filter,const char *apid,const char *ctid, int verbose);
723     /**
724      * Add new filter to filter list.
725      * @param filter pointer to structure of organising DLT filter
726      * @param apid application id to be added to filter list (must always be set).
727      * @param ctid context id to be added to filter list. empty equals don't care.
728      * @param verbose if set to true verbose information is printed out.
729      * @return negative value if there was an error
730      */
731     int dlt_filter_add(DltFilter *filter,const char *apid,const char *ctid,int verbose);
732     /**
733      * Delete filter from filter list
734      * @param filter pointer to structure of organising DLT filter
735      * @param apid application id to be deleted from filter list
736      * @param ctid context id to be deleted from filter list
737      * @param verbose if set to true verbose information is printed out.
738      * @return negative value if there was an error
739      */
740     int dlt_filter_delete(DltFilter *filter,const char *apid,const char *ctid,int verbose);
741
742     /**
743      * Initialise the structure used to access a DLT message.
744      * This function must be called before using further dlt_message functions.
745      * @param msg pointer to structure of organising access to DLT messages
746      * @param verbose if set to true verbose information is printed out.
747      * @return negative value if there was an error
748      */
749     int dlt_message_init(DltMessage *msg,int verbose);
750     /**
751      * Free the used memory by the organising structure of file.
752      * @param msg pointer to structure of organising access to DLT messages
753      * @param verbose if set to true verbose information is printed out.
754      * @return negative value if there was an error
755      */
756     int dlt_message_free(DltMessage *msg,int verbose);
757     /**
758      * Print Header into an ASCII string.
759      * This function calls dlt_message_header_flags() with flags=DLT_HEADER_SHOW_ALL
760      * @param msg pointer to structure of organising access to DLT messages
761      * @param text pointer to a ASCII string, in which the header is written
762      * @param textlength maximal size of text buffer
763      * @param verbose if set to true verbose information is printed out.
764      * @return negative value if there was an error
765      */
766     int dlt_message_header(DltMessage *msg,char *text,int textlength,int verbose);
767     /**
768      * Print Header into an ASCII string, selective.
769      * @param msg pointer to structure of organising access to DLT messages
770      * @param text pointer to a ASCII string, in which the header is written
771      * @param textlength maximal size of text buffer
772      * @param flags select, bit-field to select, what should be printed (DLT_HEADER_SHOW_...)
773      * @param verbose if set to true verbose information is printed out.
774      * @return negative value if there was an error
775      */
776     int dlt_message_header_flags(DltMessage *msg,char *text,int textlength,int flags, int verbose);
777     /**
778      * Print Payload into an ASCII string.
779      * @param msg pointer to structure of organising access to DLT messages
780      * @param text pointer to a ASCII string, in which the header is written
781      * @param textlength maximal size of text buffer
782      * @param type 1 = payload as hex, 2 = payload as ASCII.
783      * @param verbose if set to true verbose information is printed out.
784      * @return negative value if there was an error
785      */
786     int dlt_message_payload(DltMessage *msg,char *text,int textlength,int type,int verbose);
787     /**
788      * Check if message is filtered or not. All filters are applied (logical OR).
789      * @param msg pointer to structure of organising access to DLT messages
790      * @param filter pointer to filter
791      * @param verbose if set to true verbose information is printed out.
792      * @return 1 = filter matches, 0 = filter does not match, negative value if there was an error
793      */
794     int dlt_message_filter_check(DltMessage *msg,DltFilter *filter,int verbose);
795
796     /**
797      * Read message from memory buffer.
798      * Message in buffer has no storage header.
799      * @param msg pointer to structure of organising access to DLT messages
800      * @param buffer pointer to memory buffer
801      * @param length length of message in buffer
802      * @param resync if set to true resync to serial header is enforced
803      * @param verbose if set to true verbose information is printed out.
804      * @return negative value if there was an error
805      */
806     int dlt_message_read(DltMessage *msg,uint8_t *buffer,unsigned int length,int resync,int verbose);
807
808     /**
809      * Get standard header extra parameters
810      * @param msg pointer to structure of organising access to DLT messages
811      * @param verbose if set to true verbose information is printed out.
812      * @return negative value if there was an error
813      */
814     int dlt_message_get_extraparameters(DltMessage *msg,int verbose);
815
816     /**
817      * Set standard header extra parameters
818      * @param msg pointer to structure of organising access to DLT messages
819      * @param verbose if set to true verbose information is printed out.
820      * @return negative value if there was an error
821      */
822     int dlt_message_set_extraparameters(DltMessage *msg,int verbose);
823
824     /**
825      * Initialise the structure used to access a DLT file.
826      * This function must be called before using further dlt_file functions.
827      * @param file pointer to structure of organising access to DLT file
828      * @param verbose if set to true verbose information is printed out.
829      * @return negative value if there was an error
830      */
831     int dlt_file_init(DltFile *file,int verbose);
832     /**
833      * Set a list to filters.
834      * This function should be called before loading a DLT file, if filters should be used.
835      * A filter list is an array of filters. Several filters are combined logically by or operation.
836      * The filter list is not copied, so take care to keep list in memory.
837      * @param file pointer to structure of organising access to DLT file
838      * @param filter pointer to filter list array
839      * @param verbose if set to true verbose information is printed out.
840      * @return negative value if there was an error
841      */
842     int dlt_file_set_filter(DltFile *file,DltFilter *filter,int verbose);
843     /**
844      * Initialising loading a DLT file.
845      * @param file pointer to structure of organising access to DLT file
846      * @param filename filename of DLT file
847      * @param verbose if set to true verbose information is printed out.
848      * @return negative value if there was an error
849      */
850     int dlt_file_open(DltFile *file,const char *filename,int verbose);
851     /**
852      * Find next message in the DLT file and parse them.
853      * This function finds the next message in the DLT file.
854      * If a filter is set, the filter list is used.
855      * @param file pointer to structure of organising access to DLT file
856      * @param verbose if set to true verbose information is printed out.
857      * @return 0 = message does not match filter, 1 = message was read, negative value if there was an error
858      */
859     int dlt_file_read(DltFile *file,int verbose);
860     /**
861      * Find next message in the DLT file in RAW format (without storage header) and parse them.
862      * This function finds the next message in the DLT file.
863      * If a filter is set, the filter list is used.
864      * @param file pointer to structure of organising access to DLT file
865      * @param resync Resync to serial header when set to true
866      * @param verbose if set to true verbose information is printed out.
867      * @return 0 = message does not match filter, 1 = message was read, negative value if there was an error
868      */
869     int dlt_file_read_raw(DltFile *file,int resync,int verbose);
870     /**
871      * Closing loading a DLT file.
872      * @param file pointer to structure of organising access to DLT file
873      * @param verbose if set to true verbose information is printed out.
874      * @return negative value if there was an error
875      */
876     int dlt_file_close(DltFile *file,int verbose);
877     /**
878      * Load standard header of a message from file
879      * @param file pointer to structure of organising access to DLT file
880      * @param verbose if set to true verbose information is printed out.
881      * @return negative value if there was an error
882      */
883     int dlt_file_read_header(DltFile *file,int verbose);
884     /**
885      * Load standard header of a message from file in RAW format (without storage header)
886      * @param file pointer to structure of organising access to DLT file
887      * @param resync Resync to serial header when set to true
888      * @param verbose if set to true verbose information is printed out.
889      * @return negative value if there was an error
890      */
891     int dlt_file_read_header_raw(DltFile *file,int resync,int verbose);
892     /**
893      * Load, if available in message, extra standard header fields and
894      * extended header of a message from file
895      * (dlt_file_read_header() must have been called before this call!)
896      * @param file pointer to structure of organising access to DLT file
897      * @param verbose if set to true verbose information is printed out.
898      * @return negative value if there was an error
899      */
900     int dlt_file_read_header_extended(DltFile *file, int verbose);
901     /**
902      * Load payload of a message from file
903      * (dlt_file_read_header() must have been called before this call!)
904      * @param file pointer to structure of organising access to DLT file
905      * @param verbose if set to true verbose information is printed out.
906      * @return negative value if there was an error
907      */
908     int dlt_file_read_data(DltFile *file, int verbose);
909     /**
910      * Load headers and payload of a message selected by the index.
911      * If filters are set, index is based on the filtered list.
912      * @param file pointer to structure of organising access to DLT file
913      * @param index position of message in the files beginning from zero
914      * @param verbose if set to true verbose information is printed out.
915      * @return number of messages loaded, negative value if there was an error
916      */
917     int dlt_file_message(DltFile *file,int index,int verbose);
918     /**
919      * Free the used memory by the organising structure of file.
920      * @param file pointer to structure of organising access to DLT file
921      * @param verbose if set to true verbose information is printed out.
922      * @return negative value if there was an error
923      */
924     int dlt_file_free(DltFile *file,int verbose);
925
926     /**
927      * Set internal logging filename if mode 2
928      * @param filename the filename
929      */
930     void dlt_log_set_filename(const char *filename);
931     /**
932      * Set internal logging level
933      * @param level the level
934      */
935     void dlt_log_set_level(int level);
936     /**
937      * Initialize (external) logging facility
938      * @param mode positive, 0 = log to stdout, 1 = log to syslog, 2 = log to file
939      */
940     void dlt_log_init(int mode);
941     /**
942      * Log ASCII string with null-termination to (external) logging facility
943      * @param prio priority (see syslog() call)
944      * @param s Pointer to ASCII string with null-termination
945      * @return negative value if there was an error
946      */
947     int dlt_log(int prio, char *s);
948     /**
949      * De-Initialize (external) logging facility
950      */
951     void dlt_log_free(void);
952
953     /**
954      * Initialising a dlt receiver structure
955      * @param receiver pointer to dlt receiver structure
956      * @param _fd handle to file/socket/fifo, fram which the data should be received
957      * @param _buffersize size of data buffer for storing the received data
958      * @return negative value if there was an error
959      */
960     int dlt_receiver_init(DltReceiver *receiver,int _fd, int _buffersize);
961     /**
962      * De-Initialize a dlt receiver structure
963      * @param receiver pointer to dlt receiver structure
964      * @return negative value if there was an error
965      */
966     int dlt_receiver_free(DltReceiver *receiver);
967     /**
968      * Receive data from socket using the dlt receiver structure
969      * @param receiver pointer to dlt receiver structure
970      * @return negative value if there was an error
971      */
972     int dlt_receiver_receive_socket(DltReceiver *receiver);
973     /**
974      * Receive data from file/fifo using the dlt receiver structure
975      * @param receiver pointer to dlt receiver structure
976      * @return negative value if there was an error
977      */
978     int dlt_receiver_receive_fd(DltReceiver *receiver);
979     /**
980      * Remove a specific size of bytes from the received data
981      * @param receiver pointer to dlt receiver structure
982      * @param size amount of bytes to be removed
983      * @return negative value if there was an error
984      */
985     int dlt_receiver_remove(DltReceiver *receiver,int size);
986     /**
987      * Move data from last receive call to front of receive buffer
988      * @param receiver pointer to dlt receiver structure
989      * @return negative value if there was an error
990      */
991     int dlt_receiver_move_to_begin(DltReceiver *receiver);
992
993     /**
994      * Fill out storage header of a dlt message
995      * @param storageheader pointer to storage header of a dlt message
996      * @param ecu name of ecu to be set in storage header
997      * @return negative value if there was an error
998      */
999     int dlt_set_storageheader(DltStorageHeader *storageheader, const char *ecu);
1000     /**
1001      * Check if a storage header contains its marker
1002      * @param storageheader pointer to storage header of a dlt message
1003      * @return 0 no, 1 yes, negative value if there was an error
1004      */
1005     int dlt_check_storageheader(DltStorageHeader *storageheader);
1006
1007
1008     /**
1009      * Initialise static ringbuffer with a size of size.
1010      * Initialise as server. Init counters. 
1011      * Memory is already allocated.
1012      * @param buf Pointer to ringbuffer structure
1013      * @param ptr Ptr to ringbuffer memory
1014      * @param size Maximum size of buffer in bytes
1015      * @return negative value if there was an error
1016      */
1017     int dlt_buffer_init_static_server(DltBuffer *buf, const unsigned char *ptr, uint32_t size);
1018
1019     /**
1020      * Initialize static ringbuffer with a size of size.
1021      * Initialise as a client. Do not change counters.
1022      * Memory is already allocated.
1023      * @param buf Pointer to ringbuffer structure
1024      * @param ptr Ptr to ringbuffer memory
1025      * @param size Maximum size of buffer in bytes
1026      * @return negative value if there was an error
1027      */
1028     int dlt_buffer_init_static_client(DltBuffer *buf, const unsigned char *ptr, uint32_t size);
1029
1030     /**
1031      * Initialize dynamic ringbuffer with a size of size.
1032      * Initialise as a client. Do not change counters.
1033      * Memory will be allocated starting with min_size.
1034      * If more memory is needed size is increased wit step_size.
1035      * The maximum size is max_size.
1036      * @param buf Pointer to ringbuffer structure
1037      * @param min_size Minimum size of buffer in bytes
1038      * @param max_size Maximum size of buffer in bytes
1039      * @param step_size size of which ringbuffer is increased
1040      * @return negative value if there was an error
1041      */
1042     int dlt_buffer_init_dynamic(DltBuffer *buf, uint32_t min_size, uint32_t max_size,uint32_t step_size);
1043
1044     /**
1045      * Deinitilaise usage of static ringbuffer
1046      * @param buf Pointer to ringbuffer structure
1047      * @return negative value if there was an error
1048      */
1049     int dlt_buffer_free_static(DltBuffer *buf);
1050
1051     /**
1052      * Release and free memory used by dynamic ringbuffer
1053      * @param buf Pointer to ringbuffer structure
1054      * @return negative value if there was an error
1055      */
1056     int dlt_buffer_free_dynamic(DltBuffer *buf);
1057
1058     /**
1059      * Write one entry to ringbuffer
1060      * @param buf Pointer to ringbuffer structure
1061      * @param data Pointer to data to be written to ringbuffer
1062      * @param size Size of data in bytes to be written to ringbuffer
1063      * @return negative value if there was an error
1064      */
1065         int dlt_buffer_push(DltBuffer *buf,const unsigned char *data,unsigned int size);
1066
1067     /**
1068      * Write up to three entries to ringbuffer.
1069      * Entries are joined to one block.
1070      * @param dlt Pointer to ringbuffer structure
1071      * @param data1 Pointer to data to be written to ringbuffer
1072      * @param size1 Size of data in bytes to be written to ringbuffer
1073      * @param data2 Pointer to data to be written to ringbuffer
1074      * @param size2 Size of data in bytes to be written to ringbuffer
1075      * @param data3 Pointer to data to be written to ringbuffer
1076      * @param size3 Size of data in bytes to be written to ringbuffer
1077      * @return negative value if there was an error
1078      */
1079         int dlt_buffer_push3(DltBuffer *buf,const unsigned char *data1,unsigned int size1,const unsigned char *data2,unsigned int size2,const unsigned char *data3,unsigned int size3);
1080
1081     /**
1082      * Read one entry from ringbuffer.
1083      * Remove it from ringbuffer.
1084      * @param buf Pointer to ringbuffer structure
1085      * @param data Pointer to data read from ringbuffer
1086      * @param max_size Max size of read data in bytes from ringbuffer
1087      * @return size of read data, zero if no data available, negative value if there was an error
1088      */
1089         int dlt_buffer_pull(DltBuffer *buf,unsigned char *data, int max_size);
1090
1091     /**
1092      * Read one entry from ringbuffer.
1093      * Do not remove it from ringbuffer.
1094      * @param buf Pointer to ringbuffer structure
1095      * @param data Pointer to data read from ringbuffer
1096      * @param max_size Max size of read data in bytes from ringbuffer
1097      * @return size of read data, zero if no data available, negative value if there was an error
1098      */
1099         int dlt_buffer_copy(DltBuffer *buf,unsigned char *data, int max_size);
1100
1101     /**
1102      * Remove entry from ringbuffer.
1103      * @param buf Pointer to ringbuffer structure
1104      * @return size of read data, zero if no data available, negative value if there was an error
1105      */
1106         int dlt_buffer_remove(DltBuffer *buf);
1107
1108     /**
1109      * Print information about buffer and log to internal DLT log.
1110      * @param buf Pointer to ringbuffer structure
1111      */
1112         void dlt_buffer_info(DltBuffer *buf);
1113
1114     /**
1115      * Print status of buffer and log to internal DLT log.
1116      * @param buf Pointer to ringbuffer structure
1117      */
1118         void dlt_buffer_status(DltBuffer *buf);
1119
1120     /**
1121      * Get total size in bytes of ringbuffer.
1122      * If buffer is dynamic, max size is returned.
1123      * @param buf Pointer to ringbuffer structure
1124      * @return total size of buffer
1125      */
1126         int dlt_buffer_get_total_size(DltBuffer *buf);
1127
1128     /**
1129      * Get used size in bytes of ringbuffer.
1130      * @param buf Pointer to ringbuffer structure
1131      * @return used size of buffer
1132      */
1133         int dlt_buffer_get_used_size(DltBuffer *buf);
1134
1135     /**
1136      * Get number of entries in ringbuffer.
1137      * @param buf Pointer to ringbuffer structure
1138      * @return number of entries
1139      */
1140         int dlt_buffer_get_message_count(DltBuffer *buf);
1141
1142 #if !defined (__WIN32__)
1143
1144     /**
1145      * Helper function: Setup serial connection
1146      * @param fd File descriptor of serial tty device
1147      * @param speed Serial line speed, as defined in termios.h
1148      * @return negative value if there was an error
1149      */
1150     int dlt_setup_serial(int fd, speed_t speed);
1151
1152     /**
1153      * Helper function: Convert serial line baudrate (as number) to line speed (as defined in termios.h)
1154      * @param baudrate Serial line baudrate (as number)
1155      * @return Serial line speed, as defined in termios.h
1156      */
1157     speed_t dlt_convert_serial_speed(int baudrate);
1158
1159     /**
1160      * Print dlt version and dlt svn version to buffer
1161      * @param buf Pointer to buffer
1162      */
1163     void dlt_get_version(char *buf);
1164
1165     /**
1166     * Print dlt major version to buffer
1167     * @param buf Pointer to buffer
1168     */
1169     void dlt_get_major_version(char *buf);
1170
1171     /**
1172     * Print dlt minor version to buffer
1173     * @param buf Pointer to buffer
1174     */
1175     void dlt_get_minor_version(char *buf);
1176
1177 #endif
1178
1179     /* Function prototypes which should be used only internally */
1180     /*                                                          */
1181
1182     /**
1183      * Common part of initialisation
1184      * @return negative value if there was an error
1185      */
1186     int dlt_init_common(void);
1187
1188     /**
1189      * Return the uptime of the system in 0.1 ms resolution
1190      * @return 0 if there was an error
1191      */
1192     uint32_t dlt_uptime(void);
1193
1194     /**
1195      * Print header of a DLT message
1196      * @param message pointer to structure of organising access to DLT messages
1197      * @param text pointer to a ASCII string, in which the header is written
1198      * @param size maximal size of text buffer
1199      * @param verbose if set to true verbose information is printed out.
1200      * @return negative value if there was an error
1201      */
1202     int dlt_message_print_header(DltMessage *message, char *text, uint32_t size, int verbose);
1203
1204     /**
1205      * Print payload of a DLT message as Hex-Output
1206      * @param message pointer to structure of organising access to DLT messages
1207      * @param text pointer to a ASCII string, in which the output is written
1208      * @param size maximal size of text buffer
1209      * @param verbose if set to true verbose information is printed out.
1210      * @return negative value if there was an error
1211      */
1212     int dlt_message_print_hex(DltMessage *message, char *text, uint32_t size, int verbose);
1213
1214     /**
1215      * Print payload of a DLT message as ASCII-Output
1216      * @param message pointer to structure of organising access to DLT messages
1217      * @param text pointer to a ASCII string, in which the output is written
1218      * @param size maximal size of text buffer
1219      * @param verbose if set to true verbose information is printed out.
1220      * @return negative value if there was an error
1221      */
1222     int dlt_message_print_ascii(DltMessage *message, char *text, uint32_t size, int verbose);
1223
1224     /**
1225      * Print payload of a DLT message as Mixed-Ouput (Hex and ASCII), for plain text output
1226      * @param message pointer to structure of organising access to DLT messages
1227      * @param text pointer to a ASCII string, in which the output is written
1228      * @param size maximal size of text buffer
1229      * @param verbose if set to true verbose information is printed out.
1230      * @return negative value if there was an error
1231      */
1232     int dlt_message_print_mixed_plain(DltMessage *message, char *text, uint32_t size, int verbose);
1233
1234     /**
1235      * Print payload of a DLT message as Mixed-Ouput (Hex and ASCII), for HTML text output
1236      * @param message pointer to structure of organising access to DLT messages
1237      * @param text pointer to a ASCII string, in which the output is written
1238      * @param size maximal size of text buffer
1239      * @param verbose if set to true verbose information is printed out.
1240      * @return negative value if there was an error
1241      */
1242     int dlt_message_print_mixed_html(DltMessage *message, char *text, uint32_t size, int verbose);
1243
1244     /**
1245      * Decode and print a argument of a DLT message
1246      * @param msg pointer to structure of organising access to DLT messages
1247      * @param type_info Type of argument
1248      * @param ptr pointer to pointer to data (pointer to data is changed within this function)
1249      * @param datalength pointer to datalength (datalength is changed within this function)
1250      * @param text pointer to a ASCII string, in which the output is written
1251      * @param textlength maximal size of text buffer
1252      * @param byteLength If argument is a string, and this value is 0 or greater, this value will be taken as string length
1253      * @param verbose if set to true verbose information is printed out.
1254      * @return negative value if there was an error
1255      */
1256     int dlt_message_argument_print(DltMessage *msg,uint32_t type_info,uint8_t **ptr,int32_t *datalength,char *text,int textlength,int byteLength,int verbose);
1257
1258     /**
1259      * Check environment variables.
1260      */
1261         void dlt_check_envvar();
1262
1263 #ifdef __cplusplus
1264 }
1265 #endif
1266
1267 /**
1268   \}
1269 */
1270
1271 #endif /* DLT_COMMON_H */