The standard requires management TLV in replies to commands: An acknowledge management message is a response to a command management message. The value of the managementId shall be identical to that in the command message. (Table 38)
Just copy the TLV from the request. Signed-off-by: Jiri Benc <jb...@redhat.com> --- clock.c | 3 +++ msg.c | 17 +++++++++++++++++ msg.h | 11 +++++++++++ 3 files changed, 31 insertions(+), 0 deletions(-) diff --git a/clock.c b/clock.c index f06ebcd77032..80804cad1996 100644 --- a/clock.c +++ b/clock.c @@ -18,6 +18,7 @@ */ #include <errno.h> #include <poll.h> +#include <stddef.h> #include <stdlib.h> #include <string.h> #include <time.h> @@ -453,6 +454,8 @@ static int clock_management_cmd_response(struct clock *c, struct port *p, pr_err("failed to allocate response message"); return 1; } + msg_copy_tlv(rsp, offsetof(struct ptp_message, management.suffix), + req, 0); if (port_prepare_and_send(p, rsp, 0)) pr_err("failed to send response message"); msg_put(rsp); diff --git a/msg.c b/msg.c index 7edbdd2619b5..7b958e30bef9 100644 --- a/msg.c +++ b/msg.c @@ -470,3 +470,20 @@ int msg_sots_missing(struct ptp_message *m) } return (!m->hwts.ts.tv_sec && !m->hwts.ts.tv_nsec) ? 1 : 0; } + +void msg_copy_tlv(struct ptp_message *dest, unsigned int dest_base, + struct ptp_message *src, unsigned int src_base) +{ + unsigned int len; + + if (!src_base) + src_base = dest_base; + + len = src->header.messageLength; + if (len <= src_base) + return; + len -= src_base; + memcpy((void *)dest + dest_base, (void *)src + src_base, len); + dest->header.messageLength = dest_base + len; + dest->tlv_count = src->tlv_count; +} diff --git a/msg.h b/msg.h index 7f471ca555aa..a7155139fb2b 100644 --- a/msg.h +++ b/msg.h @@ -321,6 +321,17 @@ void msg_put(struct ptp_message *m); int msg_sots_missing(struct ptp_message *m); /** + * Copy TLVs from one message into another. + * @param dest Destination message. + * @param dest_base Offset of the suffix in the destination message. + * @param src Source message. + * @param src_base Offset of the suffix in the source message; 0 to use + * the value in dest_base. + */ +void msg_copy_tlv(struct ptp_message *dest, unsigned int dest_base, + struct ptp_message *src, unsigned int src_base); + +/** * Work around buggy 802.1AS switches. */ extern int assume_two_step; -- 1.7.6.5 ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel