From a736b0c2ffd70a3bbf8b7b89138b0667e59a7a71 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Tue, 27 Dec 2011 19:18:52 +0100 Subject: [PATCH] Make the slave only mode a non-default option. Now that we have the master code in place, there is no longer any need to restrict ourselves. Signed-off-by: Richard Cochran --- ptp4l.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ptp4l.c b/ptp4l.c index 96c2f78..a54dee8 100644 --- a/ptp4l.c +++ b/ptp4l.c @@ -63,6 +63,7 @@ static void usage(char *progname) " -h prints this message and exits\n" " -i [dev] interface device to use, for example 'eth0'\n" " (may be specified multiple times)\n" + " -m slave only mode\n" " -p [dev] PTP hardware clock device to use, default '%s'\n" " (ignored for SOFTWARE/LEGACY HW time stamping)\n\n", progname, DEFAULT_PHC); @@ -71,7 +72,7 @@ static void usage(char *progname) int main(int argc, char *argv[]) { char *phc = DEFAULT_PHC, *progname; - int c, i, nports = 0; + int c, i, nports = 0, slaveonly = 0; struct interface iface[MAX_PORTS]; enum transport_type transport = TRANS_UDP_IPV4; enum timestamp_type timestamping = TS_HARDWARE; @@ -80,7 +81,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, "246hi:p:rsz"))) { + while (EOF != (c = getopt(argc, argv, "246hi:mp:rsz"))) { switch (c) { case '2': transport = TRANS_IEEE_802_3; @@ -99,6 +100,9 @@ int main(int argc, char *argv[]) return -1; } break; + case 'm': + slaveonly = 1; + break; case 'p': phc = optarg; break; @@ -135,9 +139,9 @@ int main(int argc, char *argv[]) phc = NULL; } - ds.slaveOnly = TRUE; // TODO - make this programmable. + ds.slaveOnly = slaveonly ? TRUE : FALSE; ds.priority1 = 128; - ds.clockQuality.clockClass = 255; + ds.clockQuality.clockClass = slaveonly ? 255 : 248; ds.clockQuality.clockAccuracy = 0xfe; ds.clockQuality.offsetScaledLogVariance = 0xffff; ds.priority2 = 128;