78 #include <sys/types.h> 79 #include <sys/socket.h> 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)
136 if (daemon ==
NULL || runtime_directory ==
NULL)
139 int append_length = 0;
163 if(runtime_directory[0])
176 if(runtime_directory[0])
189 if(runtime_directory[0])
306 if ((daemon ==
NULL) || (apid ==
NULL) || (apid[0]==
'\0'))
324 if (application ==
NULL)
350 application->
pid = 0;
357 }
else if (pid != application->
pid) {
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);
371 if (description !=
NULL)
383 if( application->
pid != pid )
392 application->
pid = 0;
401 dlt_user_handle = open(filename, O_WRONLY|O_NONBLOCK);
402 if ( dlt_user_handle < 0 )
413 application->
pid = pid;
435 if ((daemon ==
NULL) || (application ==
NULL))
503 if ((daemon ==
NULL) || (filename ==
NULL) || (filename[0]==
'\0'))
506 fd=fopen(filename,
"r");
519 memset(buf, 0,
sizeof(buf));
522 ret=fgets(buf,
sizeof(buf),fd);
548 if (strcmp(buf,
"") != 0)
562 dlt_log(LOG_WARNING,
"dlt_daemon_applications_load dlt_daemon_application_add failed\n");
584 if ((daemon ==
NULL) || (filename ==
NULL) || (filename[0]==
'\0'))
587 memset(apid, 0,
sizeof(apid));
591 fd=fopen(filename,
"w");
605 fprintf(fd,
"%s::\n",apid);
624 if ((daemon ==
NULL) || (apid ==
NULL) || (apid[0]==
'\0') || (ctid ==
NULL) || (ctid[0]==
'\0'))
650 if (application ==
NULL)
697 if (description !=
NULL)
726 if ((new_context == 1) ||
755 if ((daemon ==
NULL) || (context ==
NULL))
780 if (application !=
NULL)
795 if ((daemon ==
NULL) || (apid ==
NULL) || (apid[0]==
'\0') || (ctid ==
NULL) || (ctid[0]==
'\0') || (daemon->
num_contexts==0))
879 if ((daemon ==
NULL) || (filename ==
NULL) ||( filename[0]==
'\0'))
882 fd=fopen(filename,
"r");
895 memset(buf, 0,
sizeof(buf));
898 ret=fgets(buf,
sizeof(buf),fd);
924 if (strcmp(buf,
"")!=0)
951 dlt_log(LOG_WARNING,
"dlt_daemon_contexts_load dlt_daemon_context_add failed\n");
976 if ((daemon ==
NULL) || (filename ==
NULL) || (filename[0]==
'\0'))
979 memset(apid, 0,
sizeof(apid));
980 memset(ctid, 0,
sizeof(ctid));
984 fd=fopen(filename,
"w");
995 fprintf(fd,
"%s:%s:%d:%d:%s:\n",apid,ctid,
1002 fprintf(fd,
"%s:%s:%d:%d::\n",apid,ctid,
1020 if ((daemon ==
NULL) || (filename ==
NULL) || (filename[0] ==
'\0'))
1023 fd=fopen(filename,
"w");
1026 fprintf(fd,
"# 0 = off, 1 = external, 2 = internal, 3 = both\n");
1027 fprintf(fd,
"LoggingMode = %d\n",daemon->
mode);
1037 if(daemon ==
NULL || filename ==
NULL)
1048 pFile = fopen (filename,
"r");
1055 if ( fgets (line , 1024 , pFile) !=
NULL )
1057 pch = strtok (line,
" =\r\n");
1063 if(strcmp(pch,
"#")==0)
1068 strncpy(token,pch,
sizeof(token)-1);
1069 token[
sizeof(token)-1]=0;
1073 strncpy(value,pch,
sizeof(value)-1);
1074 value[
sizeof(value)-1]=0;
1078 pch = strtok (
NULL,
" =\r\n");
1081 if(token[0] && value[0])
1084 if(strcmp(token,
"LoggingMode") == 0)
1086 daemon->
mode = atoi(value);
1115 DltUserHeader userheader;
1116 DltUserControlMsgLogLevel usercontext;
1121 if ((daemon ==
NULL) || (context ==
NULL))
1123 dlt_vlog(LOG_ERR,
"NULL parameter in %s", __func__);
1129 dlt_vlog(LOG_ERR,
"Failed to set userheader in %s", __func__);
1146 dlt_vlog(LOG_NOTICE,
"Send log-level to context: %.4s:%.4s [%i -> %i] [%i -> %i]\n",
1150 usercontext.log_level,
1152 usercontext.trace_status);
1157 &(userheader),
sizeof(DltUserHeader),
1158 &(usercontext),
sizeof(DltUserControlMsgLogLevel));
1162 dlt_vlog(LOG_ERR,
"Failed to send data to application in %s: %s",
1164 errno != 0 ? strerror(errno) :
"Unknown error");
1179 DltUserHeader userheader;
1180 DltUserControlMsgLogState logstate;
1185 if ((daemon ==
NULL) || (app ==
NULL))
1195 &(userheader),
sizeof(DltUserHeader),
1196 &(logstate),
sizeof(DltUserControlMsgLogState));
1217 if ((daemon ==
NULL) || (filename ==
NULL) || (filename1 ==
NULL))
1219 dlt_log(LOG_WARNING,
"Wrong parameter: Null pointer\n");
1223 if ((filename[0] ==
'\0') || (filename1[0] ==
'\0'))
1225 dlt_log(LOG_WARNING,
"Wrong parameter: Empty string\n");
1230 fd=fopen(filename,
"r");
1239 fd=fopen(filename1,
"r");
1268 dlt_log(LOG_WARNING,
"Wrong parameter: Null pointer\n");
1274 context = &(daemon->
contexts[count]);
1276 if (context !=
NULL)
1307 context = &(daemon->
contexts[count]);
1331 dlt_log(LOG_WARNING,
"Wrong parameter: Null pointer\n");
1357 dlt_log(LOG_INFO,
"Switched to init state.\n");
1361 dlt_log(LOG_INFO,
"Switched to buffer state for socket connections.\n");
1365 dlt_log(LOG_INFO,
"Switched to buffer full state.\n");
1369 dlt_log(LOG_INFO,
"Switched to send buffer state for socket connections.\n");
1373 dlt_log(LOG_INFO,
"Switched to send direct state.\n");
char runtime_application_cfg[PATH_MAX+1]
int dlt_daemon_context_del(DltDaemon *daemon, DltDaemonContext *context, int verbose)
#define PRINT_FUNCTION_VERBOSE(_verbose)
DltReturnValue dlt_buffer_init_dynamic(DltBuffer *buf, uint32_t min_size, uint32_t max_size, uint32_t step_size)
int dlt_daemon_contexts_invalidate_fd(DltDaemon *daemon, int fd, int verbose)
int dlt_daemon_contexts_load(DltDaemon *daemon, const char *filename, int verbose)
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)
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)
DltReturnValue dlt_log(int prio, char *s)
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)
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)
#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)
int dlt_daemon_configuration_save(DltDaemon *daemon, const char *filename, int verbose)
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)
static int dlt_daemon_cmp_apid(const void *m1, const void *m2)
#define DLT_RUNTIME_CONTEXT_CFG
DltDaemonApplication * dlt_daemon_application_find(DltDaemon *daemon, char *apid, int verbose)
#define DLT_USER_MESSAGE_LOG_STATE
unsigned int overflow_counter
char dltFifoBaseDir[PATH_MAX+1]
int dlt_daemon_user_send_log_level(DltDaemon *daemon, DltDaemonContext *context, int verbose)
#define DLT_DAEMON_APPL_ALLOC_SIZE
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)
char * context_description
static int dlt_daemon_cmp_apid_ctid(const void *m1, const void *m2)
DltReturnValue dlt_vlog(int prio, const char *format,...)
#define DLT_DAEMON_CONTEXT_ALLOC_SIZE
DltDaemonContext * dlt_daemon_context_find(DltDaemon *daemon, char *apid, char *ctid, int verbose)
char * application_description