diff options
author | Stefan Vacek <stefan.vacek@intel.com> | 2015-08-31 10:13:07 +0200 |
---|---|---|
committer | Alexander Wenzel <Alexander.AW.Wenzel@bmw.de> | 2015-10-07 10:38:03 +0200 |
commit | ed412acac8e9f8a5745e55adeed9652b34b9ee4f (patch) | |
tree | dd2dbde29e126c679218b7cf93455601bbeca9bd /src/lib/dlt_client.c | |
parent | 4c8d43322e89b87288fb5ba12e523237e620481b (diff) | |
download | DLT-daemon-ed412acac8e9f8a5745e55adeed9652b34b9ee4f.tar.gz |
Allow multiple instances of dlt-daemon
- Make dlt-daemon configurable to specify directory of fifos and port of dlt-daemon, this
allows to run multiple instances of dlt-daemon at one node at the same time. This is useful
in testing environment where simultanous tests should not interfere due to the same
instance of dlt-daemon
- dlt-daemon: add option -t <dir> to specify a directory where all fifos will be created
- dlt-daemon: add option -p <port> to specify the port under which dlt-daemon can be connected
- client-library: add environment variable DLT_PIPE_DIR to specify a non-default directory
of fifos for logging applications
- client-library: add environment variable DLT_DAEMON_TCP_PORT to specify the port under which
dlt-daemon can be reached (especially when using dlt-receive)
Signed-off-by: Stefan Vacek <stefan.vacek@intel.com>
Signed-off-by: Lutz Helwing <lutz_helwing@mentor.com>
Diffstat (limited to 'src/lib/dlt_client.c')
-rw-r--r-- | src/lib/dlt_client.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/lib/dlt_client.c b/src/lib/dlt_client.c index 2c9f46a..b77556d 100644 --- a/src/lib/dlt_client.c +++ b/src/lib/dlt_client.c @@ -131,7 +131,9 @@ int dlt_client_connect(DltClient *client, int verbose) char portnumbuffer[33]; struct addrinfo hints, *servinfo, *p; int rv; - + char *env_daemon_port; + /* the port may be specified by an environment variable, defaults to DLT_DAEMON_TCP_PORT */ + unsigned short servPort = DLT_DAEMON_TCP_PORT; memset(&hints, 0, sizeof(hints)); hints.ai_socktype = SOCK_STREAM; @@ -140,9 +142,20 @@ int dlt_client_connect(DltClient *client, int verbose) return -1; } + /* the port may be specified by an environment variable */ + env_daemon_port = getenv(DLT_CLIENT_ENV_DAEMON_TCP_PORT); + if (env_daemon_port != NULL) + { + servPort = atoi(env_daemon_port); + } + if (servPort == 0) + { + servPort = DLT_DAEMON_TCP_PORT; + } + if (client->serial_mode==0) { - sprintf(portnumbuffer, "%d", DLT_DAEMON_TCP_PORT); + snprintf(portnumbuffer, 32, "%d", servPort); if ((rv = getaddrinfo(client->servIP, portnumbuffer, &hints, &servinfo)) != 0) { fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv)); return -1; |