From 4f6f1e1cbafa3b42cec3a70eda8af4dce0ecec68 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sun, 29 Sep 2013 20:58:17 +0200 Subject: [PATCH] pmc: add a command line option to select the server's UDS address. Signed-off-by: Richard Cochran --- pmc.8 | 8 +++++++- pmc.c | 12 +++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pmc.8 b/pmc.8 index d91c657..759ed84 100644 --- a/pmc.8 +++ b/pmc.8 @@ -1,4 +1,4 @@ -.TH PMC 8 "July 2013" "linuxptp" +.TH PMC 8 "October 2013" "linuxptp" .SH NAME pmc \- PTP management client @@ -19,6 +19,8 @@ pmc \- PTP management client ] [ .BI \-i " interface" ] [ +.BI \-s " uds-address" +] [ .BI \-t " transport-specific-field" ] [ .B \-v @@ -69,6 +71,10 @@ Specify the domain number in sent messages. The default is 0. Specify the network interface. The default is /var/run/pmc for the Unix Domain Socket transport and eth0 for the other transports. .TP +.BI \-s " uds-address" +Specifies the address of the server's UNIX domain socket. +The default is /var/run/ptp4l. +.TP .BI \-t " transport-specific-field" Specify the transport specific field in sent messages as a hexadecimal number. The default is 0x0. diff --git a/pmc.c b/pmc.c index 3a6d697..c9851cd 100644 --- a/pmc.c +++ b/pmc.c @@ -31,6 +31,7 @@ #include "pmc_common.h" #include "print.h" #include "tlv.h" +#include "uds.h" #include "util.h" #include "version.h" @@ -676,6 +677,7 @@ static void usage(char *progname) " -h prints this message and exits\n" " -i [dev] interface device to use, default 'eth0'\n" " for network and '/var/run/pmc' for UDS.\n" + " -s [path] server address for UDS, default '/var/run/ptp4l'.\n" " -t [hex] transport specific field, default 0x0\n" " -v prints the software version and exits\n" " -z send zero length TLV values with the GET actions\n" @@ -697,7 +699,7 @@ int main(int argc, char *argv[]) /* Process the command line arguments. */ progname = strrchr(argv[0], '/'); progname = progname ? 1+progname : argv[0]; - while (EOF != (c = getopt(argc, argv, "246u""b:d:hi:t:vz"))) { + while (EOF != (c = getopt(argc, argv, "246u""b:d:hi:s:t:vz"))) { switch (c) { case '2': transport_type = TRANS_IEEE_802_3; @@ -720,6 +722,14 @@ int main(int argc, char *argv[]) case 'i': iface_name = optarg; break; + case 's': + 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 't': if (1 == sscanf(optarg, "%x", &c)) transport_specific = c << 4;