Skip to content

Commit 9c56c78

Browse files
committed
main UPDATE add unix socket param
1 parent 36293ad commit 9c56c78

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

doc/netopeer2-server.8

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ Path to pidfile.
3737
.BR "\-f \fIPATH\fP"
3838
Path to netopeer2 server files directory.
3939
.TP
40-
.BR "\-U[\fIPATH\fP]"
41-
Listen on a local UNIX socket.
40+
.BR "\-U[\fIENDPTNAME:PATH\fP]"
41+
Set UNIX socket path for a specific endpoint.
4242
.TP
4343
.BR "\-m \fIMODE\fP"
4444
Set mode for the listening UNIX socket.

src/main.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,7 @@ print_usage(char *progname)
13961396
fprintf(stdout, " -x PATH Path to a data file with data for libyang ext data callback. They are required for\n");
13971397
fprintf(stdout, " supporting some extensions such as schema-mount, in which case the ietf-yang-schema-mount\n");
13981398
fprintf(stdout, " operational data are expected to be in the file.\n");
1399+
fprintf(stdout, " -U ENDPT:PATH Set UNIX socket path for a specific endpoint.\n");
13991400
fprintf(stdout, " -v LEVEL Verbose output level:\n");
14001401
fprintf(stdout, " 0 - errors\n");
14011402
fprintf(stdout, " 1 - errors and warnings\n");
@@ -1457,7 +1458,7 @@ main(int argc, char *argv[])
14571458

14581459
/* process command line options */
14591460
optind = 0;
1460-
while ((c = getopt(argc, argv, "dFhVp:f:t:x:v:c:")) != -1) {
1461+
while ((c = getopt(argc, argv, "dFhVp:f:t:x:v:c:U:")) != -1) {
14611462
switch (c) {
14621463
case 'd':
14631464
daemonize = 0;
@@ -1521,6 +1522,25 @@ main(int argc, char *argv[])
15211522
case 'x':
15221523
np2srv.ext_data_path = optarg;
15231524
break;
1525+
case 'U':
1526+
/* parse endpoint_name:unix_socket_path */
1527+
ptr = strchr(optarg, ':');
1528+
if (!ptr) {
1529+
ERR("Invalid format for -U parameter \"%s\". Expected format: <endpoint_name>:<unix_socket_path>", optarg);
1530+
return EXIT_FAILURE;
1531+
}
1532+
1533+
/* terminate the endpoint name string */
1534+
*ptr = '\0';
1535+
1536+
/* * optarg now points to endpoint_name, (ptr + 1) points to unix_socket_path */
1537+
if (strlen(optarg) == 0 || strlen(ptr + 1) == 0) {
1538+
ERR("Empty endpoint name or socket path provided in -U parameter.");
1539+
return EXIT_FAILURE;
1540+
}
1541+
1542+
nc_server_set_unix_socket_path(optarg, ptr + 1);
1543+
break;
15241544
case 'c':
15251545
#ifndef NDEBUG
15261546
if (verb) {

0 commit comments

Comments
 (0)