diff options
author | sebastienr <sebastien.raillet@gmail.com> | 2020-11-25 01:11:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-25 09:11:43 +0900 |
commit | f093d547c2e4c68d0b7060f9accfc67784b7c06a (patch) | |
tree | 073535ce523b8bcfb66f0bff5e2056068d20b9ef /src/daemon | |
parent | 723344e43485c105fe79d21e2ba4c0dcd3dd0ca7 (diff) | |
download | DLT-daemon-f093d547c2e4c68d0b7060f9accfc67784b7c06a.tar.gz |
dlt-daemon: Adds an option to disable injection mode (#266)
A new option named "InjectionMode" allows to select if
we want to enable / disable the feature
Signed-off-by: Sebastien RAILLET <sebastien.raillet@marelli.com>
Diffstat (limited to 'src/daemon')
-rw-r--r-- | src/daemon/dlt-daemon.c | 4 | ||||
-rw-r--r-- | src/daemon/dlt-daemon.h | 3 | ||||
-rw-r--r-- | src/daemon/dlt.conf | 3 | ||||
-rw-r--r-- | src/daemon/dlt_daemon_client.c | 8 |
4 files changed, 16 insertions, 2 deletions
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c index a14de88..cd6e5d9 100644 --- a/src/daemon/dlt-daemon.c +++ b/src/daemon/dlt-daemon.c @@ -322,6 +322,7 @@ int option_file_parser(DltDaemonLocal *daemon_local) daemon_local->UDPMulticastIPPort = MULTICASTIPPORT; #endif daemon_local->flags.ipNodes = NULL; + daemon_local->flags.injectionMode = 1; /* open configuration file */ if (daemon_local->flags.cvalue[0]) @@ -705,6 +706,9 @@ int option_file_parser(DltDaemonLocal *daemon_local) dlt_vlog(LOG_WARNING, "BindAddress option is empty\n"); } } + else if (strcmp(token, "InjectionMode") == 0) { + daemon_local->flags.injectionMode = atoi(value); + } else { fprintf(stderr, "Unknown option: %s=%s\n", token, value); } diff --git a/src/daemon/dlt-daemon.h b/src/daemon/dlt-daemon.h index 6637f1d..31598bb 100644 --- a/src/daemon/dlt-daemon.h +++ b/src/daemon/dlt-daemon.h @@ -135,7 +135,8 @@ typedef struct int contextLogLevel; /**< (int) log level sent to context if registered with default log-level or if enforced*/ int contextTraceStatus; /**< (int) trace status sent to context if registered with default trace status or if enforced*/ int enforceContextLLAndTS; /**< (Boolean) Enforce log-level, trace-status not to exceed contextLogLevel, contextTraceStatus */ - DltBindAddress_t *ipNodes; /**< (String: BindAddress) The daemon accepts connections only on this list of IP addresses */ + DltBindAddress_t* ipNodes; /**< (String: BindAddress) The daemon accepts connections only on this list of IP addresses */ + int injectionMode; /**< (Boolean) Injection mode */ } DltDaemonFlags; /** * The global parameters of a dlt daemon. diff --git a/src/daemon/dlt.conf b/src/daemon/dlt.conf index 60d3315..ab2a9bd 100644 --- a/src/daemon/dlt.conf +++ b/src/daemon/dlt.conf @@ -75,6 +75,9 @@ RingbufferStepSize = 500000 # If set to 1 (ON) whenever a context registers or changes the log-level it has to be lower or equal to ContextLogLevel # ForceContextLogLevelAndTraceStatus = 1 +# Allows injection mode usage (Default: 1) +# InjectionMode = 1 + ######################################################################## # Gateway Configuration # ######################################################################## diff --git a/src/daemon/dlt_daemon_client.c b/src/daemon/dlt_daemon_client.c index 9450e77..941aa8c 100644 --- a/src/daemon/dlt_daemon_client.c +++ b/src/daemon/dlt_daemon_client.c @@ -1544,7 +1544,7 @@ void dlt_daemon_control_callsw_cinjection(int sock, PRINT_FUNCTION_VERBOSE(verbose); - if ((daemon == NULL) || (msg == NULL) || (msg->databuffer == NULL)) + if ((daemon == NULL) || (daemon_local == NULL) || (msg == NULL) || (msg->databuffer == NULL)) return; datalength = msg->datasize; @@ -1553,6 +1553,12 @@ void dlt_daemon_control_callsw_cinjection(int sock, DLT_MSG_READ_VALUE(id_tmp, ptr, datalength, uint32_t); /* Get service id */ id = DLT_ENDIAN_GET_32(msg->standardheader->htyp, id_tmp); + /* injectionMode is disabled */ + if (daemon_local->flags.injectionMode == 0) { + dlt_daemon_control_service_response(sock, daemon, daemon_local, id, DLT_SERVICE_RESPONSE_PERM_DENIED, verbose); + return; + } + /* id is always less than DLT_DAEMON_INJECTION_MAX since its type is uinit32_t */ if (id >= DLT_DAEMON_INJECTION_MIN) { /* This a a real SW-C injection call */ |