automotive-dlt
dlt_daemon_common.c
Go to the documentation of this file.
1 /*
2  * @licence app begin@
3  * SPDX license identifier: MPL-2.0
4  *
5  * Copyright (C) 2011-2015, BMW AG
6  *
7  * This file is part of GENIVI Project DLT - Diagnostic Log and Trace.
8  *
9  * This Source Code Form is subject to the terms of the
10  * Mozilla Public License (MPL), v. 2.0.
11  * If a copy of the MPL was not distributed with this file,
12  * You can obtain one at http://mozilla.org/MPL/2.0/.
13  *
14  * For further information see http://www.genivi.org/.
15  * @licence end@
16  */
17 
27 /*******************************************************************************
28 ** **
29 ** SRC-MODULE: dlt_daemon_common.c **
30 ** **
31 ** TARGET : linux **
32 ** **
33 ** PROJECT : DLT **
34 ** **
35 ** AUTHOR : Alexander Wenzel Alexander.AW.Wenzel@bmw.de **
36 ** Markus Klein **
37 ** **
38 ** PURPOSE : **
39 ** **
40 ** REMARKS : **
41 ** **
42 ** PLATFORM DEPENDANT [yes/no]: yes **
43 ** **
44 ** TO BE CHANGED BY USER [yes/no]: no **
45 ** **
46 *******************************************************************************/
47 
48 /*******************************************************************************
49 ** Author Identity **
50 ********************************************************************************
51 ** **
52 ** Initials Name Company **
53 ** -------- ------------------------- ---------------------------------- **
54 ** aw Alexander Wenzel BMW **
55 ** mk Markus Klein Fraunhofer ESK **
56 *******************************************************************************/
57 
58 /*******************************************************************************
59 ** Revision Control History **
60 *******************************************************************************/
61 
62 /*
63  * $LastChangedRevision: 1670 $
64  * $LastChangedDate: 2011-04-08 15:12:06 +0200 (Fr, 08. Apr 2011) $
65  * $LastChangedBy$
66  Initials Date Comment
67  aw 13.01.2010 initial
68  */
69 
70 #include <stdio.h>
71 #include <stdlib.h>
72 #include <string.h>
73 #include <syslog.h>
74 #include <errno.h>
75 #include <unistd.h>
76 #include <fcntl.h>
77 
78 #include <sys/types.h> /* send() */
79 #include <sys/socket.h> /* send() */
80 
81 #include "dlt_types.h"
82 #include "dlt_daemon_common.h"
83 #include "dlt_daemon_common_cfg.h"
84 #include "dlt_user_shared.h"
85 #include "dlt_user_shared_cfg.h"
86 #include "dlt-daemon.h"
87 
88 #include "dlt_daemon_socket.h"
89 #include "dlt_daemon_serial.h"
90 
92 
94 
95 static int dlt_daemon_cmp_apid(const void *m1, const void *m2)
96 {
97  if(m1 == NULL || m2 == NULL)
98  return -1;
99 
102 
103  return memcmp(mi1->apid, mi2->apid, DLT_ID_SIZE);
104 }
105 
106 static int dlt_daemon_cmp_apid_ctid(const void *m1, const void *m2)
107 {
108  if(m1 == NULL || m2 == NULL)
109  return -1;
110 
111  int ret, cmp;
112  DltDaemonContext *mi1 = (DltDaemonContext *) m1;
113  DltDaemonContext *mi2 = (DltDaemonContext *) m2;
114 
115  cmp=memcmp(mi1->apid, mi2->apid, DLT_ID_SIZE);
116  if (cmp<0)
117  {
118  ret=-1;
119  }
120  else if (cmp==0)
121  {
122  ret=memcmp(mi1->ctid, mi2->ctid, DLT_ID_SIZE);
123  }
124  else
125  {
126  ret=1;
127  }
128 
129  return ret;
130 }
131 
132 int dlt_daemon_init(DltDaemon *daemon,unsigned long RingbufferMinSize,unsigned long RingbufferMaxSize,unsigned long RingbufferStepSize,const char *runtime_directory,int InitialContextLogLevel, int InitialContextTraceStatus, int ForceLLTS, int verbose)
133 {
134  PRINT_FUNCTION_VERBOSE(verbose);
135 
136  if (daemon == NULL || runtime_directory == NULL)
137  return -1;
138 
139  int append_length = 0;
140  daemon->num_contexts = 0;
141  daemon->contexts = NULL;
142 
143  daemon->num_applications = 0;
144  daemon->applications = NULL;
145 
146  daemon->default_log_level = InitialContextLogLevel;
147  daemon->default_trace_status = InitialContextTraceStatus;
148  daemon->force_ll_ts = ForceLLTS;
149 
150  daemon->overflow_counter = 0;
151 
152  daemon->runtime_context_cfg_loaded = 0;
153 
154  daemon->mode = DLT_USER_MODE_EXTERNAL;
155 
156  daemon->connectionState = 0; /* no logger connected */
157 
158  daemon->state = DLT_DAEMON_STATE_INIT; /* initial logging state */
159 
160  /* prepare filenames for configuration */
161 
162  append_length = PATH_MAX - sizeof(DLT_RUNTIME_APPLICATION_CFG);
163  if(runtime_directory[0])
164  {
165  strncpy(daemon->runtime_application_cfg,runtime_directory,append_length);
166  daemon->runtime_application_cfg[append_length]=0;
167  }
168  else
169  {
170  strncpy(daemon->runtime_application_cfg,DLT_RUNTIME_DEFAULT_DIRECTORY,append_length);
171  daemon->runtime_application_cfg[append_length]=0;
172  }
173  strcat(daemon->runtime_application_cfg,DLT_RUNTIME_APPLICATION_CFG); /* strcat uncritical here, because max length already checked */
174 
175  append_length = PATH_MAX - sizeof(DLT_RUNTIME_CONTEXT_CFG);
176  if(runtime_directory[0])
177  {
178  strncpy(daemon->runtime_context_cfg,runtime_directory,append_length);
179  daemon->runtime_context_cfg[append_length]=0;
180  }
181  else
182  {
183  strncpy(daemon->runtime_context_cfg,DLT_RUNTIME_DEFAULT_DIRECTORY,append_length);
184  daemon->runtime_context_cfg[append_length]=0;
185  }
186  strcat(daemon->runtime_context_cfg,DLT_RUNTIME_CONTEXT_CFG); /* strcat uncritical here, because max length already checked */
187 
188  append_length = PATH_MAX - sizeof(DLT_RUNTIME_CONFIGURATION);
189  if(runtime_directory[0])
190  {
191  strncpy(daemon->runtime_configuration,runtime_directory,append_length);
192  daemon->runtime_configuration[append_length]=0;
193  }
194  else
195  {
196  strncpy(daemon->runtime_configuration,DLT_RUNTIME_DEFAULT_DIRECTORY,append_length);
197  daemon->runtime_configuration[append_length]=0;
198  }
199  strcat(daemon->runtime_configuration,DLT_RUNTIME_CONFIGURATION); /* strcat uncritical here, because max length already checked */
200 
201  /* Check for runtime cfg, if it is loadable, load it! */
202  if ((dlt_daemon_applications_load(daemon,daemon->runtime_application_cfg, verbose)==0) &&
203  (dlt_daemon_contexts_load(daemon,daemon->runtime_context_cfg, verbose)==0))
204  {
205  daemon->runtime_context_cfg_loaded = 1;
206  }
207 
208  /* load configuration if available */
209  dlt_daemon_configuration_load(daemon,daemon->runtime_configuration, verbose);
210 
211  daemon->sendserialheader = 0;
212  daemon->timingpackets = 0;
213 
214  dlt_set_id(daemon->ecuid,"");
215 
216  /* initialize ring buffer for client connection */
217  snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE,"Ringbuffer configuration: %lu/%lu/%lu\n", RingbufferMinSize,RingbufferMaxSize,RingbufferStepSize );
218  dlt_log(LOG_INFO, str);
219  if (dlt_buffer_init_dynamic(&(daemon->client_ringbuffer), RingbufferMinSize,RingbufferMaxSize,RingbufferStepSize) == DLT_RETURN_ERROR)
220  {
221  return -1;
222  }
223 
224  daemon->storage_handle = NULL;
225  return 0;
226 }
227 
228 int dlt_daemon_free(DltDaemon *daemon, int verbose)
229 {
230  PRINT_FUNCTION_VERBOSE(verbose);
231 
232  if (daemon == NULL)
233  return -1;
234 
235  /* Free contexts */
236  if (dlt_daemon_contexts_clear(daemon, verbose)==-1)
237  return -1;
238 
239  /* Free applications */
240  if (dlt_daemon_applications_clear(daemon, verbose)==-1)
241  return -1;
242 
243  /* free ringbuffer */
245 
246  return 0;
247 }
248 
249 int dlt_daemon_applications_invalidate_fd(DltDaemon *daemon, int fd, int verbose)
250 {
251  int i;
252 
253  PRINT_FUNCTION_VERBOSE(verbose);
254 
255  if (daemon == NULL)
256  return -1;
257 
258  for (i=0; i<daemon->num_applications; i++)
259  {
260  if (daemon->applications[i].user_handle==fd)
261  {
262  daemon->applications[i].user_handle = DLT_FD_INIT;
263  }
264  }
265 
266  return 0;
267 }
268 
269 int dlt_daemon_applications_clear(DltDaemon *daemon, int verbose)
270 {
271  int i;
272 
273  PRINT_FUNCTION_VERBOSE(verbose);
274 
275  if (daemon == NULL)
276  return -1;
277 
278  for (i=0; i<daemon->num_applications; i++)
279  {
280  if (daemon->applications[i].application_description != NULL)
281  {
282  free(daemon->applications[i].application_description);
284  }
285  }
286 
287  if (daemon->applications != NULL)
288  {
289  free(daemon->applications);
290  }
291 
292  daemon->applications = NULL;
293  daemon->num_applications = 0;
294 
295  return 0;
296 }
297 
298 DltDaemonApplication* dlt_daemon_application_add(DltDaemon *daemon, char *apid, pid_t pid, char *description, int verbose)
299 {
300  DltDaemonApplication *application;
302  int new_application;
303  int dlt_user_handle;
304  char filename[DLT_DAEMON_COMMON_TEXTBUFSIZE];
305 
306  if ((daemon == NULL) || (apid == NULL) || (apid[0]=='\0'))
307  {
308  return (DltDaemonApplication*) NULL;
309  }
310 
311  if (daemon->applications == NULL)
312  {
314  if (daemon->applications == NULL)
315  {
316  return (DltDaemonApplication*) NULL;
317  }
318  }
319 
320  new_application=0;
321 
322  /* Check if application [apid] is already available */
323  application = dlt_daemon_application_find(daemon, apid, verbose);
324  if (application == NULL)
325  {
326  daemon->num_applications += 1;
327 
328  if (daemon->num_applications!=0)
329  {
331  {
332  /* allocate memory in steps of DLT_DAEMON_APPL_ALLOC_SIZE, e.g. 100 */
333  old = daemon->applications;
334  daemon->applications = (DltDaemonApplication*) malloc(sizeof(DltDaemonApplication)*
336  if (daemon->applications == NULL)
337  {
338  daemon->applications = old;
339  daemon->num_applications -= 1;
340  return (DltDaemonApplication*) NULL;
341  }
342  memcpy(daemon->applications,old,sizeof(DltDaemonApplication)*daemon->num_applications);
343  free(old);
344  }
345  }
346 
347  application = &(daemon->applications[daemon->num_applications-1]);
348 
349  dlt_set_id(application->apid,apid);
350  application->pid = 0;
351  application->application_description = NULL;
352  application->num_contexts = 0;
353  application->user_handle = DLT_FD_INIT;
354 
355  new_application = 1;
356 
357  } else if (pid != application->pid) {
358 
359  snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE, "Duplicate registration of ApplicationID: '%.4s'; registering from PID %d, existing from PID %d\n",apid, pid, application->pid);
360  dlt_log(LOG_WARNING, str);
361 
362  }
363 
364  /* Store application description and pid of application */
365  if (application->application_description)
366  {
367  free(application->application_description);
368  application->application_description = NULL;
369  }
370 
371  if (description != NULL)
372  {
373  application->application_description = malloc(strlen(description)+1);
374  if (application->application_description)
375  {
376  strncpy(application->application_description,description,strlen(description));
377  application->application_description[strlen(description)]='\0';
378  }
379  }
380 
381  if( application->user_handle != DLT_FD_INIT )
382  {
383  if( application->pid != pid )
384  {
385  if ( close(application->user_handle) < 0 )
386  {
387  snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE, "close() failed to %s/dltpipes/dlt%d, errno=%d (%s)!\n",dltFifoBaseDir,pid,errno,strerror(errno)); /* errno 2: ENOENT - No such file or directory */
388  dlt_log(LOG_WARNING, str);
389  }
390 
391  application->user_handle = DLT_FD_INIT;
392  application->pid = 0;
393  }
394  }
395 
396  /* open user pipe only if it is not yet opened */
397  if (application->user_handle == DLT_FD_INIT && pid != 0)
398  {
399  snprintf(filename,DLT_DAEMON_COMMON_TEXTBUFSIZE,"%s/dltpipes/dlt%d",dltFifoBaseDir,pid);
400 
401  dlt_user_handle = open(filename, O_WRONLY|O_NONBLOCK);
402  if ( dlt_user_handle < 0 )
403  {
404  snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE, "open() failed to %s, errno=%d (%s)!\n",filename,errno,strerror(errno)); /* errno 2: ENOENT - No such file or directory */
405  dlt_log(LOG_WARNING, str);
406  } /* if */
407 
408  /* check if file file descriptor was already used, and make it invalid if it is reused */
409  /* This prevents sending messages to wrong file descriptor */
410  dlt_daemon_applications_invalidate_fd(daemon,dlt_user_handle,verbose);
411  dlt_daemon_contexts_invalidate_fd(daemon,dlt_user_handle,verbose);
412 
413  application->pid = pid;
414  application->user_handle = dlt_user_handle;
415  }
416 
417  /* Sort */
418  if (new_application)
419  {
421 
422  /* Find new position of application with apid*/
423  application = dlt_daemon_application_find(daemon, apid, verbose);
424  }
425 
426  return application;
427 }
428 
429 int dlt_daemon_application_del(DltDaemon *daemon, DltDaemonApplication *application, int verbose)
430 {
431  int pos;
432 
433  PRINT_FUNCTION_VERBOSE(verbose);
434 
435  if ((daemon == NULL) || (application == NULL))
436  {
437  return -1;
438  }
439 
440  if (daemon->num_applications > 0)
441  {
442  /* Check if user handle is open; if yes, close it */
443  if (application->user_handle >= DLT_FD_MINIMUM)
444  {
445  close(application->user_handle);
446  application->user_handle = DLT_FD_INIT;
447  }
448 
449  /* Free description of application to be deleted */
450  if (application->application_description)
451  {
452  free(application->application_description);
453  application->application_description = NULL;
454  }
455 
456  pos = application-(daemon->applications);
457 
458  /* move all applications above pos to pos */
459  memmove(&(daemon->applications[pos]),&(daemon->applications[pos+1]), sizeof(DltDaemonApplication)*((daemon->num_applications-1)-pos));
460 
461  /* Clear last application */
462  memset(&(daemon->applications[daemon->num_applications-1]), 0, sizeof(DltDaemonApplication));
463 
464  daemon->num_applications--;
465 
466  }
467 
468  return 0;
469 }
470 
472 {
473  DltDaemonApplication application;
474 
475  PRINT_FUNCTION_VERBOSE(verbose);
476 
477  if ((daemon == NULL) || (apid == NULL) || (apid[0]=='\0') || (daemon->num_applications==0))
478  {
479  return (DltDaemonApplication*) NULL;
480  }
481 
482  /* Check, if apid is smaller than smallest apid or greater than greatest apid */
483  if ((memcmp(apid,daemon->applications[0].apid, DLT_ID_SIZE) < 0) ||
484  (memcmp(apid,daemon->applications[daemon->num_applications-1].apid, DLT_ID_SIZE) > 0))
485  {
486  return (DltDaemonApplication*) NULL;
487  }
488 
489  dlt_set_id(application.apid, apid);
490  return (DltDaemonApplication*)bsearch(&application, daemon->applications, daemon->num_applications, sizeof(DltDaemonApplication), dlt_daemon_cmp_apid);
491 }
492 
493 int dlt_daemon_applications_load(DltDaemon *daemon, const char *filename, int verbose)
494 {
495  FILE *fd;
496  ID4 apid;
498  char *ret;
499  char *pb;
500 
501  PRINT_FUNCTION_VERBOSE(verbose);
502 
503  if ((daemon == NULL) || (filename == NULL) || (filename[0]=='\0'))
504  return -1;
505 
506  fd=fopen(filename, "r");
507 
508  if (fd == NULL)
509  {
510  snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE, "DLT runtime-application load, cannot open file %s: %s\n", filename, strerror(errno));
511  dlt_log(LOG_WARNING, str);
512 
513  return -1;
514  }
515 
516  while (!feof(fd))
517  {
518  /* Clear buf */
519  memset(buf, 0, sizeof(buf));
520 
521  /* Get line */
522  ret=fgets(buf,sizeof(buf),fd);
523  if (NULL == ret)
524  {
525  /* fgets always null pointer if the last byte of the file is a new line
526  * We need to check here if there was an error or was it feof.*/
527  if(ferror(fd))
528  {
529  snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE, "dlt_daemon_applications_load fgets(buf,sizeof(buf),fd) returned NULL. %s\n",
530  strerror(errno));
531  dlt_log(LOG_WARNING, str);
532  fclose(fd);
533  return -1;
534  }
535  else if(feof(fd))
536  {
537  fclose(fd);
538  return 0;
539  }
540  else {
541  snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE, "dlt_daemon_applications_load fgets(buf,sizeof(buf),fd) returned NULL. Unknown error.\n");
542  dlt_log(LOG_WARNING, str);
543  fclose(fd);
544  return -1;
545  }
546  }
547 
548  if (strcmp(buf,"") != 0)
549  {
550  /* Split line */
551  pb=strtok(buf,":");
552  if(pb != NULL)
553  {
554  dlt_set_id(apid,pb);
555  pb=strtok(NULL,":");
556  if(pb != NULL)
557  {
558  /* pb contains now the description */
559  /* pid is unknown at loading time */
560  if (dlt_daemon_application_add(daemon, apid, 0, pb, verbose) == 0)
561  {
562  dlt_log(LOG_WARNING, "dlt_daemon_applications_load dlt_daemon_application_add failed\n");
563  fclose(fd);
564  return -1;
565  }
566  }
567  }
568  }
569  }
570  fclose(fd);
571 
572  return 0;
573 }
574 
575 int dlt_daemon_applications_save(DltDaemon *daemon, const char *filename, int verbose)
576 {
577  FILE *fd;
578  int i;
579 
580  char apid[DLT_ID_SIZE+1]; /* DLT_ID_SIZE+1, because the 0-termination is required here */
581 
582  PRINT_FUNCTION_VERBOSE(verbose);
583 
584  if ((daemon == NULL) || (filename == NULL) || (filename[0]=='\0'))
585  return -1;
586 
587  memset(apid, 0, sizeof(apid));
588 
589  if ((daemon->applications != NULL) && (daemon->num_applications > 0))
590  {
591  fd=fopen(filename, "w");
592  if (fd != NULL)
593  {
594  for (i=0; i<daemon->num_applications; i++)
595  {
596  dlt_set_id(apid,daemon->applications[i].apid);
597 
598  if ((daemon->applications[i].application_description) &&
599  (daemon->applications[i].application_description[0] != '\0'))
600  {
601  fprintf(fd,"%s:%s:\n",apid, daemon->applications[i].application_description);
602  }
603  else
604  {
605  fprintf(fd,"%s::\n",apid);
606  }
607  }
608  fclose(fd);
609  }
610  }
611 
612  return 0;
613 }
614 
615 DltDaemonContext* dlt_daemon_context_add(DltDaemon *daemon, char *apid, char *ctid,int8_t log_level, int8_t trace_status, int log_level_pos, int user_handle, char *description, int verbose)
616 {
617  DltDaemonApplication *application;
618  DltDaemonContext *context;
619  DltDaemonContext *old;
620  int new_context=0;
621 
622  PRINT_FUNCTION_VERBOSE(verbose);
623 
624  if ((daemon == NULL) || (apid == NULL) || (apid[0]=='\0') || (ctid == NULL) || (ctid[0]=='\0'))
625  {
626  return (DltDaemonContext*) NULL;
627  }
628 
629  if ((log_level<DLT_LOG_DEFAULT) || (log_level>DLT_LOG_VERBOSE))
630  {
631  return (DltDaemonContext*) NULL;
632  }
633 
634  if ((trace_status<DLT_TRACE_STATUS_DEFAULT) || (trace_status>DLT_TRACE_STATUS_ON))
635  {
636  return (DltDaemonContext*) NULL;
637  }
638 
639  if (daemon->contexts == NULL)
640  {
642  if (daemon->contexts == NULL)
643  {
644  return (DltDaemonContext*) NULL;
645  }
646  }
647 
648  /* Check if application [apid] is available */
649  application = dlt_daemon_application_find(daemon, apid, verbose);
650  if (application == NULL)
651  {
652  return (DltDaemonContext*) NULL;
653  }
654 
655  /* Check if context [apid, ctid] is already available */
656  context = dlt_daemon_context_find(daemon, apid, ctid, verbose);
657  if (context == NULL)
658  {
659  daemon->num_contexts += 1;
660 
661  if (daemon->num_contexts!=0)
662  {
664  {
665  /* allocate memory for context in steps of DLT_DAEMON_CONTEXT_ALLOC_SIZE, e.g 100 */
666  old = daemon->contexts;
667  daemon->contexts = (DltDaemonContext*) malloc(sizeof(DltDaemonContext)*
669  if (daemon->contexts == NULL)
670  {
671  daemon->contexts = old;
672  daemon->num_contexts -= 1;
673  return (DltDaemonContext*) NULL;
674  }
675  memcpy(daemon->contexts,old,sizeof(DltDaemonContext)*daemon->num_contexts);
676  free(old);
677  }
678  }
679 
680  context = &(daemon->contexts[daemon->num_contexts-1]);
681 
682  dlt_set_id(context->apid,apid);
683  dlt_set_id(context->ctid,ctid);
684  context->context_description = NULL;
685 
686  application->num_contexts++;
687  new_context =1;
688  }
689 
690  /* Set context description */
691  if (context->context_description)
692  {
693  free(context->context_description);
694  context->context_description = NULL;
695  }
696 
697  if (description != NULL)
698  {
699  context->context_description = malloc(strlen(description)+1);
700 
701  if (context->context_description)
702  {
703  strncpy(context->context_description,description,strlen(description));
704  context->context_description[strlen(description)]='\0';
705  }
706  }
707 
708  if (daemon->force_ll_ts)
709  {
710  if (log_level > daemon->default_log_level)
711  {
712  log_level = daemon->default_log_level;
713  }
714  if (trace_status > daemon->default_trace_status)
715  {
716  trace_status = daemon->default_trace_status;
717  }
718  snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE, "Adapting ll_ts for context: %.4s:%.4s with %i %i\n", apid, ctid, log_level, trace_status);
719  dlt_log(LOG_NOTICE, str);
720  }
721 
722  /* Store log level and trace status,
723  if this is a new context, or
724  if this is an old context and the runtime cfg was not loaded */
725 
726  if ((new_context == 1) ||
727  ((new_context == 0) && (daemon->runtime_context_cfg_loaded == 0)))
728  {
729  context->log_level = log_level;
730  context->trace_status = trace_status;
731  }
732 
733  context->log_level_pos = log_level_pos;
734  context->user_handle = user_handle;
735 
736  /* Sort */
737  if (new_context)
738  {
739  qsort(daemon->contexts,daemon->num_contexts, sizeof(DltDaemonContext),dlt_daemon_cmp_apid_ctid);
740 
741  /* Find new position of context with apid, ctid */
742  context = dlt_daemon_context_find(daemon, apid, ctid, verbose);
743  }
744 
745  return context;
746 }
747 
748 int dlt_daemon_context_del(DltDaemon *daemon, DltDaemonContext* context, int verbose)
749 {
750  int pos;
751  DltDaemonApplication *application;
752 
753  PRINT_FUNCTION_VERBOSE(verbose);
754 
755  if ((daemon == NULL) || (context == NULL))
756  return -1;
757 
758  if (daemon->num_contexts>0)
759  {
760  application = dlt_daemon_application_find(daemon, context->apid, verbose);
761 
762  /* Free description of context to be deleted */
763  if (context->context_description)
764  {
765  free(context->context_description);
766  context->context_description = NULL;
767  }
768 
769  pos = context-(daemon->contexts);
770 
771  /* move all contexts above pos to pos */
772  memmove(&(daemon->contexts[pos]), &(daemon->contexts[pos+1]), sizeof(DltDaemonContext)*((daemon->num_contexts-1)-pos));
773 
774  /* Clear last context */
775  memset(&(daemon->contexts[daemon->num_contexts-1]), 0, sizeof(DltDaemonContext));
776 
777  daemon->num_contexts--;
778 
779  /* Check if application [apid] is available */
780  if (application != NULL)
781  {
782  application->num_contexts--;
783  }
784  }
785 
786  return 0;
787 }
788 
789 DltDaemonContext* dlt_daemon_context_find(DltDaemon *daemon, char *apid, char *ctid, int verbose)
790 {
791  DltDaemonContext context;
792 
793  PRINT_FUNCTION_VERBOSE(verbose);
794 
795  if ((daemon == NULL) || (apid == NULL) || (apid[0]=='\0') || (ctid == NULL) || (ctid[0]=='\0') || (daemon->num_contexts==0))
796  {
797  return (DltDaemonContext*) NULL;
798  }
799 
800  /* Check, if apid is smaller than smallest apid or greater than greatest apid */
801  if ((memcmp(apid,daemon->contexts[0].apid,DLT_ID_SIZE)<0) ||
802  (memcmp(apid,daemon->contexts[daemon->num_contexts-1].apid,DLT_ID_SIZE)>0))
803  {
804  return (DltDaemonContext*) NULL;
805  }
806 
807  dlt_set_id(context.apid,apid);
808  dlt_set_id(context.ctid,ctid);
809 
810  return (DltDaemonContext*)bsearch(&context,daemon->contexts,daemon->num_contexts,sizeof(DltDaemonContext),dlt_daemon_cmp_apid_ctid);
811 }
812 
813 int dlt_daemon_contexts_invalidate_fd(DltDaemon *daemon, int fd, int verbose)
814 {
815  int i;
816 
817  PRINT_FUNCTION_VERBOSE(verbose);
818 
819  if (daemon == NULL)
820  return -1;
821 
822  for (i=0; i<daemon->num_contexts; i++)
823  {
824  if (daemon->contexts[i].user_handle == fd)
825  {
826  daemon->contexts[i].user_handle = DLT_FD_INIT;
827  }
828  }
829 
830  return 0;
831 }
832 
833 int dlt_daemon_contexts_clear(DltDaemon *daemon, int verbose)
834 {
835  int i;
836 
837  PRINT_FUNCTION_VERBOSE(verbose);
838 
839  if (daemon == NULL)
840  return -1;
841 
842  for (i=0; i<daemon->num_contexts; i++)
843  {
844  if (daemon->contexts[i].context_description != NULL)
845  {
846  free(daemon->contexts[i].context_description);
847  daemon->contexts[i].context_description = NULL;
848  }
849  }
850 
851  if (daemon->contexts)
852  {
853  free(daemon->contexts);
854  }
855 
856  daemon->contexts = NULL;
857 
858  for (i=0; i<daemon->num_applications; i++)
859  {
860  daemon->applications[i].num_contexts = 0;
861  }
862 
863  daemon->num_contexts = 0;
864 
865  return 0;
866 }
867 
868 int dlt_daemon_contexts_load(DltDaemon *daemon, const char *filename, int verbose)
869 {
870  FILE *fd;
871  ID4 apid, ctid;
873  char *ret;
874  char *pb;
875  int ll, ts;
876 
877  PRINT_FUNCTION_VERBOSE(verbose);
878 
879  if ((daemon == NULL) || (filename == NULL) ||( filename[0]=='\0'))
880  return -1;
881 
882  fd=fopen(filename, "r");
883 
884  if (fd == NULL)
885  {
886  snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE, "DLT runtime-context load, cannot open file %s: %s\n", filename, strerror(errno));
887  dlt_log(LOG_WARNING, str);
888 
889  return -1;
890  }
891 
892  while (!feof(fd))
893  {
894  /* Clear buf */
895  memset(buf, 0, sizeof(buf));
896 
897  /* Get line */
898  ret=fgets(buf,sizeof(buf),fd);
899  if (NULL == ret)
900  {
901  /* fgets always returns null pointer if the last byte of the file is a new line.
902  * We need to check here if there was an error or was it feof.*/
903  if(ferror(fd))
904  {
905  snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE, "dlt_daemon_contexts_load fgets(buf,sizeof(buf),fd) returned NULL. %s\n",
906  strerror(errno));
907  dlt_log(LOG_WARNING, str);
908  fclose(fd);
909  return -1;
910  }
911  else if(feof(fd))
912  {
913  fclose(fd);
914  return 0;
915  }
916  else {
917  snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE, "dlt_daemon_contexts_load fgets(buf,sizeof(buf),fd) returned NULL. Unknown error.\n");
918  dlt_log(LOG_WARNING, str);
919  fclose(fd);
920  return -1;
921  }
922  }
923 
924  if (strcmp(buf,"")!=0)
925  {
926  /* Split line */
927  pb=strtok(buf,":");
928  if(pb != NULL)
929  {
930  dlt_set_id(apid,pb);
931  pb=strtok(NULL,":");
932  if(pb != NULL)
933  {
934  dlt_set_id(ctid,pb);
935  pb=strtok(NULL,":");
936  if(pb != NULL)
937  {
938  sscanf(pb,"%d",&ll);
939  pb=strtok(NULL,":");
940  if(pb != NULL)
941  {
942  sscanf(pb,"%d",&ts);
943  pb=strtok(NULL,":");
944  if(pb != NULL)
945  {
946  /* pb contains now the description */
947 
948  /* log_level_pos, and user_handle are unknown at loading time */
949  if (dlt_daemon_context_add(daemon, apid, ctid, (int8_t)ll, (int8_t)ts, 0, 0, pb, verbose) == NULL)
950  {
951  dlt_log(LOG_WARNING, "dlt_daemon_contexts_load dlt_daemon_context_add failed\n");
952  fclose(fd);
953  return -1;
954  }
955  }
956  }
957  }
958  }
959  }
960  }
961  }
962  fclose(fd);
963 
964  return 0;
965 }
966 
967 int dlt_daemon_contexts_save(DltDaemon *daemon,const char *filename, int verbose)
968 {
969  FILE *fd;
970  int i;
971 
972  char apid[DLT_ID_SIZE+1], ctid[DLT_ID_SIZE+1]; /* DLT_ID_SIZE+1, because the 0-termination is required here */
973 
974  PRINT_FUNCTION_VERBOSE(verbose);
975 
976  if ((daemon == NULL) || (filename == NULL) || (filename[0]=='\0'))
977  return -1;
978 
979  memset(apid, 0, sizeof(apid));
980  memset(ctid, 0, sizeof(ctid));
981 
982  if ((daemon->contexts) && (daemon->num_contexts > 0))
983  {
984  fd=fopen(filename, "w");
985  if (fd != NULL)
986  {
987  for (i=0; i<daemon->num_contexts; i++)
988  {
989  dlt_set_id(apid,daemon->contexts[i].apid);
990  dlt_set_id(ctid,daemon->contexts[i].ctid);
991 
992  if ((daemon->contexts[i].context_description) &&
993  (daemon->contexts[i].context_description[0]!='\0'))
994  {
995  fprintf(fd,"%s:%s:%d:%d:%s:\n",apid,ctid,
996  (int)(daemon->contexts[i].log_level),
997  (int)(daemon->contexts[i].trace_status),
998  daemon->contexts[i].context_description);
999  }
1000  else
1001  {
1002  fprintf(fd,"%s:%s:%d:%d::\n",apid,ctid,
1003  (int)(daemon->contexts[i].log_level),
1004  (int)(daemon->contexts[i].trace_status));
1005  }
1006  }
1007  fclose(fd);
1008  }
1009  }
1010 
1011  return 0;
1012 }
1013 
1014 int dlt_daemon_configuration_save(DltDaemon *daemon, const char *filename, int verbose)
1015 {
1016  FILE *fd;
1017 
1018  PRINT_FUNCTION_VERBOSE(verbose);
1019 
1020  if ((daemon == NULL) || (filename == NULL) || (filename[0] == '\0'))
1021  return -1;
1022 
1023  fd=fopen(filename, "w");
1024  if (fd != NULL)
1025  {
1026  fprintf(fd,"# 0 = off, 1 = external, 2 = internal, 3 = both\n");
1027  fprintf(fd,"LoggingMode = %d\n",daemon->mode);
1028 
1029  fclose(fd);
1030  }
1031 
1032  return 0;
1033 }
1034 
1035 int dlt_daemon_configuration_load(DltDaemon *daemon, const char *filename, int verbose)
1036 {
1037  if(daemon == NULL || filename == NULL)
1038  return -1;
1039 
1040  FILE * pFile;
1041  char line[1024];
1042  char token[1024];
1043  char value[1024];
1044  char *pch;
1045 
1046  PRINT_FUNCTION_VERBOSE(verbose);
1047 
1048  pFile = fopen (filename,"r");
1049 
1050  if (pFile != NULL)
1051  {
1052  while(1)
1053  {
1054  /* fetch line from configuration file */
1055  if ( fgets (line , 1024 , pFile) != NULL )
1056  {
1057  pch = strtok (line," =\r\n");
1058  token[0]=0;
1059  value[0]=0;
1060 
1061  while (pch != NULL)
1062  {
1063  if(strcmp(pch,"#")==0)
1064  break;
1065 
1066  if(token[0]==0)
1067  {
1068  strncpy(token,pch,sizeof(token)-1);
1069  token[sizeof(token)-1]=0;
1070  }
1071  else
1072  {
1073  strncpy(value,pch,sizeof(value)-1);
1074  value[sizeof(value)-1]=0;
1075  break;
1076  }
1077 
1078  pch = strtok (NULL, " =\r\n");
1079  }
1080 
1081  if(token[0] && value[0])
1082  {
1083  /* parse arguments here */
1084  if(strcmp(token, "LoggingMode") == 0)
1085  {
1086  daemon->mode = atoi(value);
1087  snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE,"Runtime Option: %s=%d\n",token,daemon->mode);
1088  dlt_log(LOG_INFO, str);
1089  }
1090  else
1091  {
1092  snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE,"Unknown option: %s=%s\n",token,value);
1093  dlt_log(LOG_WARNING, str);
1094  }
1095  }
1096  }
1097  else
1098  {
1099  break;
1100  }
1101  }
1102  fclose (pFile);
1103  }
1104  else
1105  {
1106  snprintf(str,DLT_DAEMON_COMMON_TEXTBUFSIZE,"Cannot open configuration file: %s\n",filename);
1107  dlt_log(LOG_WARNING, str);
1108  }
1109 
1110  return 0;
1111 }
1112 
1113 int dlt_daemon_user_send_log_level(DltDaemon *daemon, DltDaemonContext *context, int verbose)
1114 {
1115  DltUserHeader userheader;
1116  DltUserControlMsgLogLevel usercontext;
1117  DltReturnValue ret;
1118 
1119  PRINT_FUNCTION_VERBOSE(verbose);
1120 
1121  if ((daemon == NULL) || (context == NULL))
1122  {
1123  dlt_vlog(LOG_ERR, "NULL parameter in %s", __func__);
1124  return -1;
1125  }
1126 
1128  {
1129  dlt_vlog(LOG_ERR, "Failed to set userheader in %s", __func__);
1130  return -1;
1131  }
1132 
1133  if(context->storage_log_level != DLT_LOG_DEFAULT)
1134  {
1135  usercontext.log_level = context->log_level > context->storage_log_level ? context->log_level:context->storage_log_level;
1136  }
1137  else /* Storage log level is not updated (is DEFAULT) then no device is yet connected so ignore */
1138  {
1139  usercontext.log_level = ((context->log_level == DLT_LOG_DEFAULT)?daemon->default_log_level:context->log_level);
1140  }
1141 
1142  usercontext.trace_status = ((context->trace_status == DLT_TRACE_STATUS_DEFAULT)?daemon->default_trace_status:context->trace_status);
1143 
1144  usercontext.log_level_pos = context->log_level_pos;
1145 
1146  dlt_vlog(LOG_NOTICE, "Send log-level to context: %.4s:%.4s [%i -> %i] [%i -> %i]\n",
1147  context->apid,
1148  context->ctid,
1149  context->log_level,
1150  usercontext.log_level,
1151  context->trace_status,
1152  usercontext.trace_status);
1153 
1154  /* log to FIFO */
1155  errno = 0;
1156  ret = dlt_user_log_out2(context->user_handle,
1157  &(userheader), sizeof(DltUserHeader),
1158  &(usercontext), sizeof(DltUserControlMsgLogLevel));
1159 
1160  if (ret < DLT_RETURN_OK)
1161  {
1162  dlt_vlog(LOG_ERR, "Failed to send data to application in %s: %s",
1163  __func__,
1164  errno != 0 ? strerror(errno) : "Unknown error");
1165 
1166  if (errno == EPIPE)
1167  {
1168  /* Close connection */
1169  close(context->user_handle);
1170  context->user_handle = DLT_FD_INIT;
1171  }
1172  }
1173 
1174  return ((ret == DLT_RETURN_OK) ? DLT_RETURN_OK : DLT_RETURN_ERROR);
1175 }
1176 
1178 {
1179  DltUserHeader userheader;
1180  DltUserControlMsgLogState logstate;
1181  DltReturnValue ret;
1182 
1183  PRINT_FUNCTION_VERBOSE(verbose);
1184 
1185  if ((daemon == NULL) || (app == NULL))
1186  return -1;
1187 
1189  return -1;
1190 
1191  logstate.log_state = daemon->connectionState;
1192 
1193  /* log to FIFO */
1194  ret = dlt_user_log_out2(app->user_handle,
1195  &(userheader), sizeof(DltUserHeader),
1196  &(logstate), sizeof(DltUserControlMsgLogState));
1197 
1198  if (ret < DLT_RETURN_OK)
1199  {
1200  if (errno==EPIPE)
1201  {
1202  /* Close connection */
1203  close(app->user_handle);
1204  app->user_handle=DLT_FD_INIT;
1205  }
1206  }
1207 
1208  return ((ret == DLT_RETURN_OK) ? DLT_RETURN_OK : DLT_RETURN_ERROR);
1209 }
1210 
1211 void dlt_daemon_control_reset_to_factory_default(DltDaemon *daemon,const char *filename, const char *filename1, int InitialContextLogLevel, int InitialContextTraceStatus, int InitialEnforceLlTsStatus, int verbose)
1212 {
1213  FILE *fd;
1214 
1215  PRINT_FUNCTION_VERBOSE(verbose);
1216 
1217  if ((daemon == NULL) || (filename == NULL) || (filename1 == NULL))
1218  {
1219  dlt_log(LOG_WARNING, "Wrong parameter: Null pointer\n");
1220  return;
1221  }
1222 
1223  if ((filename[0] == '\0') || (filename1[0] == '\0'))
1224  {
1225  dlt_log(LOG_WARNING, "Wrong parameter: Empty string\n");
1226  return;
1227  }
1228 
1229  /* Check for runtime cfg file and delete it, if available */
1230  fd=fopen(filename, "r");
1231 
1232  if (fd != NULL)
1233  {
1234  /* Close and delete file */
1235  fclose(fd);
1236  unlink(filename);
1237  }
1238 
1239  fd=fopen(filename1, "r");
1240 
1241  if (fd != NULL)
1242  {
1243  /* Close and delete file */
1244  fclose(fd);
1245  unlink(filename1);
1246  }
1247 
1248  daemon->default_log_level = InitialContextLogLevel;
1249  daemon->default_trace_status = InitialContextTraceStatus;
1250  daemon->force_ll_ts = InitialEnforceLlTsStatus;
1251 
1252  /* Reset all other things (log level, trace status, etc.
1253  to default values */
1254 
1255  /* Inform user libraries about changed default log level/trace status */
1256  dlt_daemon_user_send_default_update(daemon, verbose);
1257 }
1258 
1260 {
1261  int32_t count;
1262  DltDaemonContext *context;
1263 
1264  PRINT_FUNCTION_VERBOSE(verbose);
1265 
1266  if (daemon == NULL)
1267  {
1268  dlt_log(LOG_WARNING, "Wrong parameter: Null pointer\n");
1269  return;
1270  }
1271 
1272  for (count=0; count<daemon->num_contexts; count ++)
1273  {
1274  context = &(daemon->contexts[count]);
1275 
1276  if (context != NULL)
1277  {
1278  if ((context->log_level == DLT_LOG_DEFAULT) ||
1279  (context->trace_status == DLT_TRACE_STATUS_DEFAULT))
1280  {
1281  if (context->user_handle >= DLT_FD_MINIMUM)
1282  {
1283  if (dlt_daemon_user_send_log_level(daemon, context, verbose)==-1)
1284  {
1285  return;
1286  }
1287  }
1288  }
1289  }
1290  }
1291 }
1292 
1293 void dlt_daemon_user_send_all_update(DltDaemon *daemon, int8_t log_level, int verbose)
1294 {
1295  int32_t count = 0;
1296  DltDaemonContext *context = NULL;
1297 
1298  PRINT_FUNCTION_VERBOSE(verbose);
1299 
1300  if (daemon == NULL)
1301  {
1302  return;
1303  }
1304 
1305  for (count = 0; count < daemon->num_contexts; count++)
1306  {
1307  context = &(daemon->contexts[count]);
1308  if (context)
1309  {
1310  if (context->user_handle >= DLT_FD_MINIMUM)
1311  {
1312  context->log_level = log_level;
1313  if (dlt_daemon_user_send_log_level(daemon, context, verbose) == -1)
1314  {
1315  return;
1316  }
1317  }
1318  }
1319  }
1320 }
1321 
1323 {
1324  int32_t count;
1325  DltDaemonApplication *app;
1326 
1327  PRINT_FUNCTION_VERBOSE(verbose);
1328 
1329  if (daemon == NULL)
1330  {
1331  dlt_log(LOG_WARNING, "Wrong parameter: Null pointer\n");
1332  return;
1333  }
1334 
1335  for (count=0; count<daemon->num_applications; count ++)
1336  {
1337  app = &(daemon->applications[count]);
1338 
1339  if (app != NULL)
1340  {
1341  if (app->user_handle >= DLT_FD_MINIMUM)
1342  {
1343  if (dlt_daemon_user_send_log_state(daemon, app, verbose)==-1)
1344  {
1345  return;
1346  }
1347  }
1348  }
1349  }
1350 }
1351 
1353 {
1354  switch(newState)
1355  {
1356  case DLT_DAEMON_STATE_INIT:
1357  dlt_log(LOG_INFO,"Switched to init state.\n");
1358  daemon->state = DLT_DAEMON_STATE_INIT;
1359  break;
1361  dlt_log(LOG_INFO,"Switched to buffer state for socket connections.\n");
1362  daemon->state = DLT_DAEMON_STATE_BUFFER;
1363  break;
1365  dlt_log(LOG_INFO,"Switched to buffer full state.\n");
1367  break;
1369  dlt_log(LOG_INFO,"Switched to send buffer state for socket connections.\n");
1371  break;
1373  dlt_log(LOG_INFO,"Switched to send direct state.\n");
1375  break;
1376  }
1377 
1378 }
1379 
1380 
1381 
char runtime_application_cfg[PATH_MAX+1]
int dlt_daemon_context_del(DltDaemon *daemon, DltDaemonContext *context, int verbose)
#define PRINT_FUNCTION_VERBOSE(_verbose)
Definition: dlt_common.h:220
DltReturnValue dlt_buffer_init_dynamic(DltBuffer *buf, uint32_t min_size, uint32_t max_size, uint32_t step_size)
Definition: dlt_common.c:2430
int dlt_daemon_contexts_invalidate_fd(DltDaemon *daemon, int fd, int verbose)
#define DLT_ID_SIZE
Definition: dlt_common.h:204
int dlt_daemon_contexts_load(DltDaemon *daemon, const char *filename, int verbose)
DltReturnValue
Definition: dlt_types.h:86
int dlt_daemon_applications_load(DltDaemon *daemon, const char *filename, int verbose)
void dlt_daemon_user_send_all_update(DltDaemon *daemon, int8_t log_level, int verbose)
#define DLT_USER_MESSAGE_LOG_LEVEL
#define DLT_RUNTIME_APPLICATION_CFG
void dlt_set_id(char *id, const char *text)
Definition: dlt_common.c:324
DltDaemonApplication * applications
DltReturnValue dlt_user_log_out2(int handle, void *ptr1, size_t len1, void *ptr2, size_t len2)
DltLogStorage * storage_handle
DltDaemonContext * dlt_daemon_context_add(DltDaemon *daemon, char *apid, char *ctid, int8_t log_level, int8_t trace_status, int log_level_pos, int user_handle, char *description, int verbose)
int runtime_context_cfg_loaded
int dlt_daemon_configuration_load(DltDaemon *daemon, const char *filename, int verbose)
DltReturnValue dlt_buffer_free_dynamic(DltBuffer *buf)
Definition: dlt_common.c:2494
DltReturnValue dlt_log(int prio, char *s)
Definition: dlt_common.c:2029
int8_t default_trace_status
DltBuffer client_ringbuffer
#define DLT_RUNTIME_CONFIGURATION
int dlt_daemon_contexts_clear(DltDaemon *daemon, int verbose)
char runtime_context_cfg[PATH_MAX+1]
void dlt_daemon_user_send_all_log_state(DltDaemon *daemon, int verbose)
DltDaemonContext * contexts
DltDaemonApplication * dlt_daemon_application_add(DltDaemon *daemon, char *apid, pid_t pid, char *description, int verbose)
char ctid[DLT_ID_SIZE]
int dlt_daemon_applications_clear(DltDaemon *daemon, int verbose)
int dlt_daemon_free(DltDaemon *daemon, int verbose)
int dlt_daemon_user_send_log_state(DltDaemon *daemon, DltDaemonApplication *app, int verbose)
int8_t force_ll_ts
#define DLT_RUNTIME_DEFAULT_DIRECTORY
int dlt_daemon_application_del(DltDaemon *daemon, DltDaemonApplication *application, int verbose)
void dlt_daemon_user_send_default_update(DltDaemon *daemon, int verbose)
#define DLT_DAEMON_COMMON_TEXTBUFSIZE
void dlt_daemon_control_reset_to_factory_default(DltDaemon *daemon, const char *filename, const char *filename1, int InitialContextLogLevel, int InitialContextTraceStatus, int InitialEnforceLlTsStatus, int verbose)
int dlt_daemon_applications_save(DltDaemon *daemon, const char *filename, int verbose)
void dlt_daemon_change_state(DltDaemon *daemon, DltDaemonState newState)
char ID4[DLT_ID_SIZE]
Definition: dlt_common.h:365
int dlt_daemon_configuration_save(DltDaemon *daemon, const char *filename, int verbose)
int8_t default_log_level
int dlt_daemon_init(DltDaemon *daemon, unsigned long RingbufferMinSize, unsigned long RingbufferMaxSize, unsigned long RingbufferStepSize, const char *runtime_directory, int InitialContextLogLevel, int InitialContextTraceStatus, int ForceLLTS, int verbose)
DltReturnValue dlt_user_set_userheader(DltUserHeader *userheader, uint32_t mtype)
#define DLT_FD_MINIMUM
Definition: dlt_common.h:199
static int dlt_daemon_cmp_apid(const void *m1, const void *m2)
#define DLT_RUNTIME_CONTEXT_CFG
char apid[DLT_ID_SIZE]
DltDaemonApplication * dlt_daemon_application_find(DltDaemon *daemon, char *apid, int verbose)
#define DLT_USER_MESSAGE_LOG_STATE
unsigned int overflow_counter
char apid[DLT_ID_SIZE]
DltDaemonState state
char dltFifoBaseDir[PATH_MAX+1]
Definition: dlt_common.c:72
int dlt_daemon_user_send_log_level(DltDaemon *daemon, DltDaemonContext *context, int verbose)
#define DLT_DAEMON_APPL_ALLOC_SIZE
sem_t dlt_daemon_mutex
static char str[DLT_DAEMON_COMMON_TEXTBUFSIZE]
char runtime_configuration[PATH_MAX+1]
int dlt_daemon_contexts_save(DltDaemon *daemon, const char *filename, int verbose)
int dlt_daemon_applications_invalidate_fd(DltDaemon *daemon, int fd, int verbose)
DltDaemonState
#define DLT_FD_INIT
Definition: dlt_common.h:196
char ecuid[DLT_ID_SIZE]
static int dlt_daemon_cmp_apid_ctid(const void *m1, const void *m2)
DltReturnValue dlt_vlog(int prio, const char *format,...)
Definition: dlt_common.c:2078
DltUserLogMode mode
#define DLT_DAEMON_CONTEXT_ALLOC_SIZE
DltDaemonContext * dlt_daemon_context_find(DltDaemon *daemon, char *apid, char *ctid, int verbose)
#define NULL
Definition: dlt_common.h:232