diff options
Diffstat (limited to 'src/daemon')
-rw-r--r-- | src/daemon/dlt_daemon_client.c | 161 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_client.h | 10 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_common.c | 29 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_common.h | 9 |
4 files changed, 184 insertions, 25 deletions
diff --git a/src/daemon/dlt_daemon_client.c b/src/daemon/dlt_daemon_client.c index efd8dae..24be8e4 100644 --- a/src/daemon/dlt_daemon_client.c +++ b/src/daemon/dlt_daemon_client.c @@ -563,6 +563,11 @@ int dlt_daemon_client_process_control(int sock, DltDaemon *daemon, DltDaemonLoca dlt_daemon_control_message_buffer_overflow(sock, daemon, daemon_local, daemon->overflow_counter,"",verbose); break; } + case DLT_SERVICE_ID_SET_ALL_LOG_LEVEL: + { + dlt_daemon_control_set_all_log_level(sock, daemon, daemon_local, msg, verbose); + break; + } case DLT_SERVICE_ID_OFFLINE_LOGSTORAGE: { dlt_daemon_control_service_logstorage(sock, daemon, daemon_local, msg, verbose); @@ -1524,18 +1529,87 @@ void dlt_daemon_control_callsw_cinjection(int sock, DltDaemon *daemon, DltDaemon } } -void dlt_daemon_control_set_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose) +void dlt_daemon_send_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltDaemonContext *context,int8_t loglevel, int verbose) { PRINT_FUNCTION_VERBOSE(verbose); - char apid[DLT_ID_SIZE],ctid[DLT_ID_SIZE]; - DltServiceSetLogLevel *req; - DltDaemonContext *context; - int32_t id=DLT_SERVICE_ID_SET_LOG_LEVEL; + int32_t id = DLT_SERVICE_ID_SET_LOG_LEVEL; + int8_t old_log_level = 0; - int8_t old_log_level; + old_log_level = context->log_level; + context->log_level = loglevel; /* No endianess conversion necessary*/ - if ((daemon==0) || (msg==0)) + if ((context->user_handle >= DLT_FD_MINIMUM) && + (dlt_daemon_user_send_log_level(daemon, context, verbose)==0)) + { + dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose); + } + else + { + dlt_log(LOG_ERR, "Log level could not be sent!\n"); + context->log_level = old_log_level; + dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose); + } + +} + +void dlt_daemon_find_multiple_context_and_send(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, int8_t app_flag, char *str, int8_t len, int8_t loglevel, int verbose) +{ + PRINT_FUNCTION_VERBOSE(verbose); + + int8_t count = 0; + DltDaemonContext *context = NULL; + char src_str[DLT_ID_SIZE +1] = {0}; + int8_t ret = 0; + + if (daemon == 0) + { + return; + } + + for (count = 0; count < daemon->num_contexts; count++) + { + context = &(daemon->contexts[count]); + + if (context) + { + if (app_flag == 1) + { + strncpy(src_str, context->apid, DLT_ID_SIZE); + } + else + { + strncpy(src_str, context->ctid, DLT_ID_SIZE); + } + ret = strncmp(src_str, str, len); + if (ret == 0) + { + dlt_daemon_send_log_level(sock, daemon, daemon_local, context, loglevel, verbose); + } + else if ((ret > 0) && (app_flag == 1)) + { + break; + } + else + { + continue; + } + } + } +} + +void dlt_daemon_control_set_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose) +{ + PRINT_FUNCTION_VERBOSE(verbose); + + char apid[DLT_ID_SIZE+1] = {0}; + char ctid[DLT_ID_SIZE+1] = {0}; + DltServiceSetLogLevel *req = NULL; + DltDaemonContext *context = NULL; + int8_t appid_length = 0; + int8_t ctxtid_length = 0; + + if ((daemon == 0) || (msg == 0)) { return; } @@ -1544,32 +1618,39 @@ void dlt_daemon_control_set_log_level(int sock, DltDaemon *daemon, DltDaemonLoca dlt_set_id(apid, req->apid); dlt_set_id(ctid, req->ctid); - - context=dlt_daemon_context_find(daemon, apid, ctid, verbose); - - /* Set log level */ - if (context!=0) + appid_length = strlen(apid); + ctxtid_length = strlen(ctid); + if ((appid_length != 0) && (apid[appid_length-1] == '*') && (ctid[0] == 0)) /*appid provided having '*' in it and ctid is null*/ + { + dlt_daemon_find_multiple_context_and_send(sock, daemon, daemon_local, 1, apid, appid_length-1, req->log_level, verbose); + } + else if ((ctxtid_length != 0) && (ctid[ctxtid_length-1] == '*') && (apid[0] == 0)) /*ctid provided is having '*' in it and appid is null*/ { - old_log_level = context->log_level; - context->log_level = req->log_level; /* No endianess conversion necessary*/ + dlt_daemon_find_multiple_context_and_send(sock, daemon, daemon_local, 0, ctid, ctxtid_length-1, req->log_level, verbose); + } + else if ((appid_length != 0) && (apid[appid_length-1] != '*') && (ctid[0] == 0)) /*only app id case*/ + { + dlt_daemon_find_multiple_context_and_send(sock, daemon, daemon_local, 1, apid, DLT_ID_SIZE, req->log_level, verbose); + } + else if ((ctxtid_length != 0) && (ctid[ctxtid_length-1] != '*') && (apid[0] == 0)) /*only context id case*/ + { + dlt_daemon_find_multiple_context_and_send(sock, daemon, daemon_local, 0, ctid, DLT_ID_SIZE, req->log_level, verbose); + } + else + { + context=dlt_daemon_context_find(daemon, apid, ctid, verbose); - if ((context->user_handle >= DLT_FD_MINIMUM) && - (dlt_daemon_user_send_log_level(daemon, context, verbose)==0)) + /* Set log level */ + if (context!=0) { - dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose); + dlt_daemon_send_log_level(sock, daemon, daemon_local, context, req->log_level, verbose); } else { - //dlt_log(LOG_ERR, "Log level could not be sent!\n"); - context->log_level = old_log_level; - dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose); + dlt_log(LOG_ERR, "Context not found!\n"); + dlt_daemon_control_service_response(sock, daemon, daemon_local, DLT_SERVICE_ID_SET_LOG_LEVEL, DLT_SERVICE_RESPONSE_ERROR, verbose); } } - else - { - //dlt_log(LOG_ERR, "Context not found!\n"); - dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose); - } } void dlt_daemon_control_set_trace_status(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose) @@ -1651,6 +1732,36 @@ void dlt_daemon_control_set_default_log_level(int sock, DltDaemon *daemon, DltDa } } +void dlt_daemon_control_set_all_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose) +{ + PRINT_FUNCTION_VERBOSE(verbose); + + DltServiceSetDefaultLogLevel *req = NULL; + int32_t id = DLT_SERVICE_ID_SET_ALL_LOG_LEVEL; + int8_t loglevel = 0; + + if ((daemon==0) || (msg==0)) + { + return; + } + + req = (DltServiceSetDefaultLogLevel*) (msg->databuffer); + + /* No endianess conversion necessary */ + if ((req != NULL) && (req->log_level <= DLT_LOG_VERBOSE)) + { + loglevel = req->log_level; /* No endianess conversion necessary */ + /* Send Update to all contexts using the new log level */ + dlt_daemon_user_send_all_update(daemon, loglevel, verbose); + + dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_OK, verbose); + } + else + { + dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_ERROR, verbose); + } +} + void dlt_daemon_control_set_default_trace_status(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose) { PRINT_FUNCTION_VERBOSE(verbose); diff --git a/src/daemon/dlt_daemon_client.h b/src/daemon/dlt_daemon_client.h index 7128ddb..275ee3e 100644 --- a/src/daemon/dlt_daemon_client.h +++ b/src/daemon/dlt_daemon_client.h @@ -230,6 +230,16 @@ void dlt_daemon_control_set_trace_status(int sock, DltDaemon *daemon, DltDaemonL */ void dlt_daemon_control_set_default_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose); /** + * Process and generate response to received set all log level control message + * @param sock connection handle used for sending response + * @param daemon pointer to dlt daemon structure + * @param daemon_local pointer to dlt daemon local structure + * @param msg pointer to received control message + * @param verbose if set to true verbose information is printed out. + */ +void dlt_daemon_control_set_all_log_level(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, DltMessage *msg, int verbose); + +/** * Process and generate response to received set default trace status control message * @param sock connection handle used for sending response * @param daemon pointer to dlt daemon structure diff --git a/src/daemon/dlt_daemon_common.c b/src/daemon/dlt_daemon_common.c index 6523136..988bd7b 100644 --- a/src/daemon/dlt_daemon_common.c +++ b/src/daemon/dlt_daemon_common.c @@ -1275,6 +1275,35 @@ void dlt_daemon_user_send_default_update(DltDaemon *daemon, int verbose) } } +void dlt_daemon_user_send_all_update(DltDaemon *daemon, int8_t log_level, int verbose) +{ + int32_t count = 0; + DltDaemonContext *context = NULL; + + PRINT_FUNCTION_VERBOSE(verbose); + + if (daemon == NULL) + { + return; + } + + for (count = 0; count < daemon->num_contexts; count++) + { + context = &(daemon->contexts[count]); + if (context) + { + if (context->user_handle >= DLT_FD_MINIMUM) + { + context->log_level = log_level; + if (dlt_daemon_user_send_log_level(daemon, context, verbose) == -1) + { + return; + } + } + } + } +} + void dlt_daemon_user_send_all_log_state(DltDaemon *daemon, int verbose) { int32_t count; diff --git a/src/daemon/dlt_daemon_common.h b/src/daemon/dlt_daemon_common.h index 71d3dce..02d2860 100644 --- a/src/daemon/dlt_daemon_common.h +++ b/src/daemon/dlt_daemon_common.h @@ -355,6 +355,15 @@ int dlt_daemon_user_send_log_state(DltDaemon *daemon,DltDaemonApplication *app,i void dlt_daemon_user_send_default_update(DltDaemon *daemon, int verbose); /** + * Send user messages to all user applications context, or trace status + * to update with the new log level + * @param daemon pointer to dlt daemon structure + * @param log level to be set + * @param verbose if set to true verbose information is printed out. + */ +void dlt_daemon_user_send_all_update(DltDaemon *daemon, int8_t log_level, int verbose); + +/** * Send user messages to all user applications the log status * everytime the client is connected or disconnected. * @param daemon pointer to dlt daemon structure |