79 #include <linux/limits.h> 81 #if !defined(_MSC_VER) 86 #if !defined (__WIN32__) && !defined(_MSC_VER) 94 #define PACKED __attribute__((aligned(1),packed)) 97 #if defined (__MSDOS__) || defined (_MSC_VER) 106 #define DLT_SWAP_64(value) ((((uint64_t)DLT_SWAP_32((value)&0xffffffffull))<<32) | (DLT_SWAP_32((value)>>32))) 108 #define DLT_SWAP_16(value) ((((value) >> 8)&0xff) | (((value) << 8)&0xff00)) 109 #define DLT_SWAP_32(value) ((((value) >> 24)&0xff) | (((value) << 8)&0xff0000) | (((value) >> 8)&0xff00) | (((value) << 24)&0xff000000)) 112 #if !defined __USE_BSD 113 #ifndef LITTLE_ENDIAN 114 #define LITTLE_ENDIAN 1234 118 #define BIG_ENDIAN 4321 123 #if !defined __USE_BSD 125 #define BYTE_ORDER LITTLE_ENDIAN 130 #if (BYTE_ORDER==BIG_ENDIAN) 132 #define DLT_HTOBE_16(x) ((x)) 133 #define DLT_HTOLE_16(x) DLT_SWAP_16((x)) 134 #define DLT_BETOH_16(x) ((x)) 135 #define DLT_LETOH_16(x) DLT_SWAP_16((x)) 137 #define DLT_HTOBE_32(x) ((x)) 138 #define DLT_HTOLE_32(x) DLT_SWAP_32((x)) 139 #define DLT_BETOH_32(x) ((x)) 140 #define DLT_LETOH_32(x) DLT_SWAP_32((x)) 142 #define DLT_HTOBE_64(x) ((x)) 143 #define DLT_HTOLE_64(x) DLT_SWAP_64((x)) 144 #define DLT_BETOH_64(x) ((x)) 145 #define DLT_LETOH_64(x) DLT_SWAP_64((x)) 148 #define DLT_HTOBE_16(x) DLT_SWAP_16((x)) 149 #define DLT_HTOLE_16(x) ((x)) 150 #define DLT_BETOH_16(x) DLT_SWAP_16((x)) 151 #define DLT_LETOH_16(x) ((x)) 153 #define DLT_HTOBE_32(x) DLT_SWAP_32((x)) 154 #define DLT_HTOLE_32(x) ((x)) 155 #define DLT_BETOH_32(x) DLT_SWAP_32((x)) 156 #define DLT_LETOH_32(x) ((x)) 158 #define DLT_HTOBE_64(x) DLT_SWAP_64((x)) 159 #define DLT_HTOLE_64(x) ((x)) 160 #define DLT_BETOH_64(x) DLT_SWAP_64((x)) 161 #define DLT_LETOH_64(x) ((x)) 164 #define DLT_ENDIAN_GET_16(htyp,x) ((((htyp) & DLT_HTYP_MSBF)>0)?DLT_BETOH_16(x):DLT_LETOH_16(x)) 165 #define DLT_ENDIAN_GET_32(htyp,x) ((((htyp) & DLT_HTYP_MSBF)>0)?DLT_BETOH_32(x):DLT_LETOH_32(x)) 166 #define DLT_ENDIAN_GET_64(htyp,x) ((((htyp) & DLT_HTYP_MSBF)>0)?DLT_BETOH_64(x):DLT_LETOH_64(x)) 168 #if defined (__WIN32__) || defined (_MSC_VER) 173 #define LOG_WARNING 4 179 #define LOG_DAEMON (3<<3) 192 #define DLT_DAEMON_TCP_PORT 3490 196 #define DLT_FD_INIT -1 199 #define DLT_FD_MINIMUM 3 204 #define DLT_ID_SIZE 4 206 #define DLT_SIZE_WEID DLT_ID_SIZE 207 #define DLT_SIZE_WSID (sizeof(uint32_t)) 208 #define DLT_SIZE_WTMS (sizeof(uint32_t)) 213 #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) ) 216 #if defined (__MSDOS__) || defined (_MSC_VER) 217 #define __func__ __FUNCTION__ 220 #define PRINT_FUNCTION_VERBOSE(_verbose) \ 222 static char _strbuf[255]; \ 226 snprintf(_strbuf, 255, "%s()\n",__func__); \ 227 dlt_log(LOG_INFO, _strbuf); \ 232 #define NULL (char*)0 235 #define DLT_MSG_IS_CONTROL(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \ 236 (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_CONTROL)) 238 #define DLT_MSG_IS_CONTROL_REQUEST(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \ 239 (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_CONTROL) && \ 240 (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin)==DLT_CONTROL_REQUEST)) 242 #define DLT_MSG_IS_CONTROL_RESPONSE(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \ 243 (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_CONTROL) && \ 244 (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin)==DLT_CONTROL_RESPONSE)) 246 #define DLT_MSG_IS_CONTROL_TIME(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \ 247 (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_CONTROL) && \ 248 (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin)==DLT_CONTROL_TIME)) 250 #define DLT_MSG_IS_NW_TRACE(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \ 251 (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_NW_TRACE)) 253 #define DLT_MSG_IS_TRACE_MOST(MSG) ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && \ 254 (DLT_GET_MSIN_MSTP((MSG)->extendedheader->msin)==DLT_TYPE_NW_TRACE) && \ 255 (DLT_GET_MSIN_MTIN((MSG)->extendedheader->msin)==DLT_NW_TRACE_MOST)) 257 #define DLT_MSG_IS_NONVERBOSE(MSG) (!(DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) || \ 258 ((DLT_IS_HTYP_UEH((MSG)->standardheader->htyp)) && (!(DLT_IS_MSIN_VERB((MSG)->extendedheader->msin))))) 264 #define DLT_MESSAGE_BUFFER_NO_OVERFLOW 0x00 265 #define DLT_MESSAGE_BUFFER_OVERFLOW 0x01 270 #define DLT_OUTPUT_HEX 1 271 #define DLT_OUTPUT_ASCII 2 272 #define DLT_OUTPUT_MIXED_FOR_PLAIN 3 273 #define DLT_OUTPUT_MIXED_FOR_HTML 4 274 #define DLT_OUTPUT_ASCII_LIMITED 5 276 #define DLT_FILTER_MAX 30 278 #define DLT_MSG_READ_VALUE(dst,src,length,type) \ 280 if((length<0) || ((length)<((int32_t)sizeof(type)))) \ 283 { dst = *((type*)src);src+=sizeof(type);length-=sizeof(type); } \ 286 #define DLT_MSG_READ_ID(dst,src,length) \ 288 if((length<0) || ((length)<DLT_ID_SIZE)) \ 291 { memcpy(dst,src,DLT_ID_SIZE);src+=DLT_ID_SIZE;length-=DLT_ID_SIZE; } \ 294 #define DLT_MSG_READ_STRING(dst,src,maxlength,length) \ 296 if(((maxlength)<0) || ((length)<0) || ((maxlength)<(length))) \ 297 { maxlength = -1; } \ 299 { memcpy(dst,src,length);dlt_clean_string(dst,length);dst[length]=0; \ 300 src+=length;maxlength-=length; } \ 303 #define DLT_MSG_READ_NULL(src,maxlength,length) \ 305 if(((maxlength)<0) || ((length)<0) || ((maxlength)<(length))) \ 308 { src+=length;maxlength-=length; } \ 311 #define DLT_HEADER_SHOW_NONE 0x0000 312 #define DLT_HEADER_SHOW_TIME 0x0001 313 #define DLT_HEADER_SHOW_TMSTP 0x0002 314 #define DLT_HEADER_SHOW_MSGCNT 0x0004 315 #define DLT_HEADER_SHOW_ECUID 0x0008 316 #define DLT_HEADER_SHOW_APID 0x0010 317 #define DLT_HEADER_SHOW_CTID 0x0020 318 #define DLT_HEADER_SHOW_MSGTYPE 0x0040 319 #define DLT_HEADER_SHOW_MSGSUBTYPE 0x0080 320 #define DLT_HEADER_SHOW_VNVSTATUS 0x0100 321 #define DLT_HEADER_SHOW_NOARG 0x0200 322 #define DLT_HEADER_SHOW_ALL 0xFFFF 325 #define DLT_RCV_NONE 0 326 #define DLT_RCV_SKIP_HEADER (1 << 0) 327 #define DLT_RCV_REMOVE (1 << 1) 332 #define DLT_MOUNT_PATH_MAX 1024 337 #define DLT_ENTRY_MAX 100 342 #ifndef DLT_UNIT_TESTS 343 #define STATIC static 376 }
PACKED DltStorageHeader;
386 }
PACKED DltStandardHeader;
396 }
PACKED DltStandardHeaderExtra;
407 }
PACKED DltExtendedHeader;
427 sizeof(DltStandardHeader)+
sizeof(DltStandardHeaderExtra)+
sizeof(DltExtendedHeader)];
448 }
PACKED DltServiceGetLogInfoRequest;
461 }
PACKED DltServiceSetLogLevel;
471 }
PACKED DltServiceSetDefaultLogLevel;
480 }
PACKED DltServiceSetVerboseMode;
490 }
PACKED DltServiceSetCommunicationInterfaceStatus;
500 }
PACKED DltServiceSetCommunicationMaximumBandwidth;
506 }
PACKED DltServiceResponse;
513 }
PACKED DltServiceGetDefaultLogLevelResponse;
520 uint32_t overflow_counter;
521 }
PACKED DltServiceMessageBufferOverflowResponse;
526 }
PACKED DltServiceGetSoftwareVersion;
534 }
PACKED DltServiceGetSoftwareVersionResponse;
546 }
PACKED DltServiceUnregisterContext;
557 }
PACKED DltServiceConnectionInfo;
568 }
PACKED DltServiceTimezone;
577 }
PACKED DltServiceMarker;
588 }
PACKED DltServiceOfflineLogstorage;
602 }
PACKED DltServiceGetCurrentFilterInfo;
612 }
PACKED DltServicePassiveNodeConnect;
624 }
PACKED DltServicePassiveNodeConnectionInfo;
701 #define DLT_BUFFER_HEAD "SHM" 710 #define DLT_MESSAGE_ERROR_OK 0 711 #define DLT_MESSAGE_ERROR_UNKNOWN -1 712 #define DLT_MESSAGE_ERROR_SIZE -2 713 #define DLT_MESSAGE_ERROR_CONTENT -3 1111 unsigned int to_get,
1112 unsigned int skip_header);
1263 #if !defined (__WIN32__)
DltReturnValue dlt_file_open(DltFile *file, const char *filename, int verbose)
int dlt_message_read(DltMessage *msg, uint8_t *buffer, unsigned int length, int resync, int verbose)
DltReturnValue dlt_file_read_data(DltFile *file, int verbose)
DltReturnValue dlt_buffer_push(DltBuffer *buf, const unsigned char *data, unsigned int size)
int dlt_receiver_receive_socket(DltReceiver *receiver)
DltReturnValue dlt_file_read_header(DltFile *file, int verbose)
DltReturnValue dlt_buffer_init_dynamic(DltBuffer *buf, uint32_t min_size, uint32_t max_size, uint32_t step_size)
int8_t found_serialheader
DltReturnValue dlt_message_print_header(DltMessage *message, char *text, uint32_t size, int verbose)
DltStorageHeader * storageheader
uint32_t dlt_buffer_get_total_size(DltBuffer *buf)
DltReturnValue dlt_filter_save(DltFilter *filter, const char *filename, int verbose)
DltReturnValue dlt_file_message(DltFile *file, int index, int verbose)
DltReturnValue dlt_init_common(void)
void dlt_get_minor_version(char *buf, size_t size)
void dlt_set_id(char *id, const char *text)
void dlt_buffer_info(DltBuffer *buf)
DltReturnValue dlt_file_set_filter(DltFile *file, DltFilter *filter, int verbose)
int dlt_receiver_check_and_get(DltReceiver *receiver, void *dest, unsigned int to_get, unsigned int skip_header)
DltReturnValue dlt_buffer_free_static(DltBuffer *buf)
DltReturnValue dlt_file_read_raw(DltFile *file, int resync, int verbose)
DltReturnValue dlt_file_read_header_raw(DltFile *file, int resync, int verbose)
DltReturnValue dlt_filter_delete(DltFilter *filter, const char *apid, const char *ctid, int verbose)
DltReturnValue dlt_buffer_free_dynamic(DltBuffer *buf)
DltReturnValue dlt_print_mixed_string(char *text, int textlength, uint8_t *ptr, int size, int html)
void dlt_clean_string(char *text, int length)
DltReturnValue dlt_file_read_header_extended(DltFile *file, int verbose)
DltReturnValue dlt_receiver_remove(DltReceiver *receiver, int size)
DltReturnValue dlt_message_filter_check(DltMessage *msg, DltFilter *filter, int verbose)
DltReturnValue dlt_log(int prio, char *s)
DltReturnValue dlt_file_read(DltFile *file, int verbose)
struct sDltMessage DltMessage
DltReturnValue dlt_buffer_init_static_server(DltBuffer *buf, const unsigned char *ptr, uint32_t size)
int dlt_receiver_receive_fd(DltReceiver *receiver)
DltReturnValue dlt_print_hex_string(char *text, int textlength, uint8_t *ptr, int size)
DltReturnValue dlt_filter_init(DltFilter *filter, int verbose)
DltReturnValue dlt_message_init(DltMessage *msg, int verbose)
uint32_t connection_status
DltReturnValue dlt_receiver_move_to_begin(DltReceiver *receiver)
DltExtendedHeader * extendedheader
DltReturnValue dlt_message_print_ascii(DltMessage *message, char *text, uint32_t size, int verbose)
#define DLT_MOUNT_PATH_MAX
DltReturnValue dlt_print_char_string(char **text, int textlength, uint8_t *ptr, int size)
DltReturnValue dlt_buffer_init_static_client(DltBuffer *buf, const unsigned char *ptr, uint32_t size)
int dlt_buffer_copy(DltBuffer *buf, unsigned char *data, int max_size)
static char * service_id[]
int dlt_buffer_get_used_size(DltBuffer *buf)
DltReturnValue dlt_message_set_extraparameters(DltMessage *msg, int verbose)
static char data[kDataSize]
DltReturnValue dlt_set_storageheader(DltStorageHeader *storageheader, const char *ecu)
DltReturnValue dlt_receiver_init(DltReceiver *receiver, int _fd, int _buffersize)
DltReturnValue dlt_filter_free(DltFilter *filter, int verbose)
int dlt_filter_find(DltFilter *filter, const char *apid, const char *ctid, int verbose)
int dlt_mkdir_recursive(const char *dir)
unsigned char buffer[BUFFER_SIZE]
Buffer for dlt file transfer. The size is defined by BUFFER_SIZE.
uint32_t dlt_uptime(void)
void dlt_log_set_filename(const char *filename)
DltReturnValue dlt_filter_load(DltFilter *filter, const char *filename, int verbose)
void dlt_buffer_status(DltBuffer *buf)
const char dltSerialHeader[DLT_ID_SIZE]
uint8_t headerbuffer[sizeof(DltStorageHeader)+sizeof(DltStandardHeader)+sizeof(DltStandardHeaderExtra)+sizeof(DltExtendedHeader)]
int dlt_buffer_remove(DltBuffer *buf)
int dlt_buffer_get_message_count(DltBuffer *buf)
DltStandardHeaderExtra headerextra
DltReturnValue dlt_filter_add(DltFilter *filter, const char *apid, const char *ctid, int verbose)
DltReturnValue dlt_file_init(DltFile *file, int verbose)
DltReturnValue dlt_message_payload(DltMessage *msg, char *text, int textlength, int type, int verbose)
DltReturnValue dlt_message_print_mixed_html(DltMessage *message, char *text, uint32_t size, int verbose)
void dlt_print_id(char *text, const char *id)
DltReturnValue dlt_check_storageheader(DltStorageHeader *storageheader)
char dltFifoBaseDir[PATH_MAX+1]
DltReturnValue dlt_file_free(DltFile *file, int verbose)
DltReturnValue dlt_setup_serial(int fd, speed_t speed)
DltReturnValue dlt_message_argument_print(DltMessage *msg, uint32_t type_info, uint8_t **ptr, int32_t *datalength, char *text, int textlength, int byteLength, int verbose)
DltReturnValue dlt_vnlog(int prio, size_t size, const char *format,...)
DltStandardHeader * standardheader
DltReturnValue dlt_message_free(DltMessage *msg, int verbose)
speed_t dlt_convert_serial_speed(int baudrate)
char dltSerialHeaderChar[DLT_ID_SIZE]
void dlt_print_hex(uint8_t *ptr, int size)
DltReturnValue 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)
void dlt_get_version(char *buf, size_t size)
void dlt_log_set_level(int level)
DltReturnValue dlt_message_header(DltMessage *msg, char *text, int textlength, int verbose)
int dlt_buffer_pull(DltBuffer *buf, unsigned char *data, int max_size)
DltReturnValue dlt_message_print_hex(DltMessage *message, char *text, uint32_t size, int verbose)
DltReturnValue dlt_message_get_extraparameters(DltMessage *msg, int verbose)
DltReturnValue dlt_file_close(DltFile *file, int verbose)
DltReturnValue dlt_vlog(int prio, const char *format,...)
DltReturnValue dlt_message_header_flags(DltMessage *msg, char *text, int textlength, int flags, int verbose)
void dlt_get_major_version(char *buf, size_t size)
DltReturnValue dlt_message_print_mixed_plain(DltMessage *message, char *text, uint32_t size, int verbose)
void dlt_log_init(int mode)
DltReturnValue dlt_receiver_free(DltReceiver *receiver)