From 28865f91df96e83b28bb40565f12e62bd86e451f Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Tue, 8 Jul 2014 16:14:18 +0200 Subject: [PATCH] phc2sys: Add option to set path to ptp4l UDS. Signed-off-by: Miroslav Lichvar --- phc2sys.8 | 4 ++++ phc2sys.c | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/phc2sys.8 b/phc2sys.8 index a906fb3..c4fb6f6 100644 --- a/phc2sys.8 +++ b/phc2sys.8 @@ -194,6 +194,10 @@ clock frequency (unless the .B \-S option is used). .TP +.BI \-z " uds-address" +Specifies the address of the server's UNIX domain socket. +The default is /var/run/ptp4l. +.TP .BI \-l " print-level" Set the maximum syslog level of messages which should be printed or sent to the system logger. The default is 6 (LOG_INFO). diff --git a/phc2sys.c b/phc2sys.c index 7815a8e..418f4ac 100644 --- a/phc2sys.c +++ b/phc2sys.c @@ -53,6 +53,7 @@ #include "stats.h" #include "sysoff.h" #include "tlv.h" +#include "uds.h" #include "util.h" #include "version.h" @@ -1158,6 +1159,7 @@ static void usage(char *progname) " -u [num] number of clock updates in summary stats (0)\n" " -n [num] domain number (0)\n" " -x apply leap seconds by servo instead of kernel\n" + " -z [path] server address for UDS (/var/run/ptp4l)\n" " -l [num] set the logging level to 'num' (6)\n" " -m print messages to stdout\n" " -q do not print messages to the syslog\n" @@ -1192,7 +1194,7 @@ int main(int argc, char *argv[]) progname = strrchr(argv[0], '/'); progname = progname ? 1+progname : argv[0]; while (EOF != (c = getopt(argc, argv, - "arc:d:s:E:P:I:S:F:R:N:O:L:i:u:wn:xl:mqvh"))) { + "arc:d:s:E:P:I:S:F:R:N:O:L:i:u:wn:xz:l:mqvh"))) { switch (c) { case 'a': autocfg = 1; @@ -1285,6 +1287,14 @@ int main(int argc, char *argv[]) case 'x': node.kernel_leap = 0; break; + case 'z': + if (strlen(optarg) > MAX_IFNAME_SIZE) { + fprintf(stderr, "path %s too long, max is %d\n", + optarg, MAX_IFNAME_SIZE); + return -1; + } + strncpy(uds_path, optarg, MAX_IFNAME_SIZE); + break; case 'l': if (get_arg_val_i(c, optarg, &print_level, PRINT_LEVEL_MIN, PRINT_LEVEL_MAX))