Skip to content

Commit

Permalink
pmc: optional legacy zero length TLV for GET actions.
Browse files Browse the repository at this point in the history
This patch makes the original behavior of sending the
TLV values for GET actions with a length of zero.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
  • Loading branch information
richardcochran committed Jul 22, 2013
1 parent 0650b07 commit b0d789a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion phc2sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 10 additions & 1 deletion pmc.8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH PMC 8 "November 2012" "linuxptp"
.TH PMC 8 "July 2013" "linuxptp"
.SH NAME
pmc \- PTP management client

Expand All @@ -22,6 +22,8 @@ pmc \- PTP management client
.BI \-t " transport-specific-field"
] [
.B \-v
] [
.B \-z
] [ command ] ...

.SH DESCRIPTION
Expand Down Expand Up @@ -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

Expand Down
11 changes: 8 additions & 3 deletions pmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,14 +659,15 @@ 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);
}

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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion pmc_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion pmc_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit b0d789a

Please sign in to comment.