When a messages is sent with the DEFER_EVENT flag, the lower transport
code does not fetch the time stamp right away.  This patch introduces
a method that allows a second call to retrieve the waiting transmit
time stamp.

Signed-off-by: Richard Cochran <[email protected]>
---
 transport.c | 11 +++++++++++
 transport.h | 13 +++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/transport.c b/transport.c
index ff5e307..8fb94de 100644
--- a/transport.c
+++ b/transport.c
@@ -66,6 +66,17 @@ int transport_sendto(struct transport *t, struct fdarray 
*fda,
        return t->send(t, fda, event, 0, msg, len, &msg->address, &msg->hwts);
 }
 
+int transport_txts(struct transport *t, struct fdarray *fda,
+                  struct ptp_message *msg)
+{
+       int cnt, len = ntohs(msg->header.messageLength);
+       struct hw_timestamp *hwts = &msg->hwts;
+       unsigned char pkt[1600];
+
+       cnt = sk_receive(fda->fd[FD_EVENT], pkt, len, NULL, hwts, MSG_ERRQUEUE);
+       return cnt > 0 ? 0 : cnt;
+}
+
 int transport_physical_addr(struct transport *t, uint8_t *addr)
 {
        if (t->physical_addr) {
diff --git a/transport.h b/transport.h
index 171e59f..4f6dc36 100644
--- a/transport.h
+++ b/transport.h
@@ -102,6 +102,19 @@ int transport_sendto(struct transport *t, struct fdarray 
*fda,
                     enum transport_event event, struct ptp_message *msg);
 
 /**
+ * Fetches the transmit time stamp for a PTP message that was sent
+ * with the TRANS_DEFER_EVENT flag.
+ *
+ * @param t    The transport.
+ * @param fda  The array of descriptors filled in by transport_open.
+ * @param msg  The message previously sent using transport_send(),
+ *              transport_peer(), or transport_sendto().
+ * @return     Zero on success, or negative value in case of an error.
+ */
+int transport_txts(struct transport *t, struct fdarray *fda,
+                  struct ptp_message *msg);
+
+/**
  * Returns the transport's type.
  */
 enum transport_type transport_type(struct transport *t);
-- 
2.11.0


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to