diff --git a/doc/netopeer2-server.8 b/doc/netopeer2-server.8 index 617c5522..0c68ab76 100644 --- a/doc/netopeer2-server.8 +++ b/doc/netopeer2-server.8 @@ -37,8 +37,8 @@ Path to pidfile. .BR "\-f \fIPATH\fP" Path to netopeer2 server files directory. .TP -.BR "\-U[\fIPATH\fP]" -Listen on a local UNIX socket. +.BR "\-U[\fIENDPTNAME:PATH\fP]" +Set UNIX socket path for a specific endpoint. .TP .BR "\-m \fIMODE\fP" Set mode for the listening UNIX socket. diff --git a/src/main.c b/src/main.c index ee906a2c..1524fa0f 100644 --- a/src/main.c +++ b/src/main.c @@ -1396,6 +1396,7 @@ print_usage(char *progname) fprintf(stdout, " -x PATH Path to a data file with data for libyang ext data callback. They are required for\n"); fprintf(stdout, " supporting some extensions such as schema-mount, in which case the ietf-yang-schema-mount\n"); fprintf(stdout, " operational data are expected to be in the file.\n"); + fprintf(stdout, " -U ENDPT:PATH Set UNIX socket path for a specific endpoint.\n"); fprintf(stdout, " -v LEVEL Verbose output level:\n"); fprintf(stdout, " 0 - errors\n"); fprintf(stdout, " 1 - errors and warnings\n"); @@ -1457,7 +1458,7 @@ main(int argc, char *argv[]) /* process command line options */ optind = 0; - while ((c = getopt(argc, argv, "dFhVp:f:t:x:v:c:")) != -1) { + while ((c = getopt(argc, argv, "dFhVp:f:t:x:v:c:U:")) != -1) { switch (c) { case 'd': daemonize = 0; @@ -1521,6 +1522,25 @@ main(int argc, char *argv[]) case 'x': np2srv.ext_data_path = optarg; break; + case 'U': + /* parse endpoint_name:unix_socket_path */ + ptr = strchr(optarg, ':'); + if (!ptr) { + ERR("Invalid format for -U parameter \"%s\". Expected format: :", optarg); + return EXIT_FAILURE; + } + + /* terminate the endpoint name string */ + *ptr = '\0'; + + /* * optarg now points to endpoint_name, (ptr + 1) points to unix_socket_path */ + if (strlen(optarg) == 0 || strlen(ptr + 1) == 0) { + ERR("Empty endpoint name or socket path provided in -U parameter."); + return EXIT_FAILURE; + } + + nc_server_set_unix_socket_path(optarg, ptr + 1); + break; case 'c': #ifndef NDEBUG if (verb) {