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 <[email protected]>
---
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 600fc058a391..c66a04064ff8 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>
@@ -452,6 +453,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 3fa58338f07a..4a58f065b214 100644
--- a/msg.h
+++ b/msg.h
@@ -339,6 +339,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
------------------------------------------------------------------------------
"Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE
Instantly run your Selenium tests across 300+ browser/OS combos. Get
unparalleled scalability from the best Selenium testing platform available.
Simple to use. Nothing to install. Get started now for free."
http://p.sf.net/sfu/SauceLabs
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel