diff --git a/hwstamp_ctl.8 b/hwstamp_ctl.8 index 1c1a45e..e65071d 100644 --- a/hwstamp_ctl.8 +++ b/hwstamp_ctl.8 @@ -9,6 +9,8 @@ hwstamp_ctl \- set time stamping policy at the driver level .BI \-r " rx-filter" ] [ .BI \-t " tx-type" +] [ +.B \-v ] .SH DESCRIPTION @@ -50,6 +52,9 @@ Display a help message and list of possible values for .I rx-filter and .IR tx-type . +.TP +.B \-v +Prints the software version and exits. .SH SEE ALSO .BR ioctl (2), diff --git a/hwstamp_ctl.c b/hwstamp_ctl.c index 7226ab1..4f1683a 100644 --- a/hwstamp_ctl.c +++ b/hwstamp_ctl.c @@ -29,6 +29,8 @@ #include #include +#include "version.h" + static void usage(char *progname) { fprintf(stderr, @@ -53,6 +55,7 @@ static void usage(char *progname) "\t\t%2d PTP v2/802.AS1, any layer, Sync packet\n" "\t\t%2d PTP v2/802.AS1, any layer, Delay_req packet\n" " -t [%d|%d] disable or enable transmit time stamping\n" + " -v prints the software version and exits\n" "\n", progname, HWTSTAMP_FILTER_NONE, HWTSTAMP_FILTER_PTP_V2_DELAY_REQ, @@ -85,7 +88,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, "hi:r:t:"))) { + while (EOF != (c = getopt(argc, argv, "hi:r:t:v"))) { switch (c) { case 'i': device = optarg; @@ -96,6 +99,9 @@ int main(int argc, char *argv[]) case 't': txopt = atoi(optarg); break; + case 'v': + version_show(stdout); + return 0; case 'h': usage(progname); return 0; diff --git a/makefile b/makefile index 0b27fbc..53b9e4d 100644 --- a/makefile +++ b/makefile @@ -49,11 +49,11 @@ all: $(PRG) ptp4l: $(OBJ) -pmc: pmc.o msg.o print.o raw.o sk.o tlv.o transport.o udp.o udp6.o uds.o util.o +pmc: pmc.o msg.o print.o raw.o sk.o tlv.o transport.o udp.o udp6.o uds.o util.o version.o -phc2sys: phc2sys.o sk.o sysoff.o print.o +phc2sys: phc2sys.o sk.o sysoff.o print.o version.o -hwstamp_ctl: hwstamp_ctl.o +hwstamp_ctl: hwstamp_ctl.o version.o version.o: .version version.sh $(filter-out version.d,$(DEPEND)) diff --git a/phc2sys.8 b/phc2sys.8 index 6933900..113f30c 100644 --- a/phc2sys.8 +++ b/phc2sys.8 @@ -26,6 +26,8 @@ phc2sys \- synchronize two clocks .BI \-N " clock-readings" ] [ .BI \-O " offset" +] [ +.B \-v ] .SH DESCRIPTION @@ -92,6 +94,9 @@ The default is 0 seconds. .TP .BI \-h Display a help message. +.TP +.B \-v +Prints the software version and exits. .SH SEE ALSO .BR ptp4l (8) diff --git a/phc2sys.c b/phc2sys.c index 31e88ed..edf1907 100644 --- a/phc2sys.c +++ b/phc2sys.c @@ -35,6 +35,7 @@ #include "missing.h" #include "sk.h" #include "sysoff.h" +#include "version.h" #define KP 0.7 #define KI 0.3 @@ -264,6 +265,7 @@ static void usage(char *progname) " -N [num] number of master clock readings per update (5)\n" " -O [offset] slave-master time offset (0)\n" " -h prints this message and exits\n" + " -v prints the software version and exits\n" "\n", progname); } @@ -280,7 +282,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, "c:d:hs:P:I:R:N:O:i:"))) { + while (EOF != (c = getopt(argc, argv, "c:d:hs:P:I:R:N:O:i:v"))) { switch (c) { case 'c': dst = clock_open(optarg); @@ -309,6 +311,9 @@ int main(int argc, char *argv[]) case 'i': ethdev = optarg; break; + case 'v': + version_show(stdout); + return 0; case 'h': usage(progname); return 0; diff --git a/pmc.8 b/pmc.8 index 65bedb7..568b311 100644 --- a/pmc.8 +++ b/pmc.8 @@ -20,6 +20,8 @@ pmc \- PTP management client .BI \-i " interface" ] [ .BI \-t " transport-specific-field" +] [ +.B \-v ] .SH DESCRIPTION @@ -71,6 +73,9 @@ The default is 0x0. .TP .B \-h Display a help message. +.TP +.B \-v +Prints the software version and exits. .SH MANAGEMENT IDS diff --git a/pmc.c b/pmc.c index fa331d6..b852b88 100644 --- a/pmc.c +++ b/pmc.c @@ -31,6 +31,7 @@ #include "tlv.h" #include "transport.h" #include "util.h" +#include "version.h" #define BAD_ACTION -1 #define BAD_ID -1 @@ -459,6 +460,7 @@ static void usage(char *progname) " -i [dev] interface device to use, default 'eth0'\n" " for network and '/tmp/pmc' for UDS.\n" " -t [hex] transport specific field, default 0x0\n" + " -v prints the software version and exits\n" "\n", progname); } @@ -476,7 +478,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:"))) { + while (EOF != (c = getopt(argc, argv, "246u""b:d:hi:t:v"))) { switch (c) { case '2': transport_type = TRANS_IEEE_802_3; @@ -503,6 +505,9 @@ int main(int argc, char *argv[]) if (1 == sscanf(optarg, "%x", &c)) transport_specific = c << 4; break; + case 'v': + version_show(stdout); + return 0; case 'h': usage(progname); return 0; diff --git a/ptp4l.8 b/ptp4l.8 index db5e6ca..5636a08 100644 --- a/ptp4l.8 +++ b/ptp4l.8 @@ -31,6 +31,8 @@ ptp4l \- PTP Boundary/Ordinary Clock ] [ .BI \-l " print-level" ] [ +.B \-m +] [ .B \-q ] [ .B \-v @@ -84,6 +86,10 @@ Select the legacy hardware time stamping. Read configuration from the specified file. No configuration file is read by default. .TP +.BI \-i " interface" +Specify a PTP port, it may be used multiple times. At least one port must be +specified by this option or in the configuration file. +.TP .BI \-p " phc-device" With hardware time stamping, force which PHC device (e.g. /dev/ptp0) should be used. @@ -95,15 +101,14 @@ Enable the slaveOnly mode. Set the maximum syslog level of messages which should be printed or sent to the system logger. The default is 6 (LOG_INFO). .TP +.B \-m +Print messages to the standard output. +.TP .B \-q Don't send messages to the system logger. .TP .B \-v -Print messages to the standard output. -.TP -.BI \-i " interface" -Specify a PTP port, it may be used multiple times. At least one port must be -specified by this option or in the configuration file. +Prints the software version and exits. .TP .BI \-h Display a help message. diff --git a/ptp4l.c b/ptp4l.c index 5e01521..4fc0c88 100644 --- a/ptp4l.c +++ b/ptp4l.c @@ -33,6 +33,7 @@ #include "transport.h" #include "udp6.h" #include "util.h" +#include "version.h" int assume_two_step = 0; @@ -119,8 +120,9 @@ static void usage(char *progname) " (ignored for SOFTWARE/LEGACY HW time stamping)\n" " -s slave only mode (overrides configuration file)\n" " -l [num] set the logging level to 'num'\n" + " -m print messages to stdout\n" " -q do not print messages to the syslog\n" - " -v print messages to stdout\n" + " -v prints the software version and exits\n" " -h prints this message and exits\n" "\n", progname); @@ -157,7 +159,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, "AEP246HSLf:i:p:sl:qvh"))) { + while (EOF != (c = getopt(argc, argv, "AEP246HSLf:i:p:sl:mqvh"))) { switch (c) { case 'A': *dm = DM_AUTO; @@ -213,14 +215,17 @@ int main(int argc, char *argv[]) cfg_settings.print_level = atoi(optarg); *cfg_ignore |= CFG_IGNORE_PRINT_LEVEL; break; + case 'm': + cfg_settings.verbose = 1; + *cfg_ignore |= CFG_IGNORE_VERBOSE; + break; case 'q': cfg_settings.use_syslog = 0; *cfg_ignore |= CFG_IGNORE_USE_SYSLOG; break; case 'v': - cfg_settings.verbose = 1; - *cfg_ignore |= CFG_IGNORE_VERBOSE; - break; + version_show(stdout); + return 0; case 'h': usage(progname); return 0;