summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexander Mohr <alexander.m.mohr@mercedes-benz.com>2022-08-10 11:11:32 +0200
committerGitHub <noreply@github.com>2022-08-10 16:11:32 +0700
commitfcc59cece4dc19311ed15d2ac70af7dfead7cca6 (patch)
tree0853765949725a8d8d9763621e7ad50fe956de53 /src
parent4ea28ce72e62039a1032bc9c8c2b8b68d0ce8af3 (diff)
downloadDLT-daemon-fcc59cece4dc19311ed15d2ac70af7dfead7cca6.tar.gz
enforce-trace-limit: ContextLogLevel is now enforced in the daemon (#382)
if an application sends a message with a level below context level and the level enforcement is on, the message will be dropped Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
Diffstat (limited to 'src')
-rw-r--r--src/daemon/dlt-daemon.c23
-rw-r--r--src/daemon/dlt-daemon.h4
2 files changed, 23 insertions, 4 deletions
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c
index 74f4049..b7aac0d 100644
--- a/src/daemon/dlt-daemon.c
+++ b/src/daemon/dlt-daemon.c
@@ -3177,8 +3177,10 @@ int dlt_daemon_process_user_message_log(DltDaemon *daemon,
return DLT_DAEMON_ERROR_UNKNOWN;
}
- ret = dlt_daemon_client_send_message_to_all_client(daemon,
- daemon_local, verbose);
+ /* discard non-allowed levels if enforcement is on */
+ bool keep_message = enforce_context_ll_and_ts_keep_message(daemon_local);
+ if (keep_message)
+ dlt_daemon_client_send_message_to_all_client(daemon, daemon_local, verbose);
if (DLT_DAEMON_ERROR_OK != ret)
dlt_log(LOG_ERR, "failed to send message to client.\n");
@@ -3205,7 +3207,10 @@ int dlt_daemon_process_user_message_log(DltDaemon *daemon,
return DLT_DAEMON_ERROR_UNKNOWN;
}
- dlt_daemon_client_send_message_to_all_client(daemon, daemon_local, verbose);
+ /* discard non-allowed levels if enforcement is on */
+ bool keep_message = enforce_context_ll_and_ts_keep_message(daemon_local);
+ if (keep_message)
+ dlt_daemon_client_send_message_to_all_client(daemon, daemon_local, verbose);
/* keep not read data in buffer */
size = (int) (daemon_local->msg.headersize +
@@ -3225,6 +3230,18 @@ int dlt_daemon_process_user_message_log(DltDaemon *daemon,
return DLT_DAEMON_ERROR_OK;
}
+bool enforce_context_ll_and_ts_keep_message(DltDaemonLocal *daemon_local) {
+ if (daemon_local->flags.enforceContextLLAndTS &&
+ daemon_local->msg.extendedheader) {
+ const int mtin = DLT_GET_MSIN_MTIN(daemon_local->msg.extendedheader->msin);
+ if (mtin > daemon_local->flags.contextLogLevel) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon,
DltDaemonLocal *daemon_local,
DltReceiver *rec,
diff --git a/src/daemon/dlt-daemon.h b/src/daemon/dlt-daemon.h
index 7a4b29c..071562f 100644
--- a/src/daemon/dlt-daemon.h
+++ b/src/daemon/dlt-daemon.h
@@ -249,6 +249,9 @@ int dlt_daemon_process_user_message_log(DltDaemon *daemon,
DltDaemonLocal *daemon_local,
DltReceiver *rec,
int verbose);
+
+bool enforce_context_ll_and_ts_keep_message(DltDaemonLocal *daemon_local);
+
int dlt_daemon_process_user_message_set_app_ll_ts(DltDaemon *daemon,
DltDaemonLocal *daemon_local,
DltReceiver *rec,
@@ -270,4 +273,3 @@ int create_timer_fd(DltDaemonLocal *daemon_local, int period_sec, int starts_in,
int dlt_daemon_close_socket(int sock, DltDaemon *daemon, DltDaemonLocal *daemon_local, int verbose);
#endif /* DLT_DAEMON_H */
-