a8f10ff7dd68b35f3fdd537b028098238c5e4455
[profile/ivi/dlt-daemon.git] / src / tests / dlt-test-client.c
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-test-client.c
19  * For further information see http://www.genivi.org/.
20  * @licence end@
21  */
22
23
24 /*******************************************************************************
25 **                                                                            **
26 **  SRC-MODULE: dlt-test-client.c                                             **
27 **                                                                            **
28 **  TARGET    : linux                                                         **
29 **                                                                            **
30 **  PROJECT   : DLT                                                           **
31 **                                                                            **
32 **  AUTHOR    : Alexander Wenzel Alexander.AW.Wenzel@bmw.de                   **
33 **              Markus Klein                                                  **
34 **                                                                            **
35 **  PURPOSE   :                                                               **
36 **                                                                            **
37 **  REMARKS   :                                                               **
38 **                                                                            **
39 **  PLATFORM DEPENDANT [yes/no]: yes                                          **
40 **                                                                            **
41 **  TO BE CHANGED BY USER [yes/no]: no                                        **
42 **                                                                            **
43 *******************************************************************************/
44
45 /*******************************************************************************
46 **                      Author Identity                                       **
47 ********************************************************************************
48 **                                                                            **
49 ** Initials     Name                       Company                            **
50 ** --------     -------------------------  ---------------------------------- **
51 **  aw          Alexander Wenzel           BMW                                **
52 **  mk          Markus Klein               Fraunhofer ESK                     **
53 *******************************************************************************/
54
55 /*******************************************************************************
56 **                      Revision Control History                              **
57 *******************************************************************************/
58
59 /*
60  * $LastChangedRevision: 1670 $
61  * $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
62  * $LastChangedBy$
63  Initials    Date         Comment
64  aw          13.01.2010   initial
65  */
66
67 #include <ctype.h>      /* for isprint() */
68 #include <stdlib.h>     /* for atoi() */
69 #include <sys/stat.h>   /* for S_IRUSR, S_IWUSR, S_IRGRP, S_IROTH */
70 #include <fcntl.h>      /* for open() */
71 #include <string.h>     /* for strcmp() */
72 #include <sys/uio.h>    /* for writev() */
73
74 #include "dlt_client.h"
75 #include "dlt_protocol.h"
76 #include "dlt_user.h"
77
78 #define DLT_TESTCLIENT_TEXTBUFSIZE 10024  /* Size of buffer for text output */
79 #define DLT_TESTCLIENT_ECU_ID     "ECU1"
80
81 #define DLT_TESTCLIENT_NUM_TESTS          9
82
83 /* Function prototypes */
84 int dlt_testclient_message_callback(DltMessage *message, void *data);
85
86 typedef struct
87 {
88     int aflag;
89     int sflag;
90     int xflag;
91     int mflag;
92     int vflag;
93     int yflag;
94     char *ovalue;
95     char *fvalue;
96     char *tvalue;
97     char *evalue;
98     int bvalue;
99
100     char ecuid[4];
101     int ohandle;
102
103     DltFile file;
104     DltFilter filter;
105
106     int running_test;
107
108     int test_counter_macro[DLT_TESTCLIENT_NUM_TESTS];
109     int test_counter_function[DLT_TESTCLIENT_NUM_TESTS];
110
111     int tests_passed;
112     int tests_failed;
113
114     int sock;
115 } DltTestclientData;
116
117 /**
118  * Print usage information of tool.
119  */
120 void usage()
121 {
122     char version[255];
123
124     dlt_get_version(version);
125
126     printf("Usage: dlt-test-client [options] hostname/serial_device_name\n");
127     printf("Test against received data from dlt-test-user.\n");
128     printf("%s \n", version);
129     printf("Options:\n");
130     printf("  -a            Print DLT messages; payload as ASCII\n");
131     printf("  -x            Print DLT messages; payload as hex\n");
132     printf("  -m            Print DLT messages; payload as hex and ASCII\n");
133     printf("  -s            Print DLT messages; only headers\n");
134     printf("  -v            Verbose mode\n");
135     printf("  -h            Usage\n");
136     printf("  -y            Serial device mode\n");
137     printf("  -b baudrate   Serial device baudrate (Default: 115200)\n");
138     printf("  -e ecuid      Set ECU ID (Default: ECU1)\n");
139     printf("  -o filename   Output messages in new DLT file\n");
140     printf("  -f filename   Enable filtering of messages\n");
141 }
142
143 /**
144  * Main function of tool.
145  */
146 int main(int argc, char* argv[])
147 {
148     DltClient       dltclient;
149     DltTestclientData dltdata;
150     int c,i;
151     int index;
152
153     /* Initialize dltdata */
154     dltdata.aflag = 0;
155     dltdata.sflag = 0;
156     dltdata.xflag = 0;
157     dltdata.mflag = 0;
158     dltdata.vflag = 0;
159     dltdata.yflag = 0;
160     dltdata.ovalue = 0;
161     dltdata.fvalue = 0;
162     dltdata.evalue = 0;
163     dltdata.bvalue = 0;
164     dltdata.ohandle=-1;
165
166     dltdata.running_test = 0;
167
168     for (i=0;i<DLT_TESTCLIENT_NUM_TESTS;i++)
169     {
170         dltdata.test_counter_macro[i]=0;
171         dltdata.test_counter_function[i]=0;
172     }
173
174     dltdata.tests_passed = 0;
175     dltdata.tests_failed = 0;
176
177     dltdata.sock = -1;
178
179     /* Fetch command line arguments */
180     opterr = 0;
181
182     while ((c = getopt (argc, argv, "vashyxmf:o:e:b:")) != -1)
183     {
184         switch (c)
185         {
186         case 'v':
187         {
188             dltdata.vflag = 1;
189             break;
190         }
191         case 'a':
192         {
193             dltdata.aflag = 1;
194             break;
195         }
196         case 's':
197         {
198             dltdata.sflag = 1;
199             break;
200         }
201         case 'x':
202         {
203             dltdata.xflag = 1;
204             break;
205         }
206         case 'm':
207         {
208             dltdata.mflag = 1;
209             break;
210         }
211         case 'h':
212         {
213             usage();
214             return -1;
215         }
216         case 'y':
217         {
218             dltdata.yflag = 1;
219             break;
220         }
221         case 'f':
222         {
223             dltdata.fvalue = optarg;
224             break;
225         }
226         case 'o':
227         {
228             dltdata.ovalue = optarg;
229             break;
230         }
231         case 'e':
232         {
233             dltdata.evalue = optarg;
234             break;
235         }
236         case 'b':
237         {
238             dltdata.bvalue = atoi(optarg);
239             break;
240         }
241         case '?':
242         {
243             if (optopt == 'o' || optopt == 'f' || optopt == 't')
244             {
245                 fprintf (stderr, "Option -%c requires an argument.\n", optopt);
246             }
247             else if (isprint (optopt))
248             {
249                 fprintf (stderr, "Unknown option `-%c'.\n", optopt);
250             }
251             else
252             {
253                 fprintf (stderr, "Unknown option character `\\x%x'.\n",optopt);
254             }
255             /* unknown or wrong option used, show usage information and terminate */
256             usage();
257             return -1;
258         }
259         default:
260         {
261             abort ();
262             return -1;//for parasoft
263         }
264         }
265     }
266
267     /* Initialize DLT Client */
268     dlt_client_init(&dltclient, dltdata.vflag);
269
270     /* Register callback to be called when message was received */
271     dlt_client_register_message_callback(dlt_testclient_message_callback);
272
273     /* Setup DLT Client structure */
274     dltclient.serial_mode = dltdata.yflag;
275
276     if (dltclient.serial_mode==0)
277     {
278         for (index = optind; index < argc; index++)
279         {
280             dltclient.servIP = argv[index];
281         }
282
283         if (dltclient.servIP == 0)
284         {
285             /* no hostname selected, show usage and terminate */
286             fprintf(stderr,"ERROR: No hostname selected\n");
287             usage();
288             dlt_client_cleanup(&dltclient,dltdata.vflag);
289             return -1;
290         }
291     }
292     else
293     {
294         for (index = optind; index < argc; index++)
295         {
296             dltclient.serialDevice = argv[index];
297         }
298
299         if (dltclient.serialDevice == 0)
300         {
301             /* no serial device name selected, show usage and terminate */
302             fprintf(stderr,"ERROR: No serial device name specified\n");
303             usage();
304             return -1;
305         }
306
307                 dlt_client_setbaudrate(&dltclient,dltdata.bvalue);
308     }
309
310     /* initialise structure to use DLT file */
311     dlt_file_init(&(dltdata.file),dltdata.vflag);
312
313     /* first parse filter file if filter parameter is used */
314     dlt_filter_init(&(dltdata.filter),dltdata.vflag);
315
316     if (dltdata.fvalue)
317     {
318         if (dlt_filter_load(&(dltdata.filter),dltdata.fvalue,dltdata.vflag)<0)
319         {
320             dlt_file_free(&(dltdata.file),dltdata.vflag);
321             return -1;
322         }
323
324         dlt_file_set_filter(&(dltdata.file),&(dltdata.filter),dltdata.vflag);
325     }
326
327     /* open DLT output file */
328     if (dltdata.ovalue)
329     {
330         dltdata.ohandle = open(dltdata.ovalue,O_WRONLY|O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); /* mode: wb */
331
332         if (dltdata.ohandle == -1)
333         {
334             dlt_file_free(&(dltdata.file),dltdata.vflag);
335             fprintf(stderr,"ERROR: Output file %s cannot be opened!\n",dltdata.ovalue);
336             return -1;
337         }
338     }
339
340     if (dltdata.evalue)
341     {
342         dlt_set_id(dltdata.ecuid,dltdata.evalue);
343     }
344     else
345     {
346         dlt_set_id(dltdata.ecuid,DLT_TESTCLIENT_ECU_ID);
347     }
348
349     /* Connect to TCP socket or open serial device */
350     if (dlt_client_connect(&dltclient, dltdata.vflag)!=-1)
351     {
352         dltdata.sock = dltclient.sock;
353
354         /* Dlt Client Main Loop */
355         dlt_client_main_loop(&dltclient, &dltdata, dltdata.vflag);
356
357         /* Dlt Client Cleanup */
358         dlt_client_cleanup(&dltclient,dltdata.vflag);
359     }
360
361     /* dlt-receive cleanup */
362     if (dltdata.ovalue)
363     {
364         close(dltdata.ohandle);
365     }
366
367     dlt_file_free(&(dltdata.file),dltdata.vflag);
368
369     dlt_filter_free(&(dltdata.filter),dltdata.vflag);
370
371     return 0;
372 }
373
374 int dlt_testclient_message_callback(DltMessage *message, void *data)
375 {
376     static char text[DLT_TESTCLIENT_TEXTBUFSIZE];
377     int mtin;
378     DltTestclientData *dltdata;
379
380         uint32_t type_info, type_info_tmp;
381         int16_t length,length_tmp; /* the macro can set this variable to -1 */
382         uint8_t *ptr;
383         int32_t datalength;
384
385         uint32_t id,id_tmp;
386         int slen;
387         int tc_old;
388
389         struct iovec iov[2];
390         int bytes_written;
391
392     if ((message==0) || (data==0))
393     {
394         return -1;
395     }
396
397     dltdata = (DltTestclientData*)data;
398
399     /* prepare storage header */
400     if (DLT_IS_HTYP_WEID(message->standardheader->htyp))
401     {
402         dlt_set_storageheader(message->storageheader,message->headerextra.ecu);
403     }
404     else
405     {
406         dlt_set_storageheader(message->storageheader,dltdata->ecuid);
407     }
408
409     if ((dltdata->fvalue==0) || (dltdata->fvalue && dlt_message_filter_check(message,&(dltdata->filter),dltdata->vflag)==1))
410     {
411
412         dlt_message_header(message,text,sizeof(text),dltdata->vflag);
413         if (dltdata->aflag)
414         {
415             printf("%s ",text);
416         }
417         dlt_message_payload(message,text,sizeof(text),DLT_OUTPUT_ASCII,dltdata->vflag);
418         if (dltdata->aflag)
419         {
420             printf("[%s]\n",text);
421         }
422
423         if (strcmp(text,"Tests starting")==0)
424         {
425             printf("Tests starting\n");
426         }
427
428         /* check test 1m */
429         if (strcmp(text,"Test1: (Macro IF) Test all log levels")==0)
430         {
431             printf("Test1m: (Macro IF) Test all log levels\n");
432             dltdata->running_test = 1;
433             dltdata->test_counter_macro[0] = 0;
434         }
435         else if (strcmp(text,"Test1: (Macro IF) finished")==0)
436         {
437             /* >=4, as "info" is default log level */
438             if (dltdata->test_counter_macro[0]>=4)
439             {
440                 printf("Test1m PASSED\n");
441                 dltdata->tests_passed++;
442             }
443             else
444             {
445                 printf("Test1m FAILED\n");
446                 dltdata->tests_failed++;
447             }
448             dltdata->running_test = 0;
449         }
450         else if (dltdata->running_test==1)
451         {
452             if (DLT_IS_HTYP_UEH(message->standardheader->htyp))
453             {
454                 if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_LOG)
455                 {
456                     mtin=DLT_GET_MSIN_MTIN(message->extendedheader->msin);
457
458                     if (mtin==DLT_LOG_FATAL)
459                     {
460                         dltdata->test_counter_macro[0]++;
461                     }
462                     if (mtin==DLT_LOG_ERROR)
463                     {
464                         dltdata->test_counter_macro[0]++;
465                     }
466                     if (mtin==DLT_LOG_WARN)
467                     {
468                         dltdata->test_counter_macro[0]++;
469                     }
470                     if (mtin==DLT_LOG_INFO)
471                     {
472                         dltdata->test_counter_macro[0]++;
473                     }
474                     if (mtin==DLT_LOG_DEBUG)
475                     {
476                         dltdata->test_counter_macro[0]++;
477                     }
478                     if (mtin==DLT_LOG_VERBOSE)
479                     {
480                         dltdata->test_counter_macro[0]++;
481                     }
482                 }
483             }
484         }
485
486         /* check test 2m */
487         if (strcmp(text,"Test2: (Macro IF) Test all variable types (verbose)")==0)
488         {
489             printf("Test2m: (Macro IF) Test all variable types (verbose)\n");
490             dltdata->running_test = 2;
491             dltdata->test_counter_macro[1] = 0;
492         }
493         else if (strcmp(text,"Test2: (Macro IF) finished")==0)
494         {
495             if (dltdata->test_counter_macro[1]==16)
496             {
497                 printf("Test2m PASSED\n");
498                 dltdata->tests_passed++;
499             }
500             else
501             {
502                 printf("Test2m FAILED\n");
503                 dltdata->tests_failed++;
504             }
505             dltdata->running_test = 0;
506         }
507         else if (dltdata->running_test==2)
508         {
509             /* Verbose */
510             if (!(DLT_MSG_IS_NONVERBOSE(message)))
511             {
512                 type_info=0;
513                 type_info_tmp=0;
514                 length=0;  /* the macro can set this variable to -1 */
515                 length_tmp=0;
516                 ptr = message->databuffer;
517                 datalength = message->datasize;
518
519                 /* Log message */
520                 if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_LOG)
521                 {
522                     if (message->extendedheader->noar>=2)
523                     {
524                         /* get type of first argument: must be string */
525                         DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
526                         type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
527
528                         if (type_info & DLT_TYPE_INFO_STRG)
529                         {
530                             /* skip string */
531                             DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
532                             length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
533
534                             if (length>=0)
535                             {
536                                 ptr+=length;
537                                 datalength-=length;
538
539                                 /* read type of second argument: must be raw */
540                                 DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
541                                 type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
542
543                                 if ((type_info & DLT_TYPE_INFO_STRG) && ((type_info & DLT_TYPE_INFO_SCOD) == DLT_SCOD_ASCII))
544                                 {
545                                     if (datalength==(sizeof(uint16_t)+strlen("Hello world")+1))
546                                     {
547                                         dltdata->test_counter_macro[1]++;
548                                     }
549                                 }
550                                 else if ((type_info & DLT_TYPE_INFO_STRG) && ((type_info & DLT_TYPE_INFO_SCOD) == DLT_SCOD_UTF8))
551                                 {
552                                     if (datalength==(sizeof(uint16_t)+strlen("Hello world")+1))
553                                     {
554                                         dltdata->test_counter_macro[1]++;
555                                     }
556                                 }
557                                 else if (type_info & DLT_TYPE_INFO_BOOL)
558                                 {
559                                     if (datalength==sizeof(uint8_t))
560                                     {
561                                         dltdata->test_counter_macro[1]++;
562                                     }
563                                 }
564                                 else if (type_info & DLT_TYPE_INFO_SINT)
565                                 {
566                                     switch (type_info & DLT_TYPE_INFO_TYLE)
567                                     {
568                                     case DLT_TYLE_8BIT:
569                                     {
570                                         if (datalength==sizeof(int8_t))
571                                         {
572                                             dltdata->test_counter_macro[1]++;
573                                         }
574                                         break;
575                                     }
576                                     case DLT_TYLE_16BIT:
577                                     {
578                                         if (datalength==sizeof(int16_t))
579                                         {
580                                             dltdata->test_counter_macro[1]++;
581                                         }
582                                         break;
583                                     }
584                                     case DLT_TYLE_32BIT:
585                                     {
586                                         if (datalength==sizeof(int32_t))
587                                         {
588                                             dltdata->test_counter_macro[1]++;
589                                         }
590                                         break;
591                                     }
592                                     case DLT_TYLE_64BIT:
593                                     {
594                                         if (datalength==sizeof(int64_t))
595                                         {
596                                             dltdata->test_counter_macro[1]++;
597                                         }
598                                         break;
599                                     }
600                                     case DLT_TYLE_128BIT:
601                                     {
602                                         /* Not tested here */
603                                         break;
604                                     }
605                                     }
606                                 }
607                                 else if (type_info & DLT_TYPE_INFO_UINT)
608                                 {
609                                     switch (type_info & DLT_TYPE_INFO_TYLE)
610                                     {
611                                     case DLT_TYLE_8BIT:
612                                     {
613                                         if (datalength==sizeof(uint8_t))
614                                         {
615                                             dltdata->test_counter_macro[1]++;
616                                         }
617                                         break;
618                                     }
619                                     case DLT_TYLE_16BIT:
620                                     {
621                                         if (datalength==sizeof(uint16_t))
622                                         {
623                                             dltdata->test_counter_macro[1]++;
624                                         }
625                                         break;
626                                     }
627                                     case DLT_TYLE_32BIT:
628                                     {
629                                         if (datalength==sizeof(uint32_t))
630                                         {
631                                             dltdata->test_counter_macro[1]++;
632                                         }
633                                         break;
634                                     }
635                                     case DLT_TYLE_64BIT:
636                                     {
637                                         if (datalength==sizeof(uint64_t))
638                                         {
639                                             dltdata->test_counter_macro[1]++;
640                                         }
641                                         break;
642                                     }
643                                     case DLT_TYLE_128BIT:
644                                     {
645                                         /* Not tested here */
646                                         break;
647                                     }
648                                     }
649                                 }
650                                 else if (type_info & DLT_TYPE_INFO_FLOA)
651                                 {
652                                     switch (type_info & DLT_TYPE_INFO_TYLE)
653                                     {
654                                     case DLT_TYLE_8BIT:
655                                     {
656                                         /* Not tested here */
657                                         break;
658                                     }
659                                     case DLT_TYLE_16BIT:
660                                     {
661                                         /* Not tested here */
662                                         break;
663                                     }
664                                     case DLT_TYLE_32BIT:
665                                     {
666                                         if (datalength==(2*sizeof(float)+sizeof(uint32_t)))
667                                         {
668                                             dltdata->test_counter_macro[1]++;
669                                         }
670                                         break;
671                                     }
672                                     case DLT_TYLE_64BIT:
673                                     {
674                                         if (datalength==(2*sizeof(double)+sizeof(uint32_t)))
675                                         {
676                                             dltdata->test_counter_macro[1]++;
677                                         }
678                                         break;
679                                     }
680                                     case DLT_TYLE_128BIT:
681                                         /* Not tested here */
682                                         break;
683                                     }
684                                 }
685                                 else if (type_info & DLT_TYPE_INFO_RAWD)
686                                 {
687                                     /* Get length */
688                                     DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
689                                     length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
690                                     if ((length==datalength) && (10 == length))
691                                     {
692                                         dltdata->test_counter_macro[1]++;
693                                     }
694                                 }
695                             }
696                         }
697                     }
698                 }
699             }
700         }
701
702         /* check test 3m */
703         if (strcmp(text,"Test3: (Macro IF) Test all variable types (non-verbose)")==0)
704         {
705             printf("Test3m: (Macro IF) Test all variable types (non-verbose)\n");
706             dltdata->running_test = 3;
707             dltdata->test_counter_macro[2]=0;
708         }
709         else if (strcmp(text,"Test3: (Macro IF) finished")==0)
710         {
711             if (dltdata->test_counter_macro[2]==16)
712             {
713                 printf("Test3m PASSED\n");
714                 dltdata->tests_passed++;
715             }
716             else
717             {
718                 printf("Test3m FAILED\n");
719                 dltdata->tests_failed++;
720             }
721             dltdata->running_test = 0;
722         }
723         else if (dltdata->running_test==3)
724         {
725             /* Nonverbose */
726             if (DLT_MSG_IS_NONVERBOSE(message))
727             {
728                 id=0;
729                 id_tmp=0;
730                 ptr = message->databuffer;
731                 datalength = message->datasize;
732                 slen=-1;
733
734                 tc_old=dltdata->test_counter_macro[2];
735
736                 /* Get message id */
737                 DLT_MSG_READ_VALUE(id_tmp,ptr,datalength,uint32_t);
738                 id=DLT_ENDIAN_GET_32(message->standardheader->htyp, id_tmp);
739
740                 /* Length of string */
741                 datalength-=sizeof(uint16_t);
742                 ptr+=sizeof(uint16_t);
743
744                 switch (id)
745                 {
746                 case  1:
747                 {
748                     slen=strlen("string")+1;
749                     datalength-=slen;
750                     ptr+=slen;
751                     if (datalength==sizeof(uint16_t)+strlen("Hello world")+1)
752                     {
753                         dltdata->test_counter_macro[2]++;
754                     }
755                     break;
756                 }
757                 case  2:
758                 {
759                     slen=strlen("utf8")+1;
760                     datalength-=slen;
761                     ptr+=slen;
762                     if (datalength==sizeof(uint16_t)+strlen("Hello world")+1)
763                     {
764                         dltdata->test_counter_macro[2]++;
765                     }
766                     break;
767                 }
768                 case  3:
769                 {
770                     slen=strlen("bool")+1;
771                     datalength-=slen;
772                     ptr+=slen;
773                     if (datalength==sizeof(uint8_t))
774                     {
775                         dltdata->test_counter_macro[2]++;
776                     }
777                     break;
778                 }
779                 case  4:
780                 {
781                     slen=strlen("int")+1;
782                     datalength-=slen;
783                     ptr+=slen;
784                     if (datalength==sizeof(int))
785                     {
786                         dltdata->test_counter_macro[2]++;
787                     }
788                     break;
789                 }
790                 case  5:
791                 {
792                     slen=strlen("int8")+1;
793                     datalength-=slen;
794                     ptr+=slen;
795                     if (datalength==sizeof(int8_t))
796                     {
797                         dltdata->test_counter_macro[2]++;
798                     }
799                     break;
800                 }
801                 case  6:
802                 {
803                     slen=strlen("int16")+1;
804                     datalength-=slen;
805                     ptr+=slen;
806                     if (datalength==sizeof(int16_t))
807                     {
808                         dltdata->test_counter_macro[2]++;
809                     }
810                     break;
811                 }
812                 case  7:
813                 {
814                     slen=strlen("int32")+1;
815                     datalength-=slen;
816                     ptr+=slen;
817                     if (datalength==sizeof(int32_t))
818                     {
819                         dltdata->test_counter_macro[2]++;
820                     }
821                     break;
822                 }
823                 case  8:
824                 {
825                     slen=strlen("int64")+1;
826                     datalength-=slen;
827                     ptr+=slen;
828                     if (datalength==sizeof(int64_t))
829                     {
830                         dltdata->test_counter_macro[2]++;
831                     }
832                     break;
833                 }
834                 case  9:
835                 {
836                     slen=strlen("uint")+1;
837                     datalength-=slen;
838                     ptr+=slen;
839                     if (datalength==sizeof(unsigned int))
840                     {
841                         dltdata->test_counter_macro[2]++;
842                     }
843                     break;
844                 }
845                 case  10:
846                 {
847                     slen=strlen("uint8")+1;
848                     datalength-=slen;
849                     ptr+=slen;
850                     if (datalength==sizeof(uint8_t))
851                     {
852                         dltdata->test_counter_macro[2]++;
853                     }
854                     break;
855                 }
856                 case  11:
857                 {
858                     slen=strlen("uint16")+1;
859                     datalength-=slen;
860                     ptr+=slen;
861                     if (datalength==sizeof(uint16_t))
862                     {
863                         dltdata->test_counter_macro[2]++;
864                     }
865                     break;
866                 }
867                 case 12:
868                 {
869                     slen=strlen("uint32")+1;
870                     datalength-=slen;
871                     ptr+=slen;
872                     if (datalength==sizeof(uint32_t))
873                     {
874                         dltdata->test_counter_macro[2]++;
875                     }
876                     break;
877                 }
878                 case 13:
879                 {
880                     slen=strlen("uint64")+1;
881                     datalength-=slen;
882                     ptr+=slen;
883                     if (datalength==sizeof(uint64_t))
884                     {
885                         dltdata->test_counter_macro[2]++;
886                     }
887                     break;
888                 }
889                 case 14:
890                 {
891                     slen=strlen("float32")+1;
892                     datalength-=slen;
893                     ptr+=slen;
894                     /* 2*, as the min and the max is transfered */
895                     if (datalength==2*sizeof(float))
896                     {
897                         dltdata->test_counter_macro[2]++;
898                     }
899                     break;
900                 }
901                 case 15:
902                 {
903                     slen=strlen("float64")+1;
904                     datalength-=slen;
905                     ptr+=slen;
906                     /* 2*, as the min and the max is transfered */
907                     if (datalength==2*sizeof(double))
908                     {
909                         dltdata->test_counter_macro[2]++;
910                     }
911                     break;
912                 }
913                 case 16:
914                 {
915                     slen=strlen("raw")+1;
916                     datalength-=slen;
917                     ptr+=slen;
918                     datalength-=sizeof(uint16_t);
919                     ptr+=sizeof(uint16_t);
920                     if (datalength==10)
921                     {
922                         dltdata->test_counter_macro[2]++;
923                     }
924                     break;
925                 }
926                 }
927
928                 if ((slen>=0) && (tc_old==dltdata->test_counter_macro[2]))
929                 {
930                     printf("ID=%d, Datalength=%d => Failed!",id,datalength);
931                 }
932             }
933         }
934
935         /* check test 4m */
936         if (strcmp(text,"Test4: (Macro IF) Test different message sizes")==0)
937         {
938             printf("Test4m: (Macro IF) Test different message sizes\n");
939             dltdata->running_test = 4;
940             dltdata->test_counter_macro[3]=0;
941         }
942         else if (strcmp(text,"Test4: (Macro IF) finished")==0)
943         {
944             if (dltdata->test_counter_macro[3]==4)
945             {
946                 printf("Test4m PASSED\n");
947                 dltdata->tests_passed++;
948             }
949             else
950             {
951                 printf("Test4m FAILED\n");
952                 dltdata->tests_failed++;
953             }
954             dltdata->running_test = 0;
955         }
956         else if (dltdata->running_test==4)
957         {
958             /* Extended header */
959             if (DLT_IS_HTYP_UEH(message->standardheader->htyp))
960             {
961                 /* Log message */
962                 if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_LOG)
963                 {
964                     /* Verbose */
965                     if (DLT_IS_MSIN_VERB(message->extendedheader->msin))
966                     {
967                         /* 2 arguments */
968                         if (message->extendedheader->noar==2)
969                         {
970                             /* verbose mode */
971                             type_info=0;
972                             type_info_tmp=0;
973                             length=0;
974                             length_tmp=0; /* the macro can set this variable to -1 */
975
976                             ptr = message->databuffer;
977                             datalength = message->datasize;
978
979                             /* first read the type info of the first argument: must be string */
980                             DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
981                             type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
982
983                             if (type_info & DLT_TYPE_INFO_STRG)
984                             {
985                                 /* skip string */
986                                 DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
987                                 length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
988
989                                 if (length>=0)
990                                 {
991                                     ptr+=length;
992                                     datalength-=length;
993
994                                     /* read type of second argument: must be raw */
995                                     DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
996                                     type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
997
998                                     if (type_info & DLT_TYPE_INFO_RAWD)
999                                     {
1000                                         /* get length of raw data block */
1001                                         DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
1002                                         length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
1003
1004                                         if ((length>=0) && (length==datalength))
1005                                         {
1006                                             //printf("Raw data found in payload, length=");
1007                                             //printf("%d, datalength=%d \n", length, datalength);
1008                                             dltdata->test_counter_macro[3]++;
1009                                         }
1010                                     }
1011                                 }
1012                             }
1013                         }
1014                     }
1015                 }
1016             }
1017         }
1018
1019         /* check test 5m */
1020         if (strcmp(text,"Test5: (Macro IF) Test high-level API")==0)
1021         {
1022             printf("Test5m: (Macro IF) Test high-level API\n");
1023             dltdata->running_test = 5;
1024             dltdata->test_counter_macro[4]=0;
1025         }
1026         else if (strcmp(text,"Test5: (Macro IF) finished")==0)
1027         {
1028             if (dltdata->test_counter_macro[4]==12)
1029             {
1030                 printf("Test5m PASSED\n");
1031                 dltdata->tests_passed++;
1032             }
1033             else
1034             {
1035                 printf("Test5m FAILED\n");
1036                 dltdata->tests_failed++;
1037             }
1038             dltdata->running_test = 0;
1039         }
1040         else if (dltdata->running_test==5)
1041         {
1042             if (strcmp(text,"Next line: DLT_LOG_INT")==0)
1043             {
1044                 dltdata->test_counter_macro[4]++;
1045             }
1046             if (strcmp(text,"-42")==0)
1047             {
1048                 dltdata->test_counter_macro[4]++;
1049             }
1050
1051             if (strcmp(text,"Next line: DLT_LOG_UINT")==0)
1052             {
1053                 dltdata->test_counter_macro[4]++;
1054             }
1055             if (strcmp(text,"42")==0)
1056             {
1057                 dltdata->test_counter_macro[4]++;
1058             }
1059
1060             if (strcmp(text,"Next line: DLT_LOG_STRING")==0)
1061             {
1062                 dltdata->test_counter_macro[4]++;
1063             }
1064             if (strcmp(text,"String output")==0)
1065             {
1066                 dltdata->test_counter_macro[4]++;
1067             }
1068
1069             if (strcmp(text,"Next line: DLT_LOG_RAW")==0)
1070             {
1071                 dltdata->test_counter_macro[4]++;
1072             }
1073             if (strcmp(text,"00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f")==0)
1074             {
1075                 dltdata->test_counter_macro[4]++;
1076             }
1077
1078             if (strcmp(text,"Next line: DLT_LOG_STRING_INT")==0)
1079             {
1080                 dltdata->test_counter_macro[4]++;
1081             }
1082             if (strcmp(text,"String output:  -42")==0)
1083             {
1084                 dltdata->test_counter_macro[4]++;
1085             }
1086
1087             if (strcmp(text,"Next line: DLT_LOG_STRING_UINT")==0)
1088             {
1089                 dltdata->test_counter_macro[4]++;
1090             }
1091             if (strcmp(text,"String output:  42")==0)
1092             {
1093                 dltdata->test_counter_macro[4]++;
1094             }
1095         }
1096
1097         /* check test 6m */
1098         if (strcmp(text,"Test 6: (Macro IF) Test local printing")==0)
1099         {
1100             printf("Test6m: (Macro IF) Test local printing\n");
1101             dltdata->running_test = 6;
1102             dltdata->test_counter_macro[5]=0;
1103         }
1104         else if (strcmp(text,"Test6: (Macro IF) finished")==0)
1105         {
1106             if (dltdata->test_counter_macro[5]==2)
1107             {
1108                 printf("Test6m PASSED\n");
1109                 dltdata->tests_passed++;
1110             }
1111             else
1112             {
1113                 printf("Test6m FAILED\n");
1114                 dltdata->tests_failed++;
1115             }
1116             dltdata->running_test = 0;
1117         }
1118         else if (dltdata->running_test==6)
1119         {
1120                 if (strcmp(text,"Message (visible: locally printed)")==0)
1121                 {
1122                         printf("Message (visible: locally printed)\n");
1123                         dltdata->test_counter_macro[5]++;
1124                 }
1125                 if (strcmp(text,"Message (invisible: not locally printed)")==0)
1126                 {
1127                         printf("Message (invisible: not locally printed)\n");
1128                         dltdata->test_counter_macro[5]++;
1129                 }
1130         }
1131
1132         /* check test 7m */
1133         if (strcmp(text,"Test 7: (Macro IF) Test network trace")==0)
1134         {
1135             printf("Test7m: (Macro IF) Test network trace\n");
1136             dltdata->running_test = 7;
1137             dltdata->test_counter_macro[6]=0;
1138         }
1139         else if (strcmp(text,"Test7: (Macro IF) finished")==0)
1140         {
1141             if (dltdata->test_counter_macro[6]==8)
1142             {
1143                 printf("Test7m PASSED\n");
1144                 dltdata->tests_passed++;
1145             }
1146             else
1147             {
1148                 printf("Test7m FAILED\n");
1149                 dltdata->tests_failed++;
1150             }
1151             dltdata->running_test = 0;
1152         }
1153         else if (dltdata->running_test==7)
1154         {
1155             if (DLT_IS_HTYP_UEH(message->standardheader->htyp))
1156             {
1157                 if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_NW_TRACE)
1158                 {
1159                     /* Check message type information*/
1160                     /* Each correct message type increases the counter by 1 */
1161                     mtin=DLT_GET_MSIN_MTIN(message->extendedheader->msin);
1162
1163                     if (mtin==DLT_NW_TRACE_IPC)
1164                     {
1165                                                 dltdata->test_counter_macro[6]++;
1166                     }
1167                     if (mtin==DLT_NW_TRACE_CAN)
1168                     {
1169                         dltdata->test_counter_macro[6]++;
1170                     }
1171                     if (mtin==DLT_NW_TRACE_FLEXRAY)
1172                     {
1173                         dltdata->test_counter_macro[6]++;
1174                     }
1175                     if (mtin==DLT_NW_TRACE_MOST)
1176                     {
1177                         dltdata->test_counter_macro[6]++;
1178                     }
1179
1180                     /* Check payload, must be two arguments (2 raw data blocks) */
1181                     /* If the payload is correct, the counter is increased by 1 */
1182                     if (message->extendedheader->noar==2)
1183                     {
1184                         /* verbose mode */
1185                         type_info=0;
1186                         type_info_tmp=0;
1187                         length=0,length_tmp=0; /* the macro can set this variable to -1 */
1188
1189                         ptr = message->databuffer;
1190                         datalength = message->datasize;
1191
1192                         /* first read the type info of the first argument: must be string */
1193                         DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
1194                         type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
1195
1196                         if (type_info & DLT_TYPE_INFO_RAWD)
1197                         {
1198                             /* skip string */
1199                             DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
1200                             length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
1201
1202                             if (length>=0)
1203                             {
1204                                 ptr+=length;
1205                                 datalength-=length;
1206
1207                                 /* read type of second argument: must be raw */
1208                                 DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
1209                                 type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
1210
1211                                 if (type_info & DLT_TYPE_INFO_RAWD)
1212                                 {
1213                                     /* get length of raw data block */
1214                                     DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
1215                                     length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
1216
1217                                     if ((length>=0) && (length==datalength))
1218                                     {
1219                                         //printf("Raw data found in payload, length=");
1220                                         //printf("%d, datalength=%d \n", length, datalength);
1221                                         dltdata->test_counter_macro[6]++;
1222                                     }
1223                                 }
1224                             }
1225                         }
1226                     }
1227                 }
1228             }
1229         }
1230
1231         /* check test 8m */
1232         if (strcmp(text,"Test 8: (Macro IF) Test truncated network trace")==0)
1233         {
1234             printf("Test8m: (Macro IF) Test truncated network trace\n");
1235             dltdata->running_test = 8;
1236             dltdata->test_counter_macro[7]=0;
1237         }
1238         else if (strcmp(text,"Test8: (Macro IF) finished")==0)
1239         {
1240             if (dltdata->test_counter_macro[7]==20)
1241             {
1242                 printf("Test8m PASSED\n");
1243                 dltdata->tests_passed++;
1244             }
1245             else
1246             {
1247                 printf("Test8m FAILED\n");
1248                 dltdata->tests_failed++;
1249             }
1250             dltdata->running_test = 0;
1251         }
1252         else if (dltdata->running_test==8)
1253         {
1254             if (DLT_IS_HTYP_UEH(message->standardheader->htyp))
1255             {
1256                 if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_NW_TRACE)
1257                 {
1258                     /* Check message type information*/
1259                     /* Each correct message type increases the counter by 1 */
1260                     mtin=DLT_GET_MSIN_MTIN(message->extendedheader->msin);
1261
1262                     if (mtin==DLT_NW_TRACE_IPC)
1263                     {
1264                                                 dltdata->test_counter_macro[7]++;
1265                     }
1266                     if (mtin==DLT_NW_TRACE_CAN)
1267                     {
1268                                                 dltdata->test_counter_macro[7]++;
1269                     }
1270                     if (mtin==DLT_NW_TRACE_FLEXRAY)
1271                     {
1272                         dltdata->test_counter_macro[7]++;
1273                     }
1274                     if (mtin==DLT_NW_TRACE_MOST)
1275                     {
1276                         dltdata->test_counter_macro[7]++;
1277                     }
1278
1279                     /* Check payload, must be two arguments (2 raw data blocks) */
1280                     /* If the payload is correct, the counter is increased by 1 */
1281                     if (message->extendedheader->noar==4)
1282                     {
1283                         type_info=0;
1284                         type_info_tmp=0;
1285                         length=0,length_tmp=0; /* the macro can set this variable to -1 */
1286
1287                         ptr = message->databuffer;
1288                         datalength = message->datasize;
1289
1290                         DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
1291                         type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
1292                         if(type_info & DLT_TYPE_INFO_STRG)
1293                         {
1294                                 // Read NWTR
1295                                 char chdr[10];
1296                             DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
1297                             length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
1298                             DLT_MSG_READ_STRING(chdr, ptr, datalength, length);
1299
1300                             if(strcmp((char *)chdr, "NWTR")==0)
1301                             {
1302                                 dltdata->test_counter_macro[7]++;
1303                             }
1304
1305                             DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
1306                             type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
1307                             if(type_info & DLT_TYPE_INFO_RAWD)
1308                             {
1309                                 char hdr[2048];
1310                                 DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
1311                                 length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
1312                                 DLT_MSG_READ_STRING(hdr, ptr, datalength, length);
1313
1314                                 if(length == 16 && hdr[15] == 15)
1315                                 {
1316                                         dltdata->test_counter_macro[7]++;
1317                                 }
1318
1319                                 DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
1320                                 type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
1321                                 if(type_info & DLT_TYPE_INFO_UINT)
1322                                 {
1323                                         uint16_t orig_size;
1324                                     DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
1325                                     orig_size=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
1326                                     if(orig_size == 1024*5)
1327                                     {
1328                                         dltdata->test_counter_macro[7]++;
1329                                     }
1330
1331                                     DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
1332                                     type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
1333                                     if(type_info & DLT_TYPE_INFO_RAWD)
1334                                     {
1335                                         DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
1336                                         length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
1337                                         // Size of the truncated message after headers
1338                                         if(length == 2003)
1339                                         {
1340                                                 dltdata->test_counter_macro[7]++;
1341                                         }
1342                                     }
1343                                 }
1344                             }
1345                         }
1346                     }
1347                 }
1348             }
1349         }
1350
1351
1352         /* check test 9m */
1353         if (strcmp(text,"Test 9: (Macro IF) Test segmented network trace")==0)
1354         {
1355             printf("Test9m: (Macro IF) Test segmented network trace\n");
1356             dltdata->running_test = 9;
1357             dltdata->test_counter_macro[8]=0;
1358         }
1359         else if (strcmp(text,"Test9: (Macro IF) finished")==0)
1360         {
1361                 /* (Interface types) * (results per packet)*/
1362             if (dltdata->test_counter_macro[8]==4*35)
1363             {
1364                 printf("Test9m PASSED\n");
1365                 dltdata->tests_passed++;
1366             }
1367             else
1368             {
1369                 printf("Test9m FAILED\n");
1370                 dltdata->tests_failed++;
1371             }
1372             dltdata->running_test = 0;
1373         }
1374         else if (dltdata->running_test==9)
1375         {
1376             if (DLT_IS_HTYP_UEH(message->standardheader->htyp))
1377             {
1378                 if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_NW_TRACE)
1379                 {
1380                     /* Check message type information*/
1381                     /* Each correct message type increases the counter by 1 */
1382                     mtin=DLT_GET_MSIN_MTIN(message->extendedheader->msin);
1383
1384                     if (mtin==DLT_NW_TRACE_IPC)
1385                     {
1386                                                 dltdata->test_counter_macro[8]++;
1387                     }
1388                     if (mtin==DLT_NW_TRACE_CAN)
1389                     {
1390                         dltdata->test_counter_macro[8]++;
1391                     }
1392                     if (mtin==DLT_NW_TRACE_FLEXRAY)
1393                     {
1394                         dltdata->test_counter_macro[8]++;
1395                     }
1396                     if (mtin==DLT_NW_TRACE_MOST)
1397                     {
1398                         dltdata->test_counter_macro[8]++;
1399                     }
1400
1401                     /* Payload for first segmented message */
1402                     if (message->extendedheader->noar==6)
1403                     {
1404                         /* verbose mode */
1405                         type_info=0;
1406                         type_info_tmp=0;
1407                         length=0,length_tmp=0; /* the macro can set this variable to -1 */
1408
1409                         ptr = message->databuffer;
1410                         datalength = message->datasize;
1411
1412                         /* NWST */
1413                         DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
1414                         type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
1415                         if(type_info & DLT_TYPE_INFO_STRG)
1416                         {
1417                                 char chdr[10];
1418                             DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
1419                             length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
1420                             DLT_MSG_READ_STRING(chdr, ptr, datalength, length);
1421                             if(strcmp((char *)chdr, "NWST")==0)
1422                             {
1423                                 dltdata->test_counter_macro[8]++;
1424                             }
1425
1426                             /* Streahandle */
1427                             DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
1428                             type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
1429                             if(type_info & DLT_TYPE_INFO_UINT)
1430                             {
1431                                 uint16_t handle;
1432                                 DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
1433                                 handle=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
1434                                 if(handle > 0)
1435                                 {
1436                                         dltdata->test_counter_macro[8]++;
1437                                 }
1438
1439                                 /* Header */
1440                                 DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
1441                                 type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
1442                                 if(type_info & DLT_TYPE_INFO_RAWD)
1443                                 {
1444                                     DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
1445                                     length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
1446
1447                                     // Test packet header size 16
1448                                     if(length == 16)
1449                                     {
1450                                         dltdata->test_counter_macro[8]++;
1451                                     }
1452                                     /* Skip data */
1453                                     ptr+=length;
1454                                     datalength-=length;
1455
1456                                     /* Payload size */
1457                                     DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
1458                                     type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
1459                                     if(type_info & DLT_TYPE_INFO_UINT)
1460                                     {
1461                                         uint16_t pl_sz;
1462                                         DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
1463                                         pl_sz=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
1464
1465                                         // Test packet payload size.
1466                                         if(pl_sz == 5120)
1467                                         {
1468                                                 dltdata->test_counter_macro[8]++;
1469                                         }
1470
1471                                         /* Segmentcount */
1472                                         DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
1473                                         type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
1474                                         if(type_info & DLT_TYPE_INFO_UINT)
1475                                         {
1476                                                 uint16_t scount;
1477                                             DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
1478                                             scount=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
1479
1480                                             /* Test packet segment count 5 */
1481                                             if(scount == 5)
1482                                             {
1483                                                 dltdata->test_counter_macro[8]++;
1484                                             }
1485
1486                                             /* Segment length */
1487                                             DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
1488                                             type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
1489                                             if(type_info & DLT_TYPE_INFO_UINT)
1490                                             {
1491                                                 uint16_t slen;
1492                                                 DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
1493                                                 slen=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
1494                                                 /* Default segment size 1024 */
1495                                                 if(slen == 1024)
1496                                                 {
1497                                                         dltdata->test_counter_macro[8]++;
1498                                                 }
1499                                             }
1500                                         }
1501                                     }
1502                                 }
1503                             }
1504                         }
1505                     }
1506                     /* Data segment */
1507                     else if (message->extendedheader->noar==4)
1508                     {
1509                         /* verbose mode */
1510                         type_info=0;
1511                         type_info_tmp=0;
1512                         length=0,length_tmp=0; /* the macro can set this variable to -1 */
1513
1514                         ptr = message->databuffer;
1515                         datalength = message->datasize;
1516
1517                         /* NWCH */
1518                         DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
1519                         type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
1520                         if(type_info & DLT_TYPE_INFO_STRG)
1521                         {
1522                                 char chdr[10];
1523                             DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
1524                             length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
1525                             DLT_MSG_READ_STRING(chdr, ptr, datalength, length);
1526                             if(strcmp((char *)chdr, "NWCH")==0)
1527                             {
1528                                 dltdata->test_counter_macro[8]++;
1529                             }
1530
1531                             /* handle */
1532                             DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
1533                             type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
1534                             if(type_info & DLT_TYPE_INFO_UINT)
1535                             {
1536                                 uint16_t handle;
1537                                 DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
1538                                 handle=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
1539                                 if(handle > 0)
1540                                 {
1541                                         dltdata->test_counter_macro[8]++;
1542                                 }
1543
1544                                 /* Sequence */
1545                                 DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
1546                                 type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
1547                                 if(type_info & DLT_TYPE_INFO_UINT)
1548                                 {
1549                                     //uint16_t seq;
1550                                     DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
1551                                     //seq=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
1552                                         dltdata->test_counter_macro[8]++;
1553
1554                                     /* Data */
1555                                     DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
1556                                     type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
1557                                     if(type_info & DLT_TYPE_INFO_RAWD)
1558                                     {
1559                                         DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
1560                                         length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
1561
1562                                         // Segment size by default, 1024
1563                                         if(length == 1024)
1564                                         {
1565                                                 dltdata->test_counter_macro[8]++;
1566                                         }
1567                                     }
1568                                 }
1569                             }
1570                         }
1571                     }
1572                     /* End segment */
1573                     else if (message->extendedheader->noar==2)
1574                     {
1575                         /* verbose mode */
1576                         type_info=0;
1577                         type_info_tmp=0;
1578                         length=0,length_tmp=0; /* the macro can set this variable to -1 */
1579
1580                         ptr = message->databuffer;
1581                         datalength = message->datasize;
1582
1583                                                 /* NWEN */
1584                                                 DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
1585                                                 type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
1586                                                 if(type_info & DLT_TYPE_INFO_STRG)
1587                                                 {
1588                                                         char chdr[10];
1589                                                         DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
1590                                                         length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
1591                                                         DLT_MSG_READ_STRING(chdr, ptr, datalength, length);
1592                                                         if(strcmp((char *)chdr, "NWEN")==0)
1593                                                         {
1594                                                                 dltdata->test_counter_macro[8]++;
1595                                                         }
1596
1597                                                         /* handle */
1598                                                         DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
1599                                                         type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
1600                                                         if(type_info & DLT_TYPE_INFO_UINT)
1601                                                         {
1602                                                                 uint16_t handle;
1603                                                                 DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
1604                                                                 handle=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
1605                                                                 if(handle > 0)
1606                                                                 {
1607                                                                         dltdata->test_counter_macro[8]++;
1608                                                                 }
1609                                                         }
1610                         }
1611                     }
1612                 }
1613             }
1614         }
1615
1616         /* check test 1f */
1617         if (strcmp(text,"Test1: (Function IF) Test all log levels")==0)
1618         {
1619             printf("Test1f: (Function IF) Test all log levels\n");
1620             dltdata->running_test = 10;
1621             dltdata->test_counter_function[0] = 0;
1622         }
1623         else if (strcmp(text,"Test1: (Function IF) finished")==0)
1624         {
1625             /* >=4, as "info" is default log level */
1626             if (dltdata->test_counter_function[0]>=4)
1627             {
1628                 printf("Test1f PASSED\n");
1629                 dltdata->tests_passed++;
1630             }
1631             else
1632             {
1633                 printf("Test1f FAILED\n");
1634                 dltdata->tests_failed++;
1635             }
1636             dltdata->running_test = 0;
1637         }
1638         else if (dltdata->running_test==10)
1639         {
1640             if (DLT_IS_HTYP_UEH(message->standardheader->htyp))
1641             {
1642                 if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_LOG)
1643                 {
1644                     mtin=DLT_GET_MSIN_MTIN(message->extendedheader->msin);
1645
1646                     if (mtin==DLT_LOG_FATAL)
1647                     {
1648                         dltdata->test_counter_function[0]++;
1649                     }
1650                     if (mtin==DLT_LOG_ERROR)
1651                     {
1652                         dltdata->test_counter_function[0]++;
1653                     }
1654                     if (mtin==DLT_LOG_WARN)
1655                     {
1656                                                 dltdata->test_counter_function[0]++;
1657                     }
1658                     if (mtin==DLT_LOG_INFO)
1659                     {
1660                         dltdata->test_counter_function[0]++;
1661                     }
1662                     if (mtin==DLT_LOG_DEBUG)
1663                     {
1664                         dltdata->test_counter_function[0]++;
1665                     }
1666                     if (mtin==DLT_LOG_VERBOSE)
1667                     {
1668                         dltdata->test_counter_function[0]++;
1669                     }
1670                 }
1671             }
1672         }
1673
1674         /* check test 2f */
1675         if (strcmp(text,"Test2: (Function IF) Test all variable types (verbose)")==0)
1676         {
1677             printf("Test2f: (Function IF) Test all variable types (verbose)\n");
1678             dltdata->running_test = 11;
1679             dltdata->test_counter_function[1] = 0;
1680         }
1681         else if (strcmp(text,"Test2: (Function IF) finished")==0)
1682         {
1683             if (dltdata->test_counter_function[1]==14)
1684             {
1685                 printf("Test2f PASSED\n");
1686                 dltdata->tests_passed++;
1687             }
1688             else
1689             {
1690                 printf("Test2f FAILED\n");
1691                 dltdata->tests_failed++;
1692             }
1693             dltdata->running_test = 0;
1694         }
1695         else if (dltdata->running_test==11)
1696         {
1697             /* Verbose */
1698             if (!(DLT_MSG_IS_NONVERBOSE(message)))
1699             {
1700                 type_info=0;
1701                 type_info_tmp=0;
1702                 length=0;
1703                 length_tmp=0; /* the macro can set this variable to -1 */
1704                 ptr = message->databuffer;
1705                 datalength = message->datasize;
1706
1707                 /* Log message */
1708                 if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_LOG)
1709                 {
1710                     if (message->extendedheader->noar>=2)
1711                     {
1712                         /* get type of first argument: must be string */
1713                         DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
1714                         type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
1715
1716                         if (type_info & DLT_TYPE_INFO_STRG)
1717                         {
1718                             /* skip string */
1719                             DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
1720                             length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
1721
1722                             if (length>=0)
1723                             {
1724                                 ptr+=length;
1725                                 datalength-=length;
1726
1727                                 /* read type of second argument: must be raw */
1728                                 DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
1729                                 type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
1730
1731                                 if (type_info & DLT_TYPE_INFO_BOOL)
1732                                 {
1733                                     if (datalength==sizeof(uint8_t))
1734                                     {
1735                                         dltdata->test_counter_function[1]++;
1736                                     }
1737                                 }
1738                                 else if (type_info & DLT_TYPE_INFO_SINT)
1739                                 {
1740                                     switch (type_info & DLT_TYPE_INFO_TYLE)
1741                                     {
1742                                     case DLT_TYLE_8BIT:
1743                                     {
1744                                         if (datalength==sizeof(int8_t))
1745                                         {
1746                                             dltdata->test_counter_function[1]++;
1747                                         }
1748                                         break;
1749                                     }
1750                                     case DLT_TYLE_16BIT:
1751                                     {
1752                                         if (datalength==sizeof(int16_t))
1753                                         {
1754                                             dltdata->test_counter_function[1]++;
1755                                         }
1756                                         break;
1757                                     }
1758                                     case DLT_TYLE_32BIT:
1759                                     {
1760                                         if (datalength==sizeof(int32_t))
1761                                         {
1762                                             dltdata->test_counter_function[1]++;
1763                                         }
1764                                         break;
1765                                     }
1766                                     case DLT_TYLE_64BIT:
1767                                     {
1768                                         if (datalength==sizeof(int64_t))
1769                                         {
1770                                             dltdata->test_counter_function[1]++;
1771                                         }
1772                                         break;
1773                                     }
1774                                     case DLT_TYLE_128BIT:
1775                                     {
1776                                         /* Not tested here */
1777                                         break;
1778                                     }
1779                                     }
1780                                 }
1781                                 else if (type_info & DLT_TYPE_INFO_UINT)
1782                                 {
1783                                     switch (type_info & DLT_TYPE_INFO_TYLE)
1784                                     {
1785                                     case DLT_TYLE_8BIT:
1786                                     {
1787                                         if (datalength==sizeof(uint8_t))
1788                                         {
1789                                             dltdata->test_counter_function[1]++;
1790                                         }
1791                                         break;
1792                                     }
1793                                     case DLT_TYLE_16BIT:
1794                                     {
1795                                         if (datalength==sizeof(uint16_t))
1796                                         {
1797                                             dltdata->test_counter_function[1]++;
1798                                         }
1799                                         break;
1800                                     }
1801                                     case DLT_TYLE_32BIT:
1802                                     {
1803                                         if (datalength==sizeof(uint32_t))
1804                                         {
1805                                             dltdata->test_counter_function[1]++;
1806                                         }
1807                                         break;
1808                                     }
1809                                     case DLT_TYLE_64BIT:
1810                                     {
1811                                         if (datalength==sizeof(uint64_t))
1812                                         {
1813                                             dltdata->test_counter_function[1]++;
1814                                         }
1815                                         break;
1816                                     }
1817                                     case DLT_TYLE_128BIT:
1818                                     {
1819                                         /* Not tested here */
1820                                         break;
1821                                     }
1822                                     }
1823                                 }
1824                                 else if (type_info & DLT_TYPE_INFO_FLOA)
1825                                 {
1826                                     switch (type_info & DLT_TYPE_INFO_TYLE)
1827                                     {
1828                                     case DLT_TYLE_8BIT:
1829                                     {
1830                                         /* Not tested here */
1831                                         break;
1832                                     }
1833                                     case DLT_TYLE_16BIT:
1834                                     {
1835                                         /* Not tested here */
1836                                         break;
1837                                     }
1838                                     case DLT_TYLE_32BIT:
1839                                     {
1840                                         if (datalength==(2*sizeof(float)+sizeof(uint32_t)))
1841                                         {
1842                                             dltdata->test_counter_function[1]++;
1843                                         }
1844                                         break;
1845                                     }
1846                                     case DLT_TYLE_64BIT:
1847                                     {
1848                                         if (datalength==(2*sizeof(double)+sizeof(uint32_t)))
1849                                         {
1850                                             dltdata->test_counter_function[1]++;
1851                                         }
1852                                         break;
1853                                     }
1854                                     case DLT_TYLE_128BIT:
1855                                     {
1856                                         /* Not tested here */
1857                                         break;
1858                                     }
1859                                     }
1860                                 }
1861                                 else if (type_info & DLT_TYPE_INFO_RAWD)
1862                                 {
1863                                     /* Get length */
1864                                     DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
1865                                     length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
1866                                     if ((length==datalength) && (length==10))
1867                                     {
1868                                         dltdata->test_counter_function[1]++;
1869                                     }
1870                                 }
1871                             }
1872                         }
1873                     }
1874                 }
1875             }
1876         }
1877
1878         /* check test 3f */
1879         if (strcmp(text,"Test3: (Function IF) Test all variable types (non-verbose)")==0)
1880         {
1881             printf("Test3f: (Function IF) Test all variable types (non-verbose)\n");
1882             dltdata->running_test = 12;
1883             dltdata->test_counter_function[2]=0;
1884         }
1885         else if (strcmp(text,"Test3: (Function IF) finished")==0)
1886         {
1887             if (dltdata->test_counter_function[2]==14)
1888             {
1889                 printf("Test3f PASSED\n");
1890                 dltdata->tests_passed++;
1891             }
1892             else
1893             {
1894                 printf("Test3f FAILED\n");
1895                 dltdata->tests_failed++;
1896             }
1897             dltdata->running_test = 0;
1898         }
1899         else if (dltdata->running_test==12)
1900         {
1901             /* Nonverbose */
1902             if (DLT_MSG_IS_NONVERBOSE(message))
1903             {
1904                 id=0;
1905                 id_tmp=0;
1906                 ptr = message->databuffer;
1907                 datalength = message->datasize;
1908                 slen=-1;
1909
1910                 tc_old=dltdata->test_counter_function[2];
1911
1912                 /* Get message id */
1913                 DLT_MSG_READ_VALUE(id_tmp,ptr,datalength,uint32_t);
1914                 id=DLT_ENDIAN_GET_32(message->standardheader->htyp, id_tmp);
1915
1916                 /* Length of string */
1917                 datalength-=sizeof(uint16_t);
1918                 ptr+=sizeof(uint16_t);
1919
1920                 switch (id)
1921                 {
1922                 case  1:
1923                 {
1924                     slen=strlen("bool")+1;
1925                     datalength-=slen;
1926                     ptr+=slen;
1927                     if (datalength==sizeof(uint8_t))
1928                     {
1929                         dltdata->test_counter_function[2]++;
1930                     }
1931                     break;
1932                 }
1933                 case  2:
1934                 {
1935                     slen=strlen("int")+1;
1936                     datalength-=slen;
1937                     ptr+=slen;
1938                     if (datalength==sizeof(int))
1939                     {
1940                         dltdata->test_counter_function[2]++;
1941                     }
1942                     break;
1943                 }
1944                 case  3:
1945                 {
1946                     slen=strlen("int8")+1;
1947                     datalength-=slen;
1948                     ptr+=slen;
1949                     if (datalength==sizeof(int8_t))
1950                     {
1951                         dltdata->test_counter_function[2]++;
1952                     }
1953                     break;
1954                 }
1955                 case  4:
1956                 {
1957                     slen=strlen("int16")+1;
1958                     datalength-=slen;
1959                     ptr+=slen;
1960                     if (datalength==sizeof(int16_t))
1961                     {
1962                         dltdata->test_counter_function[2]++;
1963                     }
1964                     break;
1965                 }
1966                 case  5:
1967                 {
1968                     slen=strlen("int32")+1;
1969                     datalength-=slen;
1970                     ptr+=slen;
1971                     if (datalength==sizeof(int32_t))
1972                     {
1973                         dltdata->test_counter_function[2]++;
1974                     }
1975                     break;
1976                 }
1977                 case  6:
1978                 {
1979                     slen=strlen("int64")+1;
1980                     datalength-=slen;
1981                     ptr+=slen;
1982                     if (datalength==sizeof(int64_t))
1983                     {
1984                         dltdata->test_counter_function[2]++;
1985                     }
1986                     break;
1987                 }
1988                 case  7:
1989                 {
1990                     slen=strlen("uint")+1;
1991                     datalength-=slen;
1992                     ptr+=slen;
1993                     if (datalength==sizeof(unsigned int))
1994                     {
1995                         dltdata->test_counter_function[2]++;
1996                     }
1997                     break;
1998                 }
1999                 case  8:
2000                 {
2001                     slen=strlen("uint8")+1;
2002                     datalength-=slen;
2003                     ptr+=slen;
2004                     if (datalength==sizeof(uint8_t))
2005                     {
2006                         dltdata->test_counter_function[2]++;
2007                     }
2008                     break;
2009                 }
2010                 case  9:
2011                 {
2012                     slen=strlen("uint16")+1;
2013                     datalength-=slen;
2014                     ptr+=slen;
2015                     if (datalength==sizeof(uint16_t))
2016                     {
2017                         dltdata->test_counter_function[2]++;
2018                     }
2019                     break;
2020                 }
2021                 case 10:
2022                 {
2023                     slen=strlen("uint32")+1;
2024                     datalength-=slen;
2025                     ptr+=slen;
2026                     if (datalength==sizeof(uint32_t))
2027                     {
2028                         dltdata->test_counter_function[2]++;
2029                     }
2030                     break;
2031                 }
2032                 case 11:
2033                 {
2034                     slen=strlen("uint64")+1;
2035                     datalength-=slen;
2036                     ptr+=slen;
2037                     if (datalength==sizeof(uint64_t))
2038                     {
2039                         dltdata->test_counter_function[2]++;
2040                     }
2041                     break;
2042                 }
2043                 case 12:
2044                 {
2045                     slen=strlen("float32")+1;
2046                     datalength-=slen;
2047                     ptr+=slen;
2048                     /* 2*, as the min and the max is transfered */
2049                     if (datalength==2*sizeof(float))
2050                     {
2051                         dltdata->test_counter_function[2]++;
2052                     }
2053                     break;
2054                 }
2055                 case 13:
2056                 {
2057                     slen=strlen("float64")+1;
2058                     datalength-=slen;
2059                     ptr+=slen;
2060                     /* 2*, as the min and the max is transfered */
2061                     if (datalength==2*sizeof(double))
2062                     {
2063                         dltdata->test_counter_function[2]++;
2064                     }
2065                     break;
2066                 }
2067                 case 14:
2068                 {
2069                     slen=strlen("raw")+1;
2070                     datalength-=slen;
2071                     ptr+=slen;
2072                     datalength-=sizeof(uint16_t);
2073                     ptr+=sizeof(uint16_t);
2074                     if (datalength==10)
2075                     {
2076                         dltdata->test_counter_function[2]++;
2077                     }
2078                     break;
2079                 }
2080                 }
2081
2082                 if ((slen>=0) && (tc_old==dltdata->test_counter_function[2]))
2083                 {
2084                     printf("ID=%d, Datalength=%d => Failed!",id,datalength);
2085                 }
2086             }
2087         }
2088
2089         /* check test 4f */
2090         if (strcmp(text,"Test4: (Function IF) Test different message sizes")==0)
2091         {
2092             printf("Test4f: (Function IF) Test different message sizes\n");
2093             dltdata->running_test = 13;
2094             dltdata->test_counter_function[3]=0;
2095         }
2096         else if (strcmp(text,"Test4: (Function IF) finished")==0)
2097         {
2098             if (dltdata->test_counter_function[3]==4)
2099             {
2100                 printf("Test4f PASSED\n");
2101                 dltdata->tests_passed++;
2102             }
2103             else
2104             {
2105                 printf("Test4f FAILED\n");
2106                 dltdata->tests_failed++;
2107             }
2108             dltdata->running_test = 0;
2109         }
2110         else if (dltdata->running_test==13)
2111         {
2112             /* Extended header */
2113             if (DLT_IS_HTYP_UEH(message->standardheader->htyp))
2114             {
2115                 /* Log message */
2116                 if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_LOG)
2117                 {
2118                     /* Verbose */
2119                     if (DLT_IS_MSIN_VERB(message->extendedheader->msin))
2120                     {
2121                         /* 2 arguments */
2122                         if (message->extendedheader->noar==2)
2123                         {
2124                             /* verbose mode */
2125                             type_info=0;
2126                             type_info_tmp=0;
2127                             length=0;
2128                             length_tmp=0; /* the macro can set this variable to -1 */
2129
2130                             ptr = message->databuffer;
2131                             datalength = message->datasize;
2132
2133                             /* first read the type info of the first argument: should be string */
2134                             DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
2135                             type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
2136
2137                             if (type_info & DLT_TYPE_INFO_STRG)
2138                             {
2139                                 /* skip string */
2140                                 DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
2141                                 length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
2142
2143                                 if (length>=0)
2144                                 {
2145                                     ptr+=length;
2146                                     datalength-=length;
2147
2148                                     /* read type of second argument: should be raw */
2149                                     DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
2150                                     type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
2151
2152                                     if (type_info & DLT_TYPE_INFO_RAWD)
2153                                     {
2154                                         /* get length of raw data block */
2155                                         DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
2156                                         length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
2157
2158                                         if ((length>=0) && (length==datalength))
2159                                         {
2160                                             //printf("Raw data found in payload, length=");
2161                                             //printf("%d, datalength=%d \n", length, datalength);
2162                                             dltdata->test_counter_function[3]++;
2163                                         }
2164                                     }
2165                                 }
2166                             }
2167                         }
2168                     }
2169                 }
2170             }
2171         }
2172
2173         /* check test 5f */
2174         if (strcmp(text,"Test5: (Function IF) Test high-level API")==0)
2175         {
2176             printf("Test5f: (Function IF) Test high-level API\n");
2177             dltdata->running_test = 14;
2178             dltdata->test_counter_function[4]=0;
2179         }
2180         else if (strcmp(text,"Test5: (Function IF) finished")==0)
2181         {
2182             if (dltdata->test_counter_function[4]==12)
2183             {
2184                 printf("Test5f PASSED\n");
2185                 dltdata->tests_passed++;
2186             }
2187             else
2188             {
2189                 printf("Test5f FAILED\n");
2190                 dltdata->tests_failed++;
2191             }
2192             dltdata->running_test = 0;
2193         }
2194         else if (dltdata->running_test==14)
2195         {
2196             if (strcmp(text,"Next line: dlt_log_int()")==0)
2197             {
2198                 dltdata->test_counter_function[4]++;
2199             }
2200             if (strcmp(text,"-42")==0)
2201             {
2202                 dltdata->test_counter_function[4]++;
2203             }
2204
2205             if (strcmp(text,"Next line: dlt_log_uint()")==0)
2206             {
2207                 dltdata->test_counter_function[4]++;
2208             }
2209             if (strcmp(text,"42")==0)
2210             {
2211                 dltdata->test_counter_function[4]++;
2212             }
2213
2214             if (strcmp(text,"Next line: dlt_log_string()")==0)
2215             {
2216                 dltdata->test_counter_function[4]++;
2217             }
2218             if (strcmp(text,"String output")==0)
2219             {
2220                 dltdata->test_counter_function[4]++;
2221             }
2222
2223             if (strcmp(text,"Next line: dlt_log_raw()")==0)
2224             {
2225                 dltdata->test_counter_function[4]++;
2226             }
2227             if (strcmp(text,"00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f")==0)
2228             {
2229                 dltdata->test_counter_function[4]++;
2230             }
2231
2232             if (strcmp(text,"Next line: dlt_log_string_int()")==0)
2233             {
2234                 dltdata->test_counter_function[4]++;
2235             }
2236             if (strcmp(text,"String output:  -42")==0)
2237             {
2238                 dltdata->test_counter_function[4]++;
2239             }
2240
2241             if (strcmp(text,"Next line: dlt_log_string_uint()")==0)
2242             {
2243                 dltdata->test_counter_function[4]++;
2244             }
2245             if (strcmp(text,"String output:  42")==0)
2246             {
2247                 dltdata->test_counter_function[4]++;
2248             }
2249         }
2250
2251         /* check test 6f */
2252         if (strcmp(text,"Test 6: (Function IF) Test local printing")==0)
2253         {
2254             printf("Test6f: (Function IF) Test local printing\n");
2255             dltdata->running_test = 15;
2256             dltdata->test_counter_function[5]=0;
2257         }
2258         else if (strcmp(text,"Test6: (Function IF) finished")==0)
2259         {
2260             if (dltdata->test_counter_function[5]==2)
2261             {
2262                 printf("Test6f PASSED\n");
2263                 dltdata->tests_passed++;
2264             }
2265             else
2266             {
2267                 printf("Test6f FAILED\n");
2268                 dltdata->tests_failed++;
2269             }
2270             dltdata->running_test = 0;
2271         }
2272         else if (dltdata->running_test==15)
2273         {
2274                 if (strcmp(text,"Message (visible: locally printed)")==0)
2275                 {
2276                         printf("Message (visible: locally printed)\n");
2277                         dltdata->test_counter_function[5]++;
2278                 }
2279                 if (strcmp(text,"Message (invisible: not locally printed)")==0)
2280                 {
2281                         printf("Message (invisible: not locally printed)\n");
2282                         dltdata->test_counter_function[5]++;
2283                 }
2284         }
2285
2286         /* check test 7f */
2287         if (strcmp(text,"Test 7: (Function IF) Test network trace")==0)
2288         {
2289             printf("Test7f: (Function IF) Test network trace\n");
2290             dltdata->running_test = 16;
2291             dltdata->test_counter_function[6]=0;
2292         }
2293         else if (strcmp(text,"Test7: (Function IF) finished")==0)
2294         {
2295             if (dltdata->test_counter_function[6]==8)
2296             {
2297                 printf("Test7f PASSED\n");
2298                 dltdata->tests_passed++;
2299             }
2300             else
2301             {
2302                 printf("Test7f FAILED\n");
2303                 dltdata->tests_failed++;
2304             }
2305             dltdata->running_test = 0;
2306         }
2307         else if (dltdata->running_test==16)
2308         {
2309             if (DLT_IS_HTYP_UEH(message->standardheader->htyp))
2310             {
2311                 if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_NW_TRACE)
2312                 {
2313                     /* Check message type information*/
2314                     /* Each correct message type increases the counter by 1 */
2315                     mtin=DLT_GET_MSIN_MTIN(message->extendedheader->msin);
2316
2317                     if (mtin==DLT_NW_TRACE_IPC)
2318                     {
2319                                                 dltdata->test_counter_function[6]++;
2320                     }
2321                     if (mtin==DLT_NW_TRACE_CAN)
2322                     {
2323                                                 dltdata->test_counter_function[6]++;
2324                     }
2325                     if (mtin==DLT_NW_TRACE_FLEXRAY)
2326                     {
2327                         dltdata->test_counter_function[6]++;
2328                     }
2329                     if (mtin==DLT_NW_TRACE_MOST)
2330                     {
2331                         dltdata->test_counter_function[6]++;
2332                     }
2333
2334                     /* Check payload, must be two arguments (2 raw data blocks) */
2335                     /* If the payload is correct, the counter is increased by 1 */
2336                     if (message->extendedheader->noar==2)
2337                     {
2338                         /* verbose mode */
2339                         type_info=0;
2340                         type_info_tmp=0;
2341                         length=0;
2342                         length_tmp=0; /* the macro can set this variable to -1 */
2343
2344                         ptr = message->databuffer;
2345                         datalength = message->datasize;
2346
2347                         /* first read the type info of the first argument: should be string */
2348                         DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
2349                         type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
2350
2351                         if (type_info & DLT_TYPE_INFO_RAWD)
2352                         {
2353                             /* skip string */
2354                             DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
2355                             length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
2356
2357                             if (length>=0)
2358                             {
2359                                 ptr+=length;
2360                                 datalength-=length;
2361
2362                                 /* read type of second argument: should be raw */
2363                                 DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
2364                                 type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
2365
2366                                 if (type_info & DLT_TYPE_INFO_RAWD)
2367                                 {
2368                                     /* get length of raw data block */
2369                                     DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
2370                                     length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
2371
2372                                     if ((length>=0) && (length==datalength))
2373                                     {
2374                                         //printf("Raw data found in payload, length=");
2375                                         //printf("%d, datalength=%d \n", length, datalength);
2376                                         dltdata->test_counter_function[6]++;
2377                                     }
2378                                 }
2379                             }
2380                         }
2381                     }
2382                 }
2383             }
2384         }
2385
2386         /* check test 8f */
2387         if (strcmp(text,"Test 8: (Function IF) Test truncated network trace")==0)
2388         {
2389             printf("Test8f: (Function IF) Test truncated network trace\n");
2390             dltdata->running_test = 17;
2391             dltdata->test_counter_function[7]=0;
2392         }
2393         else if (strcmp(text,"Test8: (Function IF) finished")==0)
2394         {
2395             if (dltdata->test_counter_function[7]==20)
2396             {
2397                 printf("Test8f PASSED\n");
2398                 dltdata->tests_passed++;
2399             }
2400             else
2401             {
2402                 printf("Test8f FAILED\n");
2403                 dltdata->tests_failed++;
2404             }
2405             dltdata->running_test = 0;
2406         }
2407         else if (dltdata->running_test==17)
2408         {
2409             if (DLT_IS_HTYP_UEH(message->standardheader->htyp))
2410             {
2411                 if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_NW_TRACE)
2412                 {
2413                     /* Check message type information*/
2414                     /* Each correct message type increases the counter by 1 */
2415                     mtin=DLT_GET_MSIN_MTIN(message->extendedheader->msin);
2416
2417                     if (mtin==DLT_NW_TRACE_IPC)
2418                     {
2419                                                 dltdata->test_counter_function[7]++;
2420                     }
2421                     if (mtin==DLT_NW_TRACE_CAN)
2422                     {
2423                                                 dltdata->test_counter_function[7]++;
2424                     }
2425                     if (mtin==DLT_NW_TRACE_FLEXRAY)
2426                     {
2427                         dltdata->test_counter_function[7]++;
2428                     }
2429                     if (mtin==DLT_NW_TRACE_MOST)
2430                     {
2431                         dltdata->test_counter_function[7]++;
2432                     }
2433
2434                     /* Check payload, must be two arguments (2 raw data blocks) */
2435                     /* If the payload is correct, the counter is increased by 1 */
2436                     if (message->extendedheader->noar==4)
2437                     {
2438                         type_info=0;
2439                         type_info_tmp=0;
2440                         length=0,length_tmp=0; /* the macro can set this variable to -1 */
2441
2442                         ptr = message->databuffer;
2443                         datalength = message->datasize;
2444
2445                         DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
2446                         type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
2447                         if(type_info & DLT_TYPE_INFO_STRG)
2448                         {
2449                                 // Read NWTR
2450                                 char chdr[10];
2451                             DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
2452                             length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
2453                             DLT_MSG_READ_STRING(chdr, ptr, datalength, length);
2454
2455                             if(strcmp((char *)chdr, "NWTR")==0)
2456                             {
2457                                 dltdata->test_counter_function[7]++;
2458                             }
2459
2460                             DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
2461                             type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
2462                             if(type_info & DLT_TYPE_INFO_RAWD)
2463                             {
2464                                 char hdr[2048];
2465                                 DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
2466                                 length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
2467                                 DLT_MSG_READ_STRING(hdr, ptr, datalength, length);
2468
2469                                 if(length == 16 && hdr[15] == 15)
2470                                 {
2471                                         dltdata->test_counter_function[7]++;
2472                                 }
2473
2474                                 DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
2475                                 type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
2476                                 if(type_info & DLT_TYPE_INFO_UINT)
2477                                 {
2478                                         uint16_t orig_size;
2479                                     DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
2480                                     orig_size=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
2481                                     if(orig_size == 1024*5)
2482                                     {
2483                                         dltdata->test_counter_function[7]++;
2484                                     }
2485
2486                                     DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
2487                                     type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
2488                                     if(type_info & DLT_TYPE_INFO_RAWD)
2489                                     {
2490                                         DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
2491                                         length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
2492                                         // Size of the truncated message after headers
2493                                         if(length == 2003)
2494                                         {
2495                                                 dltdata->test_counter_function[7]++;
2496                                         }
2497                                     }
2498                                 }
2499                             }
2500                         }
2501                     }
2502                 }
2503             }
2504         }
2505
2506         /* check test 9f */
2507         if (strcmp(text,"Test 9: (Function IF) Test segmented network trace")==0)
2508         {
2509             printf("Test9f: (Function IF) Test segmented network trace\n");
2510             dltdata->running_test = 18;
2511             dltdata->test_counter_function[8]=0;
2512         }
2513         else if (strcmp(text,"Test9: (Function IF) finished")==0)
2514         {
2515                 /* (Interface types) * (number of messages per complete message) */
2516             if (dltdata->test_counter_function[8]==4*35)
2517             {
2518                 printf("Test9f PASSED\n");
2519                 dltdata->tests_passed++;
2520             }
2521             else
2522             {
2523                 printf("Test9f FAILED\n");
2524                 dltdata->tests_failed++;
2525             }
2526             dltdata->running_test = 0;
2527         }
2528         else if (dltdata->running_test==18)
2529         {
2530             if (DLT_IS_HTYP_UEH(message->standardheader->htyp))
2531             {
2532                 if ((DLT_GET_MSIN_MSTP(message->extendedheader->msin))==DLT_TYPE_NW_TRACE)
2533                 {
2534                     /* Check message type information*/
2535                     /* Each correct message type increases the counter by 1 */
2536                     mtin=DLT_GET_MSIN_MTIN(message->extendedheader->msin);
2537
2538                     if (mtin==DLT_NW_TRACE_IPC)
2539                     {
2540                                                 dltdata->test_counter_function[8]++;
2541                     }
2542                     if (mtin==DLT_NW_TRACE_CAN)
2543                     {
2544                         dltdata->test_counter_function[8]++;
2545                     }
2546                     if (mtin==DLT_NW_TRACE_FLEXRAY)
2547                     {
2548                         dltdata->test_counter_function[8]++;
2549                     }
2550                     if (mtin==DLT_NW_TRACE_MOST)
2551                     {
2552                         dltdata->test_counter_function[8]++;
2553                     }
2554
2555                     /* Payload for first segmented message */
2556                     if (message->extendedheader->noar==6)
2557                     {
2558                         /* verbose mode */
2559                         type_info=0;
2560                         type_info_tmp=0;
2561                         length=0,length_tmp=0; /* the macro can set this variable to -1 */
2562
2563                         ptr = message->databuffer;
2564                         datalength = message->datasize;
2565
2566                         /* NWST */
2567                         DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
2568                         type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
2569                         if(type_info & DLT_TYPE_INFO_STRG)
2570                         {
2571                                 char chdr[10];
2572                             DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
2573                             length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
2574                             DLT_MSG_READ_STRING(chdr, ptr, datalength, length);
2575                             if(strcmp((char *)chdr, "NWST")==0)
2576                             {
2577                                 dltdata->test_counter_function[8]++;
2578                             }
2579
2580                             /* Streahandle */
2581                             DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
2582                             type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
2583                             if(type_info & DLT_TYPE_INFO_UINT)
2584                             {
2585                                 uint16_t handle;
2586                                 DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
2587                                 handle=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
2588                                 if(handle > 0)
2589                                 {
2590                                         dltdata->test_counter_function[8]++;
2591                                 }
2592
2593                                 /* Header */
2594                                 DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
2595                                 type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
2596                                 if(type_info & DLT_TYPE_INFO_RAWD)
2597                                 {
2598                                     DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
2599                                     length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
2600
2601                                     // Test packet header size 16
2602                                     if(length == 16)
2603                                     {
2604                                         dltdata->test_counter_function[8]++;
2605                                     }
2606                                     /* Skip data */
2607                                     ptr+=length;
2608                                     datalength-=length;
2609
2610                                     /* Payload size */
2611                                     DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
2612                                     type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
2613                                     if(type_info & DLT_TYPE_INFO_UINT)
2614                                     {
2615                                         uint16_t pl_sz;
2616                                         DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
2617                                         pl_sz=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
2618
2619                                         // Test packet payload size.
2620                                         if(pl_sz == 5120)
2621                                         {
2622                                                 dltdata->test_counter_function[8]++;
2623                                         }
2624
2625                                         /* Segmentcount */
2626                                         DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
2627                                         type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
2628                                         if(type_info & DLT_TYPE_INFO_UINT)
2629                                         {
2630                                                 uint16_t scount;
2631                                             DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
2632                                             scount=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
2633
2634                                             /* Test packet segment count 5 */
2635                                             if(scount == 5)
2636                                             {
2637                                                 dltdata->test_counter_function[8]++;
2638                                             }
2639
2640                                             /* Segment length */
2641                                             DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
2642                                             type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
2643                                             if(type_info & DLT_TYPE_INFO_UINT)
2644                                             {
2645                                                 uint16_t slen;
2646                                                 DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
2647                                                 slen=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
2648                                                 /* Default segment size 1024 */
2649                                                 if(slen == 1024)
2650                                                 {
2651                                                         dltdata->test_counter_function[8]++;
2652                                                 }
2653                                             }
2654                                         }
2655                                     }
2656                                 }
2657                             }
2658                         }
2659                     }
2660                     /* Data segment */
2661                     else if (message->extendedheader->noar==4)
2662                     {
2663                         /* verbose mode */
2664                         type_info=0;
2665                         type_info_tmp=0;
2666                         length=0,length_tmp=0; /* the macro can set this variable to -1 */
2667
2668                         ptr = message->databuffer;
2669                         datalength = message->datasize;
2670
2671                         /* NWCH */
2672                         DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
2673                         type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
2674                         if(type_info & DLT_TYPE_INFO_STRG)
2675                         {
2676                                 char chdr[10];
2677                             DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
2678                             length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
2679                             DLT_MSG_READ_STRING(chdr, ptr, datalength, length);
2680                             if(strcmp((char *)chdr, "NWCH")==0)
2681                             {
2682                                 dltdata->test_counter_function[8]++;
2683                             }
2684
2685                             /* handle */
2686                             DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
2687                             type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
2688                             if(type_info & DLT_TYPE_INFO_UINT)
2689                             {
2690                                 uint16_t handle;
2691                                 DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
2692                                 handle=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
2693                                 if(handle > 0)
2694                                 {
2695                                         dltdata->test_counter_function[8]++;
2696                                 }
2697
2698                                 /* Sequence */
2699                                 DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
2700                                 type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
2701                                 if(type_info & DLT_TYPE_INFO_UINT)
2702                                 {
2703                                         //uint16_t seq;
2704                                     DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
2705                                     //seq=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
2706                                     dltdata->test_counter_function[8]++;
2707
2708                                     /* Data */
2709                                     DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
2710                                     type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
2711                                     if(type_info & DLT_TYPE_INFO_RAWD)
2712                                     {
2713                                         DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
2714                                         length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
2715
2716                                         // Segment size by default, 1024
2717                                         if(length == 1024)
2718                                         {
2719                                                 dltdata->test_counter_function[8]++;
2720                                         }
2721                                     }
2722                                 }
2723                             }
2724                         }
2725                     }
2726                     /* End segment */
2727                     else if (message->extendedheader->noar==2)
2728                     {
2729                         /* verbose mode */
2730                         type_info=0;
2731                         type_info_tmp=0;
2732                         length=0,length_tmp=0; /* the macro can set this variable to -1 */
2733
2734                         ptr = message->databuffer;
2735                         datalength = message->datasize;
2736
2737                                                 /* NWEN */
2738                                                 DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
2739                                                 type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
2740                                                 if(type_info & DLT_TYPE_INFO_STRG)
2741                                                 {
2742                                                         char chdr[10];
2743                                                         DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
2744                                                         length=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
2745                                                         DLT_MSG_READ_STRING(chdr, ptr, datalength, length);
2746                                                         if(strcmp((char *)chdr, "NWEN")==0)
2747                                                         {
2748                                                                 dltdata->test_counter_function[8]++;
2749                                                         }
2750
2751                                                         /* handle */
2752                                                         DLT_MSG_READ_VALUE(type_info_tmp,ptr,datalength,uint32_t);
2753                                                         type_info=DLT_ENDIAN_GET_32(message->standardheader->htyp, type_info_tmp);
2754                                                         if(type_info & DLT_TYPE_INFO_UINT)
2755                                                         {
2756                                                                 uint16_t handle;
2757                                                                 DLT_MSG_READ_VALUE(length_tmp,ptr,datalength,uint16_t);
2758                                                                 handle=DLT_ENDIAN_GET_16(message->standardheader->htyp, length_tmp);
2759                                                                 if(handle > 0)
2760                                                                 {
2761                                                                         dltdata->test_counter_function[8]++;
2762                                                                 }
2763                                                         }
2764                         }
2765                     }
2766                 }
2767             }
2768         }
2769         if (strcmp(text,"Tests finished")==0)
2770         {
2771             printf("Tests finished\n");
2772             dltdata->running_test = 1;
2773
2774             printf("%d tests passed\n",dltdata->tests_passed);
2775             printf("%d tests failed\n",dltdata->tests_failed);
2776
2777             if (dltdata->sock!=-1)
2778             {
2779                 close(dltdata->sock);
2780             }
2781
2782             return 0;
2783         }
2784
2785         /* if no filter set or filter is matching display message */
2786         if (dltdata->xflag)
2787         {
2788             dlt_message_print_hex(message,text,DLT_TESTCLIENT_TEXTBUFSIZE,dltdata->vflag);
2789         }
2790         else if (dltdata->mflag)
2791         {
2792             dlt_message_print_mixed_plain(message,text,DLT_TESTCLIENT_TEXTBUFSIZE,dltdata->vflag);
2793         }
2794         else if (dltdata->sflag)
2795         {
2796             dlt_message_print_header(message,text,sizeof(text),dltdata->vflag);
2797         }
2798
2799         /* if file output enabled write message */
2800         if (dltdata->ovalue)
2801         {
2802             iov[0].iov_base = message->headerbuffer;
2803             iov[0].iov_len = message->headersize;
2804             iov[1].iov_base = message->databuffer;
2805             iov[1].iov_len = message->datasize;
2806
2807             bytes_written = writev(dltdata->ohandle, iov, 2);
2808             if (0 > bytes_written){
2809                     printf("dlt_testclient_message_callback, error in: writev(dltdata->ohandle, iov, 2)\n");
2810                     return -1;
2811             }
2812         }
2813     }
2814
2815     return 0;
2816 }