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 @@ -101,6 +101,19 @@ int transport_peer(struct transport *t, struct fdarray *fda, 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. */