From 3894a8d101a7be0f67262de8af3746a768433fed Mon Sep 17 00:00:00 2001 From: Christoph Lipka Date: Wed, 12 Oct 2016 12:20:55 +0900 Subject: MultiNode: Specify config file location in dlt.conf Signed-off-by: Christoph Lipka --- src/daemon/dlt-daemon.c | 14 ++++++++++++++ src/daemon/dlt-daemon.h | 1 + src/daemon/dlt.conf | 12 +++++++++--- src/gateway/dlt_gateway.c | 15 +++++++++------ 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c index d3df90f..9288d33 100644 --- a/src/daemon/dlt-daemon.c +++ b/src/daemon/dlt-daemon.c @@ -249,6 +249,9 @@ int option_file_parser(DltDaemonLocal *daemon_local) DLT_DAEMON_DEFAULT_CTRL_SOCK_PATH, sizeof(daemon_local->flags.ctrlSockPath) - 1); daemon_local->flags.gatewayMode = 0; + strncpy(daemon_local->flags.gatewayConfigFile, + DLT_GATEWAY_CONFIG_PATH, + DLT_DAEMON_FLAG_MAX - 1); daemon_local->flags.autoResponseGetLogInfoOption = 7; daemon_local->flags.contextLogLevel = DLT_LOG_INFO; daemon_local->flags.contextTraceStatus = DLT_TRACE_STATUS_OFF; @@ -503,6 +506,17 @@ int option_file_parser(DltDaemonLocal *daemon_local) daemon_local->flags.gatewayMode = atoi(value); //printf("Option: %s=%s\n",token,value); } + else if(strcmp(token,"GatewayConfigFile")==0) + { + memset( + daemon_local->flags.gatewayConfigFile, + 0, + DLT_DAEMON_FLAG_MAX); + strncpy( + daemon_local->flags.gatewayConfigFile, + value, + DLT_DAEMON_FLAG_MAX-1); + } else if(strcmp(token,"ContextLogLevel")==0) { int const intval = atoi(value); diff --git a/src/daemon/dlt-daemon.h b/src/daemon/dlt-daemon.h index a20af75..03b062e 100644 --- a/src/daemon/dlt-daemon.h +++ b/src/daemon/dlt-daemon.h @@ -124,6 +124,7 @@ typedef struct unsigned int port; /**< port number */ char ctrlSockPath[DLT_DAEMON_FLAG_MAX]; /**< Path to Control socket */ int gatewayMode; /**< (Boolean) Gateway Mode */ + char gatewayConfigFile[DLT_DAEMON_FLAG_MAX]; /**< Gateway config file path */ int autoResponseGetLogInfoOption; /**< (int) The Option of automatic get log info response during context registration. (Default: 7)*/ 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*/ diff --git a/src/daemon/dlt.conf b/src/daemon/dlt.conf index 383cbab..1e4f566 100644 --- a/src/daemon/dlt.conf +++ b/src/daemon/dlt.conf @@ -28,9 +28,6 @@ SendContextRegistration = 1 # Set ECU ID (Default: ECU1) ECUId = ECU1 -# Enable Gateway mode (Default: 0) -# GatewayMode = 1 - # Size of shared memory (Default: 100000) SharedMemorySize = 100000 @@ -75,6 +72,15 @@ 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 +######################################################################## +# Gateway Configuration # +######################################################################## +# Enable Gateway mode (Default: 0) +# GatewayMode = 1 + +# Read gateway configuration from another location +# GatewayConfigFile = /etc/dlt_gateway.conf + ######################################################################## # Control Application # ######################################################################## diff --git a/src/gateway/dlt_gateway.c b/src/gateway/dlt_gateway.c index edae0c7..99eabd8 100644 --- a/src/gateway/dlt_gateway.c +++ b/src/gateway/dlt_gateway.c @@ -442,11 +442,12 @@ int dlt_gateway_store_connection(DltGateway *gateway, /** * Read configuration file and initialize connection data structures * - * @param g DltGateway - * @param verbose verbose flag + * @param gateway DltGateway + * @param config_file Gateway configuration + * @param verbose verbose flag * @return 0 on success, -1 otherwise */ -int dlt_gateway_configure(DltGateway *gateway, int verbose) +int dlt_gateway_configure(DltGateway *gateway, char *config_file, int verbose) { int ret = 0; int i = 0; @@ -454,13 +455,13 @@ int dlt_gateway_configure(DltGateway *gateway, int verbose) PRINT_FUNCTION_VERBOSE(verbose); - if (gateway == NULL) + if (gateway == NULL || config_file == 0 || config_file[0] == '\0') { return -1; } /* read configuration file */ - file = dlt_config_file_init(DLT_GATEWAY_CONFIG_PATH); + file = dlt_config_file_init(config_file); /* get number of entries and allocate memory to store information */ ret = dlt_config_file_get_num_sections(file, &gateway->num_connections); @@ -584,7 +585,9 @@ int dlt_gateway_init(DltDaemonLocal *daemon_local, int verbose) /* Get default value from daemon_local */ gateway->send_serial = daemon_local->flags.lflag; - if (dlt_gateway_configure(gateway, verbose) != 0) + if (dlt_gateway_configure(gateway, + daemon_local->flags.gatewayConfigFile, + verbose) != 0) { dlt_log(LOG_ERR, "Gateway initialization failed\n"); return -1; -- cgit v1.2.1