Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/netopeer2-server.8
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 21 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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: <endpoint_name>:<unix_socket_path>", 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) {
Expand Down
Loading