This patch makes the original behavior of sending the
TLV values for GET actions with a length of zero.
Signed-off-by: Richard Cochran <***@gmail.com>
---
phc2sys.c | 2 +-
pmc.8 | 11 ++++++++++-
pmc.c | 11 ++++++++---
pmc_common.c | 3 ++-
pmc_common.h | 2 +-
5 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/phc2sys.c b/phc2sys.c
index 366587f..157d0e8 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -372,7 +372,7 @@ static void *get_mgt_data(struct ptp_message *msg)
static int init_pmc(struct clock *clock, int domain_number)
{
clock->pmc = pmc_create(TRANS_UDS, "/var/run/phc2sys", 0,
- domain_number, 0);
+ domain_number, 0, 1);
if (!clock->pmc) {
pr_err("failed to create pmc");
return -1;
diff --git a/pmc.8 b/pmc.8
index 1128bf7..d91c657 100644
--- a/pmc.8
+++ b/pmc.8
@@ -1,4 +1,4 @@
-.TH PMC 8 "November 2012" "linuxptp"
+.TH PMC 8 "July 2013" "linuxptp"
.SH NAME
pmc \- PTP management client
@@ -22,6 +22,8 @@ pmc \- PTP management client
.BI \-t " transport-specific-field"
] [
.B \-v
+] [
+.B \-z
] [ command ] ...
.SH DESCRIPTION
@@ -76,6 +78,13 @@ Display a help message.
.TP
.B \-v
Prints the software version and exits.
+.TP
+.B \-z
+The official interpretation of the 1588 standard mandates sending
+GET actions with valid (but meaningless) TLV values. Therefore the
+pmc program normally sends GET requests with properly formed TLV
+values. This option enables the legacy option of sending zero
+length TLV values instead.
.SH MANAGEMENT IDS
diff --git a/pmc.c b/pmc.c
index 05544a1..3097917 100644
--- a/pmc.c
+++ b/pmc.c
@@ -659,6 +659,7 @@ static void usage(char *progname)
" for network and '/var/run/pmc' for UDS.\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"
"\n",
progname);
}
@@ -666,7 +667,7 @@ static void usage(char *progname)
int main(int argc, char *argv[])
{
char *iface_name = NULL, *progname;
- int c, cnt, length, tmo = -1, batch_mode = 0;
+ int c, cnt, length, tmo = -1, batch_mode = 0, zero_datalen = 0;
char line[1024], *command = NULL;
enum transport_type transport_type = TRANS_UDP_IPV4;
UInteger8 boundary_hops = 1, domain_number = 0, transport_specific = 0;
@@ -677,7 +678,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:v"))) {
+ while (EOF != (c = getopt(argc, argv, "246u""b:d:hi:t:vz"))) {
switch (c) {
case '2':
transport_type = TRANS_IEEE_802_3;
@@ -707,6 +708,9 @@ int main(int argc, char *argv[])
case 'v':
version_show(stdout);
return 0;
+ case 'z':
+ zero_datalen = 1;
+ break;
case 'h':
usage(progname);
return 0;
@@ -730,7 +734,8 @@ int main(int argc, char *argv[])
print_set_syslog(1);
print_set_verbose(1);
- pmc = pmc_create(transport_type, iface_name, boundary_hops, domain_number, transport_specific);
+ pmc = pmc_create(transport_type, iface_name, boundary_hops,
+ domain_number, transport_specific, zero_datalen);
if (!pmc) {
fprintf(stderr, "failed to create pmc\n");
return -1;
diff --git a/pmc_common.c b/pmc_common.c
index a9e7c78..44cd8b5 100644
--- a/pmc_common.c
+++ b/pmc_common.c
@@ -62,7 +62,7 @@ struct pmc {
struct pmc *pmc_create(enum transport_type transport_type, char *iface_name,
UInteger8 boundary_hops, UInteger8 domain_number,
- UInteger8 transport_specific)
+ UInteger8 transport_specific, int zero_datalen)
{
struct pmc *pmc;
@@ -92,6 +92,7 @@ struct pmc *pmc_create(enum transport_type transport_type, char *iface_name,
pr_err("failed to open transport");
goto failed;
}
+ pmc->zero_length_gets = zero_datalen ? 1 : 0;
return pmc;
diff --git a/pmc_common.h b/pmc_common.h
index 46e080e..3807a5f 100644
--- a/pmc_common.h
+++ b/pmc_common.h
@@ -27,7 +27,7 @@ struct pmc;
struct pmc *pmc_create(enum transport_type transport_type, char *iface_name,
UInteger8 boundary_hops, UInteger8 domain_number,
- UInteger8 transport_specific);
+ UInteger8 transport_specific, int zero_datalen);
void pmc_destroy(struct pmc *pmc);
--
1.7.10.4